akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define ll long long
#define se second
using namespace std;

int main(){
	// int t;cin>>t;while(t--){
		// ll n;cin>>n;ll s[n+1],c[n+1],f[n+1];
		// for(int i=1;i<=n-1;i++)
		// {
		// 	cin>>c[i]>>s[i]>>f[i];
		// }
	
		// for(int i=1;i<=n-1;i++)
		// {
		// 	ll total=0;
		// 	total+=c[i]+s[i];
		// 	for(int j=i+1;j<=n-1;j++)
		// 	{
		// 		if(total<=s[j])
		// 		total=s[j]+c[j];
		// 		else
		// 		{
		// 			if(total%f[j]==0)
		// 			total=total+c[j];
		// 			else
		// 				total+=(total%f[j])+c[j];
					
		// 		}
				
		// 	}
		// 	cout<<total<<endl;
		// }
		// cout<<"0\n";
		
		
		
		
		ll n,k;cin>>n>>k;
		ll a[n+1];
		vector<ll> pos,neg;
		int f=0;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]==0){f++;continue;}
			if(a[i]<0)neg.push_back(a[i]*-1);
			else pos.push_back(a[i]);
			
		}
					ll P[n+1]={0},N[n+1]={0};
		P[0]=0,N[0]=0;
		if(f==1)--k;
		if(k==0){cout<<"0\n";}

		else if(neg.size()==0)
		{
					sort(pos.begin(),pos.end());
					for(int i=0;i<pos.size();i++)
					P[i+1]=P[i]+(pos[i]-P[i]);
					cout<<P[k]<<endl;


		}
		else if(pos.size()==0)
		{
					sort(neg.begin(),neg.end());
					for(int i=0;i<neg.size();i++)
					N[i+1]=N[i]+(neg[i]-N[i]);
					cout<<N[k]<<endl;

		}
		else
		{
		sort(pos.begin(),pos.end());
		sort(neg.begin(),neg.end());
		for(int i=0;i<neg.size();i++)
		N[i+1]=N[i]+(neg[i]-N[i]);
		for(int i=0;i<pos.size();i++)
		P[i+1]=P[i]+(pos[i]-P[i]);
		

			ll mi=10000000009;
			for(int i=0;i<neg.size();i++)
			{
				
			// cout<<k<<"  "<<i+1<<"  "<<N[i+1]<<"  "<<N[i+1]*2+pos[k-(i+1)-1]<<"  "<<pos.size()<<"  "<<mi<<endl;

			if(k-i+1==0){mi=min(mi,N[i+1]);break;}
			if(k-(i+1)>0)
			{
			if(pos.size()>=k-(i+1))
			mi=min(mi,N[i+1]*2+pos[k-(i+1)-1]);
			else continue;
			}
			
			
			}
			
			
			for(int i=0;i<pos.size();i++)
			{
				
			// cout<<k<<"  "<<i+1<<"  "<<P[i+1]<<"  "<<P[i+1]*2+neg[k-(i+1)-1]<<"  "<<neg.size()<<"  "<<mi<<endl;

			if(k-i+1==0){mi=min(mi,P[i+1]);break;}
			if(k-(i+1)>0)
			{
			if(neg.size()>=k-(i+1))
			mi=min(mi,P[i+1]*2+neg[k-(i+1)-1]);
			else continue;
			}
			}
			
			cout<<mi<<endl;
			
			
			
		}
		
		
		
		
		
		
		
		
		
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define MOD 10e9+7

int main(){
    rep(i,3){
        string s; cin >> s;
        transform(s.begin(), s.end(), s.begin(), ::toupper);
        cout << s[0];
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define debd(x) pf("%s = %d\n", #x, x)
#define debs(x) pf("%s = %s\n", #x, x)
#define debll(x) pf("%s = %lld\n", #x, x)
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return pos;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};


int main() {
//  freopen("input.in", "r", stdin);
	bool x[123];
	fr(i, 0, 122) x[i] = false;
	for(int i = 0 ; i < 101 ; i += 4) {
		x[i] = true;
		for(int j = 0 ; j < 101 ; j += 7) {
			if(i+j < 101) x[i+j] = true;
		}
	}
	int q;
	sf("%d", &q);
	puts(x[q] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;


int d[1000005];

int f(int k) {
        return (k%2 == 0 ? k/2 : 3*k + 1);
}

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

        int c = 1;
        d[s] = 1;
        while (1) {
                int i = f(s);
                c++;

                if (d[i])
                        break;
                d[i] = 1;
                s = i;
        }

        cout << c << endl;
        return 0;
}


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

using ll = long long;
const int INF = 1e9 + 5;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,W,w,v;
    cin>>n>>W;
    vector<ll> dp(100005,0);
    
    for(int i=0;i<n;i++){
		cin>>w>>v;
		for(int j=100000;j>=w;j--){
			dp[j] = max(dp[j],dp[j-w] + v);
		}
	}
	ll ans = 0;
	for(int i=0;i<=W;i++){
		ans = max(ans,dp[i]);
	}
    cout<<ans;
    return 0;
}









Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner s = new Scanner(System.in);
        double a = Double.parseDouble(s.next());
        double b = Double.parseDouble(s.next());
        double n = Double.parseDouble(s.next());
          
        double base = Math.floor(n/b); 
        double as = Math.floor(a*n/b);

        int iBase = (int)base;

        if (iBase == 0) System.out.println((int)(Math.floor(as - a*base)));
        else if (iBase == 1) {
            int result = (int)(Math.floor(as - a*base));
            n = b-1;
            base = Math.floor(n/b); 
            as = Math.floor(a*n/b);
            int resultb = (int) (Math.floor(as - a*base));

            System.out.println(Math.max(result, resultb));
        } else {
            int result = (int)(Math.floor(as - a*base));
            if (iBase - 1 == 0) {
                n = b*iBase - 1;
                base = Math.floor(n/b); 
                as = Math.floor(a*n/b);
                int resultb = (int) (Math.floor(as - a*base));

                result = Math.max(result, resultb);
            }
            System.out.println(result);
        }
    }
}

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

int main() {

  int n, i;
  int a[100];
  
  cin >> n;

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

  cout << a[n-1];
  
  for(i = n-2; i >= 0; i--) {
    cout << " " << a[i];
  }

  cout << endl;

  return 0;
  
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

struct Coordinate {
    int y, x;
};

int main(){
    int N, u, v; cin >> N >> u >> v; u--; v--;
    vector<vector<int> > g(N);
    int u_dist[N], v_dist[N];

    fill(u_dist, u_dist+N, MM);
    fill(v_dist, v_dist+N, MM);

    for (int i = 0; i < N-1; i++){
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    u_dist[u] = 0; v_dist[v] = 0;

    queue<int> que; 
    que.push(u);
    while(que.size()){
        int now = que.front();
        que.pop();
        for (int i = 0; i < g[now].size(); i++){
            int to = g[now][i];
            if (u_dist[to] > u_dist[now]+1){
                u_dist[to] = u_dist[now]+1;
                que.push(to);
            }
        }
    }

    que.push(v);
    while(que.size()){
        int now = que.front();
        que.pop();
        for (int i = 0; i < g[now].size(); i++){
            int to = g[now][i];
            if (v_dist[to] > v_dist[now]+1){
                v_dist[to] = v_dist[now]+1;
                que.push(to);
            }
        }
    }

    int maxDist = 0;
    for (int i = 0; i < N; i++){
        if (u_dist[i] <= v_dist[i]){
            maxDist = max(maxDist, v_dist[i]);
        }
    }
    cout << maxDist-1 << endl;
}

Measured memory_bytes: 6656
#include<iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define pb push_back 
#define vi vector<int>
#define loop(x,a,b) for(ll x=a; x<b; x++)
#define rloop(x,a,b) for(ll x=a; x>=b; x--)
#define ll long long 
int main()
{
    ll n,sum;
    string s;
    cin>>s;
    n = s.length();
    if(n == 1){
        stringstream geek(s); 
        
        int x = 0; 
        geek >> x;
        if(x%9 == 0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        sum = 0;
        loop(i,0,n){
            sum += s[i] - '0';
        } 
        if (sum%9 == 0)
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;
    }            
    return 0;
}

Measured memory_bytes: 3684
n,m=map(int,input().split())
list_0=[]
for i in range(n):
    L=list(map(int,input().split()))
    list_0.append(L[1:])
#print(list_0)
kei=[0 for i in range(m)]
#print(kei)
for i in range(n):
    for j in range(len(list_0[i])):
        kei[list_0[i][j]-1]+=1
#print(kei)
c=0
for i in range(len(kei)):
    if kei[i]==n:
        c+=1
print(c)

Measured memory_bytes: 3064
//ABC0121A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H-h)*(W-w) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
string s, t, B = "~";
bool isOK(string ss,string t)
{//sをi文字目からtと同じ文字数で切り取ったものがssとして届く
 //cout << ss<<":"<<t<<endl;
 rep(i,ss.size())
 { 
   if(ss[i]!='?'&&ss[i]!=t[i])
   {return false;}
 }
 //cout<<"true!"<<endl;
 return true;

}
int main() {
	cin >> s >> t;
	for (int i = 0; i <= (int)s.size() - (int)t.size(); i++) {
		string U = s.substr(i, t.size());
		if (isOK(U, t) == true) {
			string v = s;
			//for (int j = i; j < i + t.size(); j++)v[j] = t[j - i];
			for(int j=0; j<t.size(); j++)
	    	{v[j+i]=t[j];}
	 		rep(j,i)//i(挿入開始地点)まで見る
	 		{if(v[j]=='?')v[j]='a';}
	 		for(int j=i+t.size(); j <s.size();j++)
	 		{if(v[j]=='?')v[j]='a';}
			B = min(B, v);

	  		/*string v=s;
	    	for(int j=0; j<t.size(); j++)
	    	{v[j+i]=t[j];}
	    	//?を置き換え
	 		rep(j,i)//i(挿入開始地点)まで見る
	 		{if(v[j]=='?')v[j]='a';}
	 		for(int j=i+t.size(); j <s.size();j++)
	 		{if(v[j]=='?')v[j]='a';}*/
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int n, l, q, h[100010], dt[20][100010];

int main()
{
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; i++ ) scanf("%d", h+i);
    scanf("%d%d", &l, &q);
    for(int i = 1 ; i <= n ; i++ )
        dt[0][i] = (int)(upper_bound(h+1, h+n+1, h[i]+l) - h) - 1;
    for(int j = 1 ; j < 20 ; j++ ) for(int i = 1 ; i <= n ; i++ )
        dt[j][i] = dt[j-1][dt[j-1][i]];
    while( q-- )
    {
        int a, b, cnt = 0, d;
        scanf("%d%d", &a, &b);
        if( a > b ) swap(a, b);
        for(int i = 19 ; i >= 0 ; i-- )
        {
            if( dt[i][a] < b )
            {
                cnt += (1<<i);
                a = dt[i][a];
                d = 0;
            }
            else d = i;
        }
        printf("%d\n", cnt+(1<<d));
    }
    return 0;
}


Measured memory_bytes: 8960
#include<algorithm>
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
#define x second
#define y first
#define M st.size()
typedef complex<double> point;
pair<int,int> a[100000];
vector<int> st;
bool ccw(point a,point b,point c){
  b-=a;
  c-=a;
  c*=conj(b);
  if(c.imag()<=0)return true;  
  return false;
}

void check(int i){
 while(M>=2){
      int s=st[M-2];
      int e=st[M-1];
      point S=point(a[s].x,a[s].y);
      point E=point(a[e].x,a[e].y);
      point N=point(a[i].x,a[i].y);
      if(ccw(S,E,N))break;
      st.pop_back();
    }
 st.push_back(i);
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;
  sort(a,a+n);
  for(int i=0;i<n;i++)check(i);
  for(int i=n-2;i>=0;i--)check(i);
  st.pop_back();
  cout<<M<<endl;
  cout<<a[st[0]].x<<' '<<a[st[0]].y<<endl;
  for(int i=M-1;i>0;i--)cout<<a[st[i]].x<<' '<<a[st[i]].y<<endl;
  return 0;
}

Measured memory_bytes: 2456
#include <iostream>

using namespace std;

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

    int a[256];
    bool odd = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 1) odd = true;
    }

    int count = 0;
    while (odd == false) {
        for (int i = 0; i < n; i++) {
            if ((a[i]/=2) % 2 == 1) odd = true;
        }
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
vector<int> G[MAXN];
int dep[MAXN];
bool OK[MAXN];

void bfs(int cur, vector<int> &dis) {
    dis[cur] = 0;
    queue<int> qu;
    qu.push(cur);
    while (!qu.empty()) {
         int tp = qu.front();
         qu.pop();
         for (auto i : G[tp]) {
             if (!dis[i] && i != cur) {
                 qu.push(i);
                 dis[i] = dis[tp] + 1;
             }
         }
    }
}

int dfs(int cur, int par) {
    int ans = 0;
    for (int i : G[cur]) {
        if (i != par) {
            ans = max(dfs(i, cur), ans);
        }
    }
    return dep[cur] = ans;
}

int dfs2(int cur, int par, int tg) {
    if (cur == tg) return OK[cur] = true;
    for (int i : G[cur]) {
        if (i == par) continue;
        if (dfs2(i, cur, tg)) return OK[cur] = true;
    }
    return false;
}

int main() {
    int N, u, v;
    scanf("%d %d %d", &N, &u, &v);
    u--, v--;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> disu(N, 0), disv(N, 0);
    bfs(u, disu);
    bfs(v, disv);
    dfs(v, v);
    dfs2(v, v, u);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (disu[i] > disv[i]) continue;
        if (disu[i] == disv[i] && OK[i])
            ans = max(ans, disu[i]);
        else if (disu[i] < disv[i])
            ans = max(ans, disv[i] + dep[i] - 1);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12672
n = int(input())
numlist = [1,2,3,4,5,6,7,8,9]
flag = False

for i in numlist:
  ans1 = n / i
  for j in numlist:
    ans2 = ans1 / j
    if ans2 == 1:
      flag = True
      
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9108
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin>>a[i];
  int dp[n]={0};
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i]-a[i-2]));

  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
# include <iostream>
# include <map>
using namespace std;
# define ll long long

int main(){
  int N;
  map<ll, int> freqOfSum;
  
  cin >> N;
  
  ll sum = 0, ans = 0;
  freqOfSum[0]++;
  for(int i=0; i<N; i++){
    int num; cin >> num;
    sum += num;
    ans += freqOfSum[sum];
    freqOfSum[sum]++;
  }
  
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 16028
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(abs(c-a)<=abs(d)){
        printf("Yes\n");
    }
    else if(abs(b-a)<=abs(d)&&abs(c-b)<=abs(d)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
N = gets.chomp.to_i
aAry = gets.chomp.split(' ').map(&:to_i)

aAry.sort!

ans = 0
n = N - 1

ans += aAry.pop
n -= 1

while n > 0 do
    if n == 1 then
        ans += aAry.pop
        n -= 1
    else
        ans += aAry.pop * 2
        n -= 2
    end
end

puts ans


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}

const ll SIZE = 1e5+10;

string n;

int main(){
    cin >> n;
    for(int i = 0; i < n.length(); i++){
        if(n[i] == '7'){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << "\n";

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int x[n];
  rep(i,n) cin >> x[i];

  int ans[100];

  rep(i,100) ans[i]=0;

  
      for(int j=0;j<100;j++){
          for(int i=0;i<n;i++){
          ans[j]+=(j+1-x[i])*(j+1-x[i]);
      }
  }

  sort(ans,ans+100);

  cout << ans[0] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 101

int count = 0;

void selection_sort(int n,int *A){
  int i,j,tmp,index;
  for(i=0;i<n-1;i++){
    index = i;
    for(j=i+1;j<n;j++)
      if(A[j]<A[index])
        index = j;
    tmp = A[i];
    A[i] = A[index];
    A[index] = tmp;
    if(index!=i)count++;
  }
}

int main(){
  int n,i;
  int a[MAX];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  selection_sort(n,a);
  for(i=0;i<n-1;i++)
    printf("%d ",a[i]);
  printf("%d\n",a[i]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int ans[5][4][11];

int main()
{
	int n, b, f, r, v;

	cin >> n;
	rep(i, n) {
		cin >> b >> f >> r >> v;
		ans[b][f][r] += v;
	}

	repc(i, 1, 4) {
		repc(j, 1, 3) {
			repc(k, 1, 10) {
				cout << ' ' << ans[i][j][k];
			}
			cout << endl;
		}
		if (i < 4) cout << "####################" << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string s;
    cin >> s;
    int lower_cnt = 0;
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int C_cnt = 0;
    for(int i = 1; i < s.size(); i++) {
        if (s[i] >= 'a' && s[i] <= 'z')
            lower_cnt += 1;
        if (i >= 2 && i < s.size()-1 && s[i] == 'C')
            C_cnt += 1;

    }
    if (C_cnt == 1 && lower_cnt == s.size()-2) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M; cin>>N>>M; cout<<N*(N-1)/2+M*(M-1)/2<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int G[101][101];

int main(){
  int u,n,i,j,c,k;


  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&c);
    for(j=1;j<=c;j++){
      scanf("%d",&k);
      G[u][k] = 1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",G[i][j]);
      if (j != n) printf(" ");
    }
    printf("\n");
  }

  return 0;
  
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;

void dfs(Graph &G, int v, vector<bool> &seen, int &ans){
  seen.at(v) = true;
  bool end = true; // 行けるところが無くなったらtrue
  for (auto nv : G.at(v)){
    if (seen.at(nv)) continue;
    dfs(G, nv, seen, ans);
    end = false;
  }
  if (end){
    bool ok = true;
    for (auto vs : seen){
      ok = ok && vs;
    }
    if (ok) ans++;
  }
  seen.at(v) = false;
  return;
}

int main() {
  int N,M; cin >>N >>M;
  Graph G(N);
  for (int i=0; i<M; i++){
    int a,b; cin >>a >>b;
    a--; b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<bool> seen(N, false);
  int ans = 0;
  dfs(G, 0, seen, ans);
  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
  int n;
  cin >> n;
  int c4=0,c2=0;
  rep(i,n){
    int a;
    cin >> a;
    if(a%4==0) c4++;
    else if(a%2==0) c2++;
  }
  bool ok=0;
  int a = n/2 -c4;

  if(c4>=n/2) ok=1;
  else if(n%2==0){
    if(c2>=2*a) ok =1;
  }else{
    if(c2>2*a) ok=1;
  }
  

  if(ok) cout << "Yes" << endl;
  else cout<< "No" << endl;

  return 0; 
}


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

#define F first
#define S second
#define pb push_back

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int main() {
    int n = readInt();
    int prev_x = 0;
    int prev_t = 0;
    int prev_y = 0;
    for (int i = 1; i <= n; i++) {
    	int t = readInt(), x = readInt(), y = readInt();
		int distance = abs(x - prev_x) + abs(y - prev_y);
		if ((t - prev_t) % 2 != distance % 2 || t - prev_t < distance) {
			puts("No");
			return 0;			
		}
		prev_t = t;
		prev_x = x;
		prev_y = y;    	
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cctype>

int main(){
    char ch;
    int sum=0;
    while(true){
        while((ch = getchar()) != '\n'){
            sum += ch - '0';
        }
        if(sum == 0){
            break;
        } else {
            printf("%d\n",sum);
            sum = 0;
        }
    }
    return 0;
}



Measured memory_bytes: 2688
using System;

namespace Sample101
{
    class Program
    {

        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            char[] cArray = n.ToCharArray();

            for (int i = 0; i < cArray.Length; ++i)
            {
                if (cArray[i] == '1')
                {
                    cArray[i] = '9';
                } else
                {
                    cArray[i] = '1';
                }
            }

            Console.WriteLine(new string(cArray));
        }
    }
}

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

using namespace std;

int main(){
    string s;
    while(cin>>s,s[0]!='#'){
        int sl=s.length();
        int ans=0;
        vector<int>memo(30,-1);
        queue<string>s1,s2;
        for(int i=0;i<(1<<sl);++i){
            string a=s;
            for(int j=0;j<sl;++j){
                if(i & (1<<(sl-j-1))){
                    a[j]++;
                    if(memo[s[j]-'a'+1]!=i && s[j]!='z'){
                        memo[s[j]-'a'+1]=i;
                    }else{
                        goto BREAK1;
                    }
                }else{
                    if(memo[s[j]-'a']!=i && s[j]!='a'){
                        goto BREAK2;
                    }else{
                        memo[s[j]-'a']=i;
                    }
                }
            }
            ++ans;
            if(ans<=10)s1.push(a);
            s2.push(a);
            if(s2.size()>5)s2.pop();
            BREAK1:
            BREAK2:
            1;
        }
        cout<<ans<<endl;
        if(ans<=10){
            for(int i=0;i<ans;++i){
                cout<<s1.front()<<endl;
                s1.pop();
            }
        }
        else{
            for(int i=0;i<5;++i){
                cout<<s1.front()<<endl;
                s1.pop();
            }
            for(int i=0;i<5;++i){
                cout<<s2.front()<<endl;
                s2.pop();
            }
        }
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n+1, 0);
    rep2(i, 1, 101) rep2(j, 1, 101) rep2(k, 1, 101) {
        int curr = i * i + j * j + k * k + i * k + j * k + i * j;
        if (curr <= n) v[curr]++;
    }
    rep2(i, 1, n+1) {
        cout << v[i] << endl;
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)1e5) + 5;
const long long int M = ((long long int)1e3) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

lli n,m;
bool canredbe[N];
lli ballCount[N];
lli ans;

int main ()
{
	fast;
	//freop;
	cin >> n >> m;
	canredbe[1] = true;
	for (lli i = 1; i <= n; i++)
		ballCount[i] = 1;
	for (lli i = 1; i <= m; i++)
	{
		lli a,b;
		cin >> a >> b;
		//cout << "[d] " << ballCount[a] << " " << ballCount[b]<< "\n";
		if (ballCount[a] == 1 && canredbe[a])
		{
			ballCount[a]--;
			canredbe[a] = false;
			ballCount[b]++;
			canredbe[b] = true;
		}
		else if (ballCount[a] > 1 && canredbe[a])
		{
			ballCount[a]--;
			ballCount[b]++;
			canredbe[b] = true;
		}
		else if (!canredbe[a])
		{
			ballCount[a]--;
			ballCount[b]++;
		}
	}
	for (lli i = 1; i <= n; i++)
	{
		ans += canredbe[i];
	}
	cout << ans << "\n";
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n;
  vector<int> pi;

  cin >> n;
  for(int i=0; i<n; i++){
    int temp;
    cin >> temp;
    pi.push_back(temp);
  }

  int ans = 0;
  for(int i=1; i<n-1; i++){
    if( pi[i-1] < pi[i] && pi[i] < pi[i+1] ){
      ans += 1;
    }else if( pi[i-1] > pi[i] && pi[i] > pi[i+1] ){
      ans += 1;
    }
  }

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


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll a=0,b=0;
  ll ans=0;
  rep(i,s.size()){
    if(s[i]=='0') a++;
    else b++;
    if(a>0&&b>0){
      a--,b--;
      ans+=2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    s.insert(x);
  }
  cout << (s.size() == n ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll c500 = X / 500;
  X %= 500;
  ll c5 = X / 5;

  cout << c500 * 1000 + c5 * 5 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x,y;
	int i;
	int temp;
	int c=1;
	scanf("%d%d",&x,&y);
	if(x<y){
		temp=x;
	}else{
		temp=y;
		
	}
	//printf("a");
	/*
	if(x>y){
	for(i=1;i<=temp;i++){
		if(y%i==0&&(x%y)%i==0){
			
			a=i;
			
		}
	}
	}else{
		
		for(i=1;i<=temp;i++){
		if(x%i==0&&(y%x)%i==0){
			
			a=i;
			
		}
	}
	
	}*/
	/*for(i=temp;i>=1;i--){
		if(x%i==0&&y%i==0){
			printf("%d\n",i);
			break;
		}
	}*/
	if(x>y){
	while(c!=0){
		c=x%y;
		x=y;
		y=c;
		
		
	}
	}else{
			while(c!=0){
		c=y%x;
		y=x;
		x=c;
		
		
	}
		
		
		
		
		
	}
	if(x>y){
	printf("%d\n",x);
	}else{
		
		printf("%d\n",y);
	}
	return 0;
}


Measured memory_bytes: 2100
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
kill = 0

for i in range(N):
    if A[i] >= B[i]:
        kill += B[i]
        A[i] -= B[i]
        B[i] = 0
    else:#A[i] < B[i]
        tmp = A[i]
        kill += tmp
        B[i] -= tmp
        A[i] = 0
        if A[i+1] >= B[i]:
            kill += B[i]
            A[i+1] -= B[i]
        else:#A[i+1] < B[i]
            tmp = A[i+1]
            kill += tmp
            B[i] -= tmp
            A[i+1] = 0
print(kill)


Measured memory_bytes: 19392
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll a,b;
  cin >> a >> b;
  if((a+b)%2==1){
    cout << "IMPOSSIBLE" << endl;
  }
  else{
    cout << (a+b)/2 << endl;
  }
  return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;


void solve(long long N, std::string S, std::string T){
    for(int i = 0; i < N; ++i){
        cout << S[i] << T[i];
    }
    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
H=list(map(int,input().split()))
road=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    road[a-1].append(b)
    road[b-1].append(a)
c=0
for i in range(N):
    T=True
    for j in road[i]:
        if H[i]<=H[j-1]:
            T=False
    if T:
        c+=1
print(c)

Measured memory_bytes: 29256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

//GCD(最大公約数)
ll gcd(ll a, ll b) {
   if(a < b) return gcd(b, a);
   if(b == 0) return a;
   return gcd(b, a % b);
}

vector<pair<ll, ll>> v;
void f(ll n) {
    for(ll i = 2; i * i <= n; i++) {
        if(n % i != 0) continue;

        ll ex = 0;

        while(n % i == 0) {
            ex++;
            n /= i;
        } 

        v.push_back({i, ex});      
    }
    if(n != 1) v.push_back({n, 1});
    return;
}

int main() {
    ll a, b;
    cin >> a >> b;

    ll g = gcd(a, b);

    f(g);

    cout << v.size() + 1 << endl;

    return 0;
}


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

const int INF = 100000000;

int N,A,B,C,a,b,c; vector<int> l;
void input()
{
    cin >> N >> a >> b >> c;
    l.resize(N);
    for(int i=0; i<N; ++i) cin >> l[i];
}

void f(int l)
{
    if(l==6){ A = a; B = b; C = c;}
    if(l==5){ A = a; B = c; C = b;}
    if(l==4){ A = b; B = a; C = c;}
    if(l==3){ A = b; B = c; C = a;}
    if(l==2){ A = c; B = a; C = b;}
    if(l==1){ A = c; B = b; C = a;}
    return;
}

void solve()
{
    int loop = 6;
    int MIN = INF;
    while(loop > 0){
        f(loop);
        bitset<8> bts(0),A_bts,B_bts,C_bts;
        int min_A = INF, min_B = INF, min_C = INF;
        for(int i=1; i<(1<<N); ++i){
            bts = i;
            int sum = 0, mp = -1;
            for(int j=0; j<N; ++j){
                if(bts[j] == 1) {
                    sum += l[j];
                    ++mp;
                }
            }
            if(min_A > abs(A-sum) + mp*10){
                A_bts = bts;
                min_A = abs(A-sum) + mp*10;
            }
        }
        // cout << min_A << " " << A_bts << endl;

        for(int i=1; i<(1<<N); ++i){
            bts = i; 

            bool flag = false;
            for(int j=0; j<N; ++j){
                if((bts[j] & A_bts[j]) == 1){
                    flag = true; break;
                }
            }
            if(flag) continue;

            int sum = 0, mp = -1;
            for(int j=0; j<N; ++j){
                if(bts[j] == 1) {
                    sum += l[j];
                    ++mp;
                }
            }
            if(min_B > abs(B-sum) + mp*10){
                B_bts = bts;
                min_B = abs(B-sum) + mp*10;
            }
        }
        // cout << min_B << " " << B_bts << endl;

        for(int i=1; i<(1<<N); ++i){
            bts = i; 

            bool flag = false;
            for(int j=0; j<N; ++j){
                if((bts[j] & (A_bts[j] | B_bts[j])) == 1){
                    flag = true; break;
                }
            }
            if(flag) continue;

            int sum = 0, mp = -1;
            for(int j=0; j<N; ++j){
                if(bts[j] == 1) {
                    sum += l[j];
                    ++mp;
                }
            }
            if(min_C > abs(C-sum) + mp*10){
                C_bts = bts;
                min_C = abs(C-sum) + mp*10;
            }
        }
        // cout << min_C << " " << C_bts << endl;

        --loop;
        // cout << endl;

        MIN = min(MIN,min_A + min_B + min_C);
    }
    cout << MIN << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

if N==1:
    print(1)
    exit()

dis = {}

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        X = XY[j][0]-XY[i][0]
        Y = XY[j][1]-XY[i][1]
        if (X,Y) in dis:
            dis[(X,Y)] += 1
        else:
            dis[(X,Y)] = 1
print(N-max(dis.values()))

Measured memory_bytes: 68208
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    char c; cin >> c;

    string ans;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        ans = "vowel";
    } else {
        ans = "consonant";
    }

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

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main() {
    // input
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    // solve
    int ans = 0;

    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if (500 * i + 100 * j + 50 * k == X) ans++;
            }
        }
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Constants;

public static class Constants
{
    public const long Mod = (long)1e9 + 7;
}

public struct ModInt
{
    public long Num;

    public ModInt(long num)
    {
        Num = num;
    }

    // x^n
    public static long Power(long x, long n)
    {
        long pow = 1;
        while (n > 0)
        {
            if (n % 2 == 0)
            {
                x *= x;
                x %= Mod;
                n /= 2;
            }
            else
            {
                pow *= x;
                pow %= Mod;
                n--;
            }
        }

        return pow;
    }

    public static ModInt GetInv(long f)
    {
        // フェルマーの小定理 a^(-1) = a^(mod-2)
        return new ModInt(Power(f, Mod - 2));
    }

    public ModInt GetInv()
    {
        return GetInv(Num);
    }

    public override string ToString()
    {
        return Num.ToString();
    }

    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Num += r.Num;
        if (l.Num >= Mod)
        {
            l.Num -= Mod;
        }
        return l;
    }

    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Num -= r.Num;
        if (l.Num < 0)
        {
            l.Num += Mod;
        }
        return l;
    }

    public static ModInt operator *(ModInt l, ModInt r)
    {
        return new ModInt(l.Num * r.Num % Mod);
    }

    public static implicit operator ModInt(long n)
    {
        n %= Mod;
        if (n < 0)
        {
            n += Mod;
        }
        return new ModInt(n);
    }
}

public class Solution
{
    static int ToInt(char c)
    {
        return c - '0';
    }

    public static void Main()
    {
        var s = Console.ReadLine();
        // dp[i番目まで][余り]
        var dp = Enumerable.Range(0, s.Length).Select(_ => new ModInt[13]).ToArray();

        {
            if (s[0] == '?')
            {
                for (int j = 0; j < 10; j++)
                {
                    dp[0][j] = 1;
                }
            }
            else
            {
                dp[0][ToInt(s[0])] = 1;
            }
        }
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i] == '?')
            {
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 13; k++)
                    {
                        var m = (k * 10 + j) % 13;
                        dp[i][m] += dp[i - 1][k];
                    }
                }
            }
            else
            {
                var j = ToInt(s[i]);
                for (int k = 0; k < 13; k++)
                {
                    var m = (k * 10 + j) % 13;
                    dp[i][m] += dp[i - 1][k];
                }
            }
        }

        Console.WriteLine(dp.Last()[5]);
    }
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		vi sum(n+2);
		rep(i,m){
			int a,b; cin>>a>>b;
			sum[a]++,sum[b]--;
		}
		rep(i,n+1) sum[i+1]+=sum[i];
		
		int res=0;
		rep(i,n+1) res+=(sum[i]?3:1);
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1200
#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int h[maxn],go[maxn*2],nxt[maxn*2],fa[maxn],co[maxn],kk[maxn],bb[maxn],sta[maxn];
bool bz[maxn];
int i,j,k,l,t,n,m,u,v,a,b,x,tot,top,num;
ll ans;
bool czy,gjx;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
int getfa(int x){
	if (!fa[x]) return x;
	int t=getfa(fa[x]);
	co[x]=co[x]^co[fa[x]];
	return fa[x]=t;
}
void travel(int x,int y){
	bz[x]=1;
	int t=h[x];
	while (t){
		if (go[t]!=y){
			if (bz[go[t]]){
				u=x;v=go[t];
				if (co[u]==co[v]) gjx=1;
			}
			else{
				co[go[t]]=co[x]^1;
				travel(go[t],x);
			}
		}
		t=nxt[t];
	}
}
void dfs(int x,int y){
	int t=h[x];
	while (t){
		if (go[t]!=y&&!(x==u&&go[t]==v||x==v&&go[t]==u)){
			dfs(go[t],x);
			kk[x]+=kk[go[t]];
			bb[x]+=bb[go[t]];
		}
		t=nxt[t];
	}
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d%d",&j,&k);
		add(j,k);add(k,j);
		/*a=getfa(j);b=getfa(k);
		if (a!=b){
			add(j,k);add(k,j);
			fa[a]=b;
			co[a]=co[j]^co[k]^1;
		}
		else{
			u=j;v=k;
			if (co[j]==co[k]) gjx=1;
		}*/
	}
	//fo(i,1,n) getfa(i);
	/*if (!co[1])
		fo(i,1,n) co[i]^=1;*/
	co[1]=1;
	travel(1,0);
	fo(i,1,n) 
		if (co[i]) bb[i]=1;else bb[i]=-1;
	fo(i,1,n) num+=bb[i];
	if (m==n-1){
		if (num){
			printf("-1\n");
			return 0;
		}
	}
	else{
		if (gjx){
			if (num%2==1){
				printf("-1\n");
				return 0;
			}
			bb[u]-=num/2;bb[v]-=num/2;
			ans+=(ll)abs(num/2);
		}
		else{
			if (num){
				printf("-1\n");
				return 0;
			}
			kk[u]=1;kk[v]=-1;
		}
	}
	dfs(1,0);
	fo(i,1,n)
		if (!kk[i]) ans+=(ll)abs(bb[i]);
		else{
			if (kk[i]) bb[i]=-bb[i];
			sta[++top]=bb[i];
		}
	sta[++top]=0;
	sort(sta+1,sta+top+1);
	x=sta[(top+1)/2];
	fo(i,1,top) ans+=(ll)abs(sta[i]-x);
	printf("%lld\n",ans);
}

Measured memory_bytes: 8448