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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int NN = 111;
const int WW = 11111;
int N, W;
int w[NN], v[NN];

int bitBruteForth() {
   int ans = 0;
   rep (mask, (1<<N)) {
      int value = 0, weight = 0;;
      rep (i, N) {
         if ((mask>>i)&1) {
            value += v[i];
            weight += w[i];
         }
      }
      if (weight <= W) {
         ans = max(ans, value);
      }
   }
   return ans;
}

// int dfs(今の状態) {
//    int ret = 0;
//    for (...) ret += dfs(次の状態);
//    return ret;
// }

int dp[NN+1][WW+1];

int rec(int idx, int wLim) {
   if (idx == N) {
      return 0;
   } else if (wLim < w[idx]) {
      return rec(idx + 1, wLim);
   } else {
      int in = rec(idx + 1, wLim - w[idx]) + v[idx];
      int noIn = rec(idx + 1, wLim);
      return max(in, noIn);
   }
}

int memo(int idx, int wLim) {
   if (dp[idx][wLim] >= 0) {
      return dp[idx][wLim];
   }

   int res;
   if (idx == N) {
      res = 0;
   } else if (wLim < w[idx]) {
      res = memo(idx + 1, wLim);
   } else {
      int in = memo(idx + 1, wLim - w[idx]) + v[idx];
      int noIn = memo(idx + 1, wLim);
      res = max(in, noIn);
   }

   return dp[idx][wLim] = res;
}

int main() {
   cin >> N >> W;
   rep (i, NN+1) {
      rep (j, WW+1) {
         dp[i][j] = -1;
      }
   }
   rep (i, N) {
      cin >> v[i] >> w[i];
   }

   // cout << rec(0, W) << endl;
   cout << memo(0, W) << endl;

   return 0;
}


Measured memory_bytes: 7996
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
    // Your code here!
    int N;
    cin >> N;
    int t, x, y;
    int t_b = 0, x_b = 0, y_b = 0;
    vector<vector<int>> list;

    vector<int> tmp;
    tmp.push_back(0);
    tmp.push_back(0);
    tmp.push_back(0);
    list.push_back(tmp);

    for (int i = 0; i < N; i++)
    {
        cin >> t >> x >> y;
        vector<int> tmp;
        tmp.push_back(t);
        tmp.push_back(x);
        tmp.push_back(y);
        list.push_back(tmp);
    }

    int flag = 0;
    for (int i = 1; i <= N; i++)
    {
        int d_t = abs(list[i][0] - list[i - 1][0]);
        int d_x = abs(list[i][1] - list[i - 1][1]);
        int d_y = abs(list[i][2] - list[i - 1][2]);

        int d_distance = d_x + d_y;

        //   cout << list[i - 1][0] << " " << list[i - 1][1] << " " << list[i - 1][2] << endl;
        //    cout << d_distance << " " << d_t << endl;

        if (d_t < d_distance)
        {
            flag = 1;
            break;
        }
        else if ((d_t - d_distance) % 2)
        {
            flag = 1;
            break;
        }
    }
    if (flag == 1)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
}

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

int main()
{
  string s;
  cin>>s;
  int ans=10000,N=s.length();
  for(char t='a';t<='z';t++){
    int now=0,cnt=0;
    for(int i=0;i<N;i++){
      if(s[i]!=t){
        cnt++;
      }else{
        now=max(now,cnt);
        cnt=0;
      }
    }
    now=max(now,cnt);
    ans=min(ans,now);
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#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>;
using G = vector<vector<int>>;
    
int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll bn = b*100 + 0.5;
    a *= bn;
    a /= 100;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> c(n);
    for(int i=0;i<n;i++){
        cin>>c.at(i);
        sort(c.begin(),c.end());
        reverse(c.begin(),c.end());
    }
    int a=0,b=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            a+=c.at(i);
        }
        else{
            b+=c.at(i);
        }
    }
    cout<<a-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = pow(10, 9) + 7;

int main(){
    ll n, m;
    cin >> n >> m;
    if(max(n,m) - min(n,m) > 1) cout << 0 << endl;
    else{
        ll x = min(n, m);
        ll ans = 1;
        for(ll i = 1; i <= x; i++){
            ans *= (i * i) % mod;
            ans %= mod;
        }
        if(n == m) ans *= 2%mod;
        else ans *= (x + 1)%mod;
        cout << ans%mod << endl;
    }
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	static Scanner sc = new Scanner(System.in);
	static long[] f = null;
	static long[] fInverse = null;
	
	public static void main(String[] args) {
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		if((x + y) % 3 != 0) {
			System.out.println(0);
			return;
		}
		
		int sz = (x + y) / 3;
		f = new long[sz + 1];
		fInverse = new long[sz + 1];
		for(int i = 0; i <= sz; ++i) {
			f[i] = (i < 2) ? 1 : f[i - 1] * i % MOD;
			fInverse[i] = calcModInv(f[i]);
		}
		
		long ans = 0;
		for(int a = 0; a <= sz; ++a) {
			int b = sz - a;
			int xx = a + 2 * b;
			int yy = 2 * a + b;
			
			if(xx == x && yy == y) ans = (ans + comb(sz, a)) % MOD;
		}
		
		System.out.println(ans);
	}
	
	static long comb(int n, int r) {
		return f[n] * fInverse[r] % MOD * fInverse[n - r] % MOD;
	}
	
	static long calcModInv(long n) {
		long[] s = new long[2];
		solve(n, MOD, s);
		return s[0] >= 0 ? s[0] : s[0] + MOD;
	}
	
	static void solve(long a, long b, long[] res) {
		if(a < b) solve(b, a, res);
		
		if(b == 0) {
			res[0] = 1;
			res[1] = 0;
			return;
		}
		
		solve(b, a % b, res);
		long tmp = res[0] % MOD;
		res[0] = res[1] % MOD;
		res[1] = tmp - a / b * res[1] % MOD;
	}
}

Measured memory_bytes: 57044
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,s;
    char op;
    
    while(1){
        cin>>a>>op>>b;
        if(op=='?') break;
        switch(op){
            case('+'):s=a+b; break;
            case('-'):s=a-b; break;
            case('*'):s=a*b; break;
            case('/'):s=a/b; break;
        }
        cout << s << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
         
        #define mp make_pair
        #define pb push_back
        #define f first
        #define s second
         
        using namespace std;
         
        typedef long long ll;
        const int INF = 1e9;
        const ll INFl = 1e18;
         
        typedef pair<int,int> pii;
        typedef vector<int> vi;
        typedef set<int> si;
        typedef map<int,int> mii;
        typedef unordered_map<int,int> umii;
        typedef queue<int> qi;
         
        vi V;
         
        int main() {
        	ios::sync_with_stdio(false); cin.tie(0);
        	string s; cin >> s;
        	for (int i = 0; i < s.size(); i ++) {
    			if (s[i] == '7') {
    				cout << "Yes\n";
    				return 0;
    			}
    		}
    		cout << "No\n";
        }

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)	{rep(i,a.size())	cout<<a[i]<<" "; cout<<endl;}
#define mark(v)	cout<<"Here--"<<v<<endl;

const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision

    ll h1,m1,h2,m2,k ; cin>>h1>>m1>>h2>>m2>>k;
    ll mins;
    if(m2>m1){
       mins = abs(h2-h1)*60 +m2-m1;
    }
    else{
       mins = abs(h2-h1)*60 +m2-m1;
    }
    ll dif = mins - k;

    cout<<dif;

    return 0;
}  

Measured memory_bytes: 3652
arrayNM = list(map(int, input().split()))
array = list(map(int, input().split()))
route = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]
for i in range(1,arrayNM[1]):
  route.append(array[i] - array[i-1])
  
Max = max(route)
maxIndex = route.index(Max)
distance = 0

for i in range(0,maxIndex):
  distance += route[i]

for i in range(maxIndex + 1, arrayNM[1]):
  distance += route[i]

print(distance)



Measured memory_bytes: 26444
import itertools

seq = ('M','A','R','C','H')
p = list(itertools.combinations(seq,3))
data = {'M':0,'A':0,'R':0,'C':0,'H':0}
sum = 0

N = int(input())
for i in range(N):
    a = input()
    if a[0] in data:
        data[a[0]] += 1


for i in p:
    sum += data[i[0]]*data[i[1]]*data[i[2]]

print(sum)
    

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

using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a+b > c+d) cout << "Left" << endl;
	else if(a+b < c+d) cout << "Right" << endl;
	else cout << "Balanced" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

// off: この場所で繰り上がって「いない」ときの，枚数の最小値
// on: この場所で繰り上がって「いる」ときの，枚数の最小値
int off[1000020];
int on[1000020];
	
int main(){
	on[0] = 1;
	string s; cin >> s;
	int sz = s.size();
	for( int i = 0; i < sz; ++i ){
		int d = s[i]-'0';
		off[i+1] = min( off[i]+d, on[i]+(10-d) );
		on[i+1] = min( off[i]+d+1, on[i]+(10-d)-1 );
	}
	cout << off[sz] << endl;
}

Measured memory_bytes: 9220
#include<iostream>
#include<vector>
#include<bitset>
#include<utility>
#include<algorithm>

int main(){

    size_t n;
    std::cin >> n;

    std::vector<std::vector<std::pair<size_t, bool>>> v(n);

    for(size_t i = 0; i < n; i++){
        size_t a;
        std::cin >> a;

        for(size_t j = 0; j < a; j++){
            size_t x;
            bool y;
            std::cin >> x >> y;
            v.at(i).emplace_back(x, y); // true(1):正直者 false(0):不親切
        }
    }

    size_t max = 0;
    for(std::bitset<16> bit = 0; bit.to_ullong() < (1ul << n); bit = bit.to_ullong() + 1){
        bool flag = true;
        for(size_t i = 0; i < v.size(); i++){
            if(!bit[i]) continue;
            for(size_t j = 0; j < v.at(i).size(); j++){
                if(bit[v[i][j].first - 1] != v[i][j].second) flag = false;
            }
        }

        if(flag) max = std::max(max, bit.count());
    }

    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 256
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
				Believe in yourself ,( try and try and then try ), You can do it  
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
	K_K();
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC";
	else
		cout << "ABC";
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100005;
struct node
{
	int val,id;
	bool operator<(const node& rhs)const
	{
		if(val==rhs.val)
			return id<rhs.id;
		return val>rhs.val;
	}
}a[N];
long long ans[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].val;
		a[i].id=i;
	}
	sort(a+1,a+n+1);
	int id=a[1].id;
	a[n+1].val=0;
	for(int i=1;i<=n;i++)
	{
		ans[id]+=1ll*(a[i].val-a[i+1].val)*i;
		id=min(id,a[i+1].id);
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;
// const int mo = 1e9 + 7;

int n, m, p[maxn];

int getP(int x) {
	if (p[x] == x)
		return x;
	else {
		p[x] = getP(p[x]);
		return p[x];
	}
}

void unify(int x, int y) {
	int a = getP(x), b = getP(y);
	if (a != b)
		p[a] = b;
}

int main() {

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

	for (int i = 1; i <= n; ++i)
		p[i] = i;

	// cout << n << " " << m << endl;
	for (int i = 0; i < m; ++i)
	{
		int x, y, z;
		cin >> x >> y >> z;

		// printf("ok\n");
		unify(x, y);
		// printf("ok\n");
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i)
		if (p[i] == i)
			++ans;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# map(int, input().split())

def junkan_max_score(junkan, C, K):
    ruiseki = [0]
    for i in range(len(junkan)):
        j = junkan[i]
        ruiseki.append(ruiseki[-1]+C[j])

    n_junkan = int(K/len(junkan))
    if n_junkan == 0:
        return max(ruiseki[1:K+1])
    elif ruiseki[-1] <= 0:
        return max(ruiseki[1:])
    else:
        junkan_score = n_junkan*ruiseki[-1]
        nokori_K = K-(n_junkan*len(junkan))
        if nokori_K == 0:
            return junkan_score-ruiseki[-1]+max(ruiseki[1:])
        else:
            return junkan_score+max(ruiseki[1:nokori_K+1])
        

N,K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

p_junkan = {i:[] for i in range(1,N+1)}

for i, lst in p_junkan.items():
    j = P[i-1]
    while j != i:
        lst.append(j-1)
        j = P[j-1]
    lst.append(i-1)

junkan_max = [junkan_max_score(lst, C, K) for i,lst in p_junkan.items()]
print(max(junkan_max))

Measured memory_bytes: 290564
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <map>

using namespace std;

#define INF 210000000
#define int long long

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

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

signed main() {
    int n,m;
    cin >> n >> m;
    vector<int> a;
    vector<int> b;
    map<int,int> tyoku;
    for(int i=0;i<m;i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
        cin >> tmp;
        b.push_back(tmp);
        if(a[i] == 1){
            tyoku[b[i]]++;
        }
    }
    string ans;
    for(int i=0;i<m;i++){
        if(0 < tyoku[a[i]] && b[i] == n){
            ans = "POSSIBLE";
            break;
        }else{
            ans = "IMPOSSIBLE";
        }
    }
    cout << ans;

}



Measured memory_bytes: 16352
/***     
 * When I wrote this
 * only God & I understood
 * what I was doing
 * Now, God only knows 
 /***/ 
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
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;}
//fixed<< setprecision(2)
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n;
    string s;
    while(cin>>n>>s){
    ll ans=0,r=0,w=0;
    for(int i=0;i<n;i++)
    {
         if(s[i]=='R')r++;
         else w++;
    }
    ll j=n-1;
    string str=s;
    for(int i=0;i<n;i++)
    {
       if(str[i]=='W')
       {
         for(;j>i;j--)
         {
             if(str[j]=='R')
             {
                 str[j]='w';
                 str[i]='R';
                 ans++;
                 break;
             }
         }
       }
    }cout<<min(min(r,w),ans)<<'\n';
    }
}

Measured memory_bytes: 3488
n, m = [int(i) for i in input().split()]

ans = 0
for i in range(int(m ** 0.5)):
      if m % (i+1) == 0 and m // (i+1) >= n:
          if m // (i+1) >= n:
              ans = max(ans, i+1)
          if i+1 >= n:
              ans = max(ans, m // (i+1))
print(ans)
        
        

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

int main() {
  int N;
  cin >> N;
  int cnt = INT_MAX;

  for(int i=0;i<N;i++){
    long long x;
    cin >> x;
    int num = 0;
    while(x % 2 == 0){
      x /= 2;
      num += 1;
    }
    cnt = min(cnt, num);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
// Code Forces
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define pi 3.1415926535
#define fi first
#define se second
#define vec vector
#define str string
#define FOR(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define dvec(v) vec < ll > v
#define sortA(v) sort(v.begin(),v.end())
#define sortD(v) sort(v.begin(),v.end(),greater <int> ())

using namespace std;

int main(){
    fast
    ll x=0;
    cin>>x;
    ll res=0;
    res=(x/500)*1000;
    ll a=x%500;
    res+=((a/5)*5);
    cout<<res;
    // my code
    return 0;
}

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

int main() {
  ll x, ans = 0;
  cin >> x;

  if (400 <= x && x < 600) ans = 8;
  if (600 <= x && x < 800) ans = 7;
  if (800 <= x && x < 1000) ans = 6;
  if (1000 <= x && x < 1200) ans = 5;
  if (1200 <= x && x < 1400) ans = 4;
  if (1400 <= x && x < 1600) ans = 3;
  if (1600 <= x && x < 1800) ans = 2;
  if (1800 <= x && x < 2000) ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll a=0,b=0;
    cin>>a>>b;
    ll ans=-1;
    for(ll i=1;i<=100000;++i){
        ll x=i*0.08;
        ll y=i*0.1;
        if(x==a and y==b){
            ans=i;
            break;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<62;

int main() {
  ll l;
  cin >> l;
  vec a(l);
  for(ll i=0;i<l;i++) {
    cin >> a[i];
  }
  ll sum=0;
  for(ll i=0;i<l;i++) {
    sum+=a[i];
  }
  ll ans=sum;
  ll tsum=0;
  ll fdp=0;
  ll sdp=0;
  ll tdp=0;
  for(ll i=0;i<l;i++) {
    tdp=min({tsum,fdp,sdp,tdp})+(a[i]==0?2:a[i]%2);
    sdp=min({tsum,fdp,sdp})+(a[i]+1)%2;
    fdp=min(tsum,fdp)+(a[i]==0?2:a[i]%2);
    tsum+=a[i];
    ans=min(ans,min({tdp,sdp,fdp})+sum-tsum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import itertools
n,m,x = map(int,input().split())
c_li = []
a_li = []
for _ in range(n):
    tmp = list(map(int,input().split()))
    c_li.append(tmp[0])
    a_li.append(tmp[1:])
kumi = list(itertools.product([0,1], repeat=n))
ans_li = []
for each_kumi in kumi:
    each_li = [0]*m
    score = 0
    for i,k in enumerate(each_kumi):
        if k == 1:
            score += c_li[i]
            for j,kk in enumerate(a_li[i]):
                each_li[j] += kk
    flag = True
    for ea in each_li:
        if ea<x:
            flag = False
    if flag:
        ans_li.append(score)
if len(ans_li)==0:
    print(-1)
else:
    print(min(ans_li))


Measured memory_bytes: 69036
fun main(arg: Array<String>) {
    val N = nextInt()
    val S = next()
    val A = S.map { it == 'o'}.toBooleanArray()
    val B = BooleanArray(N)
    val C = BooleanArray(N)
    for (b in 0 .. 3) { // 00 01 10 11
        B[0] = (b and 1) != 0
        B[1] = (b and 2) != 0
        for (n in C.indices) {
            C[n] = A[n] xor B[n]
            if (n in 1 until N - 1) B[n + 1] = B[n - 1] xor C[n]
        }
        if (B[0] == (B[N - 2] xor C[N - 1]) && B[N - 1] == (B[1] xor C[0])) {
            val ans = B.map {if (it) 'S' else 'W'}.joinToString("")
            return println(ans)
        }
    }
    println(-1)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta


Measured memory_bytes: 40504
S = list(input())
l = len(S)
for i in range(l) :
    S.pop(-1)
    if i % 2 != 0 :
        A = S[0:len(S)//2]
        B = S[len(S)//2:len(S)]
        if A == B :
            print(len(S))
            break
            

Measured memory_bytes: 3060
#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>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
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 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++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

string s[10000];
vector<int> le, ri;
void solve() {
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		cin >> s[i];
		rep(j, s[i].size() - 1) {
			if (s[i][j] == 'A'&&s[i][j + 1] == 'B') {
				ans++; j++;
			}
		}
		if (s[i][0] == 'B')le.push_back(i);
		if (s[i].back() == 'A')ri.push_back(i);
	}
	int len = min(le.size(), ri.size());
	ans += len;
	if (le == ri&&le.size()>0)ans--;
	cout << ans << endl;
}

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


Measured memory_bytes: 896
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    a, b, c = mi()
    print("{} {} {}".format(c, a, b))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n = int(input().strip())
p = [ list(map(int, input().split())) for i in range(n) ]
p.insert(0, [0,0,0])
ans = True

for i in range(n):
    time = p[i+1][0] - p[i][0]
    dist = abs(sum(p[i+1][1:]) - sum(p[i][1:]))

    if time % 2 != dist % 2 or dist > time:
        ans = False
        break

if ans: print("Yes")
else: print("No")

Measured memory_bytes: 27300
H, W = map(int, input().split())
A = []
for i in range(H):
    r = list(map(int, input().split()))
    if i&1:
        r.reverse()
    A.append(r)

ans = []

for i in range(H*W-1):
    if A[i//W][i%W]&1:
        j = i+1
        A[j//W][j%W] += 1
        ans.append([i, j])

def f(n):
    x = n//W
    y = n%W
    if x&1:
        y = W-y-1
    return f"{x+1} {y+1}"

print(len(ans))
for a, b in ans:
    print(f(a), f(b))

Measured memory_bytes: 30492
import sys

# input処理を高速化する
input = sys.stdin.readline

# 入力
N, W = map(int, input().split())
# sum_vの取りうる上限値
MAX_V = (10**3) * N +1
# 最小値を求めるので無限大の値
f_inf = float('inf')

def knapsack(n, w):
    # dpの初期化　dp[sum_v]は重さの総和の最小値
    dp = [f_inf] * MAX_V
    # 初期条件
    dp[0] = 0
    sum_v = 0
    # forは全て関数の中で回す。
    # 入力
    for i in range(N):
        w, v = map(int, input().split())
        for j in range(MAX_V, v-1, -1):
            new_weight = dp[j - v] + w
            if new_weight > W:
                continue
            if dp[j] > new_weight:
                dp[j] = new_weight

    ans = 0
    for sum_v in range(MAX_V):
        if dp[sum_v] <= W:
            ans = sum_v
    print(ans)

knapsack(N, W)


Measured memory_bytes: 5348
N = int(input())
A = list(map(int,input().split()))

swapcnt = 0

def bubbleSort(A):
  global N,swapcnt
  for i in range(N):
    for j in  range(N-1,i,-1):
      if A[j] < A[j-1]:
        x = A[j]
        A[j] = A[j-1]
        A[j-1] = x
        swapcnt += 1

bubbleSort(A)
strA = [str(a) for a in A]
print(" ".join(strA))
print(swapcnt)


Measured memory_bytes: 5604
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    while (true) {
        if ((A % 2 == 1) || (B % 2 == 1) || (C % 2 == 1)) {
            break;
        }
        if ((A == B) || (B == C) || (C == A)) {
            ans = -1;
            break;
        }
        int temp_A = A;
        int temp_B = B;
        int temp_C = C;
        A = (temp_B / 2) + (temp_C / 2);
        B = (temp_A / 2) + (temp_C / 2);
        C = (temp_A / 2) + (temp_B / 2);
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1

vvi List;
vb Visit;
vi indeg;
vi out;
int V;
void bfs(int s) {
	queue<int> Q;
	Q.push(s);
	
	while (!Q.empty()) {
		int now = Q.front();
		Q.pop();
		Visit[now] = true;
		out.push_back(now);
		for (int i = 0; i < List[now].size(); i++)
		{
			int u = List[now][i];
			indeg[u]--;
			if (indeg[u]==0&&Visit[u]==false) {
				Q.push(List[now][i]);
			}
			
		}
	}
}
void tsort() {
	for (int i = 0; i < V; i++)indeg[i] = 0;
	for (int i = 0; i < V; i++)
	{
		for (int j = 0; j < List[i].size(); j++)
		{
			int u = List[i][j];
			indeg[u]++;
		}
	}
	for (int i = 0; i < V; i++)
	{
		if (indeg[i]==0&&Visit[i]==false) {
			bfs(i);
		}
	}
	for (int i = 0; i < out.size(); i++)
	{
		cout<<out[i]<<endl;
	}
}
int main() {
	int  E;
	cin >> V >> E;
	Visit.resize(V);
	rep(i, 0, V)Visit[i] = false;
	List.resize(V);
	indeg.resize(V);
	for (int i = 0; i < E; i++)
	{
		int s, t;
		cin >> s >> t;
		List[s].push_back(t);
	}
	tsort();
}


Measured memory_bytes: 3820
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

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

using namespace std;

int main(void) {	
	int n;
	while (cin >> n && n > 0) {
		int ans = 0;
		n = 1000 - n;
		ans += n / 500;
		n %= 500;
		ans += n / 100;
		n %= 100;
		ans += n / 50;
		n %= 50;
		ans += n / 10;
		n %= 10;
		ans += n / 5;
		n %= 5;
		ans += n;
		
		cout << ans << endl;
		
	}
				  
	return 0;
}

Measured memory_bytes: 1160
N = list(map(int, list(input())))[::-1]
L = len(N)

answer = 0
for i, n in enumerate(N):
    if n < 5:
        answer += n
    elif n > 5:
        answer += 10 - n
        if i < L - 1:
            N[i + 1] += 1
        else:
            answer += 1
    else:
        answer += 5
        if i < L - 1:
            if N[i + 1] >= 5:
                N[i + 1] += 1

print(answer)

Measured memory_bytes: 20968
n, m = map(int, input().split())
abs = [list(map(int, input().split())) for _ in range(n)]
abs_sorted = sorted(abs, key=lambda x: x[0])
num = 0
ans = 0
while m != 0:
    a, b = abs_sorted[num][0], abs_sorted[num][1]
    if m >= b:
        ans += a * b
        m -= b
        num += 1
    else:
        ans += a * m
        m = 0
print(ans)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi divisorNum(n+1, 0);
    rep1(i, n) {
        for (int j=i; j<=n; j+=i) {
            divisorNum[j]++;
        }
    }
    int ans = 0;
    for (int i=1; i<=n; i+=2) {
        if (divisorNum[i]==8) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,ok;

int a[4][4];
bool vis[4][4];

signed main()
{
    for(int i = 1; i <= 3; i++) 
    {
        for(int j = 1; j <= 3; j++) 
        {
            cin>>a[i][j];
        }
    }
    cin>>n;
    for(int i = 1,x; i <= n; i++) 
    {
        cin>>x;
        for(int j = 1; j <= 3; j++) 
        {
            for(int k = 1; k <= 3; k++)
            {
                if(x == a[j][k])
                {
                    vis[j][k] = 1;
                }
            }
        }
    }
    ok = 0;
    for(int i = 1; i <= 3; i++) 
    {
        if(vis[i][1] && vis[i][2] && vis[i][3]) ok = 1;
        if(vis[1][i] && vis[2][i] && vis[3][i]) ok = 1;
    }
    if(vis[1][1] && vis[2][2] && vis[3][3]) ok = 1;
    if(vis[1][3] && vis[2][2] && vis[3][1]) ok = 1;
    if(ok) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    int a,b,c; cin >> a >> b >> c;
    bool flag = 0;
    if ( a + b > c && b + c > a && c + a > b ) {
      if ( a * a == b * b + c * c ||
       b * b == c * c + a * a ||
       c * c == a * a + b * b ) flag = 1;
    }
    if ( flag ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;


int wlim = 100010;

void push(vector<P>& res, const P& p) {
    if (res.size() == 0 || p.second > res[(int)res.size() - 1].second) {
        res.push_back(p);
    }
}

vector<P> update(const vector<P>& lis, int v, int w) {
    int sz = lis.size();
    int p1 = 0, p2 = 0;
    vector<P> res;
    while (p1 < sz || p2 < sz) {
        if (p2 == sz) {
            push(res, lis[p1]);
            ++p1;
        }
        else if (p1 == sz) {
            if (lis[p2].first + w >= wlim) break;
            push(res, { lis[p2].first + w, lis[p2].second + v });
            ++p2;
        }
        else {
            if (lis[p1].first < lis[p2].first + w) {
                push(res, lis[p1]);
                ++p1;
            }
            else if (lis[p1].first > lis[p2].first + w) {
                push(res, { lis[p2].first + w, lis[p2].second + v });
                ++p2;
            }
            else {
                push(res, { lis[p1].first, max(lis[p1].second, lis[p2].second + v) });
                ++p1;
                ++p2;
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i] >> w[i];
    }
    int q;
    cin >> q;
    vector<vector<P>> que(n, vector<P>());
    for (int i = 0; i < q; ++i) {
        int u, l;
        cin >> u >> l;
        --u;
        que[u].push_back({ l, i });
    }
    int lm = 1 << 13;
    vector<vector<P>> vs(lm);
    vs[0] = { { 0, 0 } };
    vector<int> ans(q);
    for (int i = 0; i < n; ++i) {
        if (i < lm) {
            vs[i] = update(vs[(i - 1) / 2], v[i], w[i]);
            for (auto& p : que[i]) {
                int ma = 0;
                for (auto& j : vs[i]) {
                    if (j.first <= p.first) {
                        ma = max(ma, j.second);
                    }
                }
                ans[p.second] = ma;
            }
        }
        else {
            int a = i;
            vector<P> lis = { { 0, 0 } };
            while (a >= lm) {
                lis = update(lis, v[a], w[a]);
                a = (a - 1) >> 1;
            }

            for (auto& p : que[i]) {
                int l = p.first;
                int k = (int)vs[a].size() - 1;
                int ma = 0;
                for (int j = 0; j < (int)lis.size(); ++j) {
                    while (k >= 0 && lis[j].first + vs[a][k].first > l) {
                        --k;
                    }
                    if (k < 0) break;
                    ma = max(ma, lis[j].second + vs[a][k].second);
                }
                ans[p.second] = ma;
            }
        }
    }
    for (auto& i : ans) {
        cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 280500
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		final int MAX = 1000000 + 1;
		boolean[] primes = new boolean[MAX];
		Arrays.fill(primes, true);
		primes[0] = false;
		primes[1] = false;
		for (int i = 2; i < MAX; i += 2) {
			primes[i] = false;
		}
		primes[2] = true;
		primes[3] = true;
		for (int i = 3; i * i < MAX; i += 2) {
			if (primes[i]) {
				for (int j = i * 2; j < MAX; j += i) {
					primes[j] = false;
				}
			}
		}
		Set<Integer> prm = new HashSet<Integer>();
		for(int k=0;k<MAX;k++){
			if(primes[k]){
				prm.add(k);
			}
		}

		while(true){
			int a = scn.nextInt();
			int d = scn.nextInt();
			int n = scn.nextInt();
			if(a==0&&d==0&&n==0) break;
			int count=0;
			while(true){
				if(prm.contains(a)) count++;
				if(count==n) {
					pr.println(a);
					break;
				}
				a+=d;
			}
		}
		pr.flush();
		scn.close();
	}



}

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


int main()
{
    int n;
    cin >> n;
    double a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    double m=a[0];
    for(int i=1;i<n;i++){
        m=(m+a[i])/2;
    }
    cout << fixed << setprecision(7) << m << endl;
    return 0;
}


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

using namespace std;

vector<vector<int>> graph;
vector<bool> visited;
int start;
bool ret = false;

void dfs(int now) {
    visited[now] = true;
    for (auto next:graph[now]) {
        if (!visited[next])dfs(next);
        else if (next == start) ret = true;
    }
}

int main() {
    int n;
    cin >> n;
    graph = vector<vector<int>>(200);
    for (int i = 0; i < n; i++) {
        int u, d;
        string s;
        cin >> u >> s >> d;
        u--;
        d--;

        if (s == "lock")graph[u].push_back(d + 100);
        else graph[d + 100].push_back(u);
    }

    for (int i = 0; i < 200; i++) {
        visited = vector<bool>(200);
        start = i;
        dfs(i);
    }

    cout << (ret ? 1 : 0) << endl;
    return 0;
}


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

int main(){
  int a,b;
  while(cin>>a>>b){
    if(a==1) a=14;
    if(b==1) b=14;
    if(a>b) puts("Alice");
    else if(a<b) puts("Bob");
    else puts("Draw");
  }
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-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 <P> A(N);
    rep(i,N){
        ll a,b; cin >> a >> b;
        A[i]=make_pair(b,a);
    }
    sort(A.begin(),A.end());
    
    if (A[0].first<A[0].second){
        cout << "No" << endl;
        return 0;
    }
    
    bool ok=true;
    ll sum=A[0].second;
    for (ll i=1; i<N; i++){
        sum+=A[i].second;
        //cout << sum << endl;
        if (A[i].first<sum){
            ok=false;
            break;
        }
    }
    
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3328
let n = (stdin.ReadLine >> int) ()
let hs = stdin.ReadLine().Split(' ') |> Array.map int |> Array.toList

let f (xs: int list) =
    let rec loop (xs: int list) (p: int) b =
        if not b then false
        else match xs with
             | [] -> b
             | y::ys -> if p <= y-1 then loop ys (y-1) true
                        elif p = y then loop ys y true
                        else loop ys y false
    loop xs xs.[0] true

if f hs then printfn "Yes"
else printfn "No"

Measured memory_bytes: 33496
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
long long N,W;

int 
main(){
	long long X,K;
	char s[110];

	scanf("%s",s);
	int i;
	int cnt_k=0,cnt_g=0;
	for(i=0;i<strlen(s);i++){
		if(i%2==0){ //kisuu
			if(s[i]=='L'){
				printf("No\n");
				return 0;
			}
		}
		else{
			if(s[i]=='R'){
				printf("No\n");
				return 0;
			
			}
		}
	}
	printf("Yes\n");
		

 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int a=0,b=0;
	cin>>s;
	for(int i=0;i<=2;i++)
	{
		if(s[i]=='B') b++;
		if(s[i]=='A') a++;
	}
	if(b==2&&a==1||a==2&&b==1)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
int t;
int n,m; 
int main()
{
	ios::sync_with_stdio(0);
	string s;
	int q,op; s.clear();
	int cnt = 0;
	cin>>s;
	cin>>q;
	while(q--)
	{
		cin>>op;
		if(op==1)
		{
			++cnt;
		}
		if(op==2)
		{
			int x; char y; cin>>x>>y;
			if(x==1) {
				if(cnt&1) s.push_back(y);
				else s.insert(s.begin(),y);
			}
			else {
				if(cnt&1) s.insert(s.begin(),y);
				else s.push_back(y);
			}
		}
	}
	if(cnt&1) reverse(s.begin(),s.end());
	cout<<s<<"\n";
}

Measured memory_bytes: 912
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

string s;
Int res;

Int calc(vector<int> v){
    Int zerocnt = 0;
    Int zeroindcnt = 0;
    for(int i = 0;i < v.size();i++){
        if(v[i] == 1)continue;
        zerocnt++;
        zeroindcnt += i;
    }
    return zeroindcnt - zerocnt * (zerocnt - 1) / 2;
}

int main(){
    cin >> s;
    int pos = 0;
    vector<int> tmp;
    while(pos < s.size()){
        if(s[pos] == 'A'){
            tmp.push_back(1);
            pos++;
            continue;
        }
        if(pos + 1 < s.size() && s[pos] == 'B' && s[pos+1] == 'C'){
            tmp.push_back(0);
            pos+=2;
            continue;
        }
        res += calc(tmp);
        tmp.clear();
        pos++;
    }
    res += calc(tmp);
    cout << res << endl;    
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
	while(cin >> n, n) {
		n = 1000 - n;
		int r = 0;
		r += n / 500; n %= 500;
		r += n / 100; n %= 100;
		r += n / 50; n %= 50;
		r += n / 10; n %= 10;
		r += n / 5; n %= 5;
		r += n;
		cout << r << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
import heapq as h;I=lambda:list(map(int,input().split()));n,k=I();z=[i*2+1for i in range(n)];s=sorted([I()for _ in[0]*n],key=lambda x:-x[1]);q=[];v=i=T=A=0;l=[0]*-~n
for a,b in s:
 if i<k:
  if l[a]:h.heappush(q,b)
  else:T+=z[v];v+=1
  l[a]=1;T+=b
 elif l[a]^1and q:l[a]=1;T+=b+z[v]-h.heappop(q);v+=1
 A=max(A,T);i+=1
print(A)

Measured memory_bytes: 36964
#include <stdio.h>

int main (){
	int angka;
	scanf ("%d", &angka);
	
	char str[angka+1];
	scanf("%s", str);
		
		// IIDID
	
	
	int sum = 0;
	int maks = 0;
	for (int i = 0 ; i < angka; i++){
		if (str[i] == 'I'){
			sum ++;	
		}
		else if (str[i]=='D'){
		 sum--;
		}
		if (sum > maks){
			maks = sum;
		}
		
	}
	
	printf("%d\n", maks);
	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
vector<int> quq;
int main(){
	long long n,a,i,pos,ans=0,sz;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		quq.push_back(a);
	}
	sort(quq.begin(),quq.end());
	for(i=0;i<quq.size();)
	{
		pos=upper_bound(quq.begin(),quq.end(),quq[i])-quq.begin();
		sz=pos-i;
		if(sz<quq[i])
		{
			ans+=sz;
		}
		else
		{
			ans+=sz-quq[i];
		}
		i=pos;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;

  cout << (N / (A + B)) * A + min(N % (A + B), A) << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#define MAX 100

int A[MAX];
int change_num = 0;

void bubbleSort(int n) {
    int flag = 1;
    int index = 0;
    while (flag) {
        flag = 0;
        for ( int j = n-1; j > index; j-- ) {
            if ( A[j] < A[j-1] ) {
                std::swap(A[j], A[j-1]);
                flag = 1;
                change_num ++;
            }
        }
        index ++;
    }
}

void selectionSort(int n) {
    for ( int i = 0; i < n - 1; i++ ) {
        int minj = i + 1;
        for ( int j = i + 1; j < n; j++ ) {
            if ( A[minj] > A[j] ) {
                minj = j;
            }
        }
        if ( A[i] > A[minj] ) {
            change_num++;
            std::swap(A[i], A[minj]);
        }
    }
}

int main() {
    int n;
    scanf( "%d\n", &n );
    
    for ( int i = 0; i < n; i++ ) {
        int tmp;
        std::cin >> tmp;
        A[i] = tmp;
    }
    
//    bubbleSort(n);
    selectionSort(n);
    
    for (int i= 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    
    printf("\n");
    printf("%d\n", change_num);
    
    return 0;
}

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    long long a, b;
    cin >> a >> b;
    if (a % 2 == b % 2)
        cout << (a + b) / 2 << endl;
    else
        cout << "IMPOSSIBLE" << endl;
}

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

using namespace std;

int a[200500];

int main() {
  while(1) {
    int n;
    if( scanf("%d", &n) != 1) break;

    long long ans = (long long)1e18;

    long long sum = 0;
    for(int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
    }

    long long pref = 0;
    for(int i = 0; i+1 < n; i++) {
      pref += a[i];
      long long dif = pref - (sum - pref);
      if(dif < 0) dif = -dif;
      ans = min(ans, dif);
    }

    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 896