akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long
#define pb push_back

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

struct Calendar
{
	long long year;
	long long month;
	long long day;
	long long dat[2][13];
	Calendar(long long y, long long m, long long d)
	{
		year = y;
		month = m;
		day = d;
		dat[0][0] = dat[1][0] = 0;
		dat[0][1] = dat[1][1] = 31;
		dat[0][2] = dat[1][2] = 28;
		dat[0][3] = dat[1][3] = 31;
		dat[0][4] = dat[1][4] = 30;
		dat[0][5] = dat[1][5] = 31;
		dat[0][6] = dat[1][6] = 30;
		dat[0][7] = dat[1][7] = 31;
		dat[0][8] = dat[1][8] = 31;
		dat[0][9] = dat[1][9] = 30;
		dat[0][10] = dat[1][10] = 31;
		dat[0][11] = dat[1][11] = 30;
		dat[0][12] = dat[1][12] = 31;
		dat[1][2] = 29;
	}
	int uruu()
	{
		if (year % 4 == 0)
		{
			if (year % 400 != 0 && year % 100 == 0)
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
		return 0;
	}
	int uruu(long long y)
	{
		if (y % 4 == 0)
		{
			if (y % 400 != 0 && y % 100 == 0)
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
		return 0;
	}
	long long pday(long long d)
	{
		day += d;
		for (;; month++)
		{
			if (month >= 13)
			{
				year++;
				month = 1;
			}

			if (dat[uruu()][month] < day)
			{
				day -= dat[uruu()][month];
			}
			else
			{
				break;
			}
		}
		pmonth(0);
		return d;
	}
	long long pmonth(long long m)
	{
		month += m;
		for (;; year++)
		{
			if (month > 12)
			{
				month -= 12;
			}
			else
			{
				break;
			}
		}
		return m;
	}
	long long pyear(long long y)
	{
		year += y;
		return y;
	}
	long long dif(Calendar c)
	{
		long long ans = 0;
		Calendar a(year, month, day);
		ans -= a.day;
		ans += c.day;
		a.day = 0;
		c.day = 0;
		for (; a.month >= 1; a.month--)
		{
			ans -= dat[a.uruu()][a.month - 1];
		}
		for (; c.month >= 1; c.month--)
		{
			ans += dat[c.uruu()][c.month - 1];
		}
		for (; a.year != c.year; a.year++)
		{
			ans += 365;
			if (a.uruu())ans++;
		}
		return ans;
	}


};


int main()
{
	long long n;
	int k;
	cin >> n >> k;
	rep(i, k)
	{
		long long x, y; cin >> x >> y;
		cout << min(min(x-1,n-x), min(y-1,n-y)) % 3 + 1 << endl;
	}
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    string S;
    cin >> S;
    int a = S[0] - '0', b = S[1] - '0', c = S[2] - '0', d = S[3] - '0';
    if (a-b-c-d==7) printf ("%d-%d-%d-%d=7\n",a ,b ,c ,d);
    else if (a-b-c+d==7) printf("%d-%d-%d+%d=7\n", a, b, c, d);
    else if (a-b+c-d==7) printf("%d-%d+%d-%d=7\n", a, b, c, d);
    else if (a-b+c+d==7) printf("%d-%d+%d+%d=7\n", a, b, c, d);
    else if (a+b-c-d==7) printf("%d+%d-%d-%d=7\n", a, b, c, d );
    else if (a+b-c+d==7) printf("%d+%d-%d+%d=7\n", a, b, c, d );
    else if (a+b+c-d==7) printf("%d+%d+%d-%d=7\n", a, b, c, d );
    else if (a+b+c+d==7) printf("%d+%d+%d+%d=7\n", a, b, c, d );
}

Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int mod = 1'000'000'007;
struct UnionFind{
    //自身が親なら頂点数に−1かけたもの
    //そうでなければ親のID
    vector<int>r;
    UnionFind(int n){
        r = vector<int>(n,-1); 
    }
    int root(int x){
        if(r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
    bool unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(r[x] > r[y])swap(x,y);
        r[x] += r[y];
        r[y] = x;
        return true;

    }
    int size(int x){
        return -r[root(x)];
    }

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

    UnionFind UF(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        UF.unite(a,b);
    }

    int ans = 0;
    rep(i,n){
        ans = max(ans,UF.size(i));
    }
    cout << ans << endl;

}

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

int main() {
	double a, b, c, d, e, f;

	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = int(1000 * (e*c - b*f) / (a*e - b*d)) / 1000.0;
		double y = int(1000 * (c*d - a*f) / (b*d - a*e)) / 1000.0;

		cout << fixed;

		cout << setprecision(3) << x << " " 
		     << setprecision(3) << y << endl;
	}
	return 0;
}

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

const long long N = 1e3 + 17;
ll cnt, ans, lnt, sum, n, l1, x, y, a[N], mx, b[N][N];
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    cin >> n;
    string s;
    double rate = 380000.0;
    double ans = 0;
    for(ll i = 0; i < n; i ++)
    {
        double q1;
        cin >> q1 >> s;
        if(s == "BTC")
        {
           ans += q1 * rate;
        }
        else
        {
            ans += q1;
        }
    }
    printf("%.8f", ans);
    //cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(x) ((x)&-(x))

using namespace std;

inline void Assert(bool f){if(!f)puts("No"),exit(0);}

const int N=100005;
int n,a[N],b[N],v[N],perm[N],m,sum[N],pos[N];
bool rev[N],inv[2];

inline int ABS(int x){return x<0?-x:x;}
inline void inc(int x,int u){
	while(x<=n) sum[x]+=u,x+=lowbit(x);
}
inline int calc(int x){
	int r=x; while(x) r-=sum[x],x-=lowbit(x); return r;
}
bool chk(){
	memset (sum+1, 0, n<<2);
	for (int i=1; i<=m; i++) pos[perm[i]]=i;
	long long ti = 0;
	for (int i=1; i<=m; i++) ti += calc(pos[i]) - 1, inc (pos[i], 1);
	return ti & 1;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		Assert(a[i]%3==2);
		if(v[i]==a[i]+1)rev[i]=true;
		else Assert(v[i]==a[i]-1);
		b[i]=a[i]/3+1;
		Assert((b[i]&1)==(i&1));
		inv[i&1]^=rev[i];
	}
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		Assert(x+v[i]==2*a[i]);
	}
	m=0;for(int i=1;i<=n;i+=2)perm[++m]=b[i]/2+1;
	Assert((chk()^inv[0])%2==0);
	m=0;for(int i=2;i<=n;i+=2)perm[++m]=b[i]/2;
	Assert((chk()^inv[1])%2==0);
	puts("Yes");
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int r;
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
max0 = 0
count = 0
for i in range(N-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        max0 = max(max0, count)
        count = 0
print(max(max0, count))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, q, mod = 1e9 + 7;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int d2 = 500000004;
    cin >> n >> q;
    a.resize(n);
    for(auto &i : a) cin >> i;
    vector <vector <int> > p(n, vector <int>(n));
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            p[i][j] = a[i] > a[j];
        }
    }
    int g = 1;
    while(q--){
        g = 2 * g % mod;
        int x, y;
        cin >> x >> y;
        x--; y--;
        for(int i = 0 ; i < n ; i++){
            if(i == x || i == y) continue;
            int cur = 1LL * (p[x][i] + p[y][i]) * d2 % mod;
            p[x][i] = p[y][i] = cur;
            cur = 1LL * (p[i][x] + p[i][y]) * d2 % mod;
            p[i][x] = p[i][y] = cur;
        }
        int cur = 1LL * (p[x][y] + p[y][x]) * d2 % mod;
        p[x][y] = p[y][x] = cur;
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < i ; j++){
            ans += p[j][i];
            if(ans >= mod) ans -= mod;
        }
    }
    ans = 1LL * ans * g % mod;
    cout << ans << endl;
}


Measured memory_bytes: 37504
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    Scanner sc=new Scanner(System.in);
    int ans=0;
    for(int i=0;i<3;i++){
      ans+=sc.nextInt();
    }
    System.out.println(ans>=22?"bust":"win");
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				break;
			Dice d = new Dice(1, 2, 3);
			for (int i = 0; i < n; i++)
				d.move(scan.next());
			System.out.println(d.getTotal());
		}

		scan.close();
		System.exit(0);
	}
}

class Dice {
	int u, f, r, total;

	public Dice(int Up, int Front, int Right) {
		u = Up;
		f = Front;
		r = Right;
		total = u;
	}

	public int getTotal() {
		return total;
	}

	public void move(String oper) {
		int tmp;
		switch (oper) {
		case "North":
			tmp = 7 - u;
			u = f;
			f = tmp;
			break;
		case "East":
			tmp = 7 - r;
			r = u;
			u = tmp;
			break;
		case "South":
			tmp = 7 - f;
			f = u;
			u = tmp;
			break;
		case "West":
			tmp = 7 - u;
			u = r;
			r = tmp;
			break;
		case "Right":
			tmp = 7 - f;
			f = r;
			r = tmp;
			break;
		case "Left":
			tmp = 7 - r;
			r = f;
			f = tmp;
			break;
		}
		total += u;
	}

}

Measured memory_bytes: 35116
/**
 * Created By: Anonyman637
 * Created On: 3/6/2020 6:27:28 AM
 */

/* =============================================================================
   ================================== HEADERS ==================================
   ========================================================================== */

#include <cstdio>
#include <string>
#include <cmath>

/* =============================================================================
   ================================= TYPEDEFS ==================================
   ========================================================================== */

typedef char i8;
typedef short i16;
typedef int i32;
typedef long long i64;

typedef unsigned char ui8;
typedef unsigned short ui16;
typedef unsigned int ui32;
typedef unsigned long long ui64;

using namespace std;

/* =============================================================================
   ================================== MACROS ===================================
   ========================================================================== */

#ifdef DEBUG
#define debug(format, ...) printf(format, __VA_ARGS__)
#else
#define debug(format, ...) 
#endif

#ifdef FILEIO
#define INFILE "fileio\\"__FILE__"In.txt"
#define OUTFILE "fileio\\"__FILE__"Out.txt"
#endif

/* =============================================================================
   ================================== GLOBALS ==================================
   ========================================================================== */


/* =============================================================================
   =================================== SETUP ===================================
   ========================================================================== */

i32 setup() {

#ifdef FILEIO
	if(freopen(INFILE, "r", stdin) == NULL) return 401;
	if(freopen(OUTFILE, "w", stdout) == NULL) return 402;
#endif

	return 0;
}


/* =============================================================================
   ================================= FUNCTIONS =================================
   ========================================================================== */

i32 main() {

	i32 errorInSetup = setup();
	if (errorInSetup) exit(errorInSetup);

	i64 i, t;
	i64 n, sqrtN, steps;
	scanf("%lld", &n);
	sqrtN = ceil(sqrt((double) n));
	for (i = sqrtN; i > 0; i--) {
		if (n % i == 0) {
			steps = (n / i) + i - 2;
			break;
		}
	}

	printf("%lld", steps);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = "";

		if (A == B) {
			ans ="Draw";
		} else if (A == 1 && B != 1) {
			ans = "Alice";
		} else if (B == 1 && A != 1) {
			ans = "Bob";
		} else if(A < B) {
			ans = "Bob";
		} else if (B < A) {
			ans = "Alice";
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    int t = 0;
    rep(i,n) {
        if(t < a[i]) {
            t = a[i];
        } else {
            ans += t-a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3964
#include <cstdio> 
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N,M;
int P[100000],Y[100000]; vector<int> yd[100001];
int main () {

  scanf("%d%d",&N,&M);
  rep(i,M) scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]);
  rep(i,N) sort(yd[i+1].begin(),yd[i+1].end());
  rep(i,M) printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}

Measured memory_bytes: 7808
def gcd(a,b):
    if a>b :
        while b!=0:
            a,b = b,a%b
        return a
    else :
        while a!=0:
            a,b = b%a,a
        return b
def examB():
    A, B, C = LI()
    cur = gcd(A,B)
    if C%cur==0:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)

import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define ld long double
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vin(a,n) vi a(n); rep(i,0,n) cin>>a[i];
#define vout(a) rep(i,0,sz(a)) cout<<a[i]<<" "; cout<<endl;
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define inf LLONG_MAX
#define pi 3.1415926535897932384626
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

signed main()
{
    IOS
    int n;
    cin>>n;
    vin(a,n);
    map<int,int> m;
    rep(i,0,n) m[a[i]]++;
    int q;
    cin>>q;
    int sum=accumulate(all(a),0LL);
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        sum-=m[b]*b;
        sum+=m[b]*c;
        m[c]+=m[b];
        m[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

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

using namespace std;

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

  int n, m, ans = 0;
  map<string, int>
      map;

  cin >> n;

  string s;
  for (int i = 0; i < n; i++)
  {
    cin >> s;

    map[s]++;
  }

  cin >> m;

  for (int i = 0; i < m; i++)
  {
    cin >> s;

    map[s]--;
  }

  for (auto c : map)
    ans = max(ans, c.second);

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	long double x;
	cin >> x;
	int cnt = 0;
	long double a = 100.0;
	while (a < x) {
		a *= 1.01;
		a = (ll)a;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
    int n;
    cin>>n;
    vector<int>b(n);
    vector<int>ans;
    rep(i,n)cin>>b[i],b[i]--;
    for(int i=n-1;i>=0;i--){
        for(int j=b.size()-1;j>=0;j--){
            if(j==b[j]){
                b.erase(j+b.begin());
                ans.push_back(j);
                break;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    if(ans.size()==n){
        rep(i,n){
            cout<<ans[i]+1<<endl;
        }
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  long long ans=0,countW=0;
  for (long long i=0;i<S.size();i++) {
    if (S.at(i)=='W') {
      ans += i-countW;
      countW++;
    }
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      StringBuilder sb = new StringBuilder();
      for(char c : s.toCharArray()) {
        if(c == 'x') continue;
        sb.append(c);
      }
      if(!isPalin(sb.toString())) {
        System.out.println(-1);
        return;
      }
      int cnt = 0;
      int left = 0, right = s.length() - 1;
      while(left < right) {
        if(s.charAt(left) == s.charAt(right)) {
          left++;
          right--;
        } else if(s.charAt(left) == 'x') {
          cnt++;
          left++;
        } else if(s.charAt(right) == 'x') {
          cnt++;
          right--;
        }

      }
      System.out.println(cnt);
  }
  
  private static boolean isPalin(String s) {
    int left = 0, right = s.length()-1;
    while(left < right) {
      if(s.charAt(left) != s.charAt(right)) {
        return false;
      }
      left++;
      right--;
    }
    return true;
  }
}

Measured memory_bytes: 27812
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	char s[101];
	char t[101];
	int i, j;
	
	sl(N); ss(s); ss(t);
	
	for(i=0;i<N;i++) {
		for(j=0;j<N-i;j++) {
			if(t[j] != s[i+j]) break;
		}
		if(j == N - i) {
			pl(N + i);
			return 0;
		}
	}
	
	pl(2 * N);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };


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

	ll n,a,b,ans=0,ret=M,m;
	string s;
	cin >> n >> m;
	vi vi(n), w(m+1);
	rep(i, n) {
		ll k;
		cin >> k;
		rep(j, k) {
			cin >> a;
			w[a]++;
		}
	}
	rep(i, m+1) {
		if (w[i] == n) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
	//input
	string S; cin >> S;
	string divide[4] = {"dream", "dreamer", "erase", "eraser"};
	
	//compute
	queue<int> BFS;
	bool can = false;
	BFS.push(0);
	while(!BFS.empty()){ // queue が空になるまで継続
		int t = BFS.front(); // queue の先頭を取得
		BFS.pop(); // 取得した値を削除
		if(t == S.size()){ // 全部成功していたら終了
			can = true;
			break;
		}
		for(string s : divide){ // ４つの分枝を試す
			if(S.substr(t, s.size()) == s){
				BFS.push(t + s.size()); 
			}
		}
	}
	//output
	cout << (can ? "YES":"NO") << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
string qoo1[220],qoo2[220];
string nom1[220],nom2[220];

void pro(string qoo[],string nom[],string s,int &j,int &k){
    int len = s.length();
    bool ok = false,fg = false;
    for(int i=0; i<len; i++){
        if(ok==false&&s[i]!='\"'&&fg==false){
            fg = true;
            nom[++k]+=s[i];
            continue;
        }
        if(ok==false&&s[i]!='\"'&&fg){
            nom[k]+=s[i];
            continue;
        }
        if(ok==false&&s[i]=='\"'){
            ok = true;
            continue;
        }
        if(ok&&s[i]!='\"'){
            qoo[j]+=s[i];
            continue;
        }
        if(ok&&s[i]=='\"'){
            ok = false;
            fg = false;
            j++;
            continue;
        }
    }
    /*cout<<"qoo: "<<endl;
    for(int i=0; i<j; i++){
        cout<<qoo[i]<<" ";
    }cout<<endl;
    cout<<"nom: "<<endl;
    for(int i=0; i<=k; i++){
        cout<<nom[i]<<" ";
    }cout<<endl;*/

}
void ini(){
    for(int i=0; i<210; i++){
        qoo1[i] = "";
        qoo2[i] = "";
        nom1[i] = "";
        nom2[i] ="";
    }
}

int main(){
	string s1,s2;
	while(true){
        ini();
		cin>>s1;
		if(s1[0]=='.') break;
		cin>>s2;
		if(s1==s2){
			cout<<"IDENTICAL"<<endl;
			continue;
		}
		int len1 = s1.length(),len2 = s2.length();
		int j1=0,j2=0;
		int k1=-1,k2 =-1;
        pro(qoo1,nom1,s1,j1,k1);
        pro(qoo2,nom2,s2,j2,k2);
        if(k1!=k2||j1!=j2){
            cout<<"DIFFERENT"<<endl;
            continue;
        }
        bool ok = true;
        int cnt = 0;
        for(int i=0; i<j1; i++){
            if(qoo1[i]!=qoo2[i]) cnt++;
        }
        if(cnt>1){
            ok = false;
        }
        for(int i=0; i<=k1; i++){
            if(nom1[i]!=nom2[i]) ok = false;
        }
        if(ok){
            cout<<"CLOSE"<<endl;
            continue;
        }
        cout<<"DIFFERENT"<<endl;


	}
    return 0;
}



Measured memory_bytes: 3172
n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
l = make_divisors(n)
# print(l)
# print(len(l))
print(len(str(l[len(l)//2])))

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

using namespace std;

int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}

int main() {
   int n,k;
   cin>>n>>k;
   int ans=intlog(k,n);
   ++ans;
   cout<<ans<<endl;
}


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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MX = 200007;
vector<int> G[MX];
int odw[MX], odl[MX];
queue<int> Q;
void BFS(int u){
	odw[u] = 1;
	Q.push(u);
	while(!Q.empty()){
		u = Q.front(); Q.pop();
		for(int v : G[u]){
			if(odw[v] == 0){
				odl[v] = odl[u] + 1;
				odw[v] = 1;
				Q.push(v);
			}
		}
	}
}

int32_t main()
{
	int n, m; scanf("%d%d", &n, &m);
	while(m--){
		int a, b; scanf("%d%d", &a, &b);
		G[a].PB(b); G[b].PB(a);
	}
	BFS(1);
	(odl[n] == 2) ? puts("POSSIBLE") : puts("IMPOSSIBLE");
}



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


class Program
{
    static long[] kaijo;
    static long[] Ikaijo;
    static long[] kaijon;
    static long mo = 1000000007;
    
    static void Main(string[] args)
    {
        //入力を受け取る
        var NAB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long N = NAB[0];
        long A = NAB[1];
        long B = NAB[2];
        //N個のものからR個選ぶ組み合わせ
        kaijo = new long[B + 1];
        //階乗のモジュラー逆数
        Ikaijo = new long[B + 1];
        kaijon = new long[B + 1];
        kaijo[0] = 1;
        Ikaijo[0] = 1;
        kaijon[0] = N;
        
        for (long i = 1; i < B + 1; i++)
        {
            kaijo[i] = (kaijo[i - 1] * i) % mo;
            Ikaijo[i] = RepeatSquaring(kaijo[i]);
            kaijon[i] = (kaijon[i - 1] * (N - i)) % mo;
        }
        
        long ans = RepeatSquaring(2, N) + mo - nCr(B) + mo - nCr(A) + mo - 1;
       
        Console.WriteLine(ans%mo);
    }
    
    static long nCr(long r){
        return ((kaijon[r-1]%mo) * (Ikaijo[r]%mo))%mo;
    }


    //繰り返し2乗法
    static long RepeatSquaring(long N, long M = 1000000005, long mod = 1000000007)
    {
        if (M == 0)
        {
            return 1;
        }
        else if (M % 2 == 0)
        {
            long t = RepeatSquaring(N, (M / 2), mod) % mod;
            return (t * t) % mod;
        }
        else
        {
            return ((N % mod) * RepeatSquaring(N, M - 1, mod)) % mod;
        }
    }
}


Measured memory_bytes: 18004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, a, ac[200005];
ll ans;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		if(i>a) ans += ac[i-a];
		if(i+a<n) ac[i+a]++;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4600
until(n,m=gets.split.map(&:to_i)).all?(&:zero?)do
r,p,a=[],[],[]
n.times{r.unshift(gets.gsub("?",".").split)}
m.times{p<<gets.split}
p.each{|p|r.each{|r|if/#{r[1]}/=~p[0]&&p[1]=~/#{r[2]}/
a<<p*" "if/p/=~r[0]
break
end}}
puts a.size,a
end

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

import bisect
from itertools import accumulate

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()

left = -1
right = 1 + 2 * 10 ** 5

def shake(x):
    cnt = 0
    for i in A:
        cnt += N - bisect.bisect_left(A, x - i)
    if cnt >= M:
        return 1
    else:
        return 0

while True:
    mid = (left + right) // 2
    if shake(mid):
        if not shake(mid + 1):
            X = mid
            break
        else:
            left = mid
    else:
        if shake(mid - 1):
            X = mid - 1
            break
        else:
            right = mid

happy = 0
cumsum_A = list(accumulate(A))

for j in A:
    idx = bisect.bisect_right(A, X - j)
    cnt = N - idx
    if cnt == N:
        happy += cumsum_A[-1] + cnt * j
    else:
        happy += cumsum_A[-1] - cumsum_A[idx - 1] + cnt * j
    M -= cnt

happy += M * X

print(happy)


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

A = [a for i, a in enumerate(A) if a <= i+1]

k = 0
for a in A:
    if a == k+1:
        k += 1
    

if k == 0:
    print(-1)
else:
    print(N - k)

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する

template<typename T>
//templateをつかってみｔか
ll pow(T x, int y) {
    if (y == 0) return 1;
    if (y == 1) return x;
    if (y == 2) return (x * x) % MOD;
//        if (y % 2 == 1) return pow(x, y / 2) * pow(x, y / 2) % MOD;
    if (y % 2 == 1) return pow(pow(x, y / 2), 2) * x % MOD;
//        return pow(x, y / 2) * pow(x, y / 2) % MOD;
    return pow(pow(x, y / 2), 2) % MOD;
}

class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        string s;
        cin >> s;
        ll one = 0;
        ll ret = s.size();
        ll ans = 0;

        for (int i = 0; i < s.size(); ++i) {
            ret--;

            if (s[i] == '0') {
            } else {
                ll tmp = pow(3ll, (int) ret) % MOD;
                tmp *= pow(2ll, (int) one);
                tmp %= MOD;
                ans += tmp;
                ans %= MOD;
                one++;
            }
            if (i + 1 == s.size()) {
                ll tmp = pow(3ll, (int) ret) % MOD;
                tmp *= pow(2ll, (int) one);
                tmp %= MOD;
                ans += tmp;
                ans %= MOD;
            }

        }


        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "Impossible"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n, k;
    cin >> n >> k;
    int a[n];
    loop(i, n)
        cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    loop(i, k)
        ans += a[i];
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        for (int i = 1; i <= 1001001009; i++) {
            double tmp1 = i*0.08;
            int tmpa = (int)tmp1;
            double tmp2 = i*0.1;
            int tmpb = (int)tmp2;
            
            if (tmpa == a && tmpb == b) {
                System.out.println(i);
                return;
            }
            
            if (tmpa > a && tmpb > b) {
                System.out.println(-1);
                return;
            }
        }
    }
}

Measured memory_bytes: 23764
r,c = list(map(int,input().split()))
sum_li = [0]*(c+1)
for i in range(r):
    line = list(map(int, input().split()))
    line += [sum(line)]
    print(' '.join(list(map(str,line))))
    sum_li = [x+y for (x,y) in zip(sum_li,line)]
print(' '.join(list(map(str,sum_li))))

Measured memory_bytes: 7744
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n;
  cin >> n;
  bool a[n] = {0};
  vector <int> b;
  
  REP(i,n){
    int c;
    cin >> c;
    b.pb(c);
  }
  int i = 0;
  int num = 0;
  while(1){
    num++;
    if(a[i]){
      cout << -1 << endl;
      break;
    }
    a[i] = true;
    i = b[i]-1;
    if(i == 1){
      cout << num << endl;
      break;
    }
    
  }
  return 0;
}


Measured memory_bytes: 1020
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        Program pg = new Program();
        Console.WriteLine(pg.Exe());
    }

    public int Exe()
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int target_val = input[0];
        int answer = target_val;
        int num_cnt = input[1];

        //数列の長さが0の場合、目標値が答えとなるので返す
        if(num_cnt == 0) return answer;
        else answer = 999999;

        List<int> num_list = new List<int>(200);
        for(int i = 0; i <= 101;i++)
        {
            num_list.Add(i);
        }

        List<int> exclusion_numlist = new List<int>(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
        IEnumerable<int> results = num_list.Except(exclusion_numlist);

        int temp = 0;
        int temptgt = answer - target_val;
        foreach(int i in results)
        {
            temp = Math.Abs(i - target_val);
            if(temptgt > temp)
            {
                answer = i;
                temptgt = temp;
            }
            else if(temptgt == temp && answer > i)
            {
                answer = i;
                temptgt = temp;
            }
        }

        return answer;
    }
}


Measured memory_bytes: 28284
package main

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

const (
	maxBufsize = 1000000
)

func inputs(lines int) []string {
	var strSlice []string

	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

func calcCombination(rgb string) int {
	r := 0
	g := 0
	b := 0

	for i := 0; i < len(rgb); i++ {
		if rgb[i] == 'R' {
			r++
		} else if rgb[i] == 'G' {
			g++
		} else if rgb[i] == 'B' {
			b++
		}

	}

	return r * g * b

}

func count(rgb string) int {
	n := len(rgb)
	c := 0
	for i := 0; i < n; i++ {
		for j := (i + 1); j < n; j++ {
			if rgb[i] == rgb[j] {
				continue
			}

			k := 2*j - i
			if k >= n || rgb[j] == rgb[k] || rgb[k] == rgb[i] {
				continue
			}
			c++
		}
	}

	return c
}

func main() {
	line := inputs(2)

	ans := 0

	strRGB := line[1]
	com := calcCombination(strRGB)
	c := count(strRGB)

	ans = com - c
	fmt.Println(ans)
}

Measured memory_bytes: 1944
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

ll n, res = 0, c, cur;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    cin >> n;
    c = cur = n - 2;
    vector<ll> v(n);
    for(auto &i : v) cin >> i;
    sort(all(v));

    res = v.back();
    while(c > 0){
        res += v[cur], c--;
        if(c > 0) res += v[cur], cur--, c--;
    }

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  unordered_set<int> S;
  int q;
  cin>>q;
  while(q--){
    int cmd, num;
    cin>>cmd>>num;
    if(cmd == 0){
      S.insert(num);
      cout<<S.size()<<endl;
    }
    if(cmd == 1){
      cout<<S.count(num)<<endl;
    }
  }
  
  
  return 0;
}



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

int main() {
	int input;
	int num[3];
	int count = 0;
	cin >> input;
	
	num[0] = input / 100;
	num[1] = (input - num[0] * 100) / 10;
	num[2] = input - num[0] * 100 - num[1] * 10;

	for (int i = 0; i < 3; i++) {
		if (num[i] == 1) {
			count += 1;
        }
	}
	cout << count << endl;
}

Measured memory_bytes: 256
n, m, x, y = gets.split(" ").map(&:to_i)
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

amax = a.max {|a, b| a.to_i <=> b.to_i }
bmin = b.min {|a, b| a.to_i <=> b.to_i }

if amax < bmin
  if x <= amax and bmin <= y
    puts "No War"
  else
    puts "War"
  end
else
  puts "War"
end

Measured memory_bytes: 1788
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int W, H;
  while (cin >> W >> H, W) {
    vs v(H);
    rep(i, H) cin >> v[i];
    vvi dp(H, vi(W));
    int b = 0, w = 0;
    rep(i, H) rep(j, W) {
      dp[i][j] = 2 * (v[i][j] == 'B') + (v[i][j] == 'W');
      b -= v[i][j] == 'B';
      w -= v[i][j] == 'W';
    }
    rep(_, W * H) rep(i, H) rep(j, W) {
      if (v[i][j] != '.') continue;
      if (i > 0) dp[i][j] |= dp[i - 1][j];
      if (j > 0) dp[i][j] |= dp[i][j - 1];
      if (i < H - 1) dp[i][j] |= dp[i + 1][j];
      if (j < W - 1) dp[i][j] |= dp[i][j + 1];
    }
    rep(i, H) rep(j, W) {
      b += dp[i][j] == 2;
      w += dp[i][j] == 1;
    }
    cout << b << ' ' << w << endl;
  }
}

Measured memory_bytes: 3156
#include <iostream>

int main(){

  int H, W;
  std::cin >> H >> W;

  while( H!=0 && W!=0 ){

    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if( (i%2 == 0 && j%2 == 0) || (i%2 == 1 && j%2 == 1) ){
          std::cout << "#" ;
        }else std::cout <<".";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
    std::cin >> H >> W;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

//#define P 1000000007
#define P 998244353

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int a[3001];
long d[3001];
int main(void){
	int n=nextpint();
	int s=nextpint();
	for(int i=1; i<=n; i++){
		a[i]=nextpint();
	}
	for(int i=1; i<=n; i++){
		for(int j=s; j>=1; j--){
			if(a[i]<j){
				long D=d[j-a[i]];
				if(j==s){
					D*=(n-i+1);
				}
				d[j]=(d[j]+D)%P;
			}else if(a[i]==j){
				int D=i;
				if(j==s){
					D*=(n-i+1);
				}
				d[j]=(d[j]+D)%P;
			}
		}
	}
	printf("%ld\n", d[s]);
}


Measured memory_bytes: 256
// 171

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int buf, tmp;
    for(int i=0; i<5; i++){
        cin >> buf;
        if(buf == 0){
            tmp = i+1;
        }
    }
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(void){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if(a+b+c>=22){
        printf("bust");
    }else{
        printf("win");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int new_A;
  new_A = N * A;
  
  if (new_A < B){
    cout << new_A << endl;
  }else{
    cout << B << endl;
  }
}


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

typedef struct tuple_t {
    int a, b;
} tuple;

int qsort_tuple(const void *a, const void *b)
{
    return ((*(tuple *)a).a) - ((*(tuple *)b).a);
}

int main(int argc, char *argv[])
{
    int n, m;
    tuple t[100000];
    int i;
    long long ans;

    scanf("%d %d", &n, &m);

    for (i = 0; i < n; i++) {
        scanf("%d %d", &t[i].a, &t[i].b);
    }

    qsort(t, n, sizeof(tuple), qsort_tuple);

    ans = 0;
    for (i = 0; i < n; i++) {
        if (m <= t[i].b) {
            ans += (long long) t[i].a * m;
            break;
        } else {
            ans += (long long) t[i].a * t[i].b;
            m -= t[i].b;
        }
    }

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

    return 0;
}


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

int main(){
  ll K, A, B, i;
  cin >> K >> A >> B;
  for (i = A; i <= B; i++){
    if(i%K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int[]A = new int[N];
			for(int i = 0;i<N;i++)A[i] = scan.nextInt();
			
			
			
		
			
			
			int count = 0;
			
			int g = A[0];
			for(int i = 1;i<N;i++) {
				g = gcd(A[i],g);
				}
			
			
		
			
			System.out.println(g);
		}
		
		
	}
		
	private static int gcd(int A,int B){//最大公約数
		return B==0?A:gcd (B,A%B);
	}

}


Measured memory_bytes: 49816
from collections import deque

N = int(input())
C = deque(list(input()))

ans = 0
while C:
    while C and C[0]=='R':
        _ = C.popleft()
    while C and C[-1]=='W':
        _ = C.pop()
    if C:
        ans += 1
        _ = C.popleft(), C.pop()

print(ans)

Measured memory_bytes: 12340