akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){cout<<"1x1=1"<<endl;
cout<<"1x2=2"<<endl;
cout<<"1x3=3"<<endl;
cout<<"1x4=4"<<endl;
cout<<"1x5=5"<<endl;
cout<<"1x6=6"<<endl;
cout<<"1x7=7"<<endl;
cout<<"1x8=8"<<endl;
cout<<"1x9=9"<<endl;
cout<<"2x1=2"<<endl;
cout<<"2x2=4"<<endl;
cout<<"2x3=6"<<endl;
cout<<"2x4=8"<<endl;
cout<<"2x5=10"<<endl;
cout<<"2x6=12"<<endl;
cout<<"2x7=14"<<endl;
cout<<"2x8=16"<<endl;
cout<<"2x9=18"<<endl;
cout<<"3x1=3"<<endl;
cout<<"3x2=6"<<endl;
cout<<"3x3=9"<<endl;
cout<<"3x4=12"<<endl;
cout<<"3x5=15"<<endl;
cout<<"3x6=18"<<endl;
cout<<"3x7=21"<<endl;
cout<<"3x8=24"<<endl;
cout<<"3x9=27"<<endl;
cout<<"4x1=4"<<endl;
cout<<"4x2=8"<<endl;
cout<<"4x3=12"<<endl;
cout<<"4x4=16"<<endl;
cout<<"4x5=20"<<endl;
cout<<"4x6=24"<<endl;
cout<<"4x7=28"<<endl;
cout<<"4x8=32"<<endl;
cout<<"4x9=36"<<endl;
cout<<"5x1=5"<<endl;
cout<<"5x2=10"<<endl;
cout<<"5x3=15"<<endl;
cout<<"5x4=20"<<endl;
cout<<"5x5=25"<<endl;
cout<<"5x6=30"<<endl;
cout<<"5x7=35"<<endl;
cout<<"5x8=40"<<endl;
cout<<"5x9=45"<<endl;
cout<<"6x1=6"<<endl;
cout<<"6x2=12"<<endl;
cout<<"6x3=18"<<endl;
cout<<"6x4=24"<<endl;
cout<<"6x5=30"<<endl;
cout<<"6x6=36"<<endl;
cout<<"6x7=42"<<endl;
cout<<"6x8=48"<<endl;
cout<<"6x9=54"<<endl;
cout<<"7x1=7"<<endl;
cout<<"7x2=14"<<endl;
cout<<"7x3=21"<<endl;
cout<<"7x4=28"<<endl;
cout<<"7x5=35"<<endl;
cout<<"7x6=42"<<endl;
cout<<"7x7=49"<<endl;
cout<<"7x8=56"<<endl;
cout<<"7x9=63"<<endl;
cout<<"8x1=8"<<endl;
cout<<"8x2=16"<<endl;
cout<<"8x3=24"<<endl;
cout<<"8x4=32"<<endl;
cout<<"8x5=40"<<endl;
cout<<"8x6=48"<<endl;
cout<<"8x7=56"<<endl;
cout<<"8x8=64"<<endl;
cout<<"8x9=72"<<endl;
cout<<"9x1=9"<<endl;
cout<<"9x2=18"<<endl;
cout<<"9x3=27"<<endl;
cout<<"9x4=36"<<endl;
cout<<"9x5=45"<<endl;
cout<<"9x6=54"<<endl;
cout<<"9x7=63"<<endl;
cout<<"9x8=72"<<endl;
cout<<"9x9=81"<<endl;
return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
 
int gcd(int a, int b) {
  int t;    // 補助変数
  while ( b != 0 ) {          // 他方が0になるまで
    t = a%b; a = b; b = t;    // 一方を剰余に置き換える
  }
  return a;                   // 他方が0になったときの一方がGCD
}
 
int main(){
    int n;
    cin >> n;
    vector<ll> v;
    int all[1000100];
    for(int i = 0; i < 1000100; i++){
        all[i] = 0;
    }
    //ll all = 1;
    for(int i = 0; i < n; i++){
        ll temp;
        cin >> temp;
        v.push_back(temp);
        //all = all * temp % mod;
        all[temp]++;
    }
 
    ll ans = 1;
    sort(v.begin(),v.end());
    for(int i = 0; i < n;i++){
        ll temp = v[i];
        if(all[temp] == 0) continue;
        if(all[temp] > 1){
            for(int j = temp; j <= v[n-1]; j+= temp){
            all[j] =0;
        }
        }
        for(int j = 2*temp; j <= v[n-1]; j+= temp){
            all[j] =0;
        }
    }
    for(int i = v[0]+1; i <= v[n-1]; i++){
        ans += all[i];
    }
    if(v[0] == v[1]){
        ans--;
    }
    /*
    sort(v.begin(),v.end());
    int ans = 1;
    bool hoge = true;
    if(v[0] == v[1]){
        ans = 0;
    }
    for(int i = 1; i < n; i++){
        hoge = true;
        for(int j = 0; j < i; j++){
            if(v[i] % v[j] == 0){
                hoge = false;
                break;
            }
        }
        if(hoge){
            ans++;
        }
 
    }
    */
    cout << ans << endl;
 
}

Measured memory_bytes: 9276
import itertools
N = int(input())
cnt = 0
for i in range(3, len(str(N))+1):
    for j in list(itertools.product('357', repeat = i)):
        if ('3' in j) & ('5' in j) & ('7' in j):
            if int(''.join(j)) <= N:
                cnt += 1
            else:
                break
print(cnt)

Measured memory_bytes: 11668
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

void gen() {exit(0);}
int main() {
    #ifdef DEBUG
    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    string s;
    getline(cin, s);
    int count = 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == s[i - 1]) {
            count++;
            if (count == 2) {
                printf("Yes\n");
                exit(0);
            }
        } else {
            count = 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define MAX 10000
#define END 500000
  
typedef struct edge {
    int from, to, cost;
} J;
J e[END];
int d[MAX];
  
void sp(int,int);
 
int main(int argc,char* argv[])
{
    int vn, en, an;
    int i, j, vi;
    scanf("%d", &vn);
  
    en=0;
    for(i=0; i<vn; i++) {
        scanf("%d", &vi);
        scanf("%d", &an);
        for(j=1; j<=an; j++) {
            e[en].from=vi;
            scanf("%d %d", &e[en].to, &e[en].cost);
            en++;
        }
    }
      
    sp(vn, en);
    for(i=0; i<vn; i++) {
        printf("%d %d\n", i, d[i]);
    }
    return 0;
}
void sp(int vn, int en)
{
    int i, new=1;
    for(i=1; i<vn; i++) d[i]=INT_MAX;
      
    while(new) {
        new=0;
        for(i=0; i<en; i++) {
            if(d[e[i].from] !=INT_MAX && d[e[i].from]+e[i].cost < d[e[i].to]) {
                d[e[i].to] = d[e[i].from]+e[i].cost;
                new++;
            }
        }
    }
}



Measured memory_bytes: 7624
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    
    int cnt=0;
    rep(i,a+1)rep(j,b+1)rep(l,c+1){
        int sum=0;
        sum+=500*i;
        sum+=100*j;
        sum+=50*l;
        if(sum==x) cnt++;
    }
    cout1(cnt)
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int factor[200];

int num(int above){
    int cnt = 0;
    for(int i: factor){
        if(i >= above){
            cnt++;
        }
    }
    return cnt;
}

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

    for(int i=2; i<n+1; i++){
        int current = i;

        for(int j=2; j<n+1; j++){
            while(current % j == 0){
                current /= j;
                factor[j]++;
            }
        }
    }

    int count = 0;
    
    // 4, 4, 2
    count += num(4) * (num(4) - 1) * (num(2) - 2) / 2;

    // 14, 4
    count += num(14) * (num(4) -1);

    // 24, 2
    count += num(24) * (num(2) - 1);

    // 74
    count += num(74);

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
card = [list(map(int, input().split())) for _ in range(M)]

min_price = min(a) + min(b)

for C in card:
    x, y, c = C
    price = a[x - 1] + b[y - 1] - c
    if price < min_price:
        min_price = price
print(min_price)

Measured memory_bytes: 38564
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool none = true;
    for(char c='a'; c<='z'; c++){
        bool exist = false;
        for(int i=0; i<s.size(); i++){
            if(c==s[i]){
                exist=true;
                break;
            }
        }
        if(!(exist)){
            cout << c << endl;
            none=false;
            break;
        }
    }
    if(none){
        cout << "None" << endl;
    }
    return 0;
}

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

using namespace std;

const static int MAX_N = 100000 + 1;

vector<int> v[MAX_N];
int N;
int da[MAX_N];
int db[MAX_N];

void distanceA(int i, int p, int cnt) {
  if (v[i].size() == 1 && v[i][0] == p) return;

  for (int j = 0; j < v[i].size(); j++) {
    if (v[i][j] == p) continue;
    da[v[i][j]] = cnt;
    distanceA(v[i][j], i, cnt + 1);
  }

  

  return;
}

void distanceB(int i, int p, int cnt) {
  if (v[i].size() == 1 && v[i][0] == p) return;


  for (int j = 0; j < v[i].size(); j++) {
    if (v[i][j] == p) continue;
    db[v[i][j]] = cnt;
    distanceB(v[i][j], i, cnt + 1);
  }

  return;
}

int main() {
  cin >> N;

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

  da[1] = 0;
  distanceA(1, 0, 1);

  db[N] = 0;
  distanceB(N, 0, 1);

  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (da[i] <= db[i]) cnt += 1;
  }

  if (cnt > N / 2) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;

  
  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
const int INF=1e5;

int main(){
	int D, G;
	cin >> D >> G;
	vector<int> p(D), c(D);
	rep(i,D) cin >> p[i] >> c[i];
	int ans=INF;
	rep(bit,1<<D){
		int score=0, res=0;
		rep(i,D){
			if(bit&1<<i){
				score+=c[i];
				score+=100*(i+1)*p[i];
				res+=p[i];
			}
		}
		int rem=G-score;
		if(rem<=0){
			ans=min(ans,res);
			continue;
		}
		for(int i=D-1; i>=0; i--){
			if(bit&1<<i) continue;
			int s=100*(i+1);
			if(rem<=s*p[i]){
				res+=(rem+s-1)/s;
				ans=min(ans,res);
				break;
			}
			else{
				res+=p[i];
				rem-=s*p[i];
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

class Combination_with_repetition():
    def getPattern(self, arr :list, r :int) -> list:
        self._selected=[]
        self._all_pattern=[]
        
        self._make(arr,r)
        return self._all_pattern
        
    def _make(self, arr :list, r :int):
        if r == 0:
            self._all_pattern.append(self._selected[:])
            return 
        
        for i in range(len(arr)):
            self._selected.append( arr[i] )
            self._make(arr[i:],r-1)
            
            self._selected.pop()  # Backtracking

#-----
N,M,Q = list(map(int, input().rstrip().split()))
abcd_list = [list(map(int, input().rstrip().split())) for i in range(Q)]

#-----
comb_rep = Combination_with_repetition()
pattern = comb_rep.getPattern( list(range(1, M+1)) , N)


max_sum = 0

for pat in pattern:
    tmp_sum = 0
    
    for a,b,c,d in abcd_list:
        if ( pat[b-1] - pat[a-1] ) == c:
            tmp_sum += d
    
    max_sum = max(max_sum, tmp_sum)

print(max_sum)


Measured memory_bytes: 23012
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> lr(n, 0);
	vector<int> rl(n, 0);

	char cur = s[0];
	int count = 0;
	rep(i, n) {
		if (cur != s[i]) {
			count = 0;
			cur = s[i];
		}
		lr[i] = count;
		count++;
	}

	cur = s[n - 1];
	count = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (cur != s[i]) {
			count = 0;
			cur = s[i];
		}
		rl[i] = count;
		count++;
	}

	vector<int> ans(n,0);

	rep(i, n) {
		if (s[i] == 'L') {
			if (lr[i] % 2 == 0) {
				ans[i - lr[i]]++;
			} else {
				ans[i - lr[i] - 1]++;
			}
		}
		if (s[i] == 'R') {
			if (rl[i] % 2 == 0) {
				ans[i + rl[i]] ++;
			} else {
				ans[i + rl[i] + 1] ++;

			}
		}
	}
	rep(i, n) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1856
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	cout<<"vowel"<<endl;
	else
	cout<<"consonant"<<endl;
	return 0;
}

Measured memory_bytes: 256
def check_my(string):
    if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y'

s = input()
my_set = (check_my(s[0:2]), check_my(s[2:4]))
if my_set == ('YorM', 'YorM'):
    print('AMBIGUOUS')
elif my_set == ('YorM', 'Y'):
    print('MMYY')
elif my_set == ('Y', 'YorM'):
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int n,l;
   cin >> n >> l;
   string ans[n+1];
   rep(i,n)
   cin >> ans[i];
   sort(ans,ans+n);
   rep(i,n)
   cout << ans[i];
   cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int a[100001];
int x[100001]={};

int main() {

	int n;
	int total=0;

	cin>>n;

	int r=0;
	rep(i,n){
		cin>>a[i];
		x[a[i]]++;
		r=max(r,a[i]);
	}
	total=n;

	rep(i,r+1){
		if(x[i]-1>0){
			total=total-x[i]+1;
		}
	}
	if((n-total)%2>0){
		total--;
	}
	cout<<total<<endl;
	return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n)cin >> a[i];
	int ans = 0;
	REP(i, n) {
		int cnt = 0;
		while(a[i] % 2==0) {
			a[i] /= 2;
			cnt++;
		}
		ans += cnt;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	while (a > 0 || b > 0) {
	    for (int i = 0; i < a; i++) {
	        for (int o = 0; o < b; o++) {
	            if ((i % 2) - (o % 2) == 0) cout << "#";
	            else cout << ".";
	        }
	        cout << endl;
	    }
	    cout << endl;
	    cin >> a >> b;
	}
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
vector<unordered_set<int>> tree;
vector<pair<int,int>> edge;
map<pair<int,int>,int> color;
int max_color=0;

void comp(int p){
  for (auto i: tree[p]){
    tree[i].erase(p);
    comp(i);
  }
  return;
}

void paint(int p, int pre){
  int c=0;
  for (auto i: tree[p]){
    c++;
    if (c==pre) c++;
    color[make_pair(min(p,i),max(p,i))]=c;
    paint(i,c);
  }
  max_color=max(max_color,c);
  return;
}

int main(){
  int n,a,b;
  cin>> n;
  tree.assign(n,{});
  edge.assign(n-1,pair<int,int>());
  for (int i=0; i<n-1; i++){
    cin>> a >> b; a--; b--;
    tree[a].insert(b); tree[b].insert(a);
    edge[i]=make_pair(a,b);
  }
  comp(0);
  paint(0,0);
  cout<<max_color<<endl;
  for (auto i: edge) cout<<color[i]<<endl;
}

Measured memory_bytes: 22016
from collections import *
from itertools import *

N,M=map(int,input().split())
A=list(map(int,input().split()))

s=[0]+list(accumulate(A))
for i in range(len(s)):
  s[i]%=M
s_cnt=Counter(s)

ans=0
for x in s_cnt.values():
  ans+=x*(x-1)//2

print(ans)


Measured memory_bytes: 100760
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
	string a, b, c,yan;
	char now = 'a';
	long long int ac, bc, cc;
	cin >> a >> b >> c;
	ac = a.size(), bc = b.size(), cc = c.size();
	while (1) {
		if (now == 'a') {
			if (!ac) {
				cout << 'A' << endl;
				break;
			}
			now = a[0];
			a.erase(a.begin());
			ac--;
			yan = a;
		}
		if (now == 'b') {
			if (!bc) {
				cout << 'B' << endl;
				break;
			}
			now = b[0];
			b.erase(b.begin());
			bc--;
			yan = b;
		}
		if (now == 'c') {
			if (!cc) {
				cout << 'C' << endl;
				break;
			}
			now = c[0];
			c.erase(c.begin());
			cc--;
			yan = c;
		}
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	
	private static String VOWELS = "ueoai";
			
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		if (VOWELS.indexOf(s) >= 0 ) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
		
	}
	
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  while(1){
    if(a==b && b==c){
      if(a%2==0){
        cout<<-1<<endl;
        break;
      }
      else{
        cout<<ans<<endl;
        break;
      }
    }
    else{
      int x=b+c;
      int y=c+a;
      int z=a+b;
      if((x%2==0 && y%2==0) && z%2==0){
        a=x/2;
        b=y/2;
        c=z/2;
        ans++;
      }
      else {
        cout<<ans<<endl;
        break;
      }
    }
  }
}


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

int main(){
     char c;
     cin>>c;
     switch(c){
          case 'a' :cout<<"vowel"; 
          break;
          case 'e' :cout<<"vowel"; 
          break;
          case 'i' :cout<<"vowel"; 
          break;
          case 'o' :cout<<"vowel"; 
          break;
          case 'u' :cout<<"vowel"; 
          break;
          default : cout<<" consonant";
     }


}


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

int main(void){
  int n;
  cin>>n;
  if((n/1000==n/100%10)&&(n/100%10==n/10%10)) cout<<"Yes"<<endl;
  else if((n/100%10==n/10%10)&&(n/10%10==n%10)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    string a;
    cin >> a;
    ll p = a.size();
    int y = 0;
    ll ans = 0;
    for (int i = 0; i < p; i++) {
        if (a.at(i) == '1') {
            y += 1;
            ans += modpow(3, p - i - 1, 1000000007) * modpow(2, y - 1, 1000000007) % 1000000007 + modpow(2, y-1, 1000000007);
            ans %= 1000000007;
        }
    }
    cout << (ans + 1) % 1000000007 << endl;
}

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

using namespace std;
typedef long long ll;

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

    int ans = 1000000000;
    for (int i = 1; i <= 100; i++) {
        int hp = 0;
        for (int j = 0; j < n; j++) {
            hp += pow(x[j] - i, 2);
        }
        ans = min(hp, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int ans=0;
        for(int c=1;c<=n-1;c++)
        {
            int check = n-c;
            for(int r=1;r<sqrt(check);r++)
            {
                
                if(check % r == 0)
                {
                    ans+=2;
                    
                }
                
            }
            if(sqrt(check)-(int)sqrt(check)==0)
            {
                ans++;
            }
            
        }
        
        cout<<ans<<endl;
    }
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
   string s, t;
   cin >> s >> t;
   int n = s.size();
   int m = t.size();

   string ans = "~";
   for (int i = 0; i <= n-m; ++i) {
      bool ok = true;
      string s2 = s;
      for (int j = 0; j < m; ++j) {
         if (s[i+j] != '?' && s[i+j] != t[j]) {
            ok = false;
         }
         s2[i+j] = t[j];
      }
      if (ok) {
         replace(s2.begin(), s2.end(),'?', 'a');
         ans = min(ans, s2);
      }
   }

   if (ans == "~") {
      cout << "UNRESTORABLE" << endl;
   } else {
      cout << ans << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, m, c;
    cin >> n >> m >> c;
    vector<ll> b(m, 0);
    ll a[n][m];
    rep1(i, m) cin >> b[i];
    rep1(i, n){
        rep1(j, m) cin >> a[i][j];
    }
    ll ans = 0, cnt;
    rep1(i, n){
        cnt = c;
        rep1(j, m){
            cnt += b[j]*a[i][j];
        }
        if (cnt>0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
S = input()
N = len(S)
K = int(input())

MOD = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

# 必要なだけforを回す
for i in range(2, 10 ** 6):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# nCr n個から重複を許さずr個の組み合わせを選ぶ
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD

def rec(i, k, isSmaller):
    if i == N:
        if k == 0:
            return 1
        else:
            return 0
    
    if k == 0:
        return 1
    
    if isSmaller:
        return cmb(N-i, k) * pow(9, k)
    else:
        if S[i] == '0':
            return rec(i+1, k, False)
        else:
            zero = rec(i+1, k, True)
            between = rec(i+1, k-1, True) * (int(S[i]) - 1)
            same = rec(i+1, k-1, False)
            return zero + between + same

print(rec(0, K, False))


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

const double PI = acos(-1.0);
const int N = 1005;
const int MOD = 1e9 + 7;
const int inf = 1<<28;
typedef long long ll;

int a[3];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int k;
    cin>>a[0]>>a[1]>>a[2]>>k;

    sort(a, a + 3);

    for(int i = 0 ; i < k; i++)
        a[2] *= 2;
    cout<<a[0] + a[1] + a[2];





}


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

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

typedef long long Int;

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  string T = "";
  rep(i,K-1) T += S[i];
  int n = S[K-1] - 'A';
  char c = 'a' + n;
  T += c;
  if (N > K) {
    for (int i = K; i < N; i++) T += S[i];
  }
  
  cout << T << endl;
}


Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#cnt=0
#for i in range(n):
 # B=b[i]
  #A=[a[i] for i in range(n) if a[i]<B]
  #C=[c[i] for i in range(n) if c[i]>B]
  #cnt+=len(A)*len(C)
#print(cnt)
cnt=0
#真ん中のパーツをまず考える
for i in range(n):
  B=b[i]
  if B<=a[0] or B>=c[-1]:
    continue
  #Bより小さいAの最大値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if a[(i_small+i_large)//2] <B:
      i_small=(i_small+i_large)//2
    else:
      i_large=(i_small+i_large)//2
 
  A=i_large
  if a[-1]<B:
    A+=1

  #Bより大きいCの最小値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if c[(i_small+i_large)//2] >B:
      i_large=(i_small+i_large)//2
    else:
      i_small=(i_small+i_large)//2
  C=n-i_large
  if c[0]>B:
    C+=1

  cnt+=A*C
if n>1:
  print(cnt)
else:
  if a[0]<b[0]<c[0]:
    print(1)
  else:
    print(0)

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	FOR(i, 0, m - 1) {
		cin >> x[i];
	}
	sort(ALL(x));
	vector<int> dist(m - 1);
	FOR(i, 0, m - 2) {
		dist[i] = x[i + 1] - x[i];
	}
	sort(ALL(dist));
	if (n >= m) {
		ps(0);
	}
	else {
		ll res = 0;
		FOR(i, 0, m - n - 1) {
			res += dist[i];
		}
		pv(res)
	}
	return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if(B%A == 0)
        cout << B + A << endl;
    else
        cout << B - A << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << max({a, b, c}) - min({a, b, c}) << endl;
}

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

	solve();
}


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

int greater(const void* left, const void* right) {
	return *(int*)left - *(int*)right;
}

int main(void) {
	int N;
	int* A;
	scanf("%d",&N);
	A = (int*)malloc(sizeof(int)*N);
	for (int i = 0; i < N; ++i) {
		scanf("%d",&A[i]);
	}
	qsort(A,N,sizeof(int),greater);
	for (int i = 0; i < N-1; ++i) {
		if (A[i] == A[i+1]) {
			printf("NO");
			free(A);
			return 0;
		}
	}

	printf("YES");
	free(A);
	return 0;
}

Measured memory_bytes: 1788
/*input
7 11
1 2 2
1 3 1
2 4 2
2 5 2
2 6 1
3 4 1
3 5 1
3 6 1
4 7 2
5 7 2
6 7 1
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 1505
#define bit(x,y) ((x>>y)&1LL)

int n, m;
vector<vector<pair<int, int> > > a(N);
int dis[N][N];

bool inqueue[N];
deque<int> q;
int mxans = 0;
int mx[N];

void SPFA(int root) {
	dis[root][root] = 0;
	q.push_back(root); inqueue[root] = true;
	while (!q.empty()) {
		int u = q.front(); q.pop_front(); inqueue[u] = false;
		for (auto v : a[u]) {
			if (dis[root][v.fi] > dis[root][u] + v.se) {
				dis[root][v.fi] = dis[root][u] + v.se;
				if (!inqueue[v.fi]) {
					inqueue[v.fi] = true;
					if (!q.empty() && dis[root][v.fi] < dis[root][q.front()]) {
						q.push_front(v.fi);
					}
					else q.push_back(v.fi);
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) mxans = max(mxans, dis[root][i]);
}

bool visited[N]; bool mark[N];
void dfs(int u, int root) {
	if (visited[u]) return;
	visited[u] = true;
	mx[u] = dis[root][u];
	for (auto v : a[u]) {
		if (dis[root][v.fi] == dis[root][u] + v.se) {
			dfs(v.fi, root); mx[u] = max(mx[u], mx[v.fi]);
		}
	}
	if (mx[u] == mxans)
		mark[u] = 1;
}

vector<int> order;
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef in1code
	freopen("1test.inp", "r", stdin);
#endif
	memset(dis, 127, sizeof(dis));
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int u, v, c;
		cin >> u >> v >> c;
		a[u].push_back(mp(v, c));
		a[v].push_back(mp(u, c));
	}
	for (int i = 1; i <= n; i++) SPFA(i);
	for (int i = 1; i <= n; i++) {
		memset(visited, 0, sizeof(visited)); dfs(i, i);
	}
	for (int i = 1; i <= n; i++) {
		if (!mark[i]) order.push_back(i);
	}
	cout << order.size() << endl;
	for (auto it : order) cout << it << endl;
}


Measured memory_bytes: 21100
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  int MIN=INF;
  for(int i=0;i<s.size()-2;i++){
    int num=abs((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')-753);
    MIN=min(MIN,num);
  }
  cout<<MIN<<endl;
}

Measured memory_bytes: 256
H, W=map(int, input().split())

m=[[-1 for i in range(W+2)]]
mm=[[-1]+[0 for i in range(W)]+[-1] for j in range(H)]
m=m+mm+m

nexts=[]
for i in range(1, H+1):
  c=input()
  for j in range(1, W+1):
    if c[j-1]=='#':
      nexts.append([i, j])
      m[i][j]=1
      
def f(math, in_nexts):
  n=len(in_nexts)
  out_nexts=[]
  for i in range(n):
    x=in_nexts[i][0]
    y=in_nexts[i][1]
    if math[x-1][y]==0:
      math[x-1][y]=math[x][y]+1
      out_nexts.append([x-1, y])
    if math[x+1][y]==0:
      math[x+1][y]=math[x][y]+1
      out_nexts.append([x+1, y])
    if math[x][y-1]==0:
      math[x][y-1]=math[x][y]+1
      out_nexts.append([x, y-1])
    if math[x][y+1]==0:
      math[x][y+1]=math[x][y]+1
      out_nexts.append([x, y+1])
      
  return math, out_nexts

counter=0
while len(nexts)>0:
  m, nexts=f(m, nexts)
  counter+=1
  
print(counter-1)

Measured memory_bytes: 144760
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };

void solve() {
    // ll N; cin >> N;
    // ll N, M; cin >> N >> M;
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    // string s; cin >> s;
    // string t; cin >> t;
    ll ans = 0;
    ans += min(A, K);
    K -= A;
    K -= B;
    if(K>0) ans -= K;
    print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
  int x,i,j,answer[35];
  scanf("%d",&x);
  answer[0]=0;
  for(i=1;i<35;i++)
  {
    answer[i]=0;
  }
  
  if(x==0) printf("0");
  else
  {
  
  for(i=0;i<35;i++)
  {
    if(x%2!=0)
    {
      answer[i]=1;
      if(i%2==0) x=x-1;
      else x=x+1;
    }
    x=x/2;
  }
  
  for(j=34;j>=0;j--)
  {
    if(answer[j]==1) break;
  }
  while(j>=0)
  {
    printf("%d",answer[j]);
    j--;
  }
  }
  
  return 0;
}
  

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

#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pii pair<int,int>
#define que pair<pii,pii>

int X, K, D;


signed main()
{
    cin >> X >> K >> D;
    if(X < 0)X *= -1;

    if(X / D > K)
    {
        cout << X - K * D << endl;
        return 0;
    }

    if(((X - (X % D)) / D + K) % 2 == 0)cout << X % D << endl;
    else cout << -(X % D - D) << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
struct UnionFind{
public:
	vector<int> par;
	vector<int> rank;
	vector<int> s;
	int cnt;
 
	UnionFind(int n){
		rep(i,n){
			par.push_back(i);
			rank.push_back(0);
			s.push_back(1);
		}
		cnt=n;
	}
 
	int find(int x){
		if(par[x]==x) return x;
		else return par[x]=find(par[x]);
	}
 
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			par[x]=y;
			s[y]+=s[x];
		}else{
			par[y]=x;
			s[x]+=s[y];
			if(rank[x]==rank[y]) rank[x]++;
		}
		cnt--;
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}

	int size(int x){
		return s[find(x)];
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> a(m),b(m);
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	int ans=0;
	rep(i,m){
		UnionFind uf(n);
		rep(j,m){
			if(j==i) continue;
			uf.unite(a[j],b[j]);
		}
		bool flag=true;
		rep(j,n)rep(k,n){
			if(!uf.same(j,k)){
				flag=false;
			}
		}
		if(!flag) ans++;
	}
	cout<<ans<<endl;
}

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

int main()
{
  int a,b;
  cin>>a>>b;
  cout<<6-a-b<<endl;
  return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

const vector<pair<int, int>> ds = {
    {-1, 0},
    {1, 0},
    {0, 1},
    {0, -1}
};

int dist[400][400];
int h, w;
string mp[400];

void init(){
    rep(i, 400) rep(j, 400) dist[i][j] = (1 << 20);
}

int rec(int x, int y, int d) {
    if (mp[y][x] == '#') return 0;
    if (dist[y][x] != (1 << 20)) return dist[y][x];

    int res = d;
    dist[y][x] = d;
    for(auto p: ds) {
        int nx = x + p.first;
        int ny = y + p.second;
        if (0 <= nx and nx < w and 0 <= ny and ny < h) {
            res = max(res, rec(nx,ny,d+1));
        }
    }
    return res;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin>>h>>w;
    rep(i, h) cin>>mp[i];

    int ans = 0;
    rep(y, h) rep(x, w) {
        init();

        queue<tuple<int,int,int>> que;
        que.emplace(x,y,0);
        while(!que.empty()) {
            int xx, yy, dd;
            tie(xx, yy , dd) = que.front();
            que.pop();
            if (mp[yy][xx] == '#') continue;
            if (dist[yy][xx] != (1 << 20)) continue;

            dist[yy][xx] = dd;
            ans = max(ans, dd);
            for(auto p: ds) {
                int nx = xx + p.first;
                int ny = yy + p.second;
                if (0 <= nx and nx < w and 0 <= ny and ny < h) {
                    que.emplace(nx, ny, dd + 1);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(void){
   int a,b,i,s,n,k,x;
   scanf("%d %d",&a,&b);
   s=b-a;
   k=0;
   for(n=1;n<=999;n++){
      k+=n;
      if(s==n){
                   x=k-b;
                   printf("%d\n",x);
                   return 0;
}
}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
nは偶数なので、全てのaのxorをとると、すべてのスカーフの数のxorになる事がわかる。これをsumとする
あとは、sum xor a[i]とすると各スカーフの値がわかる
*/

ll n,a[200010],sum=0;

int main(void){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)sum ^= a[i];
	rep(i,n)cout<<(sum^a[i])<<" ";
	cout<<endl;
	return 0;
}

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


int main()
{
    string s; cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(i%2==0)
        {
           if (s[i]== 'L')
           {
                cout<<"No"<<'\n';
                return 0;
           }
        }
        if (i%2 !=0 )
        {
            if (s[i]=='R')
            {
                cout<<"No"<<'\n';
                return 0;
            }
        }
    }
    cout<<"Yes"<<'\n';
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**5+5)
from collections import defaultdict,deque
input = sys.stdin.readline

class LCA:
    def __init__(self,n):
        self.size = n+1
        self.bitlen = n.bit_length()
        self.ancestor = [[0]*self.size for i in range(self.bitlen)]
        self.depth = [-1]*self.size
        self.dis = [-1]*self.size
        self.depth[1] = 0
        self.dis[1] = 0
    def make(self,root):
        q = deque([root])
        while q:
            now = q.popleft()
            for nex,c,w in e[now]:
                if self.depth[nex]>= 0:
                    continue
                self.depth[nex] = self.depth[now]+1
                self.dis[nex] = self.dis[now]+w
                self.ancestor[0][nex] = now
                q.append(nex)
        for i in range(1,self.bitlen):
            for j in range(self.size):
                if self.ancestor[i-1][j] > 0:
                    self.ancestor[i][j] = self.ancestor[i-1][self.ancestor[i-1][j]]
    
    def lca(self,x,y):
        dx = self.depth[x]
        dy = self.depth[y]
        if dx < dy:
            x,y = y,x
            dx,dy = dy,dx
        dif = dx-dy
        while dif:
            s = dif & (-dif)
            x = self.ancestor[s.bit_length()-1][x]
            dif -= s
        while x != y:
            j = 0
            while self.ancestor[j][x] != self.ancestor[j][y]:
                j += 1
            if j == 0:
                return self.ancestor[0][x]
            x = self.ancestor[j-1][x]
            y = self.ancestor[j-1][y]
        return x

n,q = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(n-1):
    a,b,c,d = map(int,input().split())
    e[a].append((b,c,d))
    e[b].append((a,c,d))
    
lca = LCA(n)
lca.make(1)

Q = [[] for i in range(n+1)]
ans = []
for i in range(q):
    x,y,u,v = map(int,input().split())
    a = lca.lca(u,v)
    ans.append(lca.dis[u]+lca.dis[v]-2*lca.dis[a])
    Q[u].append((x,y,i,1))
    Q[v].append((x,y,i,1))
    Q[a].append((x,y,i,-2))
count = defaultdict(int)
weight = defaultdict(int)
def dfs1(now,p):
    for x,y,ind,z in Q[now]:
        ans[ind] += z*(y*count[x]-weight[x])
    for nex,c,w in e[now]:
        if nex == p:
            continue
        count[c] += 1
        weight[c] += w
        dfs1(nex,now)
        count[c] -= 1
        weight[c] -= w
dfs1(1,0)

for i in ans:
    print(i)

Measured memory_bytes: 765444
#include <iostream>
#include <cstdio>
#include <cmath>

#define pai 3.141592653

using namespace std;

int main(void)
{
	int n, s[1000];
	double sum, avg, a;
	int i;

	while(scanf("%d", &n)!=EOF && n!=0){
		sum = 0;
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
			sum += s[i];
		}
		avg = sum / n;

		sum = 0;
		for(i=0;i<n;i++)
			sum += pow(s[i] - avg, 2);
		a = sqrt(sum / n);

		printf("%.8f\n", a);
	}

	return 0;
}

Measured memory_bytes: 1224
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    println!("{}", (n + 1) / 2);
}


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

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    int maxv=0;
    int num;
    rep(i,n){
        cin>>h[i];
        /*if(maxv<h[i]){
            maxv=h[i];
            num=i;
        }*/
    }
    bool flag=true;
    /*for(int i=num;i<n;i++){
        if(h[num]-h[i]>=2){
            flag=false;
            break;
        }
    }*/

    for(int i=n-2;i>0;i--){
        if(h[i]-h[i+1]==1) h[i]-=1;
        else if(h[i+1]<h[i]){
            flag=false;
            break;
        }
    }

    if(flag) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}

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

using namespace std;
int main(){
    int n,x;
    cin>>n;
    int maxx=0;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x>=maxx){
            ans++;
            maxx=x;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int a[50];
int b[50];
int c[50];
int d[50];

void dfs(vector<int> &x) {
    dump(x);
    if (x.size() == N) {
        dump(x);
        int cnt = 0;
        REP(i, Q) {
            if (x[b[i]] - x[a[i]] == c[i]) {
                cnt += d[i];
            }
        }
        ans = max(cnt, int(ans));
    } else {
        for (int i = x.back(); i <= M; i++) {
            x.push_back(i);
            dfs(x);
        }
    }
    x.pop_back();
}

signed main() {
    cin >> N >> M >> Q;
    REP(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        b[i]--, a[i]--;
    }
    vi x;
    x.push_back(1);
    dfs(x);
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

  ll N;cin>>N;
  string S;
  while(N>0){
    ll A=N%26;
    ll B=N/26;
    
   if(A==0){
     S+='z';B--;
   }else{
     S+=(char)A+96;
    
     
   } N=B;
//    cout<<A<<" "<<B<<endl;
  }
  vreverse(S);
  cout<<S<<endl;
}



Measured memory_bytes: 3584