akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 0;i <= N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N) {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
from collections import Counter as ct

n = int(input())
a = [int(i) for i in input().split()]
oddlists=[a[i] for i in range(n)if i%2==0]
evenlists=[a[i]for i in range(n) if i%2!=0]

a1=ct(oddlists).most_common()
a2=ct(evenlists).most_common()


min1=a1[0][1]
min2=a2[0][1]
if a1[0][0]!=a2[0][0]:
    print(n-min1-min2)
if a1[0][0]==a2[0][0]:
    if a1[0][1]==int(n/2):
        print(int(n/2))
    elif a1[0][1]<int(n/2):
        print(min(n-a1[0][1]-a2[1][1],n-a2[0][1]-a1[1][1]))

Measured memory_bytes: 21084
import java.util.Scanner;


public class Main{
    public  static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int N=sc.nextInt();
    		int Y=sc.nextInt();
    		int[] dp= new int[20000001];
    		int a=0, b=0, c=0;
    		for(int i=0; i<=N; i++) {
    			for(int j=0; j<=N-i; j++) {
    				if(N-i-j>=0) {
    				if(i*10000+j*5000+(N-i-j)*1000==Y) {
    					a=i;
    					b=j;
    					c=N-i-j;
    					dp[Y]++;
    					break;
    				}
    				}
    			}
    		}
    		if(dp[Y]!=0) {
    			System.out.println(a+" "+b+" "+c);
    		}
    		else {
    			System.out.println(-1+" "+-1+" "+-1);
    		}
    	}
    }
}

Measured memory_bytes: 101972
#include <iostream>
#include <vector>
using namespace std;
#define MAXVALUE (1<<21)
vector<int> dp(5000+1,MAXVALUE);

void init(){
	int item[6] = {200,300,500,1000,1200,1500};
	int price[6]= {380,550,850,1520,1870,2244};
	
	dp[0]=0;

	for(int k=0;k<6;k++){
		for(int i=0;i+item[k]<=5000;i++){
			dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
		}
	}
}

int main(){
	init();
	int n,mi;
	while(cin >> n && n){
		mi = dp[n];
		/*for(int i=n;i<=5000;i++){
			mi = min(dp[i],mi);
		}*/
		cout << mi << endl;
	}
}

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

using namespace std;

int main(void) {
    int X, Y;
    cin >> X >> Y;
    for (int c = 0; c <= 100; ++c) {
        for (int t = 0; t <= 100; ++t) {
            if ((c + t) == X && (2 * c + 4 * t) == Y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

const int DENOMI = 1000000007;

int main()
{
	int n, m;
	cin >> n >> m;
	auto dp = vector<int>(n + 2);
	for(auto i = 0; i < m; ++i){
		int a;
		cin >> a;
		dp[a] = -1;
	}
	dp[0] = 1;
	for(auto i = 0; i < n; ++i){
		if(dp[i] == -1) continue;
		if(dp[i + 1] != -1) dp[i + 1] = (dp[i] + dp[i + 1]) % DENOMI;
		if(dp[i + 2] != -1) dp[i + 2] = (dp[i] + dp[i + 2]) % DENOMI;
	}
	cout << dp[n] << endl;
	return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<string> s(n);
    rep(n) cin >> s[i];

    ll ans = 0LL;
    repp(b, n){
        bool flag = true;
        char t[n][n];
        rep(n) repp(j, n) t[i][(j+b)%n] = s[i][j];
        rep(n){
            repp(j, i){
                if(t[i][j] != t[j][i]){
                    flag = false;
                    break;
                }
            }
            if(!flag) break;
        }
        if(flag) ans++;
    }
    ans *= n;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    printf("%lld\n", min(a+b, min(b+c, c+a)));
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string sa,sb,sc;
    cin>>sa;
    cin>>sb;
    cin>>sc;
    int i1=0,i2=0,i3=0;
    int ch=1;
    while (1)
    {
        if (ch==1)
        {
            if (i1==sa.size())
            {
                cout<<"A\n";
                break;
            }
            if (sa[i1]=='a')
                ch=1;
            else if (sa[i1]=='b')
                ch=2;
            else if (sa[i1]=='c')
                ch=3;
            i1++;
        }
        else if (ch==2)
        {
            if (i2==sb.size())
            {
                cout<<"B\n";
                break;
            }
            if (sb[i2]=='a')
                ch=1;
            else if (sb[i2]=='b')
                ch=2;
            else if (sb[i2]=='c')
                ch=3;
            i2++;
        }
        else if (ch==3)
        {
            if (i3==sc.size())
            {
                cout<<"C\n";
                break;
            }
            if (sc[i3]=='a')
                ch=1;
            else if (sc[i3]=='b')
                ch=2;
            else if (sc[i3]=='c')
                ch=3;
            i3++;
        }
    }
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];

  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j < n; ++j){
      int dist = 0;
      for(int k = 0; k < d; ++k){
        dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      for(int k = 1; k <= 4000; ++k){
        if(k * k == dist){
          ans++;
        }
      }
    }
  }

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[200], b[200];
  int i = 0;
  int j, num;
  int digit = 0;

  while((scanf("%d%d", &a[i], &b[i]) != EOF) && (i <= 200)){
  if(a[i], b[i] >= 0 && a[i], b[i] <= 1000000)
    i++;
  }
 
  for(j = 0; j < i; j++){
   num = a[j]+b[j];
    while(num != 0){
      num = num/10;
      digit++;
    }
    printf("%d\n", digit);
    digit = 0;
  }

  return 0;
}

Measured memory_bytes: 600
main :: IO ()
main = do
  n <- read <$> getLine :: IO Integer
  cs <- sequence . replicate 5 $ read <$> getLine :: IO [Integer]
  let
    m = minimum cs
    (k, l) = n `divMod` m
    k' = if l == 0 then k else succ k
  print $ pred k' + 5


Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<algorithm>
#include <functional>
using namespace std;

struct cell{
	int no;
	int n;
};

bool compare(const cell& left, const cell& right)
{
	return left.n > right.n ;
}

int main()
{
	vector<cell> team;
	cell c;
	int a, b, i, j;
	vector<int> rank;
	while (scanf("%d,%d", &a, &b), a||b) {
		c.no = a;
		c.n = b;
		team.push_back( c );
		rank.push_back( 0 );
	}
	rank.push_back( 0 );
	sort(team.begin(), team.end(), compare);
	rank[team[0].no] = 1;
	j = 0;
	for (i = 1; i < team.size(); i++) {
		if ( team[i].n == team[i-1].n ) j --;
		rank[team[i].no] = i + j + 1;
	}
	while (cin>>a) cout<<rank[a]<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
         if(a < b){
           System.out.println("a < b");
         }
         if(a > b){
           System.out.println("a > b");
         }
         if(a == b){
           System.out.println("a == b");
         }
    }


}

Measured memory_bytes: 26324
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>x;

    ll ara[n+9], sum[n+9];

    For(i,1,n)
    {
        cin>>ara[i];
    }

    sum[0] = 0;

    For(i,1,n)
    {
        sum[i] = sum[i-1]+ara[i];
    }

    ll cnt = 0;

    For(i,0,n)
    {
        if(sum[i]<=x)
            cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	priority_queue <int> p, q, ans;
	rep(i, A) {
		int P;
		cin >> P;
		p.push(P);
	}
	rep(i, B) {
		int Q;
		cin >> Q;
		q.push(Q);
	}
	rep(i, C) {
		int R;
		cin >> R;
		ans.push(R);
	}
	rep(i, X) {
		int num = p.top();
		p.pop();
		ans.push(num);
	}
	rep(i, Y) {
		int num = q.top();
		q.pop();
		ans.push(num);
	}
	int a = 0;
	rep(i, X + Y) {
		int num = ans.top();
		ans.pop();
		a += num;
	}
	cout << a;
}

Measured memory_bytes: 7664
#include<stdio.h>
int main(void)
 {
	int a=0;
	int b=0;
	int wa=0;
	int i=0;
	int keta=1;
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		wa=a+b;
		for (i=0;i<1;)
		{
			if (wa/10==0)
			{
				i=1;
			}
			else
			{
				wa/=10;
				keta++;
			}
		}
		printf("%d\n",keta);
		keta=1;
	}
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[]A = new int[M];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<M;i++){
			A[i] = int.Parse(str2[i]);
		}
		int[]E = new int[8];
		int[]EM = new int[8];
		for(var i=0;i<8;i++){
			E[i] = 99999;
		}
		int[]G = new int[10]{0,2,5,5,4,5,6,3,7,6};
		for(var i=0;i<M;i++){
			if(A[i]==1){
				E[2] = 2;
				EM[2] = A[i];
			} else if(A[i]==7){
				E[3] = 3;
				EM[3] = A[i];
			} else if(A[i]==4){
				E[4] = 4;
				EM[4] = A[i];
			} else if(A[i]==2 || A[i]==3 || A[i]==5){
				E[5] = 5;
				EM[5] = Math.Max(EM[5],A[i]);
			} else if(A[i]==6 || A[i]==9){
				E[6] = 6;
				EM[6] = Math.Max(EM[6],A[i]);
			} else if(A[i]==8){
				E[7] = 7;
				EM[7] = A[i];
			}
		}
		int[]DP = new int[N+1];
		int[,]DA = new int[N+1,8];
		for(var i=1;i<=N;i++){
			DP[i] = -1;
		}
		for(var i=1;i<=N;i++){
			for(var j=7;j>=2;j--){
				if(i-j>=0 && DP[i-j]!=-1){
					if(E[j] < 8){
						bool flag = false;
						if(DP[i]==-1 || DP[i-j]+1>DP[i]){
							flag = true;
						} else if(DP[i-j]+1==DP[i]){
							for(var k=9;k>=1;k--){
								if(E[G[k]]<8){
									int ta = 0;
									if(G[k]==j){
										ta = 1;
									}
									if(DA[i-j,G[k]]+ta>DA[i,G[k]]){
										flag = true;
										break;
									} else if(DA[i-j,G[k]]+ta<DA[i,G[k]]){
										flag = false;
										break;
									}
								}
							}
						}
						if(flag){
							for(var k=0;k<8;k++){
								DA[i,k] = DA[i-j,k];
							}
							DP[i] = DP[i-j]+1;
							DA[i,j] += 1;
						}
					}
				}
			}
		}
		//for(var i=0;i<=N;i++){
		//	for(var j=0;j<8;j++){
		//		Console.Write(DA[i,j]);
		//	}
		//	Console.WriteLine(" "+DP[i]);
		//}
		var list = new List<int>();
		int dn = N;
		for(var i=0;i<DP[N];i++){
			for(var j=9;j>=1;j--){
				if(EM[G[j]]==j && E[G[j]]<8){
					if(dn-E[G[j]]>=0 && DP[dn-E[G[j]]] == DP[dn]-1){
						list.Add(j);
						dn -= G[j];
						break;
					}
				}
			}
		}
		for(var i=0;i<list.Count;i++){
			Console.Write(list[i]);
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
str s1,s2,t;
ll md = 1000000007;
ll ans;
int n;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    cin>>s1;
    cin>>s2;

    int idx = 0;
    while(idx<s1.size()){
        if(s1[idx] == s2[idx]){t+='1';idx++;}
        else{t+='0';idx+=2;}
    }

    if(t[0]=='0'){ans=6;}
    else{ans=3;}

    for(int i=1;i<t.size();i++){
        char st,fn;
        st = t[i-1];
        fn = t[i];

        if(st=='0' && fn=='0'){
            ans = ((ans%md)*3)%md;
        }
        else if(st=='0' && fn=='1'){
            ans = ((ans%md)*1)%md;
        }
        else if(st=='1' && fn=='0'){
            ans = ((ans%md)*2)%md;
        }
        else if(st=='1' && fn=='1'){
            ans = ((ans%md)*2)%md;
        }
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cin >> s;

    if (s == "AAA" || s == "BBB") {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
//GG!!!
# include <iostream>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <algorithm>
# include <math.h>
# include <queue>
# define RG register
# define IL inline
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;

IL ll Read(){
	RG char c = getchar(); RG ll x = 0, z = 1;
	for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
	for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + c - '0';
	return x * z;
}

const int MAXN(500010);
int n, k, p[MAXN], id[MAXN], degree[MAXN], ft[MAXN], cnt;
priority_queue <int, vector <int>, less<int> > Q;
int t[MAXN << 2];
struct Edge{
	int nt, to;
} edge[MAXN << 1];

IL void Add(RG int u, RG int v){
	edge[cnt] = (Edge){ft[u], v}; ft[u] = cnt++; degree[v]++;
}

IL void Updata(RG int x){
	t[x] = min(t[x << 1], t[x << 1 | 1]);
}

IL void Modify(RG int x, RG int l, RG int r, RG int pos, RG int v){
	if(l == r){
		t[x] = v;
		return;
	}
	RG int mid = l + r >> 1;
	if(mid >= pos) Modify(x << 1, l, mid, pos, v);
	else Modify(x << 1 | 1, mid + 1, r, pos, v);
	Updata(x);
}

IL int Query(RG int x, RG int l, RG int r, RG int L, RG int R){
	if(l >= L && r <= R) return t[x];
	RG int mid = l + r >> 1, ans = t[0];
	if(mid >= L) ans = Query(x << 1, l, mid, L, R);
	if(mid < R) ans = min(ans, Query(x << 1 | 1, mid + 1, r, L, R));
	return ans;
}

int main(){
	Fill(t, 127); Fill(ft, -1);
	n = Read(); k = Read();
	for(RG int i = 1; i <= n; i++)
		p[i] = Read(), id[p[i]] = i;
	for(RG int i = n; i; i--){
		RG int x = Query(1, 1, n, max(1, id[i] - k + 1), id[i]);
		if(x != t[0]) Add(id[x], id[i]);
		x = Query(1, 1, n, id[i], min(id[i] + k - 1, n));
		if(x != t[0]) Add(id[x], id[i]);
		Modify(1, 1, n, id[i], i);
	}
	for(RG int i = 1; i <= n; i++)
        if(!degree[i]) Q.push(i);
	for(RG int i = n; i; i--){
		id[i] = Q.top(); Q.pop();
		for(RG int e = ft[id[i]]; e != -1; e = edge[e].nt){
			--degree[edge[e].to];
			if(!degree[edge[e].to]) Q.push(edge[e].to);
		}
	}
	for(RG int i = 1; i <= n; i++) p[id[i]] = i;
	for(RG int i = 1; i <= n; i++) printf("%d\n", p[i]);
	return 0;
}


Measured memory_bytes: 27512
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>

using namespace std;

class Point {
public:
    double _x, _y;
    Point(double x, double y): _x(x), _y(y){}
    Point(const Point& a): _x(a._x), _y(a._y){}

    Point operator+(const Point& a) const{
        return Point(_x + a._x, _y + a._y);
    }
    Point operator-(const Point& a) const{
        return Point(_x - a._x, _y - a._y);
    }
    Point operator*(double& a) const{
        return Point(_x*a, _y*a);
    }
    Point operator/(double& a) const{
        return Point(_x/a, _y/a);
    }
    void operator=(const Point& a){
        _x = a._x;
        _y = a._y;
    }
    double dot(const Point& a) const{
        return (_x*a._x + _y*a._y);
    }
};

Point operator*(double a, const Point& vec){
    return vec*a;
}
Point operator/(double a, const Point& vec){
    return vec/a;
}

typedef Point Vec;

int main(){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    Vec A(x1,y1), B(x2,y2);
    double norm = sqrt(pow(x2-x1,2) + pow(y2-y1,2));
    Vec ABunit( (B-A)/norm );

    int q;
    scanf("%d",&q);
    for(int i=0; i<q; ++i){
        double x,y;
        scanf("%lf %lf",&x,&y);
        Vec AC(Vec(x,y)-A);
        double temp = AC.dot(ABunit);
        Vec AP(temp*ABunit), PC(AC-AP), answer(A+AP-PC);

        cout << std::fixed << std::setprecision(10) << answer._x << " " << answer._y << endl;
    }
    return 0;
}


Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {
	int current = 0;
	int[] heap;
	
	public Main() {
		heap = new int[20000000];
	}
	
	public Main(int capacity) {
		heap = new int[capacity];
	}
	
	public void insert(int val) {
		current++;
		heap[current] = val;
		int iLoc = current;
		while (val > heap[parent(iLoc)]) {
			int tmp = heap[iLoc];
			heap[iLoc] = heap[parent(iLoc)];
			heap[parent(iLoc)] = tmp;
			iLoc = parent(iLoc);
		}
	}
	
	public int extractMax() {
		int max = heap[0];
		heap[0] = heap[current];
		heap[current] = 0;
		current--;
		this.maxHeapify(0);
		return max;
	}
	
	public int parent(int i) {
		return (i - 1) / 2;
	}
	
	public void maxHeapify(int i) {
		int l = 2 * i + 1;
		int r = 2 * i + 2;
		int largest;
		
		if (l < heap.length && heap[l] > heap[i]){
			largest = l;
		} else {
			largest = i;
		}
		
		if (r < heap.length && heap[r] > heap[largest]) {
			largest = r;
		}
		
		if (largest != i) {
			int tmp = heap[i];
			heap[i] = heap[largest];
			heap[largest] = tmp;
			this.maxHeapify(largest);
		}
	}
	
	public void buildMaxHeap(int[] A) {
		this.heap = A;
		for (int i = A.length / 2; i >= 0; i--) {
			this.maxHeapify(i);
		}
	}
	
	public String toString() {
		StringBuilder str = new StringBuilder();
		for (int i : heap) {
			str.append(" " + i);
		}
		//str.append("\n");
		return str.toString();
	}
	
	public static void main(String[] args) {
Scanner in = new Scanner(System.in);
		boolean notEnded = true;
		
		Main q = new Main();
		while (in.hasNextLine() && notEnded) {
			String line = in.nextLine();
			String[] components = line.split(" ");
			switch(components[0]) {
				case "insert":
					q.insert(Integer.parseInt(components[1]));
					break;
				case "extract":
					System.out.println(q.extractMax());
					break;
				default:
					notEnded = false;
					break;
			}
		}
		
	}
}


Measured memory_bytes: 546560
#include<bits/stdc++.h>	
#define int long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second 
#define mod 1000000007     
using namespace std;
const int N = 3e3 + 5;
int dp[N][N];
int par[N][N][2];
main()
{	
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string a, b, s;
	cin >> a >> b;
	memset(par, -1, sizeof par);
	int a1 = a.size(), b1 = b.size();
	for(int i = 0; i < a1; i++){
		for(int j = 0; j < b1; j++){
			if(a[i] == b[j]){
				dp[i + 1][j + 1] = 1 + dp[i][j];
				par[i + 1][j + 1][0] = i;
				par[i + 1][j + 1][1] = j;
			} else{
				if(dp[i][j + 1] >= dp[i + 1][j]){
					par[i + 1][j + 1][0] = i;
					par[i + 1][j + 1][1] = j + 1;
				}
				else{
					par[i + 1][j + 1][0] = i + 1;
					par[i + 1][j + 1][1] = j;
				}
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			} 
			
		}
	}
	int movex = a1, movey = b1;
	while (movex and movey){
		if(a[movex - 1] == b[movey - 1])
			s += a[movex - 1];
		int bla = movex;
		movex = par[movex][movey][0];
		movey = par[bla][movey][1];
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
}

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

using namespace std;
int main()
{
    int n;
    int t,a;
    cin >> n >> t >> a;
    vector<int> h(n);
    for(int i=0; i<n; i++)
    {
        cin >> h[i];
    }
    double gap = 100000000.0;
    int index = 0;
    for(int i=0; i<n; i++)
    {
        double ave = t - h[i] * 0.006;
        gap = min(abs(gap), abs(ave-a));
        if(gap == abs(ave-a))
        {
            index = i;
        }
    }
    cout << index+1;
}

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

using namespace std;

bool ans = true;
string s;
int main(){
	cin >> s;
	if(s[s.length()-1] == '1') ans = false; // N must be 0
	if(s[0] == '0') ans = false;
	for(int i=0; i<s.length()-1; ++i) if(s[i] != s[s.length()-i-2]) ans = false;
	if(ans == false) cout << "-1";
	else{
		typedef pair<int,int> pi;
		vector<pi> edgelist;
		int cur = 1, nxt = 2;
		for(int i=0; i<s.length()-1; ++i){
			edgelist.push_back(pi(cur,nxt)); 
			if(s[i] == '1') cur = nxt;
			nxt++;
		}
		for(auto i : edgelist) cout << i.first << " " << i.second << "\n";
	}
}


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


using namespace std;

typedef long long int ll;

int main(){
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> maze(h);
	for(int i = 0; i < h; i++){
		cin >> maze[i];
	}
	int res = 0;
	auto cnt = [&](int mask_i, int mask_j){
		int ct = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if( !(mask_i & (1 << i)) &&  !(mask_j & (1 << j))){
					if(maze[i][j]=='#') ++ct;
				}
			}
		}
		return ct == k;
	};
	for(int mask_i = 0; mask_i < (1 << h); mask_i++){
		for(int mask_j = 0; mask_j < (1 << w); mask_j++){
			res += cnt(mask_i,mask_j);	
		}
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int A[N];
    long long sum = 0;
    map<int,int> mp;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        mp[A[i]]++;
    }
    int Q;
    cin >> Q;
    int B[Q],C[Q];
    for (int i = 0; i < Q; i++)
    {
        cin >> B[i] >> C[i];
        mp[C[i]] += mp[B[i]];
        long long diff = mp[B[i]]*(C[i]-B[i]);
        mp[B[i]] = 0;
        sum += diff;
        cout << sum << endl;
    }
}

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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=1000000007; //998244353; //
const ld PI=3.1415926535898;
const ld EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}

int n;
int arr[20][20];
ll memo[1000000];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf("%d",&arr[i][j]);
	for(int i=0;i<(1<<n);i++){
		vector<int> v;
		int bm=i;
		while(bm&(-bm)){
			v.pb(__builtin_ctz(bm));
			bm-=(bm&(-bm));
		}
		for(int j=0;j<SZ(v);j++){
			for(int k=j+1;k<SZ(v);k++){
				memo[i]+=arr[v[j]][v[k]];
			}
		}
		for(int j=i;j;j=(j-1)&i){
			memo[i]=max(memo[i],memo[j]+memo[i-j]);
		}
	}
	printf("%lld",memo[(1<<n)-1]);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}
int main() {
  int n;
  cin >> n;
  map<ll, ll> mp;
  for (int i = 1; i <= n; ++i) {
    for (auto p : prime_factor(i)) {
      mp[p.first] += p.second;
    }
  }
  ll ans = 1;
  for(auto p :mp){
    if (p.first == 1) continue;
    ans = (ans * (p.second + 1)) % MOD;
  }
  cout << ans << endl;
}

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

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define sort(v) sort(v.begin(), v.end())
#define sortg(v) sort(v.begin(), v.end(), greater<int> ())

using namespace std;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;

using namespace std;



void solve() {

    int a, b, c;
    cin>>a>>b>>c;
    if(b*c<a){
        cout<<"No"<<endl; return;
    }
    cout<<"Yes"<<endl;
    
}

int main() {


	
	solve();

	return 0;
}

Measured memory_bytes: 3620
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m = i_map()
    for _ in range(m):
        a, b = i_map()
        num_list.append(a)
        num_list.append(b)

    num_counter = Counter(num_list)

    for i in range(1,n+1):
        print(num_counter[i])


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 764
using System;
class a
{
    static void Main()
    {
        string y = Console.ReadLine();
        int ans = 0;
        int n = int.Parse(Console.ReadLine());
        for (int k = 0; k < n; k++)
        {
            string x = Console.ReadLine();
            bool flag = false;
            for (int i = 0; i < 10; i++)
            {

                string a = x.Substring(i) + x.Substring(0, i);
                if (!flag&&a.Substring(0, y.Length) == y)
                {
                    ans++;flag = true;
                }
            }
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

Measured memory_bytes: 9116
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> k >> n;
  VI a(n),b(n); 
  rep(i,n) {
    cin >> a[i];
  }
  sort(ALL(a));
  rep(i,n-1){
    b[i] = a[i+1]-a[i];
  }
  b[n-1] = k - a[n-1]+a[0];

  rep(i,n){
    chmax(Max,b[i]);
  }

  rep(i,n){
    if(Max == b[i] && ok){
      ok = false;
    }
    else{
      ans += b[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
typedef long double ld;

int N, Q;

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

    cin >> N >> Q;
    int offset = 0;

    while (Q--) {
        int t, n;
        cin >> t >> n;
        if (t == 0) {
            cout << (offset + n - 1) % N + 1 << "\n";
        } else {
            offset = (offset + n) % N;
        }
    }
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define dg(x) cerr << #x << " = " << x <<endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define fore(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main(){
#ifdef LOCAL
    //freopen("h.txt", "r", stdin);
    // freopen("main.out", "w", stdout);
#else
    ios::sync_with_stdio(0), cin.tie(0);
    #define endl '\n'
#endif
    int n,k,q;
    cin>>n>>k>>q;
    unordered_map<int,int> mp;
    forn(i,q){
        int v;
        cin>>v;
        mp[v]++;
    }
    forn(i,n){
        int res=k-(q-mp[i+1]);
        if(res<=0)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<tuple>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int a,b;
	cin >> a >> b;

	if(a*b % 2 ==0) cout << "Even\n";
	else			cout << "Odd\n";

	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<=n;i++)
    {
        for(int j=i;j<=n;j++)
        {
            string s1="";
            for(int k=0;k<i;k++)
            s1+=s[k];
            for(int k=j;k<n;k++)
            s1+=s[k];
            if(s1.size()==7&&s1=="keyence")
            {
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
cout<<"NO"<<endl;
return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int>N(n);

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

	sort(N.begin(), N.end(),greater<int>());
	
	int sum_t = 0;

	for(int i = 0; i < k; i++){
//		cout << N[i] << endl;
		sum_t += N[i];
	}

	cout << n - sum_t << endl;
}

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

int main() {
  int K;
  cin >> K;
  int oddn=0; //奇数の個数
  int evenn=0; //偶数の個数
  for (int i=1; i<=K; i++) {
    if (i % 2 == 1) {
      oddn++;
    }
    else {
      evenn++;
    }
  }


  cout << oddn * evenn << endl;
    
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
	double x1,y1,x2,y2,x,y;
	double len;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	x = x1-x2;
	y = y1-y2;
	len = sqrt(x*x+y*y);
	printf("%f\n",len);
	return 0;
}

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

using namespace std;

const int mod = 1e9+7;

int cnt[1010101];

int solve(int n){
    int ans = 1;
    
    if (n % 2 == 1){
        if (cnt[0] != 1) return 0;
        
        for (int i = 2; i < n; i +=2){
            if (cnt[i] != 2) return 0;
            (ans *= 2) %= mod;
        }
        
        return ans;
    }
    else{
        for (int i = 1; i < n; i+=2){
            if (cnt[i] != 2) return 0;
            (ans *= 2) %= mod;
        }
        
        return ans;
    }
}


int main(){
    int n;
    cin >> n;
    
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a]++;
        
    }
    cout << solve(n) << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s;

	cin >> s;

	s[3] = '8';

	cout << s << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int a, b, c, d1, d2;
	ll cnt = 0;
	cin >> a >> b >> c;
	if (a < b) swap(a, b);
	if (a < c) swap(a, c);
	if (b < c) swap(b, c);
	d1 = a - b;
	d2 = a - c;
	cnt += d1 / 2 + d2 / 2;
	if (d1 % 2 == 1 && d2 % 2 == 1) cnt++;
	else if (d1 % 2 == 1 || d2 % 2 == 1) cnt += 2;
	cout << cnt << endl;
	return 0;
}


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

const int INF = 1e9;

vector<int> bfs(int s, const graph& G) {
	vector<int> d(G.size(), INF);
	queue<int> q;
	q.push(s);
	d[s] = 0;
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (auto to : G[v]) if (d[to] == INF) {
			q.push(to);
			d[to] = d[v] + 1;
		}
	}
	return d;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M, s, t;
	cin >> N >> M >> s >> t; --s, --t;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v; --u, --v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	auto d1 = bfs(s, G);
	auto d2 = bfs(t, G);
	int dist = d1[t];
	sort(d1.begin(), d1.end());
	sort(d2.begin(), d2.end());
	ll res = 0;
	for (int i = 0; i < N; i++) {
		if (d1[i] <= dist - 2) {
			res += upper_bound(d2.begin(), d2.end(), dist - 2 - d1[i])
				 - lower_bound(d2.begin(), d2.end(), dist - 2 - d1[i]);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 10208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<61;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return min(a,b) ? gcd(min(a,b), max(a,b)%min(a,b)) : max(a,b); }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define print(x) cout<<x<<endl;
#define wait int xxxxxxx;cin>>xxxxxxx;

//vector< vector<int> > v (max1, vector<in t>(max2) );
int main() {

	int a, b;
	cin >> a >> b;
	if (a*b == 15) { print("*")return 0; }
	else if (a + b == 15) { print("+")return 0; }
	else { print("x")return 0; }
	wait
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if (T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";
	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

void rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL) rec(T[u].r, p);
	if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL) r = i;
	}

	rec(r, 0);

	for (i = 0; i < n; i++) print(i);

	return 0;
}



Measured memory_bytes: 7688
#D
import math
X = int(input())

flag = False
for a in range(5000):
    
    for b in range(5000):
        if a**5 + b**5 == X:
            print(a,-b)
            flag = True
            break
            
        elif a**5 - b**5 == X:
            print(a,b)
            flag = True
            break
            
    if flag:
        break
    
    


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, M; cin >> N >> M;
	vector<bool> contains (N);
	vi count (N, 1);
	contains[0] = true;
	F0R(i, M) {
		int a, b; cin >> a >> b; --a; --b;
		if (count[a] == 0) continue;
		if (count[a] == 1) {
			contains[b] = contains[b] | contains[a];
			contains[a] = false;
		} else {
			contains[b] = contains[b] | contains[a];
		}
		--count[a]; ++count[b];
	}

	int total = 0;
	for (bool x : contains) total += (int) x;
	print(total);
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define listcount 100000

int main() {
	//文字列
	char type[20001];
	//左スラッシュの数
	int LeftWall[listcount];
	
	int LeftWall_count[listcount];
	//深さ
	int depth = 0;
	
	//水たまりの数
	int count = 0;
	//各水たまりの面積
	int puddlevalue[listcount];
	int puddle_Left[listcount];
	
	
	scanf("%s", type);
	for(int i = 0; type[i] != '\0'; i++){
//		printf("%c ", type[i]);
		if(type[i] == '\\'){
//			printf("type1\n");
			depth++;
			LeftWall[depth] = i;
		}else if(type[i] == '/'){
//			printf("type2");
			if(depth > 0){
				int value = i - LeftWall[depth];
				puddlevalue[count] = value;
				puddle_Left[count] = LeftWall[depth];
				for(int u = 1; u < 5;){
					if(count == 0){
						u = 10;
					}else if(puddle_Left[count - 1] > LeftWall[depth]){
						puddle_Left[count - 1] = LeftWall[depth];
						puddlevalue[count - 1] += puddlevalue[count];
						count--;
					}else{
						u = 10;
					}
				}
//				printf(" %d",value);
				depth--;
				count++;
			}
/*			printf("%d\t... ", i);
			for(int o = 0; o < count; o++){
				printf("%d(%d) ",puddlevalue[o],puddle_Left[o]);
			}
			printf("\n");*/
//			printf("\ndepth : %d\n",depth);
		}else{
//			printf("type3\n");
		}
//		printf("%d ",depth);
	}
	
	int puddletotal = 0;
	for(int i = 0; i < count; i++){
		puddletotal += puddlevalue[i];
	}
	printf("%d\n",puddletotal);
	printf("%d",count);
	for(int i = 0; i < count; i++){
		printf(" %d", puddlevalue[i]);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2092
#D
n,a,b = map(int,input().split())

MOD = 10**9 + 7

ans = pow(2,n,MOD) - 1

#n本からa本を選ぶ→繰り返し二乗法
x = 1
#x=n*(n-1)*...*(n-a+1)
for i in range(n-a+1, n+1):
    x *= i
    x %= MOD
#y=a*(a-1)*...*1
for j in range(1,a+1):
    x *= pow(j,MOD-2,MOD)
    x %= MOD
y = 1
#n本からb本選ぶ(aの時と同じ)
for i in range(n-b+1, n+1):
    y *= i
    y %= MOD
#y=a*(a-1)*...*1
for j in range(1,b+1):
    y *= pow(j,MOD-2,MOD)
    y %= MOD
    
ans -= x + y
ans %= MOD
print(ans)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define _ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int pwmd(int n, int m)
{
    int res = 1;
    while (m > 0)
    {
        if (m & 1)
            res = (res % mod * n % mod) % mod;
        m /= 2;
        n = (n % mod * n % mod) % mod;
    }
    return res;
}

int32_t main()
{
    int n, k;
    cin >> n >> k;

    int ans = 0;

    int dp[k + 1] = {0};

    for (int i = k; i > 0; i--)
    {
        int temp = pwmd(k / i, n);
        dp[i] = temp;

        for (int j = i + i; j <= k; j += i)
        {
            dp[i] = (dp[i] % mod - dp[j] + mod) % mod;
        }

        ans = (ans % mod + (i % mod * dp[i] % mod) % mod) % mod;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 4348