akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,k,a;
    cin>>n>>k;
    std::deque<pair<long long int,int>> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(pair(a,0));
    }
    long long int tmp=0;
    std::deque<long long int> loop;
    while (1) {
        deq[tmp].second++;
        if (deq[tmp].second==2) {
            loop.emplace_back(deq[tmp].first);
        } else if (deq[tmp].second==3) {
            break;
        }
        tmp=deq[tmp].first-1;
    }
    std::deque<long long int> not_loop;
    tmp=0;
    for (int i=0;i<n;i++) {
        if (deq[tmp].second==1) {
            not_loop.emplace_back(deq[tmp].first);
        } else {
            break;
        }
        tmp=deq[tmp].first-1;
    }
    loop.emplace_front(loop.back());
    loop.pop_back();
    tmp=0;
    long long int size=not_loop.size();
    if (k<=size) {
        for (int i=0;i<k;i++) {
            tmp=deq[tmp].first-1;
        }
        cout<<tmp+1<<endl;
    } else {
        k-=size;
        cout<<loop[k%loop.size()]<<endl;
    }
}

Measured memory_bytes: 8500
a, b = gets.chomp.split.map(&:to_i)
aa = 4 - (a & 3)
ba = (b & 3) + 1
ans = 0
if b - a < 10 then
  a.upto(b) do |i|
    ans ^= i
  end
else
  aa.times do |i|
    ans ^= a + i
  end
  ba.times do |i|
    ans ^= b - i
  end
end
puts ans

Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> f[i];
    }

    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());

    ll lower = -1;
    ll upper = 10000000000000LL;

    do {
        ll cur = (upper + lower) / 2;
        ll cost = 0;
        for (int i = 0; i < n; ++i) {
            cost += max(0LL, a[i] - cur / f[i]);
        }

        if (cost <= k)
            upper = cur;
        else
            lower = cur;
    } while (upper - lower > 1);

    cout << upper << endl;
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int INF=1000000007;
using ll=long long;

int main() {
	int A,B,C,D,E,F;
	cin>>A>>B>>C>>D>>E>>F;
	int suger=-1,suger_water=-1;
	for(int i=0;i<=F;i+=100*A){
		for(int j=0;i+j<=F;j+=100*B) {
			for(int k=0;i+j+k<=F;k+=C){
				for(int l=0;i+j+k+l<=F;l+=D){
					if(i+j+k+l==0||(100+E)*(k+l)>E*(i+j+k+l))continue;
					if (suger==-1||suger*(i+j+k+l)<suger_water*(k+l)){
						suger=k+l;
						suger_water=i+j+k+l;
					}
				}
			}
		}
	}
	cout<<suger_water<<" "<<suger<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define N (int)(1e5+10)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define inf mod
#define endl '\n'
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define bit(x,y) ((x>>y)&1)

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

	cout << n/2 - (n%2 == 0) << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] =="#":
            if i == 0:
                if j == 0:
                    if a[i+1][j] == "." and a[i][j+1] == ".":
                        print("No")
                        exit()
                elif j == w-1:
                    if a[i+1][j] == "." and a[i][j-1] == ".":
                        print("No")
                        exit()
                else:
                    if a[i+1][j] == "." and a[i][j+1] == "." and a[i][j-1] == ".":
                        print("No")
                        exit()
            elif i == h-1:
                if j == 0:
                    if a[i-1][j] == "." and a[i][j+1] == ".":
                        print("No")
                        exit()
                elif j == w-1:
                    if a[i-1][j] == "." and a[i][j-1] == ".":
                        print("No")
                        exit()
                else:
                    if a[i-1][j] == "." and a[i][j+1] == "." and a[i][j-1] == ".":
                        print("No")
                        exit()
            else:
                if j == 0:
                    if a[i+1][j] == "." and a[i-1][j] == "." and a[i][j+1] == ".":
                        print("No")
                        exit()
                elif j == w-1:
                    if a[i+1][j] == "." and a[i-1][j] == "." and a[i][j-1] == ".":
                        print("No")
                        exit()
                else:
                    if a[i+1][j] == "." and a[i-1][j] == "." and a[i][j+1] == "." and a[i][j-1] == ".":
                        print("No")
                        exit()
print("Yes")

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N - 1);

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i];
    }

    int cnt = 0;

    for (int i = 0; i < N; i++) {
        if (i != 0 && A[i - 1] + 1 == A[i]) {
            cnt += C[A[i] - 2];
            // cout << i << endl;
        }
        cnt += B[i];
    }

    cout << cnt << endl;
}

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

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

struct Node {
    int k;
    Node *l, *r, *p;
};

Node *root = nullptr;


void insert(Node* inode) {
    if (root == nullptr) {
        root = inode;
        return;
    }
    Node* tgt = root;
    while (true) {
        if (inode->k < tgt->k) {
            if (tgt->l == nullptr) {
                tgt->l = inode;
                break;
            }else{
                tgt = tgt->l;
            }
        }else{
            if (tgt->r == nullptr) {
                tgt->r = inode;
                break;
            }else{
                tgt = tgt->r;
            }
        }
    }
}

void find(int k) {

    Node *tgt = root;

    while (tgt != nullptr) {
        if (tgt->k == k) {
            std::cout << "yes" << std::endl;
            return;
        }
        if (k < tgt->k) tgt = tgt->l;
        else tgt = tgt->r;
    }
    std::cout << "no" << std::endl;
}

void Preorder(Node* n) {
    if (n == nullptr) {
        return;
    }
    std::cout << " " << n->k;
    Preorder(n->l);
    Preorder(n->r);
}
void Inorder(Node* n) {
    if (n == nullptr) {
        return;
    }
    Inorder(n->l);
    std::cout << " " << n->k;
    Inorder(n->r);
}

int main() {
    std::cin >> n;
    std::vector<Node> T;
    T.reserve(n);

    FOR(i, 0, n){
        std::string instruction;
        std::cin >> instruction;
        if (instruction == "insert") {
            Node n{0, nullptr, nullptr, nullptr};
            std::cin >> n.k;
            T.push_back(n);
            insert(&T[T.size() - 1]);
        }else if(instruction == "print") {
            Inorder(root);
            std::cout << std::endl;
            Preorder(root);
            std::cout << std::endl;
        }else if(instruction == "find") {
            int k;
            std::cin >> k;
            find(k);
        }
    }

}


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


int main()
{
	double a[10000];
	while(1)
	{
		int n;
		double ave=0.0f;
		cin>>n;
		if(n==0)
			break;

		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			ave+=a[i];
		}
		sort(a,a+n);
		ave/=(double)n;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]>ave)
				break;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3280
n, a, b, c = (int(x) for x in input().split())
d = {"A": a, "B": b, "C": c}
S = [input() for _ in range(n)]
ANS = []

for i, s in enumerate(S):
    if d[s[0]] == 0 and d[s[1]] == 0:
        print("No")
        exit()
    else:
        if d[s[0]] > d[s[1]] or (d[s[0]] == d[s[1]] == 1 and i < n - 1 and s[1] in S[i + 1]):
            d[s[1]] += 1
            d[s[0]] -= 1
            ANS.append(s[1])
        else:
            d[s[0]] += 1
            d[s[1]] -= 1
            ANS.append(s[0])
print("Yes")
for ans in ANS:
    print(ans)


Measured memory_bytes: 89844
#include <iostream>

int main(void){
	using namespace std;
	int H, W, i, j;
	while(cin >> H >> W){
		if(H == 0 && W ==0)
			break;
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if((i+j+2)%2)
				cout << ".";
			else
				cout << "#";
		}
		cout << endl;
	}
	cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %lf",d,r,f);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

set<pair<int, pair<int, int>>> s;

signed main() {
	int A, B, C;
	cin >> A >> B >> C;

	int ret = 0;
	s.insert(make_pair(A, make_pair(B, C)));
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		int tA = B / 2 + C / 2;
		int tB = A / 2 + C / 2;
		int tC = A / 2 + B / 2;
		A = tA; B = tB; C = tC;
		auto p = make_pair(A, make_pair(B, C));
		if (s.find(p) != s.end()) {
			ret = -1;
			break;
		}
		s.insert(p);
		ret++;
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[100010];
long long g1[100010]={0,},g2[100010]={0,},g3[100010]={0,};
long long f1[100010]={0,},f2[100010]={0,},f3[100010]={0,};
long long var[100010]={0,};
vector<long long>G1[100010],G2[100010],G3[100010];
long long pw10[100010];
long long mod=998244353;
int main(){
	long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,tmp,ans,cnt,max1=0,max2=0,max3=0;
	scanf("%lld",&n);
	scanf("%lld",&tmp);
	for(i=0;i<tmp;i++){
		scanf("%lld %lld",&a,&b);
		G1[a].push_back(b);
		G1[b].push_back(a);
	}
	scanf("%lld",&tmp);
	for(i=0;i<tmp;i++){
		scanf("%lld %lld",&a,&b);
		G2[a].push_back(b);
		G2[b].push_back(a);
	}
	scanf("%lld",&tmp);
	for(i=0;i<tmp;i++){
		scanf("%lld %lld",&a,&b);
		G3[a].push_back(b);
		G3[b].push_back(a);
	}
	pw10[0]=1;
	z=1000000000000000000%mod;
	for(i=1;i<100010;i++) pw10[i]=(pw10[i-1]*z)%mod;
	for(i=n;i>=1;i--){
		for(j=0; j<G1[i].size(); j++) if(G1[i][j]>i) var[g1[G1[i][j]]]=1;
		for(j=0;j<100010;j++) if(var[j]==0) {
			g1[i]=j;
			if(max1<j) max1=j;
			break;
		}
		for(j=0; j<G1[i].size(); j++) if(G1[i][j]>i) var[g1[G1[i][j]]]=0;
	}
	for(i=n;i>=1;i--){
		for(j=0; j<G2[i].size(); j++) if(G2[i][j]>i) var[g2[G2[i][j]]]=1;
		for(j=0;j<100010;j++) if(var[j]==0) {
			g2[i]=j;
			if(max2<j) max2=j;
			break;
		}
		for(j=0; j<G2[i].size(); j++) if(G2[i][j]>i) var[g2[G2[i][j]]]=0;
	}
	for(i=n;i>=1;i--){
		for(j=0; j<G3[i].size(); j++) if(G3[i][j]>i) var[g3[G3[i][j]]]=1;
		for(j=0;j<100010;j++) if(var[j]==0) {
			g3[i]=j;
			if(max3<j) max3=j;
			break;
		}
		for(j=0; j<G3[i].size(); j++) if(G3[i][j]>i) var[g3[G3[i][j]]]=0;
	}
	//for(i=1;i<=n;i++)printf("%lld ",g1[i]);
	//for(i=1;i<=n;i++)printf("%lld ",g2[i]);
	//for(i=1;i<=n;i++)printf("%lld ",g3[i]);
	for(i=1;i<=n;i++){
		f1[g1[i]]=(f1[g1[i]]+pw10[i])%mod;
		f2[g2[i]]=(f2[g2[i]]+pw10[i])%mod;
		f3[g3[i]]=(f3[g3[i]]+pw10[i])%mod;
	}
	ans=0;
	for(a=0;a<=max1;a++)
	for(b=0;b<=max2;b++)
	for(c=0;c<=max3;c++){
		if(((a^b)^c)==0) ans=(ans+(((f1[a]*f2[b])%mod)*f3[c])%mod)%mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 23808
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
    long long n, ans = 1;
    scanf("%lld", &n);
    long long a[100000], b = 1000000000000000000;
    for (long long i = 1; i <= n; i++) { scanf("%lld", &a[i]); }

    for (int i = 1; i <= n; i++) {
        if (a[i] == 0) { printf("0"); return 0; }
    }

    for (long long i = 1; i <= n; i++) {
        if (b / ans < a[i]) { printf("-1"); return 0; }

        ans *= a[i];
    }

    printf("%lld", ans);
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
int main()
{
    int n ,i ,t ,b;
    long long sum=0;
    scanf("%d",&n);
    if(n == 1)
    {
        printf("0");
        return 0;
    }
    int a[n];
    for(i = 0 ; i < n; i++)
    {
        scanf("%d",&t),
        a[i] = t-i;
    }
    std::sort(a,a+n);
    b = n%2==0 ? (a[n/2]+a[n/2-1])/2 : a[n/2];
    for(i = 0 ; i < n; i++)
        sum += abs(a[i]-b);
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  string s;cin>>s;
  rep(i,3){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B,k=0;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i=0;i<=VMAX;i++)C[i]=0;

  for(j=1;j<=n;j++){
   scanf("%hu",&A[j]);
    C[A[j]]++;
    if(k<A[j])k=A[j];
}
  
  for(i=1;i<=k;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%u",B[i]);
    if(i<n)printf(" ");
  }
  
  printf("\n");

  return 0;
}



Measured memory_bytes: 9652
//互いに素な集合
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Tree{
private:
	struct Element{
		int point;//ポインタ(根のvector[x])
		int rank;//階級
	};

	vector<Element> Content;

public:
	Tree(int contentsnum);

	int FindSet(int x);
	void Link(int x, int y);
	void Unite(int x ,int y);
	bool Same(int x, int y);
};

Tree::Tree(int contentsnum){
	Content.resize(contentsnum);
	for (int c = 0; c < contentsnum;++c){
		Content[c].rank = 0;
		Content[c].point = c;
	}
}

int Tree::FindSet(int x){
	if (x != Content[x].point){
		Content[x].point = FindSet(Content[x].point);
	}
	return Content[x].point;
}

void Tree::Link(int x, int y){
	if (Content[x].rank < Content[y].rank){
		Content[x].point = y;
	} else{
		Content[y].point = x;
		if (Content[x].rank = Content[y].rank)
			++Content[y].rank;
	}
}

void Tree::Unite(int x, int y){
	Link(FindSet(x), FindSet(y));
}

bool Tree::Same(int x, int y){
	return FindSet(x) == FindSet(y);
}

int main(){
	int contentnum;
	cin >> contentnum;
	Tree tree(contentnum);

	int ordernum = 0;
	cin >> ordernum;
	int a = 0, b = 0;//ローダー
	for (int i = 0; i < ordernum; ++i){
		cin >> a;
		if (a == 0){//unite
			cin >> a; cin >> b;
			tree.Unite(a, b);
		} else{
			cin >> a; cin >> b;
			cout << (tree.Same(a, b) ? 1 : 0) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>

int main(void){

	int width,height,wcount;

	while(1){
		scanf("%d",&height);
		scanf("%d",&width);
		
		if(height==0&&width==0){
			break;
		}
		
		while(height>0){
			for(wcount=width;wcount>0;wcount--){
				printf("#");
			}
			printf("\n");
			height--;
		}
		
		printf("\n");
	}
		
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n, k, d;
bool ds[10];

bool check(int v) {
	while (v > 0) {
		if (ds[v % 10]) return false;
		v /= 10;
	}
	return true;
}

int main(int argc, char **argv) {
	CLEAR(ds);
	cin >> n >> k;
	REP(i, k) {
		cin >> d;
		ds[d] = true;
	}
	while (!check(n)) ++n;
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void main()
{
             char s[100];
              int i;
             scanf("%s",s);
             for(i=0;s[i]!='\0';i++)
             {
                       if(i==2)
                       {
                                if(s[i]!=s[i+1])
                                {
                                         printf("No");
                                         break; 
                                 }
                        }
                        if(i==4)
                        {
                                      if(s[i]!=s[i+1])
                                      {
                                                   printf("No");
                                                     break;
                                      }
                         }
             }
             if(s[i]=='\0')
                      printf("Yes");
             return;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
 
int n, m;
vector<int> p1, p2;
int main()
{
  while(true){
    scanf("%d%d", &n, &m);
    if(!n && !m)
      break;

    p1.clear();
    p2.clear();
     
    //chap1
    p1.push_back(0);
    for(int i = 0; i < n; i++){
      int p;
      cin >> p;
      p1.push_back(p);
    }
 
    //chap2
    for(int i = 0; i <= n; i++)
      for(int j = i; j <= n; j++)
    p2.push_back(p1[i] + p1[j]);
 
    sort(p2.begin(), p2.begin() + p2.size());
 
    //chap3
    int ans = 0;
    for(int i = 0; i < p2.size(); i++){
      vector<int>::iterator count2 = upper_bound(p2.begin(), p2.end(), m - p2[i]);
      if(count2 != p2.begin())
    ans = max(ans, *(count2 - 1) + p2[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


int used[200000];
vector<int> G[200000];
deque<int> ans;
void dfs(int u, int f){
  if(used[u] == 0){
    if(f == 0)ans.pb(u);
    else ans.pf(u);
  }
  used[u] = 1;
  rep(i,G[u].size())if(used[G[u][i]] == 0){
    dfs(G[u][i], f);
    return;
  }
}

signed main(){
  int n, m, from, to;
  scanf("%lld%lld", &n, &m);
  rep(i,m){
    int x, y;
    scanf("%lld%lld", &x, &y);
    G[x].pb(y);G[y].pb(x);
    from = x;to = y;
  }
  ans.pb(from);ans.pb(to);
  used[from] = used[to] = 1;
  dfs(to, 0);
  dfs(from, 1);
  
  int size = ans.size();
  printf("%lld\n", size);
  rep(i,size)printf("%lld%c", ans[i], " \n"[i == size-1]);
	return 0;
}









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

using namespace std;

#define ll long long

const int N = 303;
const int inf = (int)1e9 + 7;

int dp[N][N][N];

int mult (int a, int b) {
    return a * 1LL * b % inf;
}

int add (int a, int b) {
    a += b;
    if (a >= inf) a -= inf;
    return a;
}

main() {
    int n, m; scanf ("%d %d", &n, &m);
    dp[0][1][1] = 1;
    for (int i = 0; i < m; i++) {
        for (int j = 1; j <= n; j++) {
            for (int l = 1; l <= n; l++) {
                int delta = dp[i][j][l];
                if (delta == 0) continue;
                dp[i + 1][j + 1][l] = add(mult(delta,(n - j)), dp[i + 1][j + 1][l]);
                dp[i + 1][j][l] = add(mult(delta, j - l),dp[i + 1][j][l]);
                dp[i + 1][j][j] = add(mult(delta, l), dp[i + 1][j][j]);
            }
        }
    }
    cout << dp[m][n][n];
}


Measured memory_bytes: 106752
#include<iostream>

using namespace std;

int main(void){

    int n;
    cin >> n;

    int a[n];

    int i;

    for(i = 0;i < n;i++){

        cin >> a[i];

    }//??°?????\???

    for(i = n - 1;i >= 0;i--){

        if(i == 0)cout << a[i] << endl;
        
        else{cout << a[i] << " ";

        }

    }//??°?????????(????????§??????)

return 0;

}

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

#define int long long

using namespace std;

int par[5];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < 3; i++) {
    int x, y;
    cin >> x >> y;
    par[x]++;
    par[y]++;
  } 
  vector<int> t;
  for (int i = 1; i <= 4; i++) {
    t.push_back(par[i]);
  } 
  sort(t.begin(), t.end());
  if (t[0] == t[1] && t[1] == 1 && t[2] == t[3] && t[3] == 2) {
    cout << "YES" << "\n";
  }
  else {
    cout << "NO" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve() {
  ini(N);
  ins(S);

  ll opened = 0;
  ll left = 0;

  for (auto c : S) {
    if (c == '(') {
      opened++;
    } else {
      if (opened > 0) {
        opened--;
      } else {
        left++;
      }
    }
  }

  rep(i, left) cout << "(";
  cout << S;
  rep(i, opened) cout << ")";
  out();
}


Measured memory_bytes: 3600
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static final int MOD = (int)Math.pow(10,9)+7;

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int n = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();

        long ret = powMod(2, n) - 1 - combinationMod(n, a) - combinationMod(n, b);
        ret %= MOD;

        os.println(ret < 0 ? ret + MOD : ret);
    }


    static long powMod(long seed, long n) {
        long ret = 1;
        while(n > 0) {
            if((n & 1) == 1) ret = seed * ret % MOD;
            seed = seed * seed % MOD;
            n = n >> 1;
        }
        return ret;
    }

    static long combinationMod(long n, long k) {
        long ret = 1;

        for(long i = n; i >= n-k+1; i--) {
            ret = ret * i % MOD;
//            System.out.println(i);
            BigInteger inv = new BigInteger(String.valueOf(n-i+1)).modInverse(BigInteger.valueOf(MOD));
            ret = ret * inv.longValue() % MOD;
        }

        return ret;
    }

}

Measured memory_bytes: 97396
#include <bits/stdc++.h>
using namespace std;
int N;
int main(){
	cin >> N;
	int arr[N];
	int mem[N];
	for (int i = 0; i < N; i++)
		cin >> arr[i];
	mem[0] = 0;
	mem[1] = abs(arr[0] - arr[1]);
	for (int i = 2; i < N; i++)
		mem[i] = min(abs(arr[i] - arr[i - 1]) + mem[i - 1], abs(arr[i] - arr[i - 2]) + mem[i - 2]);
	cout << mem[N-1] << "\n";
}


Measured memory_bytes: 4412
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let s: String = read();
    let s: Vec<usize> = s.into_bytes().into_iter().map(|u| (u - 'a' as u8) as usize).collect();

    let mut ans = 0;
    for i in 1..n {
        let mut left: i32 = 0;
        let mut right: i32 = 0;
        for j in 0..i {
            left |= 1<<s[j];
        }
        for j in i..n {
            right |= 1<<s[j];
        }
        ans = max(ans, (left & right).count_ones());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    int n, r0;
    cin >> n;
    cin >> r0;
    int ans = -INF, rmin = r0;
    for(int i=1; i < n; i++){
        int r;
        cin >> r;
        chmax(ans, r-rmin);
        chmin(rmin, r);
    }
    cout << ans << endl;
    return 0;
}


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

const int DIM = 1e5 + 5;

int arr[DIM];

int main( void ) {
    
    int k, t;
    cin >> k >> t;
    
    for( int i = 1; i <= t; i ++ )
        cin >> arr[i];
    
    sort( arr + 1, arr + t + 1 );
    cout << max( 0, arr[t] - (k - arr[t] + 1) ) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <queue>

using namespace std;

int H, W;
char map[1000][1000];

struct Point{
    int x;
    int y;
    int depth;
};

queue<Point> que;

int is_white(int h, int w){
    if(h < 0 || h >= H) return 0;
    if(w < 0 || w >= W) return 0; 
    if(map[h][w] == '#') return 0;

    map[h][w] = '#';
    return 1;
}

int to_black(){
    int depth = 0;
    while(!que.empty()){
        Point p = que.front();
        que.pop();
        depth = p.depth;
        map[p.x][p.y] = '#';

        if( is_white(p.x + 1, p.y) ){
            Point q = p;
            q.x++;
            q.depth ++;
            que.push(q);
        }
        if( is_white(p.x - 1, p.y) ){
            Point q = p;
            q.x--;
            q.depth ++;
            que.push(q);
        }
        if( is_white(p.x, p.y + 1) ){
            Point q = p;
            q.y++;
            q.depth ++;
            que.push(q);
        }
        if( is_white(p.x, p.y - 1) ){
            Point q = p;
            q.y--;
            q.depth ++;
            que.push(q);
        }

    }

    cout << depth << endl;
}



int main(){

    cin >> H >> W;
    Point p;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cin >> map[h][w];
            if(map[h][w] == '#'){
                p.x = h;
                p.y = w;
                p.depth = 0;
                que.push(p);
            }
        }
    }
    
    to_black();


}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;


int main(){
	int a,b,c;
	cin>>a>>b>>c;
	string ans;
	if(a<=c&&c<=b) ans="Yes";
	else ans="No";
	p(ans);
	return 0;
}


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

int main()
{
    char ballA[15], ballB[15], input[15];
    int numBallA, numBallB;

    scanf("%s %s", ballA, ballB);
    scanf("%d %d%*c", &numBallA, &numBallB);
    scanf("%s", input);

    if (strcmp(input, ballA) == 0)
    {
        numBallA--;
    } else if (strcmp(input, ballB) == 0)
    {
        numBallB--;
    }

    printf("%d %d", numBallA, numBallB );

    return 0;
}

Measured memory_bytes: 1684
#include<stdio.h>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<stack>
#include<iostream>
using namespace std;
int main(){
	int n,a[200005];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int maxl=-1e9,minw=a[0];
	for(int i=1;i<n;i++){
		maxl=max(maxl,a[i]-minw);
		minw=min(minw,a[i]);
	}
	cout<<maxl<<endl;
	return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int > A(N), B(N), C(N-1);
  int ans = 0;
  rep(i,N) cin >> A.at(i);
  rep(i,N){
    cin >> B.at(i);
    ans += B.at(i);
  }
  rep(i,N-1) cin >> C.at(i);

  for(int i = 1; i < N; i++){
    if( A.at(i-1) != N && A.at(i) - 1 == A.at(i-1)){
      ans += C.at(A.at(i-1)-1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
l = list(int(input())for i in range(N))
ans = float('inf')

def dfs(x,a,b,c):
    if x == N:
        return (abs(a-A) + abs(b-B) + abs(c-C) -30) if min(a,b,c)> 0 else float('inf')
    ret0 = dfs(x+1,a,b,c)
    ret1 = dfs(x+1,a+l[x],b,c)+10
    ret2 = dfs(x+1,a,b+l[x],c)+10
    ret3 = dfs(x+1,a,b,c+l[x])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std ;

int main(){
    std::ios_base::sync_with_stdio(0);  cin.tie(NULL);  cout.tie(NULL);
    int N, L ;
    cin >> N >> L ;
    vector<string> words(N) ;
    for (int i = 0; i < N && cin >> words[i]; i++);
    sort(words.begin(), words.end());
    for (int i = 0; i < N && cout << words[i]; i++) ;
    return 0 ;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

const int M = int(1e9)+7;
ll f(int x){
	ll ret=1;
	for(int i=1; i<=x; ++i) ret=ret*i%M;
	return ret;
}

int main()
{
	int n, m;
	read(n, m);
	if(m == n-1){
		printf("%lld\n", f(n)*f(m)%M);
	} else if(m == n){
		printf("%lld\n", 2*f(n)*f(m)%M);
	} else if(m == n+1){
		printf("%lld\n", f(n)*f(m)%M);
	} else puts("0");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

int main(){
    int X, A;
    cin >> X >> A;
    if(X < A) cout << 0 << endl;
    else      cout << 10 << endl;

    return 0;
}

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

int n,x,maxx;
char s;

int max(int a,int b)
{
	return(a>b?a:b);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		switch(s)
		{
			case 'I':	
					x+=1;
					break;
			case 'D':
					x-=1;
					break;
		}
		maxx=max(maxx,x);
	}
	cout<<maxx;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;

int N;
string s;
string si;
string t;
string tj;

int ans=0;

int main()
{

	cin >> N;
	cin >> s;
	cin >> t;
	for(int i=0; i<N; i++){
		for (int j=0; j<N-i; j++){
			si=s[i+j];
			tj=t[j];
			if (si==tj) {
				ans++;
				if (j==N-i-1){
					cout << N+N-ans<<endl;
					return 0;
				}
			}
			else {
				ans=0;
				break;
			}
		}
	}
	cout << N+N-ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self._bit = [0] * size
        self._size = size

    def add(self, i, w):
        """
        i 番目に w を加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= self._size:
            self._bit[x - 1] += w
            x += x & -x

    def sum(self, i):
        """
        0 番目から i 番目までの合計
        :param int i:
        :return:
        """
        ret = 0
        x = i + 1
        while x > 0:
            ret += self._bit[x - 1]
            x -= x & -x
        return ret

    def __len__(self):
        return self._size


N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
A = np.array(A, dtype=int)
ans = np.zeros(N, dtype=int)

# for i in range(N):
#     if A[i] <= 0:
#         continue
#     ans[i] = np.minimum(A, A[i]).sum()
#     A = np.maximum(0, A - A[i])
# print(ans)

counts = Counter(A)
counts[0] = 0
counts[IINF] = 0
keys = list(sorted(counts.keys()))

ki = 0
cnt = 0
s = 0
for i in range(N):
    if A[i] - s <= 0:
        continue
    m = A[i]
    # s 以上 m 以下のやつの合計
    p = s
    while keys[ki] <= m:
        ans[i] += (keys[ki] - p) * (N - cnt)
        p = keys[ki]
        cnt += counts[keys[ki]]
        ki += 1

    s = A[i]

print(*ans, sep='\n')
# [10  7  0  4  0  3  0  2  3  0]


Measured memory_bytes: 32544
#include <stdio.h>
int f[60005];
int main()
{
	for (int x = 1;x<=100;x++)
		for (int y = 1;y<= 100;y++)
			for (int z = 1;z <= 100;z++)
			{
				int ans = x*x+y*y+z*z+x*y+y*z+x*z;
				f[ans]++;
			}
	int n;
	scanf("%d",&n);
	for (int i = 1;i<= n;i++)
		printf("%d\n",f[i]);
	return 0;
}

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

int n;
int a[1000100];
vector<int> prime;
bool setwise_coprime = 0;
bool not_prime[1010];
bool prime_has[1010];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i, n) cin >> a[i];
	int g = 0;
	rep(i, n) g = __gcd(g, a[i]);
	if(g == 1) setwise_coprime = 1;
	if(!setwise_coprime){
		cout << "not coprime" << endl;
		return 0;
	}
	for(int i = 2; i <= 1000; i++){
		if(!not_prime[i]) prime.push_back(i);
		for(int j = i+i; j <= i*i && j <= 1000; j += i){
			not_prime[j] = 1;
		}
	}
	rep(i, n){
		rep(j, prime.size()){
			if(a[i] % prime[j] == 0){
				if(prime_has[j]){
					cout << "setwise coprime" << endl;
					return 0;
				}
				prime_has[j] = 1;
				while(a[i] % prime[j] == 0){
					a[i] /= prime[j];
				}
			}
		}
	}
	sort(a, a+n);
	int pos = 0;
	while(pos < n && a[pos] == 1) pos++;
	for(; pos < n-1; pos++){
		if(a[pos] == a[pos+1]){
			cout << "setwise coprime" << endl;
			return 0;
		}
	}
	cout << "pairwise coprime" << endl;
	return 0;
}

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

int A[105];
int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    int sum, minsum = 10000000;
    for (int i = -100; i <= 100; i++) {
        sum = 0;
        for (int j = 0; j < N; j++) {
            sum += (A[j] - i) * (A[j] - i);
        }
        if (sum < minsum) {
            minsum = sum;
        }
    }
    printf("%d\n", minsum);
    return 0;
}

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

using namespace std;

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




Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 998244353;
ll mul(ll a, ll b){
    return ((a % mod) * (b % mod)) % mod;
}
ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b){
        d = extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else{
        x = 1;
        y = 0;
    }
    return d;
}
ll modi(ll a){
    ll x, y;
    extgcd(a,mod,x,y);
    return (mod+x%mod)%mod;
}
ll tmp[300010];
ll N, A, B, K, ans = 0;
ll pat(ll x){
    ll res = mul(tmp[N], modi(tmp[x]));
    res = mul(res, modi(tmp[N-x]));
    return res;
}

int main(){
    tmp[0] = 1;
    for(ll i = 1; i <=300005; i++){
        tmp[i] = mul(tmp[i-1], i);
    }
    cin>>N>>A>>B>>K;
    for(ll a = 0; a <= N; a++){
        if((K-a*A)%B)continue;
        ll b = (K-a*A)/B;
        if(b>N || b< 0)continue;
        ans = (ans + mul(pat(a), pat(b))) % mod;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2560
N = int(input())
H = list(map(int,input().split()))
count = 0
ans = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    count += 1
  else:
    if ans < count:
      ans = count
    count = 0
if ans < count:
      ans = count
print(ans)

Measured memory_bytes: 14224
//#include "std_lib_facilities.h"
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;

int main(){
	int n;
	scanf("%d", &n);
	int arr[n + 1];
	int vis[n + 1] = { 0 };
	for (int i = 1; i <= n; i++)
		scanf("%d", &arr[i]);
	int ans = 0, press = 1, pos = 1;
	while (pos != 2) {
		if (vis[pos])
			return printf("-1\n"), 0;
		vis[pos] = 1;
		pos = arr[press];
		press = pos;
		ans++;

	}

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

}



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

int main(void){
  char c;
  int md9 = 0;
  
  while (cin >> c){
    md9 += (c-'0');
    md9 %= 9;
  }
  cout << (md9==0?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    int N,count1=0,count2=0;
    string c;
    cin >> N;
    cin >> c;
    for(int i=0;i<c.length();i++){
        if(c[i] == 'R') count1++;
    }
    for(int i=0;i<count1;i++){
        if(c[i] == 'R') count2++;
    }
    cout << count1-count2;
}

Measured memory_bytes: 3692
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
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;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	string s;
	cin>>s;
	int c=0;
	rep(i,4)if(s[i]=='2')c++;
	cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll a = in(),b = in(),c = in();
    cout << (c-a-b > 0 && (a+b-c)*(a+b-c)>4*a*b ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    Array.Sort(nums);
    long sum = 0;
    for(int i = 0; i < n-1; i++) sum += nums[i];
		Console.WriteLine((sum > nums[n-1]?"Yes":"No"));
	}
}

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

int main() {
	int a,b;
	while(1){
		cin>>a>>b;
		if (a==0 && b==0){break;}
		for(int i=0; i<a; i++){
			for(int j=0; j<b; j++){
				if((i+j)%2==0){
					cout<<"#";
				}else{
					cout<<".";
				}
		
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>

int main()
{
	std::string str1,str2, str3;
	std::cin >> str1;
	std::cin >> str2;
	std::cin >> str3;

	std::cout << str1[0] << str2[1] << str3[2] << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	cin>>a>>b;
	// ll x=min(a,b),y=max(a,b);
	ll g=__gcd(a,b);
	// cout<<g<<endl;
	ll cnt=1;
	ll n=g;
	if(n%2==0)
	{
		// cout<<2<<endl;
		cnt++;
		while(n%2==0)
			n/=2;
	}
	// cout<<n2<<endl;
	for(ll i=3;i*i<=g;i+=2)
	{
		// cout<<i<<endl;
		if(n%i==0)
		{
			// cout<<i<<endl;
			cnt++;
			while(n%i==0)
				n/=i;
		}
	}
	if(n>2)
		cnt++;
	cout<<cnt;
}

Measured memory_bytes: 256