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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	string x;
	cin >> x;
	int len = x.length();
	string out  ="";
	loop(len)
	{
		if (x[i] != 'B')
			out += x[i];
		else if(!out.empty())
			out.pop_back();
	}
	cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
s = list(map(int, input().split()))
ans = deque()

for i in range(n):
    if (i + 1) % 2 == 0:
        ans.appendleft(s[i])
    else:
        ans.append(s[i])
if n % 2 == 1:
    ans.reverse()
ans = map(str, ans)
print(' '.join(ans))

Measured memory_bytes: 123604
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  vector<int> vec(3);
  cin>>vec[0]>>vec[1]>>vec[2];
  sort(vec.begin(),vec.end());
  
  int K;
  cin>>K;
  
  cout<<vec[0]+vec[1]+vec[2]*pow(2,K)<<endl;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,countp=0,countw=0,countg=0,county=0;
    vector<char> arare;
    char iro;


    cin>>N;

    for(int i=0;i<N;i++){
        cin>>iro;
        if(iro=='P')countp++;
        if(iro=='W')countw++;
        if(iro=='G')countg++;
        if(iro=='Y')county++;
    }

    if(countp&&countw&&countg&&county){
        cout<<"Four"<<endl;
    }else{
        cout<<"Three"<<endl;
    }


}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    if(n == 1){
        puts("Hello World");
        return 0;
    }
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<bool> > cam(h+2);
  for(int i=0;i<h+2;i++) cam[i].resize(w+2);
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      cam[i][j]=false;
    }
  }
  int bsum=0;
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      char c;
      cin >> c;
      if(c=='#'){
	cam[i][j]=true;
	bsum++;
      }
    }
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(cam[i][j]==true){
	if(cam[i+1][j]==false&&cam[i-1][j]==false){
	  if(cam[i][j+1]==false&&cam[i][j-1]==false){
	    cout << "No\n";
	    goto OUT;
	  }
	}
	bsum--;
      }
    }
  }
 OUT:
  if(bsum==0) cout << "Yes\n";
  
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

taro = hanako = 0
for i in range(int(input())):
    a, b = input().split()
    if a == b:
        taro+=1
        hanako+=1
    elif a > b:
        taro+=3
    else:
        hanako+=3
print(taro, hanako)


Measured memory_bytes: 5600
N = input()
A = input()
B = input()
C = input()


def get_n_trial(a_str, b_str, c_str):
    ret = 0
    for a, b, c in zip(a_str, b_str, c_str):
        if a == b == c:
            continue
        elif (a != b) and (b != c) and (c != a):
            ret += 2
        else:
            ret += 1
        # print(ret)
    return ret


print(get_n_trial(A, B, C))


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    if(a[a[i] - 1] == i + 1){
      ans ++;
    }
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 3752
import math

Inp = input()
List = Inp.split(" ")
A = int(List[0])
B = int(List[1])
H = int(List[2])
M = int(List[3])

"""
DegA = int(H*30 + M*0.5)
DegB = int(M*6)

if abs(DegA - DegB) < 180:
    Deg = DegA - DegB

else:

    if DegA > DegB:
        Deg = 360 - DegA + DegB

    else:
        Deg = 360 - DegB + DegA
"""   

Deg = math.radians(abs(0.5 * (60 * H + M) - 6 * M))

C = math.sqrt((A**2 + B**2 - 2*A*B*math.cos(Deg)))

print(format(C,'.20f'))

Measured memory_bytes: 9524
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
int main()
{
    ll a,b,c,x,y,z;
    while(cin>>a>>b>>c)
    {
        x=c;
        y=a;
        z=b;
        cout<<x<<" "<<y<<" "<<z<<" "<<endl;
    }
    return 0;
}


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

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

struct SegmentTree{

   int SZ;
   vector<int> seg;
   const int root=0;
   const int nil=-1;
   SegmentTree(int n){
      SZ=1;
      while(SZ<n) SZ*=2;
      seg.resize(SZ*2-1, 0);
   }

   int getmax(int a, int b, int i, int l, int r){
      // cout<< i<<" "<<l<<" "<<r<< endl;
      if(b<=l or r<=a){
         return nil;
      }else if(a<=l and r<=b){
         return seg[i];
      }else{
         int m=(r+l)/2;
         int vl=getmax(a, b, 2*i+1, l, m);
         int vr=getmax(a, b, 2*i+2, m, r);
         return max(vl, vr);
      }
   }
   int getmax(int a, int b){
      return getmax(a, b, root, 0, SZ);
   }

   void update(int i, int data){
      i+=SZ-1;
      seg[i]=data;
      while(i){
         i=(i-1)/2;
         seg[i]=max(seg[2*i+1], seg[2*i+2]);
      }
   }

   int answer(){
      return seg[root];
   }
};

int main(){

   int n;
   cin>> n;
   vector<int> a(n);
   repeat(i, n) cin>> a[i];

   vector<pii> b;
   repeat(i, n) b.push_back(pii(a[i], -i));
   sort(b.begin(), b.end());

   SegmentTree st(n);
   repeat(i, n){
      // cout<< i<< endl;
      int j=-b[i].second;
      // cout<< j<< endl;
      int ma=st.getmax(0, j+1);
      st.update(j, ma+1);
   }

   cout<< st.answer()<< endl;

   return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "YES" : "NO"));}
//----------------------------------------------------------------

int main(void) {
  int n, m;
  cin >> n >> m;

  vec num(n);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--, b--;
    num[a]++;
    num[b]++;
  }

  rep(i,n){
    prt(num[i]);
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
using namespace std;


int main() {
	int N;

	cin >> N;
	vector<int> W(N);
	vector<int> sum(N,0);


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

	int min = 99999999;
	for (int T = 0; T < N; T++) {

		int sum1 = 0, sum2 = 0;

		for (int i = 0; i < T; i++)
			sum1 += W[i];

		for (int i = T; i < N; i++)
			sum2 += W[i];

		if (abs(sum1 - sum2)<min)
			min = abs(sum1 - sum2);

	}
	cout << min << endl;

}




Measured memory_bytes: 256
#include <iostream>

class dice{
public:
	explicit dice(int in[6]){
		for(int i=0;i<6;i++){
			v[i]=in[i];
		}
	}
	void mov(const char c){
		int buf;
		switch(c){
			case 'N':{
				buf = v[0];
				v[0] = v[1];
				v[1] = v[5];
				v[5] = v[4];
				v[4] = buf;
				break;
			}
			case 'E':{
				buf = v[0];
				v[0] = v[3];
				v[3] = v[5];
				v[5] = v[2];
				v[2] = buf;
				break;
			}
			case 'W':{
				buf = v[0];
				v[0] = v[2];
				v[2] = v[5];
				v[5] = v[3];
				v[3] = buf;
				break;
			}
			case 'S':{
				buf = v[0];
				v[0] = v[4];
				v[4] = v[5];
				v[5] = v[1];
				v[1] = buf;
				break;
			}
		}
	}
	int top(){
		return v[0];
	}
private:
	int v[6];
};

int main(){
	int in[6];
	std::string s;
	for(int i=0;i<6;i++){
		std::cin >> in[i];
	}
	dice d(in);
	std::cin >> s;
	for(auto it=s.begin();it!=s.end();it++){
		d.mov(*it);
	}
	std::cout << d.top() << std::endl;
}

Measured memory_bytes: 1208
#include<set>
#include<cstdio>
#include<cstring>

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

using namespace std;

typedef long long ll;

ll rolling_hash(int n,const char *s){
	static const ll P=1000000007;
	ll h=0;
	rep(i,n) h=(h*P+s[i]);
	return h;
}

void strrev(char *s,const char *t){
	int n=strlen(t);
	rep(i,n) s[n-i-1]=t[i];
	s[n]='\0';
}

int main(){
	int T; scanf("%d",&T);
	while(T--){
		char s[73]; scanf("%s",s);
		int n=strlen(s);

		set<ll> H;
		rep(i,n){
			char t1[73],t2[73];
			strncpy(t1,s,i); t1[i]='\0';
			strcpy(t2,s+i);
			rep(S,4){
				char u1[73],u2[73];
				strcpy(u1,t1); if(S&1) strrev(u1,t1);
				strcpy(u2,t2); if(S&2) strrev(u2,t2);
				rep(j,2){
					char v[73];
					if(j==0) sprintf(v,"%s%s",u1,u2);
					if(j==1) sprintf(v,"%s%s",u2,u1);
					H.insert(rolling_hash(n,v));
				}
			}
		}

		printf("%d\n",H.size());
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

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

	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	} else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	} else {
		cout << "Sunny" << endl;
	}	
}


Measured memory_bytes: 256
n= (int)(input())
ans = ""
count = 0

if n % 26 != 0:
    ans += chr(n % 26 + 96)
    n -= n % 26
else:
    ans += 'z'
    n -= 26

for i in range(1, 11):
    n = n // 26
    if n == 0:
        break
    if n % 26 != 0:
        ans = chr(n % 26 + 96) + ans
        n -= n % 26
    else:
        ans = 'z' + ans
        n -= 26
    
print(ans)

Measured memory_bytes: 61804
#include <iostream>
#include <stdio.h>
using namespace std;

int binarySearch(int A[],int n,int key);

int main(){
  int n,S[100000],q,key,C=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    C += binarySearch(S,n,key);
  }
  printf("%d\n",C);
  return 0;
}

int binarySearch(int A[],int n,int key){
  int l = 0;
  int r = n;
  while(r>l){
    int mid = (l + r)/2;
    if(A[mid] == key) return true;
    if(A[mid] < key) l = mid+1;
    if(A[mid] > key) r = mid;
  }
  return false;
}

Measured memory_bytes: 1580
N,M = map(int,input().split())
import numpy as np
A = np.empty((N,2), dtype=np.int)
CP = np.empty((M,2), dtype=np.int)
for _ in range(N):
  A[_][:] = list(map(int,input().split()))
for _ in range(M):
  CP[_][:] = list(map(int,input().split()))
for n in range(N):
  ans = 0
  mnda = 4*10**8
  for m in range(M):
    mnd = sum(np.abs(A[n]-CP[m]))
    if mnd < mnda:
      mnda = mnd
      ans = m+1
  print(ans)

Measured memory_bytes: 12504
while True :
    x,y=input().split()
    if int(x)==0 and int(y)==0 : break
    i=1
    while i<=int(x) :
        k=1
        while k<=int(y) : 
            if i%2>0 and k%2>0 : print("#",end="")
            elif i%2==0 and k%2==0 : print("#",end="")
            else : print(".",end="")
            k=k+1
        print("")
        i=i+1
    print("")


Measured memory_bytes: 7012
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a > b)
        a^=b^=a^=b;
    for(unsigned i=0;i<b;++i)
        cout<<a;
}

Measured memory_bytes: 384
// Your code here!

import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.conv;
import std.string;

void main(){
  auto ab = readln().chomp().split().map!(to!long);
  auto a = ab[0];
  auto b = ab[1];
  solve(a, b).writeln();
}

long solve(long a, long b){
    auto eastIdx = b - a;
    long westLength = iota(1, eastIdx).sum;
    return westLength - a;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 6e5+20;

vector <int> v;
int n, k, este, actual;
int arr [N];

void f(int actual)
{
    if(actual == 0) arr[0] = 0;
    else
    {
        for(int i = 0; i <= k; i++)
        {
            if(actual-i >= 0)
            {
                int peso = arr[actual-i] + abs(v[actual] - v[actual-i]);
                //cout<<peso1<<endl;
                if(peso < arr[actual])
                    arr[actual] = peso;
            } 
        }
        
    }
}
int main()
{
    cin>>n>>k;
    for(int i = 0; i < n; i++){cin>>este;v.push_back(este);}
    memset(arr, 1000000, sizeof arr);
    for(int i = 0; i < n; i++)f(i);
    cout<<arr[n-1]<<endl;
    //for(int i = 0; i < n; i++)cout<<arr[i]<<" - ";
}

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

int main(){
  int min = 1e9, max = -1e9, n, a[200000];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n - 1; i++){
    min = min > a[i] ? a[i] : min;
    max = max < a[i+1] - min ? a[i+1] - min : max;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 3880
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define VI(v,n) vector<int> v(n)



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

	int fn = 0, fe = 0, fw = 0, fs = 0;

	REP(i, s.size()) {
		if (s[i] == 'N') {
			fn = 1;
		}
		if (s[i] == 'E') {
			fe = 1;
		}
		if (s[i] == 'W') {
			fw = 1;
		}
		if (s[i] == 'S') {
			fs = 1;
		}

		if (fn + fe + fw + fs == 4) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	if (fn + fs == 2 && fe + fw == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (fn + fs == 0 && fe + fw == 2) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10)
    cout << r << endl;
  else
    cout << r + 100 * (10 - n) << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string a,b,res;
long long da[3005][3005];
int main()
{
    cin>>a>>b;
    a=' '+a;
    b=' '+b;
    for(int i=1;i<a.size();i++)
        for(int j=1;j<b.size();j++)
    {
        if(a[i]==b[j])
            da[i][j]=da[i-1][j-1]+1;
        else
            da[i][j]=max(da[i][j-1],da[i-1][j]);
    }
    ll k=a.size()-1,h=b.size()-1;
    ll g=da[k][h];
    while(k>0&&h>0&&g>=0)
    {
        if(a[k]==b[h])
        {
            res=a[k]+res;
            g--;
            k--; h--;
        }
        else
        {
            if(da[k][h]==da[k][h-1])
                h--;
            else if(da[k][h]==da[k-1][h]) k--;
        }
    }
    cout<<res;
}


Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;



int main()
{
	int s1 = 0, s0 = 0;
	string test;
	int size;

	cin >> test;
	size = test.size();

	for (int i = 0; i < size; i++) {
		if (i % 2) {
			if (test[i] == '0') {
				s1++;
			} else {
				s0++;
			}
		} else {
			if (test[i] == '0') {
				s0++;
			} else {
				s1++;
			}
		}
	}

	printf("%d", (s0 > s1 ? s1 : s0));

	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define n 100001
//void swap(int ,int);

int A[n],key;
int partition(int ,int);
/*void swap(int x, int y)
{
  int temp;
  temp = x;
  x = y;
  y = temp;
}
*/
int main()
{
  int num,i;
  scanf("%d",&num);

  for(i = 0 ; i < num ; i++)
    {
      scanf("%d",&A[i]);
    }

  key = partition(0,num-1);

  printf("%d",A[0]);

  for(i = 1 ; i < num ; i++)
    {
      if(key == i)printf(" [%d]",A[i]);
      else printf(" %d",A[i]);
    }

  printf("\n");


  return 0;
}


int partition(int p,int r)
{
  int x,i,j;
  int temp;

  x = A[r];
  i = p - 1;
  for(j = p ; j <= r-1 ; j++)
    {
      if(A[j] <= x){
	i = i + 1;
	temp = A[i];
	A[i] = A[j];
	A[j] = temp;
	
	//swap(A[i],A[j]);
      }
    }
  //swap(A[i+1],A[r]);
 
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;




 return i+1;
}

Measured memory_bytes: 992
n=int(input())
w=list(map(int,input().split()))
sum=int(0)
for i in range(n):
  sum+=w[i]
dif=sum
for i in range(n):
  psum=int(0)
  for j in range(i):
    psum+=w[j]
  dif=min(dif,abs(psum-(sum-psum)))
print(dif)


Measured memory_bytes: 9120
#include <iostream>
using namespace std;
string num[3]={"Sunny","Cloudy","Rainy"};
string s;
int main()
{
	cin>>s;
	for(int i=0;i<3;i++)
		if(num[i]==s)
			cout<<num[(i+1)%3]<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var Q = Sarray()[0];
            for (var i = 0; i < Q; ++i)
            {
                var ab = Sarray();
                var a = ab[0];
                var b = ab[1];
                WriteLine(Calc(a, b));
            }
        }
        static long Calc(long A, long B)
        {
            if (A == B)
                return A - 1 + B - 1;

            var lim = A * B;
            var r = (long)Sqrt(lim);
            if (lim < r * r) --r;
            if ((r + 1) * (r + 1) < lim) ++r;
            if (r * r == lim)
                return r - 1 + r - 1 - 1;
            var a = r + r - 1 - 1;
            if (r * (r + 1) < lim)
                ++a;
            return a;
        }
    }
}

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    int x,t;
    std::cin >> x>>t;
    std::cout << max(0,x-t) << std::endl;
}

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


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

    string n;
    cin >> n;
    int  ans=0;
    for (int i=0;i<n.size();i++){
        ans += (n[i]-'0');
        if (ans >= 9 )
            ans-=9;
    }
    if (ans == 0 )
        cout << "Yes";
    else
    cout << "No";


    return 0;
}


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

K = 2019

def f(a):
	return a // K

def main():
	l, r = map(int, input().strip().split())
	ans = 0
	if f(r) - f(l) >= 1:
		pass
	else:
		t = 10**9
		for i in range(l, r):
			for j in range(l+1, r+1):
				t = min(t , (i*j) % K)
		ans = t
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    cin>>n>>a;
    int w[n],v[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    int dp[100001];
    for(int i=1;i<100001;i++){
        dp[i]=mod;
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=100000;j>=v[i];j--){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    for(int i=100000;i>=0;i--){
        if(dp[i]<=a){
            cout << i<<endl;
            return 0;
        }
    }
    return 0;

}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

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

using namespace std;

int max(int a, int b){
  return a > b? a : b;
}

int n, m;
vector< vector<int> > v(200010, vector<int>(0));
bool dfs(int x, int depth){
  if(depth > 2) return false;
  if(depth == 2 && x == n) return true;

  REP(i, v[x].size()){
    if(dfs(v[x][i], depth + 1)) return true;
  }
  return false;
}

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

  int a, b;
  REP(i, m){
    cin >> a >> b;
    if(a == 1 || b == n) v[a].push_back(b);
  }

  cout << (dfs(1, 0)? "POSSIBLE" : "IMPOSSIBLE") << endl;

  return 0;
}

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

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

using namespace std;

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

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

  string result = "No";
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        result = "Yes";
        break;
      }
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

idx = 1
count = 0
flag = False
for i in range(n):
  if a[i] == idx:
    flag = True
    idx+=1
  else:
    count+=1
   
if flag:
  print(count)
else:
  print(-1)

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

int M, N, A[100009], X, cnt1, cnt2;

int main() {
	cin >> M >> N >> X;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		if (A[i] < X) cnt1++;
		if (A[i] > X) cnt2++;
	}
	cout << min(cnt1, cnt2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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(void){
  int n; cin >> n;
  int p[n];
  FOR(i,0,n-1) cin >> p[i];

  sort(p,p+n);

  int ans = 0;
  FOR(i,0,n-2) ans += p[i];
  ans += p[n-1] / 2;

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
li_A = list(map(int, input().split()))
count = 0
find = 1
for i in range(N):
    if li_A[i] == find:
        find += 1
    else:
        count += 1
if count < N:
    print(count)
else:
    print("-1")

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

ll calc(ll n){
    ll m = n+1;
    ll ans = 0;
    for(int i=0;i<50;i++){
        ll tmp = 0;
        ll loop = 1LL<<(i+1);
        //cout << "loop" << i << "=" << loop << endl;
        tmp += m/loop * (loop/2);
        tmp += max(0LL,m%loop-loop/2);
        if(tmp%2==1) ans += (1LL<<i);
    }
    return ans;
}

int main(void){
    ll a,b;
    cin >> a >> b;
    ll ans = calc(b)^calc(a-1);
    cout << ans << endl;
    //cout << calc(a) << ", " << calc(b) << endl;
}

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

long long N, M;
vector<long long> tree[100005];

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
	  // 最初は全てのデータiがグループiに存在するものとして初期化
	  for(int i = 0; i < n; i++){
		  par[i] = i;
	  }
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

long long colarr[100005];

bool nibuhelp(long long pa, long long idx, long long col){
	if(colarr[idx] != 0 && colarr[idx] != col){
		return false;
	}
	if(colarr[idx] != 0){
		return true;
	}
	colarr[idx] = col;
	for(long long i = 0; i < tree[idx].size(); i++){
		if(tree[idx][i] == pa){
			continue;
		}
		if(nibuhelp(idx, tree[idx][i], -1 * col) == false){
			return false;
		}
	}
	return true;
}


bool nibu(long long idx){
	return nibuhelp(-1, idx, 1);
}

int main(){
	cin >> N >> M;
	UnionFind uf(N);
	for(long long i = 0; i < M; i++){
		long long u, v;
		cin >> u >> v;
		u--;v--;
		tree[u].push_back(v);
		tree[v].push_back(u);
		uf.unite(u, v);
	}

	set<long long> single;
	for(long long i = 0; i < N; i++){
		if(uf.size(i) == 1){
			single.insert(i);
		}
	}

	long long nibunum = 0;
	long long nonnibunum = 0;

	set<long long> done;
	for(long long i = 0; i < N; i++){
		if(single.count(i) != 0){
			continue;
		}
		if(done.count(uf.find(i)) != 0){
			continue;
		}

		done.insert(uf.find(i));
		if(nibu(i) == true){
			nibunum++;
		}else{
			nonnibunum++;
		}
	}
	long long ans = 0;
	//single vs single
	//single vs nibu
	//single vs nonnibu
	ans += single.size() * N;

	//nibu vs single
	//nonnibu vs single
	//single vs single
	ans += N * single.size();

	//- single vs single
	ans -= single.size() * single.size();

	//nibu vs nibu
	ans += nibunum * nibunum * 2;
	//nibu vs nonnibu
	ans += nibunum * nonnibunum;
	//nonnibu vs nibu
	ans += nonnibunum * nibunum;
	//nonnibu vs nonnibu
	ans += nonnibunum * nonnibunum;

	cout << ans << endl;
}


Measured memory_bytes: 11776
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int T, P, R;

	while(cin >> T >> P >> R, T) {
		vvi solve(T, vi(P, 0)), time(T, vi(P, 0)), penal(T, vi(P, 0));

		int tid, pid, t;
		string message;
		REP(i, R) {
			cin >> tid >> pid >> t >> message;

			if(message == "CORRECT") {
				solve[tid-1][pid-1]++;
				time[tid-1][pid-1] += (t+penal[tid-1][pid-1]*1200);
			} else {
				penal[tid-1][pid-1]++;
			}
		}

		vi score(T), times(T);
		REP(i, T) {
			REP(j, P) {
				score[i] += solve[i][j];
				times[i] += time[i][j];
			}
		}

		REP(i, T) {
			int maxteam = 0, maxscore = -1;
			REP(j, T) {
				if(maxscore < score[j]) {
					maxscore = score[j];
					maxteam = j;
				} else if(maxscore == score[j]) {
					if(times[maxteam] > times[j]) {
						maxscore = score[j];
						maxteam = j;
					}
				}
			}
			cout << maxteam+1 << " " << score[maxteam] << " " << times[maxteam] << endl;
			score[maxteam] = -2;
			times[maxteam] = -2;
		}
	}

	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define ffor(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))  
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
#define rep(i, n) ffor(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define all(v) v.begin(), v.end()  
#define TC(t) while (t--) 
#define N 200005
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n"; 
 
 
int main(){
    fast;
    ll l,r,i,j,m,k,a,b,c,q,t,x,y,d,n;
    cin>>n;
  	set<string> s;
    string str;
    rep(i,n){
        cin>>str; 
        if(s.find(str)==s.end()) s.insert(str);
    } 	
    pp(s.size());
}

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

int main() {
  int N;
  cin >> N;
  int num=N;
  int sum=0;
  while (N >= 10){
    sum += N%10;
    N /= 10;
  }
  sum += N;
  if(num%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
/*int const nmax = 1000006; 
vector<int> v[nmax]; 
void dfs(int i , int p)
{
	for(int j = 0; j<v[i].size(); j++)
	{
		int node = v[i][j]; 
		if(node!=p)
		{
			dfs(node,i); 
		}
	}
}*/
/////////////////////////////
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////


void solve()
{
 string s; cin>>s ; 
 if(s[1]=='B')
 s[1]='R'; 
 else
 s[1]='B'; 
 cout<<s; 
}
int main()
{ ios; 

ll t =1; 
 while(t--)
	solve(); 
	return 0 ; 
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>

using namespace std;

void SelectSort(int x[], int N);
void BubbleSort(int x[], int N);
void InsertSort(int x[], int N, int num);
void ShellSort(int x[], int N);
void Trace(int x[], int N);

int gCount = 0;

int main() {
    int N;

    cin >> N;

    int x[N];

    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    SelectSort(x, N);
    Trace(x, N);
    cout << gCount << endl;

    return 0;
}


void SelectSort(int x[], int N) {
    int min;

    for (int i = 0; i < N - 1; i++) {
        min = i;
        for (int j = i; j < N; j++) {
            if (x[min] > x[j]) {
                min = j;
            }
        }
        if (i != min) {
            gCount++;
            swap(x[min], x[i]);
        }
    }
}

void Trace (int x[], int N) {
    int i;
    for (i = 0; i < N - 1; i++) {
        cout << x[i] << " ";
    }
    cout << x[i] << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  vector<long> x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];
  rep(i,n) if(x[i]>y[i]) swap(x[i],y[i]);

  // x[i] < y[i]

  vector<pair<long,int>> ps(2*n);
  rep(i,n) ps[i*2]=mp(x[i],i), ps[i*2+1]=mp(y[i],i);
  sort(all(ps));

  int j = ps[0].se;
  int k = ps[2*n-1].se;

  if(j == k){
    long mx = 0;
    long mn = INF;
    rep(i,n) if(i!=k){
      mx = max(mx, x[i]);
      mn = min(mx, y[i]);
    }
    long xx = y[k];
    long nn = x[k];
    long ans = (xx-mn)*(mx-nn);
    cout << ans << endl;
    return 0;
  }

  // j: smallest, k: largest

  long ans = 1234567890123456789LL;
  {
    // min,maxちがう色 -> 各ペアの大小だけで
    long mx = x[k];
    long mn = y[j];
    rep(i,n) if(i!=k && i!=j){
      mx = max(mx, x[i]);
      mn = min(mn, y[i]);
    }
    ans = min(ans, (y[k]-mn)*(mx-x[j])); //dbg(ans);
  }
  {
    // min,maxおなじ色
    multiset<int> st;
    st.insert(x[k]);
    st.insert(y[j]);

    rep(i,n)if(i!=k && i!=j) st.insert(x[i]);

    int w = *(--st.end()) - *(st.begin());
    repl(i,1,2*n-1){
      int idx = ps[i].se;
      if(idx==k || idx==j) continue;
      if(ps[i].fi == y[idx]) continue;
      st.erase(st.lower_bound(x[idx]));
      st.insert(y[idx]);
      int nw = *(--st.end()) - *(st.begin()); //dbg(i,nw);
      w = min(w, nw);
    }

    long aa = (y[k]-x[j])*w;

    ans = min(ans, aa);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20992
/*input
10000
*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#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 <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  ll ans = 0, cur = 100, x = 1, y = 100;
  while (cur < n) {
    ans++;
    cur += cur / 100;
  }
  
  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
 
const int INF = 1000000000;
 
int main()
{
    while(true){
        int n, m;
        cin >> n >> m;
 
        if(n==0 && m==0)
            break;
 
        int C[100][100];
        int T[100][100];
        for(int i=0; i<m; i++){
            for(int j=0; j<m; j++){
                if(i==j){
                    C[i][j] = T[i][j] = 0;
                }
                else{
                    C[i][j] = T[i][j] = INF;
                }
            }
        }
 
        for(int i=0; i<n; i++){
            int a, b, c, t;
            cin >> a >> b >> c >> t;
 
            C[a-1][b-1] = C[b-1][a-1] = c;
            T[a-1][b-1] = T[b-1][a-1] = t;
        }
 
        int k;
        cin >> k;
        int p[k],q[k],r[k];
        for(int i=0; i<k; i++){
            cin >> p[i] >> q[i] >> r[i];
        }
 
        for(int k=0; k<m; k++){
            for(int i=0; i<m; i++){
                for(int j=0; j<m; j++){
                    if(C[i][j]>C[i][k]+C[k][j]){
                        C[i][j] = C[i][k]+C[k][j];
                    }
                    if(T[i][j]>T[i][k]+T[k][j]){
                        T[i][j] = T[i][k]+T[k][j];
                    }
                }
            }
        }
 
        for(int i=0; i<k; i++){
            int s=p[i]-1; int g=q[i]-1;
            if(r[i]==0){
                cout<<C[s][g]<<endl;
            }
            else{
                cout<<T[s][g]<<endl;
            }
        }
 
    }
 
    return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int a,b,c ,A,B,C ;
    cin >> a >> b >> c ;
    A = min({a,b,c}) ;
    B = max({a,b,c}) ;
    if(A == a && B == b)
    C = c ;
    else if(A == b && B == a)
    C = c ;
    else if(A == c && B == b)
    C = a ;
    else if(A == b && B == c)
    C = a ;
    else if(A == a && B == c)
    C = b ;
    else if(A == c && B == a)
    C = b ;



    cout << (B-C)+(C-A) ;









    return 0 ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N;
    int guu = 0;
    int ki = 0;

    cin >> N;

    REP(i, 0, N) {
        int tmp;
        cin >> tmp;

        if (tmp % 2 == 0) guu++;
        else ki++;
    }

    ll ans = (ll) (pow(3, (guu + ki)) - pow(2, guu));

    cout << ans << endl;


    return 0;
}


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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	int n,m,tmp;
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<int> point(n);
		for (int i = 0; i < n; i++) point[i] = 0;
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				cin >> tmp;
				point[j] += tmp;
			}
		}
		cout << *max_element(all(point)) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    ll s, x=0, a_1, a_2;
    cin >> n >> a_1 >> a_2;
    s = a_1 + a_2;
    for(int i=2; i<n; ++i){
        ll a;
        cin >> a;
        x ^= a;
    }
    // a + b = s, a ^ b = x, a <= a_1 なる (a, b) は存在するか、存在すれば最大のaを求めよ
    // a + b = a ^ b + 2 * (a & b) <=> s = x + 2 * (a & b)
    if (s - x < 0 || (s - x) % 2 == 1){
        cout << -1;
        return 0;
    }
    ll d = (s - x) / 2;
    // d = a & b （ d & x = 0 ）
    // x の bit を二分割したものを y, z とする（ y & z = 0, y ^ z = x ）と、 a = d ^ y, b = d ^ z は条件を満たす
    // (a, b) <=> (y, z) は全単射
    // a >= d が必要なので、 d > a_1 なら (a, b) は存在しない
    if(d > a_1 || (d & x) != 0){
        cout << -1;
        return 0;
    }
    ll y = 0;
    for(int i=45; i>=0; i--){
        // 降順で貪欲に d ^ y <= a_1 である範囲で y += (xのiビット目) を入れる
        const ll x_i = x & (1LL << i);
        if (x_i > 0 && (d ^ (y + x_i)) <= a_1) {
            y += x_i;
        }
    }
    if ((d^y) == 0){
        cout << -1;
        return 0;
    }
    cout << a_1 - (d ^ y);

    return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) if (s[i] != t[i]) ++ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long int
using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector<int> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  
  sort(v.begin(), v.end());
  double ans = v[0];
  
  for (int i = 1; i < n; i++) ans = (ans + v[i])/2;
  
  printf("%.10f\n", ans);
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define INF 1000000
using namespace std;

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    int i, plus, minus;
    for(i=0;i<n;i++){
        cin >> p.at(i);
    }

    int ans=INF;
    int count = 0;
    while(1){
        minus=INF;
        plus=INF;
        for(i=0;i<n;i++){
            if(p.at(i)==x-count){
                minus = p.at(i);
            }
            if(p.at(i)==x+count){
                plus = p.at(i);
            }
        }
        if(minus==INF){
            ans=x-count;
            break;
        }
        if(plus==INF){
            ans=x+count;
            break;
        }
        count++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3168