akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

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

struct edge{int to,cost;};
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int h,w;
	cin >> h >> w;

	int a[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> a[i][j];
		}
	}

	vector<P> ans[h*w];
	P left;
	bool ki=false;
	int num=0;
	int hnum=0;
	int s=0;
	for(int i=0;i<h;i++){
		if(i%2 == 0){
			for(int j=0;j<w;j++){
				if(ki){
//					cout << "in ki\n" << "\n";
					ans[hnum].push_back(P(i,j));
					if(a[i][j]%2 == 1) {
						num++;
						
			//			cout << ans[hnum].size() << " です\n";
						
						s+=ans[hnum].size()-1;
						hnum++;
						ki=false;

//						cout << "ki close " << i << "," << j << " " << a[i][j] << "\n";
					}
				}else if(a[i][j]%2 == 1){
					num++;
//					left = P(i,j);
//					s = ans.size();
					ans[hnum].push_back(P(i,j));
					ki=true;

//					cout << i << "," << j << " " << "ki" << a[i][j] << "\n";

				}
			}
		}
		else{
			for(int j=w-1;j>=0;j--){
				if(ki){
//					cout << "in ki\n" << "\n";
					ans[hnum].push_back(P(i,j));
					if(a[i][j]%2 == 1) {
						num++;
						
			//			cout << ans[hnum].size() << " です\n";
						
						s+=ans[hnum].size()-1;
						hnum++;
						ki=false;
						
//						cout << "ki close " << i << "," << j << " " << a[i][j] << "\n";
					
					}
				}else if(a[i][j]%2 == 1){
					num++;
//					left = P(i,j);
//					s = ans.size();
					ans[hnum].push_back(P(i,j));
					ki=true;
					
//					cout << i << "," << j << " " << "ki" << a[i][j] << "\n";
				
				}

			}
		}
	}
//	if(num%2 == 1) hnum--;
	cout << s << "\n";

//	cout << "hnum:" << hnum << "\n";

	for(int i=0;i<hnum;i++){
		for(int j=0;j<ans[i].size()-1;j++){
			cout << ans[i][j].first+1 << " " << ans[i][j].second+1 << " " << ans[i][j+1].first+1 << " " << ans[i][j+1].second+1 << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using namespace std;


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

int main(int argc, const char * argv[]) {
  long long n, x;
  cin >> n >> x;
  vector<long long> v(n);

  for(long long i = 0; i < n; i++){
    cin >> v[i];
    v[i] -= x;
  }

  long long ans = abs(v[0]);
  for(long long i = 0; i < n; i++){
    ans = gcd(ans, abs(v[i]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

ll dp[100001][2];
vector<int> ki[100001];
ll al[100001];

void dfs(int i,int p){
    //cout<<i<<endl;
    if(ki[i].size()==1&&ki[i][0]==p){
       // cout<<"o"<<endl;
        dp[i][0]=1;
        dp[i][1]=1;
    }else {
        ll kuro = 1;
        ll siro = 1;

        rep(j, ki[i].size()) {
            int h=ki[i][j];
            if(ki[i][j]!=p) {
               // cout << h << i << endl;
                dfs(ki[i][j], i);
                kuro *= dp[h][0];
                kuro %= MOD;
                siro *= (dp[h][0] + dp[h][1]);
                siro %= MOD;
            }
        }

        dp[i][0]+=siro;
        dp[i][1]+=kuro;
    }
}

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

rep(i,n-1){
    int x,y;
    cin>>x>>y;
    ki[x].push_back(y);
    ki[y].push_back(x);
}

al[1]=1;
dfs(1,-1);

cout<<(dp[1][0]+dp[1][1])%MOD<<endl;








    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

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

Measured memory_bytes: 256
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

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

const int MX=1e5+10;
int N,K; 
int t[MX];
int memo[MX][4];
int a[MX],b[MX],c[MX];


int solve(int i, int l){
	if(i==N) return 0;
	if(memo[i][l]!=-1)return memo[i][l];
	int ans=-INF;
	if(l!=1) ans=max(ans,solve(i+1,1)+a[i]);
	if(l!=2) ans=max(ans,solve(i+1,2)+b[i]);
	if(l!=3) ans=max(ans,solve(i+1,3)+c[i]);
	return memo[i][l]=ans;
}

int32_t main(){
   boost;
   IO();

   memset(memo,-1,sizeof(memo));
   cin>>N;
   for(int i=0; i<N;i++) cin>>a[i]>>b[i]>>c[i];

   cout << solve(0,0) << endl;
	


   return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i=1; i*i<=n; i++) {
        if(n%i==0) {
            ret.pb(i);
            if(i*i!=n) {
                ret.pb(n/i);
            }
        }
    }
    return ret;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll g = __gcd(a,b);
    Vec div = divisor(g);
    Vec ans;
    sort(ALL(div));
    rep(i,div.size()){
        bool chk = true;
        rep(j,ans.size()){
            if(__gcd(div[i],ans[j])!=1){
                chk = false;
                break;
            }
        }
        if(chk){
            ans.pb(div[i]);
        }
    }
    cout<<ans.size()<<endl;
    return  0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int num[11];
int pcnt,H,W,K;
string S[11];
int sum[11];

int judge(){
  rep(i,pcnt+1) sum[i]=0;
  int res=0,pre=0;
  rep(i,W){
    rep(j,H){
      int k=num[j];
      sum[k]+=(S[j][i]=='1');
    }
    int flag=0;
    rep(j,pcnt+1) flag|=(sum[j]>K);
    if(flag){
      if(i==pre) return -1;
      res++,pre=i;
      rep(l,pcnt+1) sum[l]=0;
      i--;
    }
  }
  return res;
}

int main(){
  cin>>H>>W>>K;
  rep(i,H) cin>>S[i];
  int ans=1e9;
  rep(bit,(1<<(H-1))){
    pcnt=__builtin_popcount(bit);
    int ind=0;
    rep(i,H-1){
      if((1<<i)&bit){
        num[i]=ind;
        ind++;
      }else{
        num[i]=ind;
      }
    }
    num[H-1]=ind;
    int res=judge();
    if(res!=-1) ans=min(ans,res+pcnt);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
($N,$C)=glob<>;
@D=map[split$",<>],@@=0..$C-1;
for(<>){
	$j=0;
	for$x(split){
		$k=($i+$j)%3;
		for(@@){
			$_[$k][$_]+=$D[$x-1][$_]
		}
		++$j
	}
	++$i
}
$\=1e15;
for$i(@@){
	for$j(@@){
		for(@@){
			$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$_[0][$i]-$_[1][$j]-$_[2][$_]
		}
	}
}
print


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

typedef long long int ll;

int main() {
  ll A, B, ans;
  char op;

  cin >> A >> op >> B;

  if (op == '+') ans = A + B;
   else if (op == '-') ans = A - B;
 
  cout << ans << endl;

return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int cnt = 0;
    while (b <= a) {
        b *= 2;
        cnt++;
    }
    while (c <= b) {
        c *= 2;
        cnt++;
    }

    if (cnt <= k) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 Integer a[] = new Integer[N];
		 
		 for (int i = 0; i < N; i++) {
			 a[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(a, Collections.reverseOrder());
		 
		 int sum_Allice = 0;
		 int sum_Bob = 0;
		 
		 for (int i = 0; i < N; i++) {
			 if (i % 2 == 0) {
				 sum_Allice += a[i];
			 } else {
				 sum_Bob += a[i];
			 }
		 }
		 
		 System.out.println(sum_Allice - sum_Bob);
		 scan.close();
		 

	}

}


Measured memory_bytes: 22996
N, H = map(int, input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
s = []
for i in range(N):
    a[i], b[i] = map(int, input().split())
    s.append(a[i])
    s.append(b[i])

a.sort(reverse=True)
b.sort(reverse=True)
s.sort(reverse=True)
low=0
high=2*N
t=(low+high) // 2
while(low<=high):
    if s[t] == a[0]:
        break
    elif s[t] < a[0]:
        high=t-1
    else:
        low=t+1
    t=(low+high) // 2

m = 0
P = 0
flag = False
for i in range(t+1):
    m+=1
    P+=s[i]
    if P >= H:
        flag = True
        break

if flag == False:
    k = (H-P)//a[0]
    m += k
    P += k * a[0]
    if H > P:
        m+=1

print(m)


Measured memory_bytes: 13504
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<string> S(n);
    string ans = "Three";
    for(int i=0;i<n;i++){
        cin>>S[i];
        if(S[i]=="Y"){
            ans = "Four";
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//３つの整数を入力してもらう
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		//575→5が2回、7が1回であればそれぞれカウントするヒープを作る
		int a = 0 , b = 0;

		if(A==5) {
			a++;
		}else if(A==7) {
				b++;
		}

		if(B==5) {
			a++;
		}else if(B==7){
			b++;
		}

		if(C==5) {
			a++;
		}else if(C==7){
			b++;
		}
		//aとｂの数値を判定
		if(a==2 && b==1) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}
}


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

using namespace std;

const int MAXN = 200005;

map<int, int> cnt;

int a[MAXN], n, res = 0;

int f(int x)
{
	for (int i = 1; i <= 30; i++)
		if ((1 << i) > x)
			return (1 << i);
	return 0;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]), cnt[a[i]]++;
	sort(a + 1, a + n + 1);
	for (int i = n; i >= 1; i--)
	{
//		cerr << "i: " << i << endl;
		int x = f(a[i]) - a[i];
		if (x == a[i])
		{
			if (cnt[x] > 1)
				++res, cnt[x] -= 2;	
		}
		else if (cnt[x] && cnt[a[i]])
			++res, --cnt[x], --cnt[a[i]];
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;

bool vecfind(int A[],int n,int x){
  for(int i=0;i<n;i++){
    if(A[i]==x) return true;
  }
  return false;
}

int main (){
  int n,ans=0;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int b,m;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>b;
    if(vecfind(A,n,b)) ans++;
  }
  cout<<ans<<endl;
}


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

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

  int res = 0;
  while(true){  
    bool exist = false;
    for(int i = 0; i < N; i++){
      if(A[i] % 2 != 0){
        exist = true;
      }
    }
    if(exist == true) break;
    for(int i = 0; i < N; i++){
      A[i] /= 2;
    }
    res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int q, ta[114514];

signed main() {
	cin >> q;
	ta[3] = 0;
	for (int i = 3; i <= 100000; i++) {
		if (prime(i) && prime((i + 1) / 2))ta[i + 1] = ta[i] + 1;
		else ta[i + 1] = ta[i];
	}
	rep(i, q) {
		int l, r;
		cin >> l >> r;
		cout << ta[r + 1] - ta[l] << endl;
	}
	ggr
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void){
    char ans[11],line[21],*temp;
    int num,sum,i;
    for(sum=0,scanf("%s\n%d",ans,&num);i=-1,num;num--){
        scanf("%s",line);
        while(++i!=11)
            line[10+i]=line[i];
        line[20]=0;
        if(strstr(line,ans))
                sum++;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 604
N = int(input())
s = list(input())
t = list(input())

def output(i): #i文字目以降が重なっている
    print (*s[:i], sep = '\n')
    print (*t, sep = '\n')
    return 

for i in range(N): #スタート位置
    flag = True
    for j in range(N - i):
        if s[i + j] == t[j]:
            pass
        else:
            flag = False
    if flag == True:
        print (2 * N - (N - i))
        exit()
print (2 * N)

Measured memory_bytes: 3064
while True:
    n,r = map(int,input().split())
    if n==r==0: break
    l = list(range(n,0,-1))
    for i in range(r):
        p,c = map(int,input().split())
        l = l[p-1:p+c-1]+l[:p-1]+l[p+c-1:]
    print(l[0])

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

int main() {
long long x,y,z,n,p,ans;
x = y = z = p = ans=  0;
cin >> n;
for (long long i = 2; i*i < n; i++)
{
  if (n%i == 0)
  {
  x =n/i;
  if (n/(i-1) == n % (i-1))
  ans +=i-1;
  if (n/(x-1) == n % (x-1))
  ans +=x-1;
  }
}
if(n>2)
ans += n-1;
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def make_table(s):
    n = len(s)
    res = [-1]*(n+1)
    j = -1
    
    for i in range(n):
        while j>=0 and s[i]!=s[j]:
            j = res[j]
        
        j += 1
        res[i+1] = j
    
    return res

def kmp(s, w): #s中のwと一致する箇所の先頭インデックスのリストを作成
    table = make_table(w)
    res = []
    m, i, n = 0, 0, len(s)
    
    while m+i<n:
        if w[i]==s[m+i]:
            i += 1
            
            if i==len(w):
                res.append(m)
                m = m+i-table[i]
                i = table[i]
        else:
            m = m+i-table[i]
            
            if i>0:
                i = table[i]
    
    return res

T = input()[:-1]
P = input()[:-1]
res = kmp(T, P)

for res_i in res:
    print(res_i)


Measured memory_bytes: 47924
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)
	s := make([]int, 1<<uint(n))
	for i := 0; i < 1<<uint(n); i++ {
		fmt.Fscan(reader, &s[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(s)))

	p := make([]int, 0, 1<<uint(n))
	p = append(p, s[0])
	ok := true
	for i := 0; i < n; i++ {
		sort.Sort(sort.Reverse(sort.IntSlice(p)))
		k := 0
		m := len(p)
		for j := 0; j < len(s); j++ {
			if s[j] == 0 { // in p
				continue
			}
			if k == m {
				break
			}
			if p[k] > s[j] {
				p = append(p, s[j])
				s[j] = 0
				k++
			}
		}
		if k != m {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
            // cerr<<"\x1b[7m"<<"'int' is 'long long'"<<"\x1b[m"<<endl;
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

struct RMQ {
    int n;
    vector<int> dat;
    RMQ(int n_=0) {
        n=1;
        while(n<n_) n*=2;
        dat=vector<int>(n*2-1,2147483647);
    }
    void update(int i,int x) {
        i+=n-1;
        dat[i]=x;
        while(i>0) {
            i=(i-1)/2;
            dat[i]=min(dat[i*2+1],dat[i*2+2]);
        }
    }
    int query(int a,int b) {
        return query(a,b,0,0,n);
    }
    int query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return 2147483647;
        if(a<=l and r<=b) return dat[k];
        int ml=query(a,b,k*2+1,l,(r+l)/2);
        int mr=query(a,b,k*2+2,(r+l)/2,r);
        return min(ml,mr);
    }
};
signed main() {
    int n,q;
    cin>>n>>q;
    RMQ segtree(n);
    while(q--) {
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0) {
            segtree.update(x,y);
        }
        else {
            cout<<segtree.query(x,y+1)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4924
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string s,t;

void solve(){
    cin >> s >> t;
    int ans=0;
    rep(i,s.length()){
        ans+=(s[i]!=t[i]);
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

const ll INF = 1LL << 60;

ll N, x;
vector<ll> a;
int main() {
    cin >> N >> x;
    a.resize(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 0;
    rep(i, N) {
        if (i == N - 1) {
            if (a[i] == x) ans++;
            x -= a[i];
            continue;
        } 

        if (x >= a[i]) {
            x -= a[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
D, G = map(int, input().split())
pc = [[int(i) for i in input().split()] for _ in range(D)]

ret = float('inf')
for i in range(2 ** D) :
    g = G
    last = 0
    count = 0
    for j in range(D) :
        if i % 2 == 0 :
            last = j
        else :
            g -= pc[j][0] * (j + 1) * 100 + pc[j][1]
            count += pc[j][0]
        i //= 2
    
    if pc[last][0] * (last + 1) * 100 <= g :
        continue
        
    if g <= 0 :
        ret = min(ret, count)
    else :
        count += -(-g // ((last + 1) * 100))
        ret = min(ret, count)
        
print(ret)

Measured memory_bytes: 40688
#include <iostream>
#include <climits>
#include <algorithm>

#define lson l, m, o << 1
#define rson m + 1, r, o << 1 | 1

const int N = 1e5 + 1;

int mn[N << 2];
int lazy[N << 2];

void up(int o) {
  mn[o] = std::min(mn[o << 1], mn[o << 1 | 1]);
}

void down(int o) {
  if (lazy[o] != -1) {
    mn[o << 1] = lazy[o];
    mn[o << 1 | 1] = lazy[o];
    lazy[o << 1] = lazy[o];
    lazy[o << 1 | 1] = lazy[o];
    lazy[o] = -1;
  }
}

void build(int l, int r, int o) {
  lazy[o] = -1;
  if (l == r) {
    mn[o] = INT_MAX;
    return;
  }
  int m = (l + r) >> 1;
  build(lson);
  build(rson);
  up(o);
}

void modify(int v, int L, int R, int l, int r, int o) {
  if (L <= l && R >= r) {
    lazy[o] = v;
    mn[o] = v;
    return;
  }
  down(o);
  int m = (l + r) >> 1;
  if (L <= m) modify(v, L, R, lson);
  if (R > m) modify(v, L, R, rson);
  up(o);
}

int query(int L, int R, int l, int r, int o) {
  if (L <= l && R >= r) {
    return mn[o];
  }
  down(o);
  int m = (l + r) >> 1;
  int res = INT_MAX;
  if (L <= m) res = std::min(res, query(L, R, lson));
  if (R > m) res = std::min(res, query(L, R, rson));
  return res;
}

int main() {
  int n, q;
  while (std::cin >> n >> q) {
    build(1, n, 1);
    while (q --) {
      int op;
      std::cin >> op;
      if (op == 0) {
        int l, r, v;
        std::cin >> l >> r >> v;
        l ++;
        r ++;
        modify(v, l, r, 1, n, 1);
      } else {
        int l, r;
        std::cin >> l >> r;
        l ++;
        r ++;
        std::cout << query(l, r, 1, n, 1) << std::endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 5152
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n), x;
    REP(i, n) cin >> a[i];
    x = a;
    sort(all(x));
    
    if(x[n-1] == x[n-2])
    {
        REP(i, n) cout << x[n-1] << endl;
    }
    else 
    {
        REP(i, n) cout << (x[n-1] == a[i] ? x[n-2] : x[n-1]) << endl;
    }
    
}

Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    ll n,k,ans;
    cin >> n >> k;
    ans=1;
    for(int i=0;i<n;i++){
        ans *= k;
        ans %= 1000000007;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 1000000007
#define pb push_back
using namespace std;
int main(){
	int n,a[1000],ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int cur=1;
	for(int i=1;i<n;i++){
		if(a[i]==a[i-1])cur++;
		else{
			ans+= cur/2;
			cur=1;
		}
	}
	ans+=cur/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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; cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    sort(all(a));
    vector<int> v(1000100,0);
    ll ans=0;
    rep(i,0,n){
        ll now=a[i];
        if(v[now]==1) continue;
        for(ll j=1; j*now<1000100; j++) v[j*now]=1;
        if(i!=n-1 and now==a[i+1]) continue;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8740
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
using namespace std;




int main ( ){

    long long n;
    cin>>n;
    vector <int>vec;
    int t;
    for(int i =0;i<n;i++){
        scanf("%d",&t);
        vec.push_back(t);
    }
    sort(vec.begin(),vec.end());
    long long count =0;
    for(int i = 0 ; i < n-2 ; i++){
        for( int  j = i +1 ; j < n -1 ; j++){
            for(int k = j + 1; k < n;k++){
                if((vec[i] < vec[j]+vec[k])&&(vec[j]<vec[i]+vec[k])&&(vec[k]<vec[j]+vec[i]))count++;
            }
        }
    }
    cout << count;
    return 0;
    
}



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

using namespace std;

using ll = long long;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   ll N;
   cin >> N; ++N;
   function<vector<int>(ll, int)> go = [&](ll N, int cur) {
      if (N == 1) return vector<int>{};
      if (N % 2 == 0) {
         auto ans = go(N / 2, cur + 1);
         ans.insert(ans.begin() + int(ans.size()) / 2, cur);
         ans.emplace_back(cur);
         return ans;
      } else {
         auto ans = go(N - 1, cur + 1);
         ans.insert(ans.begin(), cur);
         ans.emplace_back(cur);
         return ans;
      }
   };
   auto ans = go(N, 1);
   cout << int(ans.size()) << "\n";
   for (int v : ans) cout << v << " ";
   return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 805;

int g[MAXN][MAXN];
int deg_in[MAXN];
int deg_out[MAXN];
int mx = 200;
int offset_val = 200;
int offset_part = 401;

int used[MAXN];
vi comp;

void dfs(int s) {
	used[s] = 1;
	comp.pb(s);
	REP(i, 0, MAXN) {
		if ((g[s][i] || g[i][s]) && !used[i]) {
			dfs(i);
		}
	}
}

void solve(){
	int n, h, a, b, c, d;
	scanf("%d%d", &n, &h);
	REP(i, 0, n) {
		scanf("%d%d%d%d", &a, &b, &c, &d);
		if (c) {
			a = -c;
		}
		if (d) {
			b = -d;
		}
		//printf("added: %d %d\n", a, b);
		g[offset_val + a][offset_part + offset_val + b]++;
		if (a < 0) {
			g[offset_part + offset_val - a][offset_val + a]++;
		}
		if (b < 0) {
			g[offset_part + offset_val + b][offset_val - b]++;
		}
	}
	REP(i, 0, MAXN) {
		REP(j, 0, MAXN) {
			deg_in[j] += g[i][j];
			deg_out[i] += g[i][j];
			/*if (g[i][j]) {
				printf("%d %d: %d\n", i, j, g[i][j]);
			}*/
		}
	}
	REPN(i, 1, mx) {
		if (deg_in[offset_val + i] > deg_out[offset_val + i]) {
			printf("NO\n");
			return;
		}
		if (deg_in[offset_part + offset_val + i] < deg_out[offset_part + offset_val + i]) {
			printf("NO\n");
			return;
		}
	}
	REP(i, 0, MAXN) {
		if ((deg_in[i] || deg_out[i]) && !used[i]) {
			comp.clear();
			dfs(i);
			int fl_balance = 0;
			REP(j, 0, SZ(comp)) {
				int v = comp[j];
				if (deg_in[v] != deg_out[v]) {
					fl_balance = 1;
					break;
				}
			}
			if (!fl_balance) {
				printf("NO\n");
				return;
			}
		}
	}
	printf("YES\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2816
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        boolean ok = true;
        for (int i = 1; i <= S.length(); i++) {
            char c = S.charAt(i-1);
            if (i % 2 != 0 && !(c == 'R' || c == 'U' || c == 'D')) ok = false;
            if (i % 2 == 0 && !(c == 'L' || c == 'U' || c == 'D')) ok = false;
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll dp[105][100005];

int main(){
	ll n,k; cin >> n >> k;
	vl a(n);
	rep(i,n) cin >> a[i];
	rep(j,k+1) dp[0][j] = 1;
	rep(i,n){
		rep(j,k+1){
			ll c = 0;
			if(j-a[i]-1>=0) c = dp[i][j-a[i]-1];
			dp[i+1][j] = dp[i][j] - c;
			if(dp[i+1][j]<0) dp[i+1][j] += mod;
		}
		rep(j,k) dp[i+1][j+1] += dp[i+1][j], dp[i+1][j+1] %= mod;
	}
	ll ans = dp[n][k] - dp[n][k-1];
	if(ans < 0) ans += mod;
	cout << ans << endl;
}

Measured memory_bytes: 80128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<bool> seen(n);
	vector<int> g[n], p(n), c(n);
	rep (i, n - 1) {
		int s, t;
		cin >> s >> t;
		g[s - 1].push_back(t - 1);
		g[t - 1].push_back(s - 1);
	}
	ll sum = 0;
	rep (i, n) cin >> c[i];
	sort(all(c), [](int a, int b) {return a > b;});
	repp (i, 1, n) sum += c[i];
	printf("%lld\n", sum);
	int start = -1, count = 0;
	rep (i, n) if (g[i].size() == 1) start = i;
	eprintf("start: %d\n", start);
	priority_queue<int> pq;
	pq.push(start);
	seen[start] = true;
	while (!pq.empty()) {
		int now = pq.top();
		pq.pop();
		eprintf("now:%d count:%d c[count]:%d\n", now, count, c[count]);
		p[now] = c[count++];
		for (int x : g[now]) {
			if (!seen[x]) pq.push(x);
			seen[x] = true;
		}
	}
	rep (i, n) printf("%d ", p[i]); printf("\n");
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static string S;
    static void INPUT()
    {
        S = NextString();
    }

    static void OUT()
    {
        var c = S.ToCharArray();
        var aa = new int[c.Length];
        var cc = 0;
        for (int i = 0; i < c.Length; i++)
        {
            if (c[i] == 'R') cc++;
            else
            {
                var a = cc / 2;
                var b = cc - a;
                aa[i - 1] += b;
                aa[i] += a;
                cc = 0;
            }
            var s = c[i];
        }
        cc = 0;
        for (int i = c.Length - 1; i >= 0; i--)
        {
            if (c[i] == 'L') cc++;
            else
            {
                var a = cc / 2;
                var b = cc - a;
                aa[i + 1] += b;
                aa[i] += a;
                cc = 0;
            }
            var s = c[i];
        }
        Console.WriteLine(string.Join(" ", aa));
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}




Measured memory_bytes: 14652
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		int D = scanner.nextInt();

		if( (A*B) < (C*D) ){
			System.out.println(C*D);
		}else{
			System.out.println(A*B);
		}
	}
}


Measured memory_bytes: 9804
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"

    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    ll a[5];
    ll id=0;
    rep(i,5)
    {
        cin>>a[i];
    if(a[i]==0)id=i;
    }
    cout<<id+1;

}




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

int main() {
    int n, k;
    cin >> n >> k;
    int l[50];
    rep(i, n) cin >> l[i];
    sort(l, l + n, greater<int>());
    int ans = 0;
    rep(i, k) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <limits>
#include <cstring>
#define maxn 2000+10
//#define int long long
#define P pair <int,int >
#define _1 first
#define _2 second

using namespace std;
#define INF numeric_limits<int >::max()
char A[maxn],B[maxn];
int n,cnt,g,l[maxn],r[maxn],ans,pos,top;
P st[maxn];

int cal()//对于st内若干个【l_i，r_i】 ,要求X，Y，使得所有i满足l_i<=X||r_i<=Y且X+Y最小 
{
	if (!top) return 0;
	sort(st+1,st+1+top);
	int X=st[top]._1,Y=0,tmp=X+Y;
	for (int i=top;i;--i)
	{
		X=st[i-1]._1;
		Y=max(Y,st[i]._2);
		tmp=min(tmp,X+Y);
	}
	return tmp;
}

int solve(char * A,char *B)
{
	for (int i=0;i<n;++i)
	  {
	  	 for (r[i]=0;B[(i+r[i])%n]!='1';++r[i]);
	  	 for (l[i]=0;B[(i-l[i]+n)%n]!='1';++l[i]);
	  }
	int tmp=INF;
	for (int d=0;d<n;++d)//枚举右移位数 
	{
		int count=0;
		top=0;
		for (int i=0;i<n;++i)
		  if (A[i]!=B[(i+d)%n])
		  {
		  	++count;
		  	if (r[i]>d) st[++top]=(P){l[i],r[i]-d};
		  }
		tmp=min(tmp,2*cal()+d+count);//到达所需取反位置最小步数+右移+ 取反次数 
	}
	return tmp;
}

signed main()
{
	scanf("%s%s",A,B);
	n=strlen(A);
	int t1=0;
	for (int i=0;i<n;++i) cnt+=B[i]=='1',t1+=A[i]=='1';
	if (cnt==0)
	{
		t1==0?printf("0\n"):printf("-1\n");
		return 0;
	}
	ans=solve(A,B);
	reverse(A,A+n);
	reverse(B,B+n);
	ans=min(ans,solve(A,B));
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int x1, x2, a;
  cin>> x1 >> x2;

  if ( x1 < x2 ){
    a=x2-x1;
    cout<< a << endl;
  }else{
    a=x1-x2;
    cout<< a << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<int> root[200005];
vector<int> ans;

void dfs(int a,int p=-1){
    for(auto r:root[a]){
        if(r==p)continue;
        ans[r]+=ans[a];
        dfs(r,a);
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    
    for(int i=0; i<n-1; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        root[a].push_back(b);
        root[b].push_back(a);
    }
    ans.resize(n);
    for(int i=0; i<q; i++){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p]+=x;
    }
    dfs(0);
    for(int i=0; i<n; i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 23424
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	const ll INF = 100010;
	ll cnt[INF] = {};
	ll ans = 0;
	REP(i, N) {
		ll a;
		cin >> a;
		if (a > 100000)  ans++;
		else {
			cnt[a]++;
		}
	}
	REP(i, INF) {
		if (cnt[i] > i) {
			ans += cnt[i]-i;
		}
		else if (cnt[i] < i) {
			ans += cnt[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>

using namespace std;

int main(){

    int a,b;
    double n;
    cin >> a >> b;
    cout << a/b << endl;
    cout << a - (a/b)*b << endl;
    cout << fixed;
    cout << setprecision(15) << double(a)/double(b) << endl;

    return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  V a(n+2);
  ll s = 0;
  rep(i,n+1) {
    cin >> a[i+1];
    s += abs(a[i+1]-a[i]);
  }
  Rep(i,1,n+1) {
    if ((a[i] >= a[i-1] && a[i] <= a[i+1]) || (a[i] <= a[i-1] && a[i] >= a[i+1])) {
      cout << s << '\n';
    }
    else {
      ll t = min(abs(a[i]-a[i-1]), abs(a[i]-a[i+1]));
      cout << s-2*t << '\n';
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 4048