akhauriyash/Code-Regression huggingface dataset:
/**
 * C - Back and Forth
 * https://atcoder.jp/contests/abc051/tasks/abc051_c
 **/
#include<iostream>

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx-sx;
    int y = ty-sy;
    // 1週目
    if(y>0) {
        for(int i=0;i<abs(y);i++) cout << "U";
    } else {
        for(int i=0;i<abs(y);i++) cout << "D";
    }
    if(x>0) {
        for(int i=0;i<abs(x);i++) cout << "R";
    } else {
        for(int i=0;i<abs(x);i++) cout << "L";
    }
    if(y>0) {
        for(int i=0;i<abs(y);i++) cout << "D";
    } else {
        for(int i=0;i<abs(y);i++) cout << "U";
    }
    if(x>0) {
        for(int i=0;i<abs(x);i++) cout << "L";
    } else {
        for(int i=0;i<abs(x);i++) cout << "R";
    }
    // 2週目
    if(x>0) {
        cout << "L";
        if(y>0) {
            for(int i=0; i<abs(y)+1; i++) cout << "U";
        } else {
            for(int i=0; i<abs(y)+1; i++) cout << "D";
        }
        for(int i=0; i<abs(x)+1; i++) cout << "R";
        if(y>0) {
            cout << "D";
        } else {
            cout << "U";
        }
        cout << "R";
        if(y>0) {
            for(int i=0;i<abs(y)+1;i++) cout << "D";
        } else {
            for(int i=0;i<abs(y)+1;i++) cout << "U";
        }
        for(int i=0;i<abs(x)+1; i++) cout << "L";
        if(y>0) {
            cout << "U";
        } else {
            cout << "D";
        }
    } else {
        cout << "R";
        if(y>0) {
            for(int i=0; i<abs(y)+1; i++) cout << "U";
        } else {
            for(int i=0; i<abs(y)+1; i++) cout << "D";
        }
        for(int i=0; i<abs(x)+1; i++) cout << "L";
        if(y>0) {
            cout << "D";
        } else {
            cout << "U";
        }
        cout << "L";
        if(y>0) {
            for(int i=0;i<abs(y)+1;i++) cout << "D";
        } else {
            for(int i=0;i<abs(y)+1;i++) cout << "U";
        }
        for(int i=0;i<abs(x)+1; i++) cout << "R";
        if(y>0) {
            cout << "U";
        } else {
            cout << "D";
        }
    }


    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    k, t = LI()
    a = LI()
    a.sort(reverse=True)

    ans = max(a[0]-1-sum(a[1:]), 0)
    print(ans)


main()


Measured memory_bytes: 74472
#include <iostream>
using namespace std;
int main(){
  int prime[55002];
  prime[0] = prime[1] = 0;
  for(int i = 2 ; i < 55001 ; i++)prime[i] = 1;

  for(int i = 2 ; i*i < 55001 ; i++){
    if(prime[i] == 1 ){
      for(int j = i*2 ; j < 55001 ; j+=i)prime[j] = 0;
    }
  }

  int n;
  while(cin >> n){
    int ans_M,ans_m;

    for(int i = n-1 ;; i-- ){
      if(prime[i]){
	ans_m = i;break;
      }
    }
    for(int i = n+1 ;; i++ ){
      if(prime[i]){
	ans_M = i;break;
      }
    }
    cout << ans_m<<" "<<ans_M<<endl;

  }
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int N;
string S;

int main(){
  cin >> N >> S;
  string::iterator itr = unique(S.begin(), S.end());
  S.erase(itr, S.end());
  cout << S.size() << endl;
}

Measured memory_bytes: 3772
#include <stdio.h>

int main(void) {
  int flag[55556];
  int n;
  int a[55556];
  int i, j;
  int x = 0;
  for(i = 0; i < 55556; i++) flag[i] = 1;
  flag[0] = flag[1] = 0;
  for(i = 2; i < 55556; i++) {
    for(j = i; j < 55556; j += i) {
      if(i != j) flag[j] = 0;
    }
  }
  for(i = 0; i < 55556; i++) if(flag[i] == 1 && i % 5 == 1) a[x] = i, x++;
  scanf("%d", &n);
  for(i = 0; i < n; i++) printf("%d ", a[i]);
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int s,i=1;
    scanf("%d",&s);
    if(s<3) {
    	printf("4");
    	return 0;
    }
    while(s!=4){
    	if(s%2)s=3*s+1;
        else s/=2;
        i++;
    }
    printf("%d",i+3);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input();
		var a = p[0].ToLong();
		var b = p[1].ToLong();
		var k = p[2].ToLong();
		
		if(a - k >= 0)
		{
			Console.WriteLine("{0} {1}", a - k, b);
			return;
		}
		long c = b - (k - a) ;
		if(c >= 0)
		{
			Console.WriteLine("{0} {1}", 0, c);
			return;
		}
		
		Console.WriteLine("0 0");
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll INF = 1001001001001001001;
int A, B, Q;
ll S[100100], T[100100];

ll f(ll x, int n, ll (&S)[100100], int A){
    if(n == 0){
        return 0;
    }

    int i = std::lower_bound(S, S + A, x) - S;
    
    if(A - i < n){
        return INF;
    }

    return S[i + n - 1] - x;
}

ll g(ll x, int n, ll (&S)[100100], int A){
    if(n == 0){
        return 0;
    }

    int i = std::lower_bound(S, S + A, x) - S;

    if(i < n){
        return INF;
    }

    return x - S[i - n];
}

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

    std::cin >> A >> B >> Q;

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

    for(int i=0;i<B;++i){
        std::cin >> T[i];
    }

    for(int i=0;i<Q;++i){
        ll x;
        std::cin >> x;

        ll minDist = INF;
        
        for(int j=0;j<2;++j){
            for(int k=0;k<2;++k){
                ll d1 = std::max(g(x, j, S, A), g(x, k, T, B)),
                    d2 = std::max(f(x, 1 - j, S, A), f(x, 1 - k, T, B)),
                    d = std::min(d1 * 2 + d2, d2 * 2 + d1);
                minDist = std::min(minDist, d);
            }
        }

        std::cout << minDist << std::endl;
    }
}


Measured memory_bytes: 2944
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int result = 0;

		for (int i = 1; i <= n; i++) {
			int currentSum =0;
			if(i>=1){
				currentSum += i%10;
				if(i/10>=1){
					currentSum += (i/10)%10;
					if(i/100>=1){
						currentSum += (i/100)%10;
						if(i/1000>=1){
							currentSum += (i/1000)%10;
							if(i/10000>=1){
								currentSum += (i/10000)%10;
							}
						}
					}
				}
			}
			// System.out.println("i "+i);
			// System.out.println("currentSum "+currentSum);
			if(currentSum>=a&& currentSum <=b){
				result += i;
			}
		}
		System.out.println(result);


	}
}


Measured memory_bytes: 21332
//110
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include <vector>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    int ans = A * B * 3;
    if(ans % 2 != 0){
        cout << "Yes"  << endl;
    }else{
        cout << "No" << endl;
    }



}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int time,h,m,s;
	cin>>time;
	h=time / 3600;
	m=(time % 3600)/60;
	s=time % 60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  string sa,sb,sc;
  cin >> sa >> sb >> sc;
  
  char ch = 'a';
  for(; ;) {
    switch(ch) {
      case 'a': 
        if(sa.size() == 0) {
          cout << "A" << endl;
          return 0;
        }
        else {
          ch = sa[0];
          sa.erase(0,1);
          break;
        }
      case 'b': 
        if(sb.size() == 0) {
          cout << "B" << endl;
          return 0;
        }
        else {
          ch = sb[0];
          sb.erase(0,1);
          break;
        }
      case 'c': 
        if(sc.size() == 0) {
          cout << "C" << endl;
          return 0;
        }
        else {
          ch = sc[0];
          sc.erase(0,1);
          break;
        }
    }
  }
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int a[20]={0};
int d[20];
int c[20][2];
int n;
double sum;
void dfs(int x)
{
	int i;
	if(x==n+1)
	{
		for(i=2;i<=n;i++)
		{
//			printf("%d\n",d[i]);
			sum+=sqrt((c[d[i]][0]-c[d[i-1]][0])*(c[d[i]][0]-c[d[i-1]][0])+(c[d[i]][1]-c[d[i-1]][1])*(c[d[i]][1]-c[d[i-1]][1]));
		}
		return;
	 } 
	 for(i=1;i<=n;i++)
	 {
	 	if(!a[i])
	 	{
	 		a[i]=1;
	 		d[x]=i;
	 		dfs(x+1);
	 		a[i]=0;
		 }
	 }
}
int main()
{
	int i,m=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d %d",&c[i][0],&c[i][1]);
	sum=0;
	dfs(1);
	for(i=1;i<=n;i++)
	m*=i;
	printf("%.10lf\n",sum/m);
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim],B[lim],C[lim];
// map<lld,lld> M;
lld Mat[503][503], dp[503][503];

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc3(n,m,q);
    rep(i,1,m) {
        sc2(l,r);
        Mat[l][r]++;
    }
    rep(i,1,n) dp[i][i] = Mat[i][i];
    rep(i,1,n-1) dp[i][i+1] = Mat[i][i] + Mat[i+1][i+1] + Mat[i][i+1];
    rep(k,2,n) {
        for(lld i = 1; i + k <= n; i++) {
            j = i + k;
            dp[i][j] = dp[i+1][j] + dp[i][j-1] - dp[i+1][j-1] + Mat[i][j];
            // Error4(dp[i][j], dp[i+1][j], dp[i][j-1], dp[i+1][j-1]);
        }
    }
    while(q--) {
        sc2(l,r);
        prL(dp[l][r]);
    }
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long x;
    cin >> x;
    long long now = 100;
    rep(i, 100000000)
    {
        if (now >= x)
        {
            cout << i << endl;
            return 0;
        }
        now *= 1.01;
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main () {
	int argA, argB, argC, argX;
	cin >> argA >> argB >> argC >> argX;
	argA++;
	argB++;
	argC++;

	int counter = 0;
	for (int i = 0; i < argA; ++i) {
		int ret0 = i * 500;
		for (int j = 0; j < argB; ++j) {
			int ret1 = ret0 + j * 100;
			for (int k = 0; k < argC; ++k) {
				int ret2 = ret1 + k * 50;
				if (ret2 == argX) {
					counter++;
				}
			}
		}
	}

	cout << counter << endl;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(int,input().split()))
s = list(range(1,N+ 1))
count = 0
for i in range(N):
  if s[i] != p[i]:
    count += 1
if count == 0 or count ==2:
  print("YES")
else:
  print("NO")


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

int main() {
  int N, K;
  
  cin >> N >> K;
  int arr[N];
  
  for (int i = 0; i < N; i++) {
  	cin >> arr[i];  
  }
  
  int dp[N];
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  
  for (int i = 2; i < N; i++) {
    dp[i] = INT_MAX; 
    for (int j = 1; j <= K && i - j >= 0; j++) {
      dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
    }
  }
  
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int[] cost = new int[n];
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }

        cost[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
            cost[i] = Math.min(cost[i - 2] + Math.abs(h[i] - h[i - 2]), cost[i - 1] + Math.abs(h[i] - h[i - 1]));
        }
        System.out.println(cost[n-1]);
    }
}


Measured memory_bytes: 62724
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;

int main() {
	int L;
	cin >> L;
	int c=1;
	vector<int> p,q,r;
	L--;
	while(L){
		if(L%2){
			p.push_back(c);
			q.push_back(c+1);
			r.push_back((L+1)/2);
			p.push_back(c);
			q.push_back(c+1);
			r.push_back(0);
			L-=(L+1)/2;
		}
		else{
			p.push_back(c);
			q.push_back(1000);
			r.push_back(L);
			p.push_back(c);
			q.push_back(c+1);
			r.push_back(L/2);
			p.push_back(c);
			q.push_back(c+1);
			r.push_back(0);
			L-=L/2+1;
		}
		c++;
	}
	cout << c << " " << r.size() << endl;
	for(int i=0;i<r.size();i++){
		cout << p[i] << " " << min(q[i],c) << " " << r[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

ll n, k, t, d;
vector<pair<ll, int>> v;

int main() {
    cin >> n >> k;
    
    for(int i = 1; i <= n; i++) {
        cin >> t >> d;
        v.push_back({d, t});
    }

    map<int, ll> m;
    sort(v.begin(), v.end());

    ll ans = 0, sum = 0, cnt = 0, r = 0;
    for(int i = n-1; i >= 0; i--) {
        if(i >= n-k) {
            m[v[i].second]++;
            sum += v[i].first;

            if(i == n-k) {
                ll s = m.size();
                ans = sum + s*s;
                r = n-k;
            }
        }
        else {
            if(!m.count(v[i].second)) {
                m[v[i].second]++;

                while(r <= n-1 && m[v[r].second] == 1) {
                    r++;
                }

                if(r == n) {
                    break;
                }

                sum += v[i].first - v[r].first;
                m[v[r].second]--;
                r++;
                ll s = m.size();
                ans = max(ans, sum + s*s);
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int getDigit(int n) {
    int result = 0;
    while (n > 0) {
        n /= 10;
        result++;
    }
    return result;
}
int main(void) {
    int N;cin>>N;
    int result = 0;
    for (int i = 1; i <= N; i++) {
        if (getDigit(i) % 2 == 1) result++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  int ans=0;
  for(int i=1;i<str.size();i++){
    if(str[i-1]!=str[i])
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int sc = 0, tc = 0;
  for(int i = 0; i < n; i++) {
    string s, t;
    cin >> s >> t;
    if(s == t) {
      sc++;
      tc++;
    } else {
        bool f = true;
        for(int j = 0; j < min(s.size(), t.size()); j++) {
          if(s[j] > t[j]) {
            sc = sc + 3;
            f = false;
            break;
          } else if(s[j] < t[j]) {
            tc = tc + 3;
            f = false;
            break;
          }
        }
        if(f) {
          if(s.size() > t.size()) sc = sc + 3;
          else tc = tc + 3;
        }
    }
  }
  cout << sc << " " << tc << endl;
  return 0;
}


Measured memory_bytes: 3140
while n = gets.to_i
  break if n == 0
  sum = Array.new(2) { Array.new(n+1,0) }
  ret = 0
  n.times do |i|
    mtx = gets.split("").map{|s| s == "."}
    n.times do |j|
      sum[1][j+1] = mtx[j] ? [sum[1][j], sum[0][j], sum[0][j+1]].min + 1 : 0
    end
    ret = [ret,sum[1].max].max
    sum.rotate!
  end
  p ret
end

Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    string a, b, c; cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
        
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


///////////////////////////////////////////////////////////////////////////////////
int N;
long long K;
vector<int> P;
vector<long long> C;

long long solve() {
    long long res = -INF;

    vector<bool> used(N, false);
    vector<vector<long long>> ss;
    for (int i = 0;i < N;i++){
        if (used[i]) continue;
        int cur = i;
        vector<long long> s;
        while (!used[cur]) {
            used[cur] = true;
            s.push_back(C[cur]);
            cur = P[cur];
        }
        ss.push_back(s);
    }

    for (auto v : ss) {
        long long M = v.size();

        vector<long long> sum(M*2+1, 0);
        for (int i = 0;i < M*2;i++) sum[i+1] = sum[i] + v[i%M];

        vector<long long> amari(M, -INF);
        for (int i = 0;i < M;i++){
            for (int j = 0;j < M;j++){
                amari[j] = max(amari[j], sum[i+j] - sum[i]);
            }
        }
        for (int i = 0;i < M;i++){
            if (i > K) continue;
            long long q = (K - i) / M;
            if (q == 0 && i == 0) continue;

            if (sum[M] > 0) res = max(res, amari[i] + sum[M] * q);
            else if (i > 0) res = max(res, amari[i]);
        }
    }
    return res;
}

int main(){
    cin >> N >> K;
    P.resize(N);
    C.resize(N);
    for (int i = 0;i < N;i++){
        cin >> P[i];
        P[i]--;
    }
    for (int i = 0;i < N;i++){
        cin >> C[i];
    }
    cout << solve() << endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

// based on https://atcoder.jp/contests/dp/submissions/11467760

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    string k;
    int d;
    cin >> k >> d;
    vector< vector<int> > dp(d, vector<int>(2));
    // dp[i][j] -> i: mod d, j:ギリギリか否か
    dp[0][true] = 1;

    rep(i, k.size()) {
        int focus = k[i] - '0'; // 見ている数字
        vector <vector<int> > after(d, vector<int>(2));
        // 回避用(あとでまとめてdpに入れる)

        for(int prevmod = 0; prevmod < d; prevmod++) {
            for(int now = 0; now <= 9; now++) {
                int nowmod = (prevmod + now) % d;

                // ギリギリ->自由の遷移
                if(now < focus) {
                    after[nowmod][false] += dp[prevmod][true];
                    after[nowmod][false] %= MOD;
                }
                // ギリギリ->ギリギリの遷移
                else if(now == focus) {
                    after[nowmod][true] += dp[prevmod][true];
                    after[nowmod][true] %= MOD;
                }
                // 自由->自由の遷移
                after[nowmod][false] += dp[prevmod][false];
                after[nowmod][false] %= MOD;
            }
        }
        dp = after;
    }
    // 0も含んでしまうため -1
    cout << (dp[0][true] + dp[0][false] - 1 + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int one = 8;
int f = 3;
int g = 4;
int s = 5;
int t = 6;
int u = 7;
int r[30];
int a[30];
int b[30];
int k[60];
void comp(int x, int y, int z) {
	printf("< %d %d %d\n", x, y, z);
}
void add(int x, int y, int z) {
	printf("+ %d %d %d\n", x, y, z);
}
void an(int x, int y, int z) {
	add(x, y, f);
	comp(one, f, z);
}
void no(int x) {
	comp(x, one, x);
}
void xo(int x, int y, int z) {
	comp(x, y, f);
	comp(y, x, g);
	add(f, g, z);
}
int main() {
	for (int i = 0; i < 30; i++) {
		r[i] = 8 + i;
		a[i] = 38 + i;
		b[i] = 68 + i;
	}
	for (int i = 0; i < 60; i++) {
		k[i] = 98 + i;
	}
	printf("14788\n");
	add(0, 1, 8);
	comp(2, 8, 8);
	for (int i = 1; i < 30; i++) {
		add(r[i - 1], r[i - 1], r[i]);
	}
	for (int i = 29; i >= 0; i--) {
		add(s, r[i], g);
		comp(0, g, f);
		no(f);
		add(f, a[i], a[i]);
		for (int j = 0; j < i; j++) {
			add(f, f, f);
		}
		if (i != 0)add(f, s, s);
	}
	for (int i = 29; i >= 0; i--) {
		add(t, r[i], g);
		comp(1, g, f);
		no(f);
		add(f, b[i], b[i]);
		for (int j = 0; j < i; j++) {
			add(f, f, f);
		}
		if (i != 0)add(f, t, t);
	}
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 30; j++) {
			an(a[i], b[j], t);
			an(u, t, s);
			xo(u, t, t);
			an(t, k[i + j], u);
			xo(t, k[i + j], k[i + j]);
			add(u, s, u);
		}
		add(u, k[i + 30], k[i + 30]);
		if (i != 29)add(2, 2, u);
	}
	for (int i = 0; i < 60; i++) {
		for (int j = 0; j < i; j++) {
			add(k[i], k[i], k[i]);
		}
		add(k[i], 2, 2);
	}
}

Measured memory_bytes: 1548
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];
	ll exor = 0;
	REP(i,n) exor ^= a[i];
	vector<bool> cnt(30, false); // 最下位 1 bit が i
	REP(i, n) {
		bitset<30> bi(a[i]);
		REP(j, 30) if(bi[j]) {
			cnt[j] = true;
			break;
		}
	}
	ll ans = 0;
	bitset<30> bi(exor);
	for(ll i = 29; i >= 0; i--) {
		if(bi[i]) {
			if(!cnt[i]) {
				cout << -1 << endl;
				return 0;
			}
			ans++;
			for(ll j = i; j >= 0; j--) bi[j] = bi[j] ^ 1;
		}
	}
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */



Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc153/tasks/abc153_e
# コイン問題の応用で解けそう
# ナップサック解法をあとでちゃんと確認

# INFで初期化したdpテーブルでコイン問題を解いて、ピッタリ勝てないときは最小コストにmin(B)を足す
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


H, N = read_ints()
A, B = read_col(N, 2)
minb = min(B)
maxa = max(A)
INF = 10**10 + 1

dp = [INF] * (H + 1 + maxa)
dp[0] = 0

for i in range(1, H + 1 + maxa):
    for a, b in zip(A, B):
        if i - a < 0:
            continue
        dp[i] = min(dp[i], dp[i - a] + b)

# if dp[H] < INF:
#     print(dp[H])
#     exit()

print(min(dp[H:]))


Measured memory_bytes: 44220
import java.util.Scanner;

class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int[] hako = new int[] {a, b, c};
		
		for(int i=0;i<hako.length-1;i++){
			for(int j=hako.length-1;j>i;j--){
				if(hako[j]<hako[j-1]){
					  int t=hako[j];
					  hako[j]=hako[j-1];
					  hako[j-1]=t;
				}
			}
		}
		System.out.println(hako[0] + " " + hako[1] + " " + hako[2]);
	}
}

Measured memory_bytes: 26140
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
using namespace boost::multiprecision;

int main(){

    int n,k;
    cin >> n >> k;

    vector<ll> h(n);

    rep(i,n){
        cin >> h[i];
    }

    sort(ALL(h));

    ll ans = 0;

    ans = 0;

    for(int i = 0; i < n - min(n, k); i++){
        ans += h[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef long long ll;

ll evp (ll x) {
  if (x < 0) return -100;
  return x - x % 2;
}

int main () {
  ll I, O, T, J, L, S, Z;
  cin >> I >> O >> T >> J >> L >> S >> Z;

  ll ans_a = 3 + evp(L - 1) + evp(J - 1) + evp(I - 1);
  ll ans_b = evp(L) + evp(J) + evp(I);

  ll ans = max(ans_a, ans_b) + O;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;




int main(){
    int k,a,b;
    cin >> k >> a >> b;
    
    for(int i = a; i <= b; i++){
        if (i%k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int main(){
	int N, T;
	cin >> N >> T;
	vector<pair<int, int>> CT(N);
	rep(i, N){
		cin >> CT[i].second >> CT[i].first;
	}
	SORT(CT);
	if(CT[0].first > T){
		cout << "TLE" << endl;
	} else {
		int ans = 10000;
		rep(i, N){
			if(CT[i].first <= T){
				ans = min(ans, CT[i].second);
			} else {
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>         // abs
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{  
    string s;
    cin >> s;
    int a = s.size();
    int ans = 999;
    for(int i = 0; i <= a-3; i++){
        int sum = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        ans = min(ans, abs(sum-753));

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <string>

using namespace std;

int main() {
    int X;
    cin >> X;

    int ans = 1;
    for (int b = 2; b <= X; ++b) {
        for (int p = 2; ; ++p) {
            int pow = 1;
            for (int i = 0; i < p; ++i) {
                pow *= b;
            }
            if (pow > X) break;
            ans = max(ans, pow);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define M 998244353
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
		ios;
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll chance=0;
		while(a>0 && c>0){
			if(chance%2==0){
				c=c-b;
			}
			else{
				a=a-d;
			}
			chance++;
		}
		if(c<=0){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
		return 0;
}

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

int main()
{
    string A;
    cin >> A;
    bitset<26> state(0);
    bitset<26> state_true; state_true.set();

    vector<int> p{(int)A.size()};

    for (int i=A.size()-1; i>=0; i--)
    {
        state.set(A[i] - 'a');
        if (state == state_true)
        {
            state.reset();
            p.push_back(i);
        }
    }

    int start = 0;
    while(!p.empty())
    {
        state.reset();
        for (int i=start; i<p.back(); i++) state.set(A[i] - 'a');

        for (int i=0; i<26; i++)
        {
            if (!state[i])
            {
                cout << (char)('a'+i);
                for (int j=p.back(); j<A.size(); j++)
                {
                    if ((char)('a'+i) == A[j])
                    {
                        start = j + 1;
                        break;
                    }
                }
                break;
            }
        }
        p.pop_back();
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		sc.close();
		double m = 0;
		double l;

		for (int i = 0; i < n; i++)
			m = m + (double) 1 / a[i];

		l = 1 / m;

		System.out.println(l);

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin>>N>>M;
    
    map<int,vector<pii>> dic;
    rep(i,M){
        int p,y; cin>>p>>y;
        dic[p].push_back({y,i});
    }
    
    pii ans[M];
    for(auto x:dic){
        vector<pii> nums = x.second;
        sort(all(nums));
        rep(i,nums.size()){
            pii p = nums[i];
            ans[p.second] = {x.first,i+1};
        }
    }
    rep(i,M){
        printf("%06d%06d\n",ans[i].first,ans[i].second);
    }
}

Measured memory_bytes: 13184
m=(""+require("fs").readFileSync(0)).split`
`;n=m[a=0];s=m[1];for(c=b=1<<n;b--;m[u]=-~m[u])for(u=[i=n];i--;)u[b>>i&1]+=s[i];for(;c--;a+=~~m[u])for(u=[i=n];i--;)u[c>>i&1]+=s[2*n+~i];console.log(a)

Measured memory_bytes: 72084
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int rx[] = new int[n];
		int ry[] = new int[n];
		
		int bx[] = new int[n];
		int by[] = new int[n];
		
		for(int i = 0; i < n  ; i ++){
			
			rx[i] = sc.nextInt();
			ry[i] = sc.nextInt();
			
		}
		
		for(int i =0 ; i < n;  i++){
			bx[i] = sc.nextInt();
			by[i] = sc.nextInt();
		}
		
		
		List<E> list = new ArrayList<E>();
		
		
		for(int i = 0; i < n ;i++){
			for(int j =0 ; j < n ; j++){
				if(rx[i] < bx[j] && ry[i] < by[j]){
					E e =new E();
					e.from = i;
					e.to = n+j;
					e.cap = 1;
					list.add(e);
					
					E rev  = new E();
					rev.from = n+j;
					rev.to = i;
					rev.cap = 0;
					list.add(rev);
				}
			}
		}
		
		for(int i =0 ; i< n ;i++){
			E e =new E();
			e.from = i;
			e.to = 2*n;
			e.cap = 0;
			list.add(e);
			
			E rev  = new E();
			rev.from = 2*n;
			rev.to = i;
			rev.cap = 1;
			list.add(rev);			
		}
		
		for(int i =0 ; i< n ;i++){
			E e =new E();
			e.from = n+i;
			e.to = 2*n+1;
			e.cap = 1;
			list.add(e);
			
			E rev  = new E();
			rev.from = 2*n+1;
			rev.to = n+i;
			rev.cap = 0;
			list.add(rev);		
		}
		
		long ans = 0;
		int[] depth = new int[2*n+2];
		boolean[] visited = new boolean[2*n+2];
		for (;;) {
			Arrays.fill(depth, 2*n+2+5);
			Arrays.fill(visited, false);
			if (!bfs(list, depth, visited, 2*n, 2*n+1)) {
				break;
			}
	
			for (;;) {
				Arrays.fill(visited, false);
				visited[2*n] = true;
				int flow = dfs(1,list, depth,visited, 2*n,2*n+1,0);
				if(flow == 0){
					break;
				}
				ans += flow;
			}
		}
		System.out.println(ans);
		
	}
	
	
	int dfs(int flow ,List<E> edges, int[]depth,boolean[] visited, int now,int to,int d){
		if(now == to){
			return flow;
		}
		long ans = 0;
		for(int ii = 0 ; ii < edges.size(); ii++){
			E e =edges.get(ii);
			if(e.from == now && !visited[e.to] && depth[e.to] > depth[e.from] && e.cap > 0){
				visited[e.to] = true;
				
				int res = dfs(Math.min(flow,e.cap),edges,depth,visited,e.to,to,d+1);
				if(res > 0 ){
					e.cap -= res;
					edges.get(ii^1).cap += res;
					return res;
				}
				visited[e.to] = false;
			}
		}
		return 0;
	}
	
	
	boolean bfs(List<E> edges, int[] depth, boolean[] visited, int from, int to) {

		PriorityQueue<EE> q = new PriorityQueue<>((ee1, ee2) -> Integer.compare(ee1.depth, ee2.depth));
		EE init = new EE();
		init.depth = 0;
		init.pos = from;
		q.add(init);

		for (; !q.isEmpty();) {

			EE x = q.poll();
			if (x.pos == to) {
				depth[x.pos] = x.depth;
				return true;
			}

			if (depth[x.pos] <= x.depth) {
				continue;
			}
			depth[x.pos] = x.depth;
			visited[x.pos] = true;

			for (E e : edges) {
				if (e.from == x.pos && !visited[e.to] && e.cap > 0) {
					EE ex = new EE();
					ex.depth = x.depth + 1;
					ex.pos = e.to;
					q.add(ex);
				}
			}
		}
		return false;
	}

	class EE {
		int pos;
		int depth;
	}

	class E {
		int from;
		int to;
		int cap;
	}

}


Measured memory_bytes: 29496
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int a11, a12, a13, a21, a22, a23, a31, a32, a33;
	cin >> a11 >> a12 >> a13 >> a21 >> a22 >> a23 >> a31 >> a32 >> a33;
	int n;
	cin >> n;
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> b.at(i);
	}

	bool ab11 = false;
	bool ab12 = false;
	bool ab13 = false;
	bool ab21 = false;
	bool ab22 = false;
	bool ab23 = false;
	bool ab31 = false;
	bool ab32 = false;
	bool ab33 = false;
	for (int i = 0; i < n; i++) {
		if (b.at(i) == a11) {
			ab11 = true;
		}
		if (b.at(i) == a12) {
			ab12 = true;
		}
		if (b.at(i) == a13) {
			ab13 = true;
		}
		if (b.at(i) == a21) {
			ab21 = true;
		}
		if (b.at(i) == a22) {
			ab22 = true;
		}
		if (b.at(i) == a23) {
			ab23 = true;
		}
		if (b.at(i) == a31) {
			ab31 = true;
		}
		if (b.at(i) == a32) {
			ab32 = true;
		}
		if (b.at(i) == a33) {
			ab33 = true;
		}
	}

	string ans = "No";
	if ((ab11 && ab12 && ab13) == true || (ab21 && ab22 && ab23) == true || (ab31 && ab32 && ab33) == true || (ab11 && ab21 && ab31) == true || (ab12 && ab22 && ab32) == true || (ab13 && ab23 && ab33) == true || (ab11 && ab22 && ab33) == true || (ab13 && ab22 && ab31) == true) {
		ans = "Yes";
	}

	cout << ans << endl;
}

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

int a, b;

int main () {
	cin >> a >> b;
	if (a==1){
		a=14;
	}
	if (b==1){
		b=14;
	}
	if (a==b){
		cout << "Draw" << endl;
	} else if (a<b){
		cout << "Bob" << endl;
	} else if (a>b){
		cout << "Alice" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

ll n;
double ans = 0;
ll x[8], y[8];
bool f[8];
void calc(int now, double len){
	f[now] = true;
	
	bool all = true;
	rep(i, n) if(!f[i]) all = false;
	if(all){
		ans += len;
		f[now] = false;
		return;
	}

	rep(i, n) if(!f[i]) {
		calc(i, len + sqrt((x[now] - x[i]) * (x[now] - x[i]) + (y[now] - y[i]) * (y[now] - y[i]))); 
	}
	f[now] = false;
	return;
}
int main(){
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i];
	rep(i, n) {
		rep(j, 8) f[j] = false;
		calc(i, 0);
	}
	rep(i, n) ans /= (i + 1); 
	cout << fixed << setprecision(7) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    auto e = minmax_element(begin(a), end(a));
    cout << 2 * n - 1 << endl;
    if(abs(*e.first) <= abs(*e.second)){
        for(int i = 0; i < n; i++){
            cout << e.second - a.begin() + 1 << " " << i + 1 << endl;
        }
        for(int i = 1; i < n; i++){
            cout << i << " " << i + 1 << endl;
        }
    }else{
        for(int i = 0; i < n; i++){
            cout << e.first - a.begin() + 1 << " " << i + 1 << endl;
        }
        for(int i = n; i > 1; i--){
            cout << i << " " << i - 1 << endl;
        }
    }
    return 0;
}


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

using namespace std;


int main() {
    int n = 0, a = 0, b = 0;
    cin >> n;

    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> a;
        cin >> b;
        cout << a + b << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll X;
    cin >> X;
    ll sum = 100;
    ll count = 0;
    while(1){
        if ( sum >= X ) {
            break;
        }
        sum += sum / 100;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	ll a, b; cin >> a >> b;
	ll ans = 1;
	vector<int> v;
	if(a > b) swap(a, b);
	int q = sqrt(a);
	bool f[q] = {};
	for(int i = 2; i <= q; i++){
		if(!f[i]) {
			v.push_back(i);
			for(int j = 2; i * j <= q; j++){
				f[i * j] = true;
			}
		}
	}
		if(a != 1){
		auto itr = v.begin();
		while(a >= *itr * *itr && itr != v.end()){
			if(a % *itr == 0){
				if(b % *itr == 0) ans++;
				while(a % *itr == 0) a /= *itr;
			}
			else itr++;
		}
		if(a != 1 && b % a == 0) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1916
#include <cstdio>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define pb push_back
const int maxn = 200001;
int N,Q,psa[maxn]; vi adj[maxn];
void dfs(int cur,int par) {
    psa[cur]+=psa[par];
    for (int nxt : adj[cur]) if (nxt != par) dfs(nxt,cur);
}
int main() {
    scanf("%d%d",&N,&Q); for (int i = 1,a,b;i < N;i++) scanf("%d%d",&a,&b),adj[a].pb(b),adj[b].pb(a);
    for (int i = 0,p,x;i < Q;i++) scanf("%d%d",&p,&x),psa[p]+=x;
    dfs(1,0); for (int i = 1;i <= N;i++) printf("%d ",psa[i]); printf("\n");
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a - b), 0) << endl;



    return 0;
}



Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s="1";
		for(int i=0;i<80;i++)	s+="0";
		BigInteger out=new BigInteger(s);
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			BigInteger a=new BigInteger(sc.next());
			BigInteger b=new BigInteger(sc.next());
			a=a.add(b);
			if(a.min(out).equals(out))	System.out.println("overflow");
			else 	System.out.println(a.toString());
		}
		sc.close();
	}

}

Measured memory_bytes: 26536
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	if (N >= M)cout << 0 << endl;
	else {
		int *X = new int[M];
		int *d = new int[M - 1];
		for (int i = 0; i < M; i++)cin >> X[i];
		sort(X, X + M);
		for (int i = 1; i < M; i++)d[i - 1] = X[i] - X[i - 1];
		sort(d, d + M - 1);
		int ans = 0;
		for (int i = 0; i < M - N; i++)ans += d[i];
		cout << ans << endl;
	}
}


Measured memory_bytes: 1152