akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){
    string s;cin>>s;
    bool b=true;
    rep(i,0,s.size()-1){
        if(i%2==0){
            if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
                
            }else{
                b=false;
            }
        }else{
            if(s[i]=='L' || s[i]=='U' || s[i]=='D'){
                
            }else{
                b=false;
            }
        }
    }
    if(b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
S = input()
dict = defaultdict(int)

ans = 1
pre = S[0]
i = 1
while i < len(S):
    if len(pre) > 1:
        ans += 1
        pre = S[i]
    elif pre != S[i]:
        ans += 1
        pre = S[i]
    elif pre == S[i]:
        if i != len(S)-1:
            ans += 1
            pre = S[i:i+2]
            i += 1
    i += 1

print(ans)

Measured memory_bytes: 4008
// 4/30
// 過去問攻略

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <deque>
using namespace std;

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

    deque<char> deq;
    for (int i = 0; i < S.size(); i++) {
        deq.push_back(S[i]);
    }

    int Q;
    cin >> Q;

    bool hanten = false;

    for (int i = 0; i < Q; i++) {
        int T, F;
        char C;
        cin >> T;

        if (T == 1) {
            hanten = !hanten;
        }
        else {
            cin >> F >> C;
            if (F == 1) {
                if (!hanten) {
                    // S = C + S;
                    deq.push_front(C);
                } else {
                    // S = S + C;
                    deq.push_back(C);
                }
            } else {
                if (!hanten) {
                    // S = S + C;
                    deq.push_back(C);
                } else {
                    // S = C + S;
                    deq.push_front(C);
                }
            }
        }
    }

    // cout << "途中経過" << endl;
    // cout << S << endl;

    // if (hanten) {
    //     string S2;
    //     for (int i = 0; i < S.size(); i++) {
    //         S2[i] = S[S.size() - 1 - i];
    //     }

    //     S = S2;
    // }

    // cout << S << endl;

    // for (int i = 0; i < S.size(); i++) {
    //     if (!hanten) {
    //         cout << S[i];
    //     } else {
    //         cout << S[S.size() - 1 - i];
    //     }
    // }

    // cout << endl;

    // if (hanten) {
    //     // reverse(S.begin(), S.end());
    // }

    // cout << S << endl;

    while (deq.size()) {
        if (!hanten) {
            cout << deq.front();
            deq.pop_front();
        } else {
            cout << deq.back();
            deq.pop_back();
        }
    }

    cout << endl;
}


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

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

    vector<ll> A(N+1), B(N);
    rep(i, N+1) cin >> A[i];
    rep(i, N) cin >> B[i];

    ll ans = min(B[0], A[0]);
    B[0] = max(0LL, B[0] - A[0]);

    for (int i=1; i<N; ++i) {
        ans += min(A[i], B[i-1]+B[i]);
        A[i] -= B[i-1];
        if (A[i] < 0) A[i] = 0;
        B[i] = max(0LL, B[i]-A[i]);
    }

    ans += min(A[N], B[N-1]);
    B[N-1] = max(0LL, A[N] - B[N-1]);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int N;

signed main(){
    cin>>N;
    string res="";
    while(N>0){
        N--;
        int m=N%26;
        N/=26;
        res+=(char)('a'+m);
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {

	int n;
	cin>>n;
	int a[51];
	rep(i,n){
		cin>>a[i];
	}
	ll total=0;
	rep(i,n-1){
		for(int j=i+1; j<n; j++){
			total+=a[j]*a[i];
		}
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int>a(200005,0);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.at(x)++;
    }
    sort(a.begin(),a.end());
    int syurui=0;
    for(int i=0;i<200005;i++){
        if(a.at(i)!=0){
            syurui++;
        }
    }
    if(syurui<=k){
        cout<<0<<endl;
        return 0;
    }
    // cout<<"syurui "<<syurui<<endl;
    // for(int i=199998;i<200005;i++){
    //     cout<<"a.at(i)= "<<a.at(i)<<endl;
    // }
    int i=0;
    while(a.at(i)==0){
        i++;
    }
    // cout<<"i "<<i<<endl;
    int ans=0;
    for(int j=i;j<200005;j++){
        if(syurui==k){
            break;
        }
        ans+=a.at(j);
        syurui--;
    }
    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(){
  int n,m,i,r=0;
  char s[100][11],t[100][11];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s",&s[i]);
  scanf("%d",&m);
  for(i=0;i<m;i++)scanf("%s",&t[i]);
  for(i=0;i<n;i++){
    int b=0;
    for(int j=0;j<n;j++)if(strcmp(s[i],s[j])==0)b++;
    for(int j=0;j<m;j++)if(strcmp(s[i],t[j])==0)b--;
    if(r<b)r=b;
  }
  if(r<0)r=0;
  printf("%d",r);
  return 0;
}

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

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

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(y == 10000 * i + 5000 * j + 1000 * (n - i - j) && n - i - j >= 0){
                cout << i << ' ' << j << ' ' << n - i - j;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
         
int main() {
  char a;
  cin>>a;
  if(a=='a'||a=='i'||a=='i'||a=='u'||a=='e'||a=='o'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }


      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>;
const long long INF = 1ll << 60;



int main() {
  ll n, x; cin >> n >> x;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  int ans = 0;
  ll nokori = x;
  rep(i,n-1){
    ll want = a[i];
    if(nokori >= want){
        ans++;
        nokori -= want;
    }
  }

  if(a[n-1] == nokori) ans++;

  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3608
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 2e5 + 10;
vector<int> adj[maxn];
int n, m, vis[maxn];
bool dfs(int u, int dep) {
	if( dep == 0 && u == n) return 1; 
	if(dep > 0)
	for(int v : adj[u]) if(!vis[v]) {
		vis[v] = 1; 
		if(dfs(v, dep-1)) return 1;
		vis[v] = 0;
	} return 0;  
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	cin>>n>>m;
	for(int i = 0; i < m; i++) {
		int u, v; cin>>u>>v; 
		adj[u].push_back(v); 
		adj[v].push_back(u); 
	}
	if(dfs(1, 2)) { cout<<"POSSIBLE\n"; }
	else cout<<"IMPOSSIBLE\n"; 
}

Measured memory_bytes: 12784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);

		int N = sc.nextInt();

		long ans = 0;
		for (int k = 1; k <= N; k++) {
			ans += k * sum(N / k);
		}

		System.out.println(ans);
	}

	public static long sum(int x) {
		return (long) x * (x + 1) / 2;
	}

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}

Measured memory_bytes: 32556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            int D = in.nextInt();
            int[] map = new int[H * W];
            int[] dist = new int[H * W];
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    int A = in.nextInt() - 1;
                    map[A] = i * 300 + j;
                }
            }
            for (int i = 0; i < H * W; i++) {
                if (i + D >= H * W) continue;
                int nowI = map[i] / 300;
                int nowJ = map[i] % 300;
                int nxtI = map[i + D] / 300;
                int nxtJ = map[i + D] % 300;
                dist[i + D] += dist[i] + Math.abs(nowI - nxtI) + Math.abs(nowJ - nxtJ);
            }
            int Q = in.nextInt();
            for (int i = 0; i < Q; i++) {
                int L = in.nextInt() - 1;
                int R = in.nextInt() - 1;
                int d = L % D;
                out.println(dist[R] - dist[L]);
            }

        }

    }
}



Measured memory_bytes: 91652
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)
	a := -1; b := -1; c := -1

	for i := 0; i <= N; i++ {
		for j := 0; j <= (N - i); j++ {
			k := N - i - j
			if i * 10000 + j * 5000 + 1000 * k == Y{
				a = i
				b = j
				c = k
			}
		}
	}
	fmt.Println(a, b, c)
	}

Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt(); // T - 標高 x 0.006
        int a = sc.nextInt(); // 目標の値
        int[] hArr = new int[n];

        for (int i = 0; i < n; i++) {
            hArr[i] = sc.nextInt();
        }

        double res = 10000.0d;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            double tmpRes = t - (hArr[i] * 0.006);
            if (res > (Math.abs(a - tmpRes))) {
                res = Math.abs(a - tmpRes);
                ans = i;
            }
        }

        System.out.println(ans+1);
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
const int INF=1e8;
int h[maxn],mem;
struct
{
    int v,next;
}e[maxn];
void add(int u,int v)
{
    e[mem].v=v;
    e[mem].next=h[u];
    h[u]=mem++;
}
int p[maxn];
bool flag;
int dp[maxn][maxn*5];
int ans[maxn];
void dfs(int u)
{
    if(flag) return;
    dp[u][0]=0;
    for(int i=h[u];i+1;i=e[i].next)
    {
        int v=e[i].v;
        dfs(v);
        for(int j=p[u];j>=0;j--)
        {
            if(ans[v]==0||p[v]==0){
                if(dp[u][j]<1e7)
                    dp[u][j]=dp[u][j]+max(p[v],ans[v]);
                else
                    dp[u][j]=INF;
                if(p[v]>0&&j>=p[v])
                dp[u][j]=min(dp[u][j],dp[u][j-p[v]]);
                if(ans[v]>0&&j>=ans[v])
                dp[u][j]=min(dp[u][j],dp[u][j-ans[v]]);
            }
            else{
                dp[u][j]=INF;
                if(j>=ans[v])
                    dp[u][j]=dp[u][j-ans[v]]+p[v];
                if(j>=p[v]){
                    dp[u][j]=min(dp[u][j],dp[u][j-p[v]]+ans[v]);
                }
            }
        }
    }
    ans[u]=INF;
    for(int i=0;i<=p[u];i++)
    {
        ans[u]=min(ans[u],dp[u][i]);
    }
//    printf("-----------%d\n",u);
//    for(int i=0;i<=p[u];i++)
//        printf("%d ",dp[u][i]);
//    printf("----%d",ans[u]);
//    printf("\n");
    if(ans[u]>=1e7){
        //printf("%d\n",u);
        ans[u]=1e7;
        flag=1;
    }
    //printf("%d\n",u);
}
int main()
{
    int n;
    scanf("%d",&n);
    memset(h,-1,sizeof(h));mem=0;
    memset(dp,17,sizeof(dp));
    for(int i=2;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        //x=i-1;
        //x=i/2;
        //x=1;
        add(x,i);
    }
    for(int i=1;i<=n;i++)
    {
//        if(i==1) p[i]=0;
//        else p[i]=5000;
        scanf("%d",p+i);
        //p[i]=5000;
    }
    flag=0;
    dfs(1);
    printf("%s\n",flag?"IMPOSSIBLE":"POSSIBLE");
    return 0;
}


Measured memory_bytes: 19968
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 3000 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000000 * 1ll * 1000000000 + 500000;
const ld pi = acosl(-1.0);

int D, S, T;

void input() {
    cin >> D >> S >> T;
}

void solve(int testId) {
    cout << (S * T >= D ? "Yes" : "No") << endl;

}

int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


Measured memory_bytes: 3636
n,m=map(int,input().split())

#全ての要素をn個分初期化
road = [0] * n

#全ての道路について調べる
for i in range(m):
  a,b = map(int,input().split())
  road[a-1] += 1
  road[b-1] += 1
  
for x in range(n):
  print(road[x])

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace ABC132C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderBy(x => x);

            var ABC = d.Take(N / 2).ToArray();
            var ARC = d.Skip(N / 2).ToArray();

            var ABClast = ABC.Last();
            var ARCfirst = ARC.First();

            if (ABClast != ARCfirst)
                Console.WriteLine(ARCfirst - ABClast);
            else
                Console.WriteLine(0);
        }
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second


#define MAX_N 10000

int parent[MAX_N];
int rank[MAX_N];

struct DisjointSet {
  int parent[MAX_N];
  int rank[MAX_N];

  DisjointSet(int N) {
    for (int i = 0; i < N; i++) {
      parent[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return ;

    if (rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

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

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

  int N, Q;
  cin >> N >> Q;
  DisjointSet uf(N);

  REP(i, Q) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      uf.unite(x, y);
    } else {
      cout << uf.same(x, y) << endl;
    }
  }

  return 0;
}

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

int main(){
    LL N, A, B;
    cin >> N >> A >> B;
    vector<LL>  h(N);
    for(int i = 0;i < N;i++)    cin >> h[i];
    LL M = 1e9;
    LL m = 0;
    LL mid;
    while(true){
        mid = (m+M)/2;
        LL count = 0;
        for(int i = 0;i < N;i++){
            LL hi = h[i];
            hi -= B*mid;
            if(hi > 0){
                count += hi/(A-B);
                if(hi%(A-B))    count++;
            }
        }
        if(count > mid) m = mid;
        else    M = mid;
        if(M-m == 1)    break;
    }
    cout << M << endl;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;

  int cnt = INF;
  rep(i, 0, s.size() - t.size() + 1) {
    int now = t.size();
    rep(j, 0, t.size()) {
      if (s[i + j] == t[j]) --now;
    }
    chmin(cnt, now);
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3544
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = n - r - g

total = r*g*b

for i in range(n):
    for j in range(i+1, n):
        if 2*j-i < n and len({s[i], s[j], s[2*j-i]}) == 3:
            total -= 1

print(total)


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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,k;cin>>n>>k;
  vector<int> h(n, 0);
  for (int i=0; i<n; i++) {
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  int ans=inf;
  for (int i=0; i<n-k+1; i++) {
    ans = min(ans, h[i+k-1]-h[i]);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 640
// a_i < b_iに対して、a_iはb_iの親であると仮定した場合（after_contest_*が通らない）
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

vector<int> ans;
vector<int> to[200005]; // 2次元配列 無向グラフ

void dfs(int me, int parent){
	for(int child : to[me]){
		if(child == parent) continue; // 自分の親にはカウンタは足さない
		ans[child] += ans[me]; // 子に自分のカウンタを足す
		dfs(child, me);
	}

}

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


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

int ordena (const void *a, const void *b) {
    int x= (*(int *)a);
    int y= (*(int *)b);

    if (x>y)
        return -1;
     else
        return 1;
}

int main () {

    int n,k,t[1234], soma=0;

    scanf ("%d%d", &n,&k);
    for (int i=0; i<n; i++){
        scanf("%d", &t[i]);
    }
    
    qsort(t, n, sizeof(int), ordena);

    for (int j=0; j<k; j++) {
        soma += t[j];
    }
    printf("%d",soma);


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

bool ok(string s){
  bool c = false;
  REP(i,s.size()){
    if (i==0){
      if (s.at(i) != 'A'){
        return false;
      }
    }else if (i >= 2 && i <= s.size() - 2 && s.at(i) == 'C' && !c){
      c = true;
    }else{
      if (isupper(s.at(i))){
        return false;
      }
    }
  }
  if (c){
    return true;
  }
}

int main(){
  string s;
  cin >> s;
  cout << (ok(s) ? "AC" : "WA") << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    static int N;
    static HashMap<Long,Long> data;



    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int hp = sc.nextInt();
        N = sc.nextInt();
        long attack[] = new long[N];
        long magic[] = new long[N];
//        attack[] = new int[N];
//        magic[] = new int[N];
        for (int i =0;i<N;i++){
            attack[i] = sc.nextInt();
            magic[i] = sc.nextInt();
        }
        data = new HashMap<>();
        System.out.println(HP(hp,attack,magic));
    }

    public static Long HP(long hp,long[] attack ,long[] magic){
        if(hp<=0){
            return Long.parseLong("0");
        }
        if(data.containsKey(hp)){
            return data.get(hp);
        }else {
            Long min = Long.MAX_VALUE;
            for(int i = 0; i< N;i++){

                min = Math.min(min,HP(hp-attack[i],attack,magic)+magic[i]);

            }
            data.put(hp,min);
//            System.out.println(min);
//            System.out.println(ii);
            return min;
        }
    }
}


Measured memory_bytes: 257912
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));

    bool ans = true;

    if (A[0] == A[N - 1]) {
        if (A[0] > N / 2 && A[0] != N - 1) {
            ans = false;
        }
    }
    else {
        int small = 0;
        rep(i, 1, N) {
            if (A[i] != A[0]) {
                if (A[i] - A[0] != 1) {
                    ans = false;
                }
                if (A[N - 1] != A[i]) {
                    ans = false;
                }
                small = i;
                break;
            }
        }

        int l = small + 1, h = small + (N - small) / 2;
        if (A[0] < l - 1 || A[N - 1] > h) {
            ans = false;
        }
    }    

    write(ans ? "Yes" : "No");
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for (int i=1;i<n;i++)a[sc.nextInt()]++;
        for (int i=1;i<=n;i++)System.out.println(a[i]);
    }
}


Measured memory_bytes: 60464
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long X) {
  FOR(a, -1000, 1000) {
    FOR(b, -1000, 1000) {
      if (pow(a, 5) - pow(b, 5) == X) {
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include <string>
#include <sstream>
#include <stdio.h>
using namespace std;

  int ctoi( char b){
	switch (b) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main()
{
  
    string a;
    cin >> a;
   unsigned char b = a[a.size()-1];
    int i = ctoi(b);

    
    if((i==2)|| (i==4)|| (i==5)||(i==7)||(i==9)){
        cout << "hon"  << endl;
    }else if((i==0)|| (i==1)|| (i==6)||(i==8)){
        cout << "pon"  << endl;
         
    }else{
         cout << "bon"  << endl;
    }  
    return 0;
}
  

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	int n;
	int c[100] = {};
	bool temp;
	cin >> n;
	rep(i, 0, n)
		cin >> c[i];
	bool dp[100][100] = {};
	rep(i, 1, n) {
		rep(j, 0, n - i) {
			if (i == 1) {
				if (c[j] == c[j + i]) {
					dp[j][j + i] = 1;
				}
			}
			else {
				temp = 0;
				rep(k, 0, i) {
					temp |= dp[j][j + k] & dp[j + k + 1][j + i];
				}
				if (c[j] == c[j + i]) {
					temp |= dp[j + 1][j + i - 1];
					if (i == 2&&c[j]==c[j+1]) {
						temp = 1;
					}
					rep(k, 1, i) {
						if (c[j + k] == c[j]) {
							if (k == 1) {
								temp |= dp[j + 2][j + i - 1];
							}
							else if (k == i - 1) {
								temp |= dp[j + 1][j + i - 2];
							}
							else {
								temp |= dp[j + 1][j + k - 1] & dp[j + k + 1][j + i - 1];
							}
						}
					}
				}
				dp[j][j + i] = temp;
			}
		}
	}
	if (dp[0][n - 1]) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0511
{
    public class Program

    {
        public static void Main(string[] args)
        {
            bool[] studens = new bool[30];
            for (int i = 0 ; i < 28 ; i++)
            {
                studens[ReadInt() - 1] = true;
            }

            for (int i = 0 ; i < studens.Count() ; i++)
            {
                if(!studens[i]) Console.WriteLine(i + 1);
            }            
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 18272
from bisect import bisect_left

INF = 10**9 + 1
n = int(input())
dp = [INF] * (n+1)

for _ in range(n):
    a = int(input())
    i = bisect_left(dp, a)
    dp[i] = a
    # print(dp)
print(bisect_left(dp, INF))


Measured memory_bytes: 9476
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;

void updateRanking(int *top, int *jiten, vector<pair<int,int>> info){
	*top = 1;
	*jiten = 2;
	for(int i=3; i<info.size(); i++) if(info[i].second > info[*top].second){
		*jiten = *top;
		*top = i;
	}
}
int main(){
	int n,r,l;
	cin>>n>>r>>l;
	vector<pair<int,int>> info(1+n,make_pair(0,0));
	int top=0,ti=0,jiten=0;
	for(;r--;){
		int d,t,x;
		cin>>d>>t>>x;
		info[d].second+=x;
		if(d==top){
			if(x<0 && (info[top].second < info[jiten].second || (info[top].second == info[jiten].second && top > jiten))){
				info[top].first += t-ti;
				ti=t;
				updateRanking(&top, &jiten, info);
			}
		}else if(d==jiten && x<0){
			updateRanking(&top, &jiten, info);
		}else if(info[d].second > info[top].second || (info[d].second == info[top].second && d < top)){
			info[top].first += t-ti;
			ti=t;
			updateRanking(&top, &jiten, info);
		}
	}
	info[top].first += l-ti;
	int mi=1;
	for(int i=2; i<info.size(); i++) if(info[i].first > info[mi].first) mi = i;
	cout<<mi<<endl;
}

Measured memory_bytes: 4440
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

ll n, m, d[3], x[3][15], d2[3], x2[3][15];

int main() {
  while (scanf("%lld%lld", &n, &m), n != 0) {
    for (ll i = 0; i < 3; i++) {
      scanf("%lld", &d2[i]);
      for (ll j = 0; j < d2[i]; j++) scanf("%lld", &x2[i][j]);
    }
    ll ans = m+1;
    for (ll p = 0; p <= 1; p++) {
      for (ll i = 0; i < 3; i++) {
        d[i] = d2[i];
        for (ll j = 0; j < d[i]; j++) x[i][j] = x2[i][j];
      }
      ll now = p, counter = 0, first, second;
      while (counter <= m) {
        if (d[0] == n || d[2] == n) {
          if (ans > counter) ans = counter;
          break;
        }
        if (now == 0) {
          if (d[0] == 0) first = 1, second = 0;
          else if (d[1] == 0) first = 0, second = 1;
          else if (x[0][d[0]-1] < x[1][d[1]-1]) first = 1, second = 0;
          else first = 0, second = 1;
        } else {
          if (d[1] == 0) first = 2, second = 1;
          else if (d[2] == 0) first = 1, second = 2;
          else if (x[1][d[1]-1] < x[2][d[2]-1]) first = 2, second = 1;
          else first = 1, second = 2;
        }
        x[second][d[second]] = x[first][d[first] - 1];
        d[first]--; d[second]++;
        now = !now;
        counter++;
      }
    }
    if (ans == m+1) ans = -1;
    printf("%lld\n", ans);
  }
}



Measured memory_bytes: 2576
#include<iostream>
#include<algorithm>
#include<utility>

using namespace std;

const int MAX=10000;
typedef pair<int,int> P;

int n;
vector<P> G[MAX];
int dph[MAX][MAX];//vertex number, edge number
int h[MAX];

int dfs(int u,int e)
{
	if(dph[u][e]>=0)return dph[u][e];
	dph[u][e]=G[u][e].second;
	int v=G[u][e].first;
	
	for(int i=0;i<G[v].size();i++)
	{
		if(G[v][i].first==u)continue;
		dph[u][e]=max(dph[u][e],dfs(v,i)+G[u][e].second);
	}
	
	return dph[u][e];
}

void getheight()
{
	for(int i=0;i<n;i++)
	{
		h[i]=0;
		for(int j=0;j<G[i].size();j++)
		{
			dph[i][j]=-1;
		}
	}
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<G[i].size();j++)
		{
			if(dph[i][j]<0)dph[i][j]=dfs(i,j);
		}
	}
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<G[i].size();j++)
		{
			h[i]=max(h[i],dph[i][j]);
		}
	}
	
	return;
}

int main()
{
	cin>>n;
	int u,v,s;
	for(int i=0;i<n-1;i++)
	{
		cin>>u>>v>>s;
		G[u].push_back(P(v,s));
		G[v].push_back(P(u,s));
	}
	
	getheight();
	
	for(int i=0;i<n;i++)cout<<h[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 44568
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int DP[100000] = {};
int rec[100000] = {};
int ans[100000] = {};

int main(){
	
	int N, M;
	cin >> N >> M;
	
	int A[9] = {2,5,5,4,5,6,3,7,6};
	bool val[9] = {};
	
	for(int i = 0; i < M; i++){
		int num;
		cin >> num;
		val[num - 1] = true;
	}
	
	for(int i = 0; i <= N; i++){
		DP[i] = -1;
	}
	
	DP[0] = 0;
	
	for(int i = 1; i <= N; i++){
		for(int j = 8; j >= 0; j--){
			if(!val[j] || A[j] > i){
				continue;
			}
			if(DP[i - A[j]] == -1){
				continue;
			}
			if(DP[i] < DP[i - A[j]] + 1){
				DP[i] = DP[i - A[j]] + 1;
				rec[i] = i - A[j];
				ans[i] = j + 1;
			}
		}
	}
	
	int pos = N;
	while(pos != 0){
		cout << ans[pos];
		pos = rec[pos];
	}
	cout << endl;
	
	return 0;
}


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

#define ran 101101

int n;
char s[ran];
map<string, int> mp;
map<string, int> ::iterator it;

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%s", s);
		int len = strlen(s);
		sort(s, s+len);
		
		string str = "";
		for(int j=0;j<len;j++)
			str += s[j];
		mp[str]++;
	}
	
	long long ans = 0;
	for(it = mp.begin(); it != mp.end(); it++) {
		int x = (*it).second;
		ans += 1LL*x*(x-1)/2;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 12800
x,n=map(int,input().split())
p=list(map(int,input().split()))
q=list(range(-1,200))
for i in range(n):
    q.remove(p[i])
ans=-100
for i in q:
    if abs(x-i)==abs(x-ans):
        ans=min(i,ans)
    elif abs(x-i)<abs(x-ans):
        ans=i
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    n-=400;
    n/=200;
    n=8-n;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3632
def f(a):
    i = 0
    a,r = divmod(a, 2)
    while r == 0:
        i += 1
        a,r = divmod(a, 2)
    return i

n = int(input())
a = map(int, input().split())
x = list(filter(lambda x:x > 0, map(f, a)))
print(sum(x))


Measured memory_bytes: 3828
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	static boolean check(String str) {
		Stack<Character>  stack=new Stack<>();
		for(int i=0; i<str.length(); i++) {
			char s=str.charAt(i);
			if(s=='.') {
				break;
			}
			if(s=='(') {
				stack.push(')');
			}
			if(s=='[') {
				stack.push(']');
			}
			if(s==')'|| s==']') {
				if(stack.isEmpty() || stack.pop()!=s) {
					return false;
				}
			}
		}
		return stack.isEmpty();
		
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNextLine()) {
				String str=sc.nextLine();
				if(str.equals(".")) {
					break;
				}
				if(check(str)) {
					System.out.println("yes");
				}
				else{
					System.out.println("no");
				}

			}
			

		}
	}
}


Measured memory_bytes: 42324
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
 
int main(){
  ll i, j;
  ll h, w;
  cin >> h >> w;
  char a[h][w];
  for(i = 0; i < h; i++)
    for(j = 0; j < w; j++)
      cin >> a[i][j];
  vector<ll> judgeh(h), judgew(w); 
  ll counth = h, countw = w;
  for(i = 0; i < h; i++)
    for(j = 0; j < w && a[i][j] == '.'; j++)
      if(j == w - 1){
        judgeh[i] = 1;
        counth--;
      }
  
  for(i = 0; i < w; i++)
    for(j = 0; j < h && a[j][i] == '.'; j++)
      if(j == h - 1){
        judgew[i] = 1;
        countw--;
      }
  
  //cout << counth spa countw << endl;
  for(i = 0; i < h; i++)
    if(judgeh[i] == 0){
    for(j = 0; j < w; j++)
      if(judgew[j] == 0)
      cout << a[i][j];
    cout << endl;
    }
  
        
        
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
const double eps = 1e-8;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MOD = 1000000007;
ll COM[51][51];
void COMint() {
    Fill(COM, 0);
    rep(i, 51) {
        rep(j, i+1) {
            if (j == 0 || i == j) COM[i][j] = 1LL;
            else COM[i][j] = COM[i - 1][j - 1] + COM[i - 1][j];
        }
    }
}
int main(void) {
    ll n, a, b; cin >> n >> a >> b;
    COMint();
    vector<ll> v(n); map<ll, int> mp,m;
    rep(i, n) {
        cin >> v[i]; mp[v[i]]++;
    }
    sort(RALL(v)); ll ans = 0,sum =0;
    rep(i, a)  ans += v[i],m[v[i]]++;
    if (v[0] == v[a - 1]) {
        for (int i = a; i <= b; i++) {
            int r = mp[v[a - 1]];
            sum += COM[r][i];
        }
    }
    else {
        sum = COM[mp[v[a - 1]]][m[v[a - 1]]];
    }cout << fixed << setprecision(10) << (ld)ans / a << endl;
    cout << sum << endl;
}

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

int main(){
    int n,m=0;
		cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        m=max(a[i],m);
    }
    set<int> s;
    for(int i=1;i<=m;i++) if(m%i==0)s.insert(i);
    int d=0;
    for(int i=0;i<n;i++){
        d+=*(s.lower_bound(a[i]))-a[i];
    }
    cout<<d<<endl;
}



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

int main(){
  int N,X,m,mx=1000;
  cin >> N >> X;
  for(int i=0;i<N;i++){
    cin >> m;
    X-=m;
    mx=min(m,mx);
  }
  int ans=N;
  ans+=X/mx;
  cout << ans << endl;    
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li x;
    cin>>x;
    cout<<(10-(x/200))<<endl;

    return 0;
}

Measured memory_bytes: 3632
a,b=map(int,input().split())
if(a==4 or a==6 or a==9 or a==11):
  aa=2
elif(a==2):
  aa=3
else:
  aa=1
  
if(b==4 or b==6 or b==9 or b==11):
  bb=2
elif(b==2):
  bb=3
else:
  bb=1

if(aa==bb):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	if (N % 1000 == 0)cout << 0 << endl;
	else cout << 1000-N % 1000 << endl;
}


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

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

    if ((a == b && a != c) || (b==c && a!=b) || (a==c && b!=a))
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}



Measured memory_bytes: 256