akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 2002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, m, A[CMax][CMax], B[CMax][CMax], C[CMax][CMax], D[CMax][CMax];
string S[CMax];

int gcd(int a, int b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (S[i][j] == '.') {
                A[i][j]++; C[i][j]++;
                if (j > 0) A[i][j] += A[i][j-1];
                if (i > 0) C[i][j] += C[i-1][j];
            } else {
                A[i][j] = 0;
                C[i][j] = 0;
            }
        }
    }

    for (int i = n-1; i >= 0; i--) {
        for (int j = m-1; j >= 0; j--) {
            if (S[i][j] == '.') {
                B[i][j]++; D[i][j]++;
                if (j < m-1) B[i][j] += B[i][j+1];
                if (i < n-1) D[i][j] += D[i+1][j];
            } else {
                B[i][j] = 0;
                D[i][j] = 0;
            }
        }
    }

    int res = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            res = max(res, A[i][j] + B[i][j] + C[i][j] + D[i][j] - 3);
        }
    }


    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 66944
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

string shuffle(string str,int h){
	string head = str.substr(0, h);
	string tail = str.substr(h, str.size() - h);
	return tail + head;
}

int main()
{
	string cards;
	int m, h;

	while (1) {
		cin >> cards;
		if (cards=="-")break;

		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> h;
			cards = shuffle(cards, h);
		}
		cout << cards << endl;
	}
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int AA[200000];
int BB[200000];
main(){
    int N,M,ai = 0,bi = 0;
    scanf("%d%d",&N,&M);
    for(int i = 0;i < M;i++){
        int A,B;
        scanf("%d%d",&A,&B);
        if(A==1){
            AA[B-1] = 1;
        }
        if(B==N){
            BB[bi] = A;
            bi++;
        }
    }
    for(int i = 0;i < bi;i++){
        if(AA[BB[i]-1]){
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
l = []
for k, v in dic.items():
  if v >= 2:
    l.append(k)
l.sort()
if len(l) == 0:
  print(0)
elif len(l) == 1:
  if dic[l[-1]] >= 4:
    print(l[-1] ** 2)
  else:
    print(0)
else:
  if dic[l[-1]] >= 4:
    print(l[-1] ** 2)
  else:
    print(l[-1] * l[-2])

Measured memory_bytes: 17960
let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

let n = read int
let ds = reads int

let mutable acc = 0
for i = 0 to n-2 do
    for j = (i+1) to n-1 do
        acc <- acc + (ds.[i] * ds.[j])
printfn "%d" acc    

Measured memory_bytes: 11996
#include <iostream>
using namespace std;
int main() {
    long long n;
    cin >> n;
    int ans = 0;
    long long _n = n;
    for (int i = 2; (long long)i * i <= _n; i++)
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            // cout << i << ' ' << cnt << endl;
            for (int j = 1; cnt > 0; j++) {
                if (cnt < j)
                    break;
                ans++;
                cnt -= j;
            }
        }
    if (n > 1)
        ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
S = input().split(" ")
N = int(S[0])
W = int(S[1])

ARR = []

for i in range(N):
    ar = list(input())
    ARR.append(ar)


def calculate(n, w, arr):
    result = True
    hasShape = False
    for i in range(n):
        for j in range(w):
            if arr[i][j] == "#":
                hasShape = True
                sss = []
                if i -1 >= 0:
                    sss.append(arr[i-1][j])
                if i + 1 < n:
                    sss.append(arr[i+1][j])

                if j - 1 >= 0:
                    sss.append(arr[i][j-1])
                if j + 1 < w:
                    sss.append(arr[i][j+1])

                if "#" not in sss:
                    result = False
                    break

    if hasShape == False:
        print("Yes")
        return

    if result:
        print("Yes")
    else:
        print("No")


calculate(N, W, ARR)


Measured memory_bytes: 3064
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M; cin >> N >> M;
  vector<int> box(N, 1), red(N, 0);
  red[0] = 1;
  REP(i, M) {
    int x, y; cin >> x >> y; x--, y--;
    if (red[x] == 1) red[y] = 1;
    box[x]--, box[y]++;
    if (box[x] == 0) red[x] = 0;
  }
  cout << accumulate(ALL(red), 0) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC129();
}

void ABC129(){
    int p,q,r,max;
    cin>>p>>q>>r;
    max=p;
    if(q>max)max=q;
    if(r>max)max=r;
    cout<<p+q+r-max<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mod7 1000000007

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c, k, ct=0;
	cin>>a>>b>>c>>k;
	while(a>=b) {
		b *= 2;
		ct++;
	}
	while(b>=c) {
		c *= 2;
		ct++;
	}
	if (ct>k) cout<<"No\n";
	else cout<<"Yes\n";
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 1005
ll mod=1e9+7;
int n,m,a,b;
vector<int> G[MAX],g[MAX];
int p[MAX];
bool flg[MAX];
 
int update(int x){
  flg[x]=true;
  if(p[x]==x)return x;
  return p[x]=update(p[x]);
}
 
int find(int x){
  if(p[x]==x)return x;
  return find(p[x]);
}
 
ll dfs(int pos){
  ll res=1;
  for(int i=0;i<(int)g[pos].size();i++)
    res=res*dfs(g[pos][i])%mod;
  return res+1;
}
 
int main(){
  cin>>n>>m;
    for(int i=1;i<=n;i++)p[i]=i;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      G[b].push_back(a);
      if(find(b)==a)update(b);
      else p[a]=b;
    }
    for(int i=1;i<=n;i++){
      for(int j=0;j<(int)G[i].size();j++){
        int w=G[i][j];
        if(flg[w])continue;
        if(flg[i])g[p[i]].push_back(w);
        else g[i].push_back(w);
      }
    }
    ll ans=1;
    for(int i=1;i<=n;i++)if(p[i]==i)ans=ans*dfs(i)%mod;
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1300
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

string s;
int dp[100010][4];

signed main(){
    cin >> s;
    int n = sz(s);

    dp[n][3] = 1;
    REPN(i,n){
        auto c = s[i];
        REP(j,4) dp[i][j] = dp[i+1][j] * (c=='?' ? 3 : 1) % mod;
        if (c == 'C' || c == '?') dp[i][2] += dp[i+1][3];
        if (c == 'B' || c == '?') dp[i][1] += dp[i+1][2];
        if (c == 'A' || c == '?') dp[i][0] += dp[i+1][1];
    }
    cout << dp[0][0] % mod << endl;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;

int main() {
	int w, n, a, b;
	char comma;
	int amida[31];
	for (int i = 1;i < 31;i++) amida[i] = i;
	cin >> w >> n;

	for (int i = 0;i < n;i++) {
		cin >> a >> comma >> b;
		swap(amida[a], amida[b]);
	}

	for (int i = 1;i <= w;i++) {
		cout << amida[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;
typedef long long ll;

int main() {
    ll n, res = 0;
    cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n);
    multiset<ll> my_set;
    set<ll> ym_set;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    sum[0] = a[0];
    my_set.insert(sum[0]);
    for (int i = 1; i < n; i++) {
        sum[i] = sum[i - 1] + a[i];
        my_set.insert(sum[i]);
    }
    for (int i = 0; i < n; i++) {
        if (ym_set.find(sum[i]) == ym_set.end()) {
            ll k = my_set.count(sum[i]);
            res += (k * (k - 1)) / 2;
            ym_set.insert(sum[i]);
        }
    }
    res += my_set.count(0);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
//快读
ll read() {
	char c = getchar();
	ll x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
ll x, k, d, ans;
int main() {
	cin >> x >> k >> d;
	if (x >= 0) {
		ll cnt = x / d;
		if (cnt >= k) ans = x - k * d;
		else {
			ans = x - cnt * d;
			k -= cnt;
			if (k % 2 == 1) ans = d - ans;
		}
	}
	else {
		ll cnt = (-x) / d;
		if (cnt >= k) ans = x + k * d, ans *= -1;
		else {
			ans = x + cnt * d;
			k -= cnt;
			if (k % 2 == 1) ans += d;
			else ans *= -1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;

int main() {
    int N, M, res = 0;
    cin >> N >> M;
    N = N-1;
    M = M-1;
    //cal for N
    res += (N*(N+1)) / 2;
    res += (M*(M+1)) / 2;

    cout << res << "\n";
}

Measured memory_bytes: 256
import sys
from itertools import permutations
import math
from functools import lru_cache


@lru_cache(maxsize=None)
def distance(x1, y1, x2, y2):
    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    c = [0] * n
    for i in range(n):
        x, y = map(int, input().split())
        c[i] = (x, y)
    ans = 0
    for p in permutations(range(n)):
        for i in range(1, n):
            ans += distance(*c[p[i]], *c[p[i - 1]])
    ans /= math.factorial(n)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9320
//                          **********  YATIN KWATRA  ********** 

//AC bakshi Rabha

#include <bits/stdc++.h>
#define ll                      long long 
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<long,long>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define mod                     1000000007
// #define node                    Node

using namespace std;

void INPUT() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}


void solve()
{ 
        int k;
        cin >> k;
        
        string s;
        cin >> s;

        int l = s.length();

        if(l<=k) cout << s << endl;
        else cout << s.substr(0,k) << "...\n";

       
}
int main() {
    
    FIO
  //  INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
int main(){
  int N;
  int dig,sum=0;
  cin>>N;
  int n=N;
  while(n){
    dig = n % 10;
    sum = sum + dig;
    n = n / 10;
  }
  if(N%sum){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  vector<int> v(3);
  for(int i=0;i<3;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  cout << v.at(0)+v.at(1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#define LL long long
#define num 4
#define rep(i,n) for(i=0;i<(n);i++)
using namespace std;

int main(){
  
  LL i,n;
  char S[num];
 
  rep(i,4){
  	scanf("%c",&S[i]);
  }
  
  
  rep(i,3){
  	
    if(S[i]==S[i+1]){
    	
      puts("Bad");
    	return 0;
    }
    
    
  }
  
  
  puts("Good");
  
 
  return 0;
  
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

   
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if (a < b && b < c){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
    }
}


Measured memory_bytes: 26348
#include <iostream>
#include <queue>
#define N 200
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
void bfs(int,int);
int dy[6]={-1,-1,0,1,1,0};
int dx[6]={-1,0,1,1,0,-1};
int t;
int data[N][N];
int main(){
  int n,x,y,sx,sy;
  while(1){
    cin >> t >> n;
    if(t==0&&n==0) break;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) data[i][j]=0;
    while(n--){
      cin >> x >> y;
      data[y+100][x+100]=-1;
    }
    cin >> sx >> sy;
    data[sy+100][sx+100]=1;
    bfs(sy+100,sx+100);
    int cnt=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	if(data[i][j]==1) cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
void bfs(int y,int x){
  queue<P1> Q;
  Q.push(P1(0,P(y,x)));
  while(Q.empty()!=1){
    P1 v=Q.front();
    Q.pop();
    int d=v.first,y1=v.second.first,x1=v.second.second;
    for(int i=0;i<6;i++){
      if(0<=y1+dy[i]&&y1+dy[i]<N&&0<=x1+dx[i]&&x1+dx[i]<N&&data[y1+dy[i]][x1+dx[i]]==0){
	data[y1+dy[i]][x1+dx[i]]=1;
	if(d<=t-2) Q.push(P1(d+1,P(y1+dy[i],x1+dx[i])));
      }
    }
  }
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x=0;
	char c=getchar();
	while(!isdigit(c))c=getchar();
	while(isdigit(c))x=x*10+c-48,c=getchar();
	return x;
}
const int N=2005;
int n;
int a[N];
int sta[N*N],len;
bitset<N*N+N>b;
int main(){
//	freopen("mid0.in","r",stdin);
//	freopen("mid.in","r",stdin);
//	freopen("mid.out","w",stdout);
	n=read();
	int sum=0;
	for(int i=1;i<=n;++i)sum+=(a[i]=read());
	b[0]=1;
	for(int i=1;i<=n;++i)b|=(b<<a[i]);
	for(int i=1;i<=sum;++i)if(b[i]==1)sta[++len]=i;
	printf("%d",sta[(len+1)/2]);
	return 0;
}

Measured memory_bytes: 11520
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	string s;
	cin >> N >> s;
	int ans = 0;
	rep(i, N-1){
		set<char> left, right;
		rep(j, i+1){
			left.insert(s[j]);
		}
		for(int j=i+1;j<N;j++){
			right.insert(s[j]);
		}
		int cnt = 0;
		rep(i, 26){
			char c = 'a'+i;
			if(left.find(c) != left.end() && right.find(c) != right.end()) cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;

int C[102][102];

void meiro(int W,int H,int c){
 if(C[W][H]!=c){
   return;
 }

 C[W][H] = -1;

 meiro(W-1,H  ,c);
 meiro(W  ,H+1,c);
 meiro(W+1,H  ,c);
 meiro(W  ,H-1,c);
}

int main(){
 while(1){
   int w,h;
   cin >> w >> h;
   if(w==0 && h==0){
     break;
   }

   for(int i=0;i<20;i++){
     for(int j=0;j<20;j++){
       C[i][j] = 0;
     }
   }

   int xs,ys,xg,yg;
   cin >> xs >> ys >> xg >> yg;

   int n;
   cin >> n;

   int c,d,x,y;
   for(int i=0;i<n;i++){
     cin >> c >> d >> x >> y;

     if(d==0){
       for(int j=x;j<x+4;j++){
         for(int k=y;k<y+2;k++){
           C[j][k]=c;
         }
       }
     }else{
       for(int j=x;j<x+2;j++){
         for(int k=y;k<y+4;k++){
           C[j][k]=c;
         }
       }
     }
   }
if(C[xs][ys] == 0){
cout << "NG"<<endl;
continue;
}
   meiro(xs,ys,C[xs][ys]);
   //print(w,h);

   if(C[xg][yg] == -1){
     cout << "OK" << endl;
   }else{
     cout << "NG" << endl;
   }
 }

 return 0;
}


Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        int G = sc.nextInt();
        System.out.println(R + (G - R) * 2);
    }
}


Measured memory_bytes: 23764
import statistics

n = input()
l = list(map(int, input().split()))
x = []
for i in range(len(l)):
  x.append(l[i] - i)
    
b = 0
if (len(x) % 2 == 1):
  b = statistics.median(x)
else:
  b = statistics.median_low(x)

sad = 0
for i in x:
  sad += abs(i - b)

print(sad)

Measured memory_bytes: 27244
#include <bits/stdc++.h>
using namespace std;

struct Edge {
	int from, to;
	Edge(int f, int t) : from(f), to(t) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;
vector<int> tarjan(const Graph& g) {
	int n = g.size(), idx = 0, k = 0, s = 0;
	vector<int>ord(n, -1), low(n), onS(n), cmp(n), stk(n);
	function<void(int)>dfs;
	dfs = [&](int v) {
		ord[v] = low[v] = idx++;
		stk[s++] = v;
		onS[v] = true;
		for (auto &e : g[v]) {
			int w = e.to;
			if (ord[w] == -1) {
				dfs(w);
				low[v] = min(low[v], low[w]);
			}
			else if (onS[w]) {
				low[v] = min(low[v], ord[w]);
			}
		}
		if (low[v] == ord[v]) {
			while (1) {
				int w = stk[--s];
				onS[w] = false;
				cmp[w] = k;
				if (w == v)break;
			}
			++k;
		}
	};
	for (int v = 0; v<n; ++v)
		if (ord[v] == -1)dfs(v);
	return cmp;
}

int main()
{
	int V, E, Q;
	cin >> V >> E;
	Graph G(V);
	for (int i = 0, s, t; i < E; i++) {
		cin >> s >> t;
		G[s].emplace_back(s, t);
	}
	auto ta = tarjan(G);
	cin >> Q;
	for (int i = 0, u, v; i < Q; i++) {
		cin >> u >> v;
		cout << (ta[u] == ta[v]) << endl;
	}
	return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	
	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
	}

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (h.at(i) >= K) { count++; }
	}

	cout << count << endl;

}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
ll modpow(ll x, ll n){
	ll r=1;
	while(n){
		if(n&1) r=r*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return r;
}

int main(){
  ll n;cin>>n;
  if(n<2){out(0);return 0;}
  ll u=modpow(10,n),x=modpow(9,n),y=modpow(8,n);
  cout<<mod(u-x*2+y,MOD)<<endl;
  
  
}



Measured memory_bytes: 3628
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> one = nextStrArray();
      String s = one.get(1).substring(0, 1);
      myout("A" + s + "C");
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 36360
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007ll;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    int n=s.size();
    vector<vector<vector<in>>> dp(n,vector<vector<in>>(2,vector<in>(2,0ll)));
    dp[0][0][0]=0ll;
    dp[0][0][1]=1ll;
    dp[0][1][0]=2ll;
    dp[0][1][1]=0ll;

    REP(i,1,n){
        if(s[i]=='1'){
            dp[i][0][0]=0ll;
            dp[i][0][1]=dp[i-1][0][0]+dp[i-1][0][1]+dp[i-1][1][0]+dp[i-1][1][1];
                dp[i][0][1] %=MOD;
            dp[i][1][0]=dp[i-1][0][0]*2ll+dp[i-1][1][0]*2ll;
                dp[i][1][0] %= MOD;
            dp[i][1][1]=dp[i-1][0][1]*2ll+dp[i-1][1][1]*2ll;
                dp[i][1][1] %= MOD;
        }
        else{
            dp[i][0][0]=dp[i-1][0][0]+dp[i-1][1][0];
                dp[i][0][0] %= MOD;
            dp[i][0][1]=dp[i-1][0][1]+dp[i-1][1][1];
                dp[i][0][1] %= MOD;
            dp[i][1][0]=0ll;
            dp[i][1][1]=dp[i-1][0][1]*2ll+dp[i-1][1][1]*2ll;
                dp[i][1][1] %=MOD;
        }
    }
    in ans=dp[n-1][0][0]+dp[n-1][0][1]+dp[n-1][1][0]+dp[n-1][1][1];
    ans %= MOD;
    cout<<ans<<endl;
   // rep(i,2)rep(j,2)cout<<i<<" "<<j<<" "<<dp[n-1][i][j]<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 18252
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int N;
    map<int, int>mp;
    cin >> N;
    rep(i, 0, N){
        int a;
        cin >> a;
        mp[i+1] = a;
    }
    int index = 1;
    rep(i, 0, N){
        if(mp[index]==2){
            cout << i+1 << endl;
            return 0;
        }
        index = mp[index];
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 8328
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

map<string, int> blueCard;
map<string, int> redCard;

int main(int argc, char const *argv[])
{
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  cout << (min(A,B)+min(C,D)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n, A, B;
	cin>>n>>A>>B;
	string s;
	cin>>s;
	int pass = 0, passk=0;
	rep(i, n){
		bool f = false;
		if(s[i]=='a'){
			if(pass < A+B)f=true,pass++;
		}
		else if(s[i] == 'b'){
			if(pass<A+B && passk<B) f=true, pass++,passk++;
		}
		cout<<(f?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 896
N,T=map(int,input().split())
t = [int(i) for i in input().split()]
tot = 0
l = len(t)
i = 0
while i < l-1:
  if t[i+1]-t[i] >= T:
    tot += T
    i += 1
  else:
    tot += t[i+1]-t[i]
    i += 1
tot += T
print(tot)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int MAX = 3005;
string s, t, r;
int dp[MAX][MAX], n, m;
pii rec[MAX][MAX];

int f(int i, int j){
    if(i == n || j == m)return 0;
    int &ans = dp[i][j];
    if(ans != -1)return ans;
    ans = 0;
    ans = max(ans, f(i, j+1));
    ans = max(ans, f(i+1, j));
    ans = max(ans, f(i+1, j+1)+(s[i]==t[j]));
    return ans;
}

void build(int i, int j){
    if(i == n || j == m)return;
    int &ans = dp[i][j];
    if(f(i, j+1) == ans)build(i, j+1);
    else if(f(i+1, j) == ans)build(i+1, j);
    else if(f(i+1, j+1)+(s[i]==t[j]) == ans){
        r.pb(s[i]);
        build(i+1, j+1);
    }
}

//botton-up
int lcs(){
    dp[0][0] = 0;
    forn(i, 0, n+1){
        forn(j, 0, m+1){
            int &ans = dp[i][j];
            if(i){
                if(dp[i-1][j] > ans){
                    ans = dp[i-1][j];
                    rec[i][j] = {i-1, j};
                }
            }
            if(j){
                if(dp[i][j-1] > ans){
                    ans = dp[i][j-1];
                    rec[i][j] = {i, j-1};
                }
            }
            if(i && j){
                if(dp[i-1][j-1]+(s[i-1]==t[j-1]) > ans){
                    ans = dp[i-1][j-1]+(s[i-1]==t[j-1]);
                    rec[i][j] = {i-1, j-1};
                }
            }
        }
    }
    return dp[n][m];
}

string buildlcs(){
    int i = n, j = m;
    string r;
    while(i > 0 && j > 0){
        pii prev = rec[i][j];
        i = prev.F;
        j = prev.S;
        if(s[i] == t[j])r.pb(s[i]);
    }
    return r;
}


int main() {
  ios::sync_with_stdio(0); cin.tie(0);

  cin >> s >> t;

  n = s.size(), m = t.size();
  memset(dp, -1, sizeof dp);
//   f(0, 0);
//   build(0, 0);
  lcs();
  string ans = buildlcs();
  reverse(ans.begin(), ans.end());
  cout << ans << endl;


}





Measured memory_bytes: 109324
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> X(N), Y(N);
  REP(i, N) cin >> X[i] >> Y[i];

  double rx = 1000;
  double lx = 0;

  auto g = [&](double x, double y){
    double ret = 0;
    REP(i, N){
      chmax(ret, sqrt((x-X[i])*(x-X[i])+(y-Y[i])*(y-Y[i])));
    }
    return ret;
  };

  auto f = [&](double x){
    double ry = 1000;
    double ly = 0;

    REP(i, 200){
      double m1 = (ly*2+ry*1)/3;
      double m2 = (ly*1+ry*2)/3;
      if(g(x, m1) > g(x, m2)) ly = m1;
      else ry = m2;
    }
    return g(x, ry);
  };

  REP(i, 200){
    double m1 = (lx*2+rx*1)/3;
    double m2 = (lx*1+rx*2)/3;
    if(f(m1) > f(m2)) lx = m1;
    else rx = m2;
  }

  cout << f(rx) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long A, B, N;

long long calc(long long x) {
    long long y = (A * x) / B;
    long long z = A * (x / B);
    return y - z;
}

int main() {
    cin >> A >> B >> N;
    long long X;
    if (B - 1 < N) {
        X = B - 1;
    } else {
        X = N;
    }
    cout << calc(X);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

bool f(long long N) {
    long long r = (long long)floor(sqrt((long double)N));  // 切り捨てした平方根
    return (r * r) == N;
}

int main(){
	int n;
    cin >> n;
	for(int i = n;i >= 1;i--){
		if(f(i)){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        char[] t = sc.next().toCharArray();
        sc.close();
        char[] tmp = (s+s).toCharArray();
        int[][] index = new int[26][n];
        for(int i=0;i<26;i++){
            index[i][n-1] = -1;
        }
        for(int i= n*2-1;i>=n-1;i--){
            index[tmp[i]-'a'][n-1] = i;
        }
        int ii;
        for(int i=n-2;i>=0;i--){
            ii = tmp[i]-'a';
            for(int j=0;j<26;j++){
                if(ii==j){
                    index[ii][i] = i;
                }else{
                    index[j][i] = index[j][i+1];
                }
            }
        }
        long ans = 0;
        int prev = 0;
        for(int i=0;i<t.length;i++){
            ii = t[i]-'a';
            if(index[ii][prev]==-1){
                System.out.println(-1);
              return;
            }else{
                ans += index[ii][prev]-prev+1;
                prev = (index[ii][prev]+1)%n;
            }

        }
        System.out.println(ans);


    }
}


Measured memory_bytes: 38608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}
	
	// a^{-1} modulo M
	long inv(long a,long M) {
		return a==1?a:(M+(-M*inv(M%a,a)+1)/a);
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		if (N==1) {
			System.out.println(1);
			return;
		}
		N*=2;
		ArrayList<Long> a=new ArrayList<>();
		{
			long N_=N;
			for (long p=2;p*p<=N_;++p) {
				long pe=1;
				while (N_%p==0) {
					pe*=p;
					N_/=p;
				}
				if (pe!=1) a.add(pe);
			}
			if (N_!=1) a.add(N_);
		}
		int n=a.size();
		
		long ans=Long.MAX_VALUE;
		for (int s=1;s<(1<<n)-1;++s) {
			long P=1;
			for (int shift=0;shift<n;++shift) {
				if ((s>>shift)%2==1) P*=a.get(shift);
			}
			long Q=N/P;
			long u=inv(P,Q);
			long v=(u*P-1)/Q;
			ans=Math.min(ans, v*Q);
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 36328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N + 1);
    for (int i = 0; i <= N; ++i)
        cin >> A[i];

    vector<ll> vlim(N + 1);
    vlim[0] = 1;
    for (int i = 1; i <= N; ++i) {
        vlim[i] = min<ll>((vlim[i - 1] - A[i - 1]) << 1, 1e18);
        if (vlim[i] < 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    if (vlim[N] < A[N]) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    vlim[N] = A[N];
    for (int i = N; i >= 0; --i) {
        if (i + 1 <= N)
            vlim[i] = min(vlim[i + 1] + A[i], vlim[i]);
        ans += vlim[i];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4520
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

void chmax (long long &a, long long b) {
	if (a < b) a = b;
}

int main() {
	long long n, a[2], b[2], c[2];
	std::cin >> n;
	std::cin >> a[0] >> b[0] >> c[0];
	std::cin >> a[1] >> b[1] >> c[1];
	
	std::vector<long long> dp1(n + 1);
	std::iota(dp1.begin(), dp1.end(), 0);
	for (long long i = 0; i < n + 1; i++) {
		if (i + a[0] < n + 1) chmax(dp1[i + a[0]], dp1[i] + a[1]);
		if (i + b[0] < n + 1) chmax(dp1[i + b[0]], dp1[i] + b[1]);
		if (i + c[0] < n + 1) chmax(dp1[i + c[0]], dp1[i] + c[1]);
	}
	
	const long long m = *std::max_element(dp1.begin(), dp1.end());
	std::vector<long long> dp2(m + 1);
	std::iota(dp2.begin(), dp2.end(), 0);
	for (long long i = 0; i < m + 1; i++) {
		if (i + a[1] < m + 1) chmax(dp2[i + a[1]], dp2[i] + a[0]);
		if (i + b[1] < m + 1) chmax(dp2[i + b[1]], dp2[i] + b[0]);
		if (i + c[1] < m + 1) chmax(dp2[i + c[1]], dp2[i] + c[0]);
	}
	
	std::cout << *max_element(dp2.begin(), dp2.end()) << '\n';
	
	return 0;
}

Measured memory_bytes: 198540
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  int h[N] = {}; rep(i,N) cin >> h[i];
  int result[N] = {};
  repr(i,1,N) {
    if (i==1) result[i] = result[i-1] + abs(h[i]-h[i-1]);
    else result[i] = min(result[i-1]+abs(h[i]-h[i-1]), result[i-2]+abs(h[i]-h[i-2]));
  }
  cout << result[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
//:Ditttoo
#include<bits/stdc++.h>
#define int long long int 
using namespace std;
const int MOD = (int)1e9+7;
int32_t main()
{
	int h,w;
	cin>>h>>w;

	string grid[h];
	for(int i=0;i<h;i++){
		cin>>grid[i];
	}

	int dp[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){

			if(grid[i][j]=='.'){
				if(i>0 & j>0)
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD ;
			    else if(i>0)
			    	dp[i][j] = dp[i-1][j];
			    else if(j>0)
			    	dp[i][j] = dp[i][j-1];
			}
		}
	}

	cout<<dp[h-1][w-1];
	return 0;
}        

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    cout << A[N-1]-A[0] << endl;


    return 0;
    

}

Measured memory_bytes: 3568
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

vector<ll> v[4];

int main(){
	ll n, W;
	cin>>n>>W;
	rep(i, 4) v[i].push_back(0);
	ll w;
	cin>>w;
	v[0].push_back(0);
	cin>>v[0][1];
	rep(i, n-1){
		ll ww, vv;
		cin>>ww>>vv;
		v[ww-w].push_back(vv);
	}
	rep(i, 4) sort(v[i].rbegin(), v[i].rend()-1);
	rep(i, 4) rep(j, v[i].size()-1) v[i][j+1] += v[i][j];
	ll res = 0;
	rep(i0, v[0].size()) rep(i1, v[1].size()) rep(i2, v[2].size()) rep(i3, v[3].size()){
		if(w*i0+(w+1)*i1+(w+2)*i2+(w+3)*i3>W) continue;
		chmax(res, v[0][i0]+v[1][i1]+v[2][i2]+v[3][i3]);
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string s;int n;cin>>n;cin>>s;
	rep(i,s.size()){
		s[i]='A'+((s[i]-'A')+n)%26;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int r;
    	cin>>r;
    	// cout<<fixed<<setprecision(10);
    	
    	// cout<<x;
    	float ans=(2*3.14159*r);
    	cout<<ans<<endl;

    	
    	
    }
    return 0;
}

Measured memory_bytes: 3804