akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define Maxn 207
#define Maxm 80007
int n;
int last[Maxm],pre[Maxm],other[Maxm],cnt=0;
int col[Maxn];
char s[Maxn][Maxn];
bool flag=true;
bool vis[Maxn];
int que[Maxn];
void insert(int u,int v)
{
    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
}
void pre_dfs(int u)
{
    for (int q=last[u];q;q=pre[q])
    {
        int v=other[q];
        if (col[v]==-1)
        {
            col[v]=col[u]^1;
            pre_dfs(v);
        } else if (col[u]==col[v]) flag=false;
    }
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%s",s[i]+1);
        for (int j=1;j<=n;j++)
            if (s[i][j]=='1') insert(i,j);
    }
    memset(col,-1,sizeof(col));
    col[1]=0;
    pre_dfs(1);
    if (!flag)
    {
        printf("%d\n",-1);
        return 0;
    }
    int ans=2;
    for (int i=1;i<=n;i++)
    {
        memset(vis,false,sizeof(vis));
        memset(col,0,sizeof(col));
        int tmp=1;
        int lx=0,rx=0;
        que[++rx]=i;
        vis[i]=true;
        col[i]=1;
        while (lx<rx)
        {
            int u=que[++lx];
            for (int q=last[u];q;q=pre[q])
            {
                int v=other[q];
                if (!vis[v])
                {
                    vis[v]=true;
                    col[v]=col[u]+1;
                    tmp=max(tmp,col[v]);
                    que[++rx]=v;
                }
            }
        }
        ans=max(ans,tmp);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4020
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}



int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) { cout << 0 << endl; return 0;}
	if (A == B && B == C) { cout << -1 << endl; return 0; }
	int cnt = 0;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		int a = A, b = B, c = C;
		A = (b + c) / 2; B = (a + c) / 2; C = (a + b) / 2;
		cnt++;
	}
	p(cnt);
}

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

#define P 1000000007

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(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
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;}

#define nextInt nextpint
int main(void){
	int N = nextInt();
	int *A = calloc(N, sizeof(int));
	for(int i=0; i<N; i++){
		A[i] = nextInt();
	}
	qsort(A, N, sizeof(int), comp);
	long answer = 0;
	int l = N/2;
	for(int i=N-1; i>=l; i--){
		answer += A[i]*2;
	}
	for(int i=0; i<l; i++){
		answer -= A[i]*2;
	}
	if(N%2==0){
		answer += A[l-1];
		answer -= A[l];
	}else{
		if(A[l-1]+A[l+1] > A[l]*2){
			answer += A[l-1];
			answer -= A[l]*3;
		}else{
			answer -= A[l]+A[l+1];
		}
	}
	printf("%ld\n", answer);
}


Measured memory_bytes: 892
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    s = SI()
    ds = s + s
    t = SI()

    z = [0] * 26
    nt = [[] for _ in range(len(ds))]

    for i in range(len(ds),0,-1):
        z[ord(ds[i-1])-ord('a')] = i
        nt[i-1] = copy.copy(z)

    rev = 0
    a = 0
    for x in t:
        x = ord(x) - ord('a')
        a = nt[a][x]
        if a == 0:
            print(-1)
            return
        if a >= len(s):
            a -= len(s)
            rev += 1
    print(rev*len(s)+a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 105928
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }


void main() {
    string[] a;
    int n, m; readf("%d %d\n",&n, &m);
    foreach (i; 0..n) {
        string s = readln.chomp;
        if (s.count('.') != m)
            a ~= s;
    }
    string[] b;
    foreach (x; 0..m) {
        bool f = true;
        string t;
        foreach(y; 0..a.length) {
            f &= a[y][x] == '.';
            t ~= a[y][x];
        }
        if (f) continue;
        b ~= t;
    }
    
    foreach (x; 0..b[0].length) foreach (y; 0..b.length) {
        write(b[y][x]);
        if (y == b.length - 1) writeln();
    }
}


Measured memory_bytes: 380
#include <stdio.h>
#define MAX 100000
#define SEN 2000000000

typedef struct{
  char suit;
  int value;
}Card;

Card L[MAX/2+2], R[MAX/2+2];

void merge(Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(i=0;i<n2;i++)
    R[i]=A[mid+i];

  L[n1].value=R[n2].value=SEN;

  i=j=0;

  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergesort(Card A[], int n, int left, int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int part(Card A[], int n, int p, int r){
  int i, j;
  Card t, x;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

void quick(Card A[], int n, int p, int r){
  int q;
  if(p<r){
    q=part(A,n,p,r);
    quick(A,n,p,q-1);
    quick(A,n,q+1,r);
  }
}

int main(){
  int n, i, v;
  Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d", S, &v);

    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }

  mergesort(A,n,0,n);
  quick(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)
      stable=0;
  }
  if(stable==1)
    printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  return 0;
}

Measured memory_bytes: 2956
#include<bits/stdc++.h>
using namespace std;
int main()
{
 ios::sync_with_stdio(false);
 cin.tie(0);
 int n; cin>>n;
 int k=n%10;
 if(k==0||k==1||k==6||k==8)
 cout<<"pon"<<'\n';
 else if(k==3)
 cout<<"bon"<<'\n';
 else
 cout<<"hon"<<'\n';
 return 0;
}




Measured memory_bytes: 3640
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1 + a2*t2 == b1*t1 + b2*t2:
    print("infinity")
else:
    A = a1*t1 + a2*t2
    B = b1*t1 + b2*t2
    M1,m1 = max(a1*t1,b1*t1),min(a1*t1,b1*t1)
    M2,m2 = max(A,B),min(A,B)
    gap1,gap2 = M1-m1,M2-m2
    Mv,mv = max(a1,b1),min(a1,b1)
    vgap = Mv-mv
    possible = vgap*t1
    count = possible//gap2
    if possible%gap2 == 0:
        pitta = 1
    else:
        pitta = 0
    if (a1*t1 > b1*t1 and A > B) or (a1*t1 < b1*t1 and A < B):
        print(0)
    elif (a1*t1 > b1*t1 and A < B) or (a1*t1 < b1*t1 and A > B):
        if pitta == 1:
            print(1+count*2-1)
        else:
            print(1+count*2)

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

// MOD p でいくつクラス
#define MOD 1000000007 // 10^9 + 7
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		mll c = val * u; // この計算でoverflowしないか？
		val = c.val;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	unsigned long long getVal() {
		return val;
	}
	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD

map<int,map<int, mll> > F;
vector<mll> Ki(500001, 0);

mll combi(int a, int b) {
	if (a == b) return mll(1);
	return Ki[a] / (Ki[a - b] * Ki[b]);
}

int main() {

	int N, M;
	cin >> N >> M;

	Ki[0] = 1;
	for (int i = 1; i <= M; i++) {
		Ki[i] = Ki[i - 1] * mll(i);
	}

	mll ans = 0;
	for (int k = 0; k <= N; k++) {
		ans += combi(N, k) * (Ki[M] / Ki[M - k]) * (Ki[M - k] / Ki[M - N]) * (Ki[M - k] / Ki[M - N]) * mll(-1).pow(k);
	}

	cout << ans.getVal() << endl;
	return(0);
}


Measured memory_bytes: 7108
#include <stdio.h>
#include <stdlib.h>
#define ll int
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

//ワーシャルフロイド
//頂点数（と隣接行列）を引いて全点間最短距離を返す
//O(V^3)
//*
ll cost[300][300];
ll dddd[300][300];
void waasharuhuroido(ll n){
	rep(i,0,n)rep(j,0,n)dddd[i][j]=cost[i][j];//辺が無いところはINFにする前処理が必要
	rep(k,0,n)rep(i,0,n)rep(j,0,n)dddd[i][j]=min(dddd[i][j],dddd[i][k]+dddd[k][j]);
}

int main(){
	rep(i,0,300)rep(j,0,300)cost[i][j]=i==j?0:1e9;
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,m){
		int x,y;
		scanf("%d%d",&x,&y);
		cost[x-1][y-1]=1;
	}
	waasharuhuroido(n);
	
	rep(i,0,n){
		int cnt=0;
		rep(j,0,n)if(dddd[i][j]!=1e9&&dddd[j][i]!=1e9)printf(cnt++?" %d":"%d",j+1);
		puts("");
	}
}


Measured memory_bytes: 2480
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N, X;
    std::cin >> N >> X;

    int64_t count = 1;
    int64_t position = 0;
    for (int64_t i = 0; i < N; ++i) {
        int64_t L;
        std::cin >> L;
        position += L;
        if (position > X) break;
        count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main () {
  int i, j, k, l, n;
  int p[101], m[101][101];
   
  scanf("%d", &n); 
  for(i = 1; i <= n; i++){
    scanf("%d %d", &p[i - 1], &p[i]);
  }
   
  for(i = 0; i <= n; i++){
    m[i][i] = 0;
  }
   
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      int j = i+l-1;
      m[i][j] = 10000000000;
       
      for(k = i; k <= j-1; k++){
        if( m[i][j] < m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]){
          m[i][j] = m[i][j] ;
        } else {
          m[i][j] = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        }
      }
    }
  }
   
  printf("%d\n", m[1][n]);
   
  return 0;
}

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

void mD(char C, int *D) {
	switch (C) {
		int t;
	case 'N':
		t = D[0]; D[0] = D[1]; D[1] = D[5]; D[5] = D[4]; D[4] = t;
		break;
	case 'S':
		t = D[0]; D[0] = D[4]; D[4] = D[5]; D[5] = D[1]; D[1] = t;
		break;
	case 'E':
		t = D[0]; D[0] = D[3]; D[3] = D[5]; D[5] = D[2]; D[2] = t;
		break;
	case 'W':
		t = D[0]; D[0] = D[2]; D[2] = D[5]; D[5] = D[3]; D[3] = t;
		break;
	case 'R':
		t = D[1]; D[1] = D[3]; D[3] = D[4]; D[4] = D[2]; D[2] = t;
		break;
	case 'L':
		t = D[1]; D[1] = D[2]; D[2] = D[4]; D[4] = D[3]; D[3] = t;
		break;
	}
	return;
}

/* サイコロが一致していたら1、それ以外は0 */
int cD(int *D1, int *D2) {
	int d;
	/* すべての面が必ず1度は上面にくる回転 */
	char C[] = { ' ','N','N','N','E','E','E' }; int c;
	/* 必ずC[]の要素数だけ繰り返す。
	同じ数字が複数の面に存在する可能性があるので */
	for (c = 0; c < 7; c++) {
		mD(C[c], D2);
		/* サイコロ1と2の上面の数字が一致したら…… */
		if (D1[0] == D2[0]) {
			/* サイコロを右回転させて、すべての面の数字が一致する
			ポジションがないか調べる */
			for (d = 0; d < 6; d++) {
				mD('R', D2);
				/* ポジションがあったらフラグを立てる */
				if (D1[1] == D2[1]) {
					if ((D1[2] == D2[2]) && (D1[3] == D2[3]) && (D1[4] == D2[4]) && (D1[5] == D2[5]))
						return 1;
				}
			}
		}
	}
	return 0;
}

int main(void) {
	int D[101][6], d, N, n;
	scanf("%d\n", &N);
	/* サイコロ初期値の設定 */
	for (n = 0; n < N; n++)
		for (d = 0; d < 6; d++)
			scanf("%d", &D[n][d]);

	/* サイコロの一致判定 */
	for (n = 0; n < (N - 1); n++) {
		int m;
		for (m = n + 1; m < N; m++) {
			if (cD(D[n], D[m])) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n;
vector<bool> b[200001];

bool can_add(vector<bool> og, vector<bool> ad)
{
    rep(i, 20)
    {
        if(og[i] && ad[i])
            return false;
    }

    return true;
}

int main(void)
{
    cin >> n;
    rep(i, n)
    {
        lin a;
        cin >> a;

        lin e = 1;
        rep(j, 20)
        {
            b[i].push_back((a / e % 2) == 1);
            e *= 2; 
        }
    }

    vector<bool> bb;
    rep(i, 20)
    {
        bb.push_back(false);
    }

    lin bg = 0;
    lin res = 0;

    rep(i, n)
    {
        while(!can_add(bb, b[i]))
        {
            rep(j, 20)
            {
                if(b[bg][j])
                    bb[j] = false;
            }
            bg++;
        }

        rep(j, 20)
        {
            if(b[i][j])
                bb[j] = true;
        }

        //cout << i << " - " << bg << endl;

        res += (i - bg + 1);
    }

    cout << res << endl;

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int prea;
    cin>>prea;
    int res=0;
    for(int i=0;i<n-1;i++){
        int a;
        cin>>a;
        if(prea==a){
            res++;
            prea=-1;
        }
        else{
            prea=a;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int main(){
    string a, b;
    cin >> a >> b;
    if(a.length() > b.length()){
        cout << "GREATER";
    }else if(a.length() < b.length()){
        cout << "LESS";
    }else{
        if(a < b){
            cout << "LESS";
        }else if(a > b){
            cout << "GREATER";
        }else{
            cout << "EQUAL";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// value


void solve() {

	int P, Q, R;
	cin >> P >> Q >> R;

	cout << min({P + Q, Q + R, R + P}) << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 892
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int W = GetInt();
		int[] w = new int[N];
		long[] v = new long[N];
		for(int i = 0; i < N; i++)
		{
			w[i] = GetInt();
			v[i] = GetLong();
		}

		long[,] dp = new long[N + 1, W + 1];
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j <= W; j++)
			{
				dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j]);

				if(j + w[i] > W)
					continue;
				dp[i + 1, j + w[i]] = Math.Max(dp[i + 1, j + w[i]], dp[i, j] + v[i]);
			}
		}

		long max = long.MinValue;
		for(int i = 0; i <= W; i++)
			max = Math.Max(max, dp[N, i]);
		Console.WriteLine(max);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 

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

  string s;
  cin >> s;
  int n = sz(s);
  rep(i,n) {
    s.erase(sz(s)-1);
    if(sz(s) % 2 == 1) continue;
    if(s.substr(0,sz(s)/2) == s.substr(sz(s)/2)) {
      cout << sz(s) << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;

using namespace std;


void solve(long long N, std::vector<long long> X){
    ll total = 0;
    ll min_t = 9e10;

    REP(i, 101) {
        total = 0;
        REP(j, N) {
            total += (X[j] - i) * (X[j] - i );
        }
        if(min_t > total) {
            min_t = total;
        }
    }
    cout << min_t << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


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

int main()
{
	int r = 0, d = 0, x = 0;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++)
	{
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a_list = list(map(int, input().split()))
a_list = sorted(a_list)

count = 0
for i in range(N):
  if x - sum(a_list[:i]) > 0:
    count += 1
  else:
    break
if x - sum(a_list[:count]) != 0:
  count += -1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace  std;
int dig (long long  x)
{
    int ans=0;
    while(x)
    {
        x/=10;
        ans++;

    }
    return  ans;
}


int main()
{
  int n;
  cin>>n;
vector <int> vec;
for(int i=0;i<n;i++)
{int x;
cin>>x;
vec.push_back(x);
}
int ans=0;
int cn=0;
for(int i=0;i<n-1;i++)
{
   // cout<<count
    if(vec[i]<vec[i+1]) {
        if (cn > ans)
            ans = cn;
        cn = 0;
    }
    else
        cn++;
}
if(cn>ans)
    ans=cn;
cout<<ans;
}


Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

typedef unsigned long long ll;
int n,K;
int xf[100],xt[100];
int yf[100],yt[100];
int zf[100],zt[100];
vector<int> vx;
vector<int> vy;
vector<int> vz;
int cnt[201][201][201];

void zatu(){
	for(int i=0;i<n;i++){
		vx.push_back(xf[i]);
		vx.push_back(xt[i]);
		vy.push_back(yf[i]);
		vy.push_back(yt[i]);
		vz.push_back(zf[i]);
		vz.push_back(zt[i]);
	}
	sort(vx.begin(),vx.end());
	vx.erase(unique(vx.begin(),vx.end()),vx.end());
	sort(vy.begin(),vy.end());
	vy.erase(unique(vy.begin(),vy.end()),vy.end());
	sort(vz.begin(),vz.end());
	vz.erase(unique(vz.begin(),vz.end()),vz.end());	
	for(int i=0;i<n;i++){
		//printf("%d %d %d %d %d %d\n",xf[i],xt[i],yf[i],yt[i],zf[i],zt[i]);
		xf[i]=find(vx.begin(),vx.end(),xf[i])-vx.begin();
		xt[i]=find(vx.begin(),vx.end(),xt[i])-vx.begin();
		yf[i]=find(vy.begin(),vy.end(),yf[i])-vy.begin();
		yt[i]=find(vy.begin(),vy.end(),yt[i])-vy.begin();
		zf[i]=find(vz.begin(),vz.end(),zf[i])-vz.begin();
		zt[i]=find(vz.begin(),vz.end(),zt[i])-vz.begin();
		//printf("%d %d %d %d %d %d\n",xf[i],xt[i],yf[i],yt[i],zf[i],zt[i]);
	}
}

int main(void){
	scanf("%d%d",&n,&K);
	for(int i=0;i<n;i++){
		scanf("%d%d%d%d%d%d",&xf[i],&yf[i],&zf[i],&xt[i],&yt[i],&zt[i]);
	}
	zatu();
	for(int i=0;i<n;i++){
		for(int j=xf[i];j<xt[i];j++){
			for(int k=yf[i];k<yt[i];k++){
				for(int l=zf[i];l<zt[i];l++){
					cnt[j][k][l]++;
				}
			}
		}
	}
	ll res=0;
	for(int i=0;i<vx.size()-1;i++){
		for(int j=0;j<vy.size()-1;j++){
			for(int k=0;k<vz.size()-1;k++){
				if(cnt[i][j][k]>=K){
					res+=(ll)(vx[i+1]-vx[i])*(vy[j+1]-vy[j])*(vz[k+1]-vz[k]);
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

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

int main () {
    string S, T;
    int mcnt = 0;
    cin >> S >> T;
    rep(i, S.size() - T.size() + 1) {
        int cnt = 0;
        rep(j, T.size()) {
            if(S[i+j] == T[j]) {
                cnt++;
            }
        }
        if(mcnt < cnt) {
            mcnt = cnt;
        }
    }
    cout << T.size() - mcnt << endl;
    return 0;
}

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

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const int MAX_N=2e5+2;

map<LL,int> zip;
LL unzip[MAX_N];

int compress(vector<LL> x) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(),x.end()),x.end());
    for(int i = 0; i < x.size(); i++){
        zip[x[i]] = i+1;
        unzip[i] = x[i];
    }
    return x.size();
}

int bit[MAX_N+1];
LL n;

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}


int add(int i,int x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
    return 0;
}

int main(){
    LL N,K;
    cin>>N>>K;
    vector<LL>b(N+1);
    b[0]=0;
    REP(i,N){
        LL a;
        cin>>a;
        b[i+1]=b[i]+a-K;
    }
    n=MAX_N;
    compress(b);
    CLR(bit);
    LL ans=0;
    REP(i,N+1){
        //cout<<"!"<<" "<<b[i]<<endl;
        ans+=sum(zip[b[i]]);
        //cout<<"!!"<<endl;
        add(zip[b[i]],1);
    }
    cout<<ans<<endl;
    return 0;
}

/*

*/

Measured memory_bytes: 17408
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n; cin >> n;
	while (n--) {
		string s, t; cin >> t >> s;
		int m = s.length();
		reverse(t.begin(), t.end());
		for (int j = 0; j < t.size(); j++)
			switch (t[j]) {
			case 'J':
				s = s[m - 1] + s.substr(0, m - 1);
				break;
			case 'C':
				s = s.substr(1) + s[0];
				break;
			case 'E':
				if (m % 2 == 0) s = s.substr(m / 2) + s.substr(0, m / 2);
				else s = s.substr(m / 2 + 1) + s[m / 2] + s.substr(0, m / 2);
				break;
			case 'A':
				reverse(s.begin(), s.end());
				break;
			case 'P':
				for (int i = 0; i < m; i++)
					if (s[i] >= '0' && s[i] <= '9')
						s[i] = '0' + (s[i] - '0' + 9) % 10;
				break;
			case 'M':
				for (int i = 0; i < m; i++)
					if (s[i] >= '0' && s[i] <= '9')
						s[i] = '0' + (s[i] - '0' + 1) % 10;
				break;
			}
		cout << s << endl;
	}
}

Measured memory_bytes: 1208
#include <stdio.h>

int main()
{
	int N;
	int cnt = 0;

	scanf("%d", &N);

	for(int i=1; i<=N; i++){
		if(1 == i%2)    cnt++;
	}

	printf("%f\n", (double)cnt/(double)N);

	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	static Scanner sc = new Scanner(System.in);
	
	static int input, max=0;
	static int counter[] = new int[100];
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		//出現カウンタ初期化
		Arrays.fill(counter, 0);
		
		while(read()){
		}
		
		solve();
	}
		
	public static boolean read(){
		if(!sc.hasNext()) return false;
		
		input = sc.nextInt();
		counter[input-1]++;
		
		return true;
	}

	public static void solve(){
				
		for(int i=0; i < counter.length; i++){
			if(max < counter[i]){
				max = counter[i];
			}
		}
		for(int i=0; i < counter.length; i++){
			if(max == counter[i]){
				System.out.println(i+1);
			}
		}
	}
}

Measured memory_bytes: 18128
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B >> C;
    if (A <= C && C <= B) {
        cout << "Yes" << endl;
    } else
        cout << "No" << endl;
}

Measured memory_bytes: 3576
import sys
n=int(input())
plan=[[0,0,0]]
for i in range(n):
    plan.append(list(map(int,input().split())))
for i in range(n):
    dt=abs(plan[i][0]-plan[i+1][0])
    dx=abs(plan[i][1]-plan[i+1][1])
    dy=abs(plan[i][2]-plan[i+1][2])
    if dt<dx+dy:
        print('No')
        sys.exit()
    if abs(dx+dy-dt)%2!=0:
        print('No')
        sys.exit()
print('Yes')
    


Measured memory_bytes: 27324
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> ya;
int main()
{
	int n,m,out=0;
	cin>>n>>m;
	for(int i=1;i*i<=m;i++){
		if(m%i==0) ya.pb(i),ya.pb(m/i);
	}
	rep(i,ya.size()){
		if(ya[i]>=n) out=max(out,m/ya[i]);
	}
	cout<<out<<endl;
}


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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (S == U)
        A--;
    if (T == U)
        B--;
    cout << A << " " << B << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  set<int> st1,st2,st3;
  st1.insert(1);
  st1.insert(3);
  st1.insert(5);
  st1.insert(7);
  st1.insert(8);
  st1.insert(10);
  st1.insert(12);
  st2.insert(4);
  st2.insert(6);
  st2.insert(9);
  st2.insert(11);
  if((st1.count(a)&&st1.count(b))||(st2.count(a)&&st2.count(b))) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int K; cin>>K;
	ll ret=0;
	for (int a=1; a<=K; a++)
		for (int b=1; b<=K; b++)
			for (int c=1; c<=K; c++)
				ret+=__gcd(a,__gcd(b,c));
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    return len(set(S))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(solve(N, S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 35564
N = int(input())
c = input()
Wcou = 0
Rcou = 0
ans = 0
for i in range(N):
    if(c[i] == "W"):
        Wcou += 1
    else:
        Rcou += 1
tmp = ""
for i in range(Rcou):
    tmp = tmp + "R"
for i in range(Wcou):
    tmp = tmp + "W"
for i in range(N):
    if(tmp[i] != c[i]):
        ans += 1
print(str(ans//2))

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

int main(){
  string s;
  while(cin >> s){
    int joi = 0,ioi = 0;
    for(int i=0;i<s.size()-2;i++){
      if(s.substr(i,3) == "JOI") joi++;
      if(s.substr(i,3) == "IOI") ioi++;
    }
    cout << joi << endl << ioi << endl;
  }
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p.at(i);
    rep(i,n) cin >> q.at(i);
    vector<int> a(n);
    rep(i,n) a.at(i) = i+1;
    map<vector<int>, int> mp;
    do {
        mp[a] = mp.size(); // mp[123] = 0, ,mp[132] = 1,...というふうに連想配列の要素の数が増えるのでsizeは順番を表す事ができる。
    }while(next_permutation(a.begin(), a.end()));
    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
        return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int k;
	cin>> k;
	ll pref[n+1]={0};
	ll dp[n+1]={0};
	dp[1]=1;
	pref[1]=1;
	ll mod = 998244353;
	pair<int,int> con[k];
	for(int i=0;i<k;i++){
		cin>>con[i].first>>con[i].second;
	}
	for(int i = 2;i<=n;i++){
		for(int j=0;j<k;j++){
			if(i-con[j].first<=0)continue;
			ll sum = pref[i-con[j].first];
			if(i-con[j].second-1>0){
				sum = (sum - pref[i-con[j].second-1] + mod)%mod;
			}
			dp[i] = (dp[i] + sum)%mod;
		}
		pref[i] = (dp[i] + pref[i-1])%mod;
	}
	cout<<dp[n];
	return 0;
}

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

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

    int max_divide_count = 0;
    int ans = 1;

    for (int i = 2; i <= n; i++) {
        int count = 0;
        int j = i;

        while (j % 2 == 0) {
            j /= 2;
            count++;
        }

        if (max_divide_count < count) {
            max_divide_count = count;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(10)





void solve() {

	int a, b;
	cin >> a >> b;
	cout << a * b << "\n";
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = Math.min(n, m / 2);
		m -= ans * 2;
		ans += m / 4;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
fn main () {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let p: Vec<_> = s.by_ref().take(n).map(|a| a.parse::<i32>().unwrap() - 1).collect();
	let q: Vec<_> = s.by_ref().take(n).map(|a| a.parse::<i32>().unwrap() - 1).collect();
	let fact = |i: u32| {
		if i == 0 { 1 }
		else {
			(2..i + 1).fold(1, |r, i| r * i)
		}
	};
	let f = |a: Vec<i32>| {
		let mut r: u32 = 0;
		let mut b: u32 = (1 << n) - 1;
		for a in a {
			b ^= 1 << a;
			r += (b & ((1 << a) - 1)).count_ones() * fact(b.count_ones());
		}
		r as i32
	};
	println!("{}", (f(p) - f(q)).abs());
}


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

typedef long long int ll;

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

    ll n;
    cin>>n;

    ll arr[n+1];
    map <ll,ll> mp;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        mp[arr[i]]++;
    }

    for(ll i=0;i<n;i++){
        mp[arr[i]]--;
        if(mp[arr[i]]==0){
            mp.erase(arr[i]);
        }
        auto x = mp.end();
        x--;
        cout<<x->first<<endl;
        mp[arr[i]]++;
    }

}


Measured memory_bytes: 10624
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1010,TOP=30;
int rec[N][2],d[N];
int n,m;
int Abs(int x){return x<0?-x:x;}
bool firstcheck(){
	for (int i=2;i<=n;++i)
		if ((Abs(rec[i][0]+rec[i][1])%2)^(Abs(rec[1][0]+rec[1][1])%2))
			return false;
	return true;
}
void solve(int x,int y){
	int val;
	for (int i=m;i>=1;--i){
		val=d[i];
		if (Abs(x)>=val){
			if (x<0) x+=val,printf("L");
			else x-=val,printf("R");
		}
		else if (Abs(y)>=val){
			if (y<0) y+=val,printf("D");
			else y-=val,printf("U");
		}
		else{
			if (Abs(x)>Abs(y)){
				if (x<0) x+=val,printf("L");
				else x-=val,printf("R");
			}
			else{
				if (y<0) y+=val,printf("D");
				else y-=val,printf("U");
			}
		}
	}
	printf("\n");
	if (x||y) printf("fish qwq\n");
}
void get_ans(){
	int flag=(Abs(rec[1][0]+rec[1][1])%2)^1;
	m=TOP+1+flag;
	printf("%d\n",m);
	int tot=m;
	for (int i=TOP;i>=0;--i,--tot) printf("%d ",1<<i),d[tot]=1<<i;
	if (flag) printf("1"),d[tot]=1;
	printf("\n");
	for (int i=1;i<=n;++i)
		solve(rec[i][0],rec[i][1]);
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%d%d",&rec[i][0],&rec[i][1]);	
	if (!firstcheck()) printf("-1\n");
	else{
		get_ans();
	}
}


Measured memory_bytes: 256
import numpy
import heapq
import math

N,M = list(map(int, input().split()))
data = [[]for _ in range(M)]
for _ in range(N):
    A,B = list(map(int, input().split()))
    if (A - 1) < M:
        data[A-1].append(-B)

rew = 0
heap=[]
for i in range(M):
    for rewo in data[i]:
        heapq.heappush(heap,rewo)
    if len(heap) > 0:
        r = heapq.heappop(heap)
        rew += -r

print(rew)
    
        


Measured memory_bytes: 32608
import collections
N = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
L = {key:(B[key] * (B[key] - 1) // 2) for key in B}
total = sum(L.values())
#print(f"A = {A}\nB = {B}\nL = {L}\ntotal = {total}")
[print(total if L[i] == 0 else total - L[i] + ((B[i] - 1) * (B[i] - 2) // 2)) for i in A]

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

int main() {
    int N;
    cin >> N;
    int l = 100001;
    ll v[l]{};
    ll A[N];
    ll s = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        v[A[i]]++;
        s += A[i];
    }
    int Q;
    cin >> Q;
    ll B[Q], C[Q];
    for (int i = 0; i < Q; i++) {
        cin >> B[i] >> C[i];
    }
    for (int i = 0; i < Q; i++) {
        ll e = C[i] * v[B[i]] - B[i] * v[B[i]];
        s += e;
        v[C[i]] += v[B[i]];
        v[B[i]] = 0;
        cout << s << "\n";
    }
    return 0;
}


Measured memory_bytes: 6700
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  for (ll i = 1; i <= n; ++i)
  {
    for (ll j = 1; j <= m; ++j)
    {
      if(j%10>=2 && j/10>=2 && (j/10)*(j%10)==i){ans++;}
    }
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& vec){
    os << "[";
    for(const auto& v : vec){
        os << v << ",";
    }
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int N,L;

int main(){
    cin >> N >> L;
    vector<string> S(N);
    rep(i,N) cin >> S[i];

    sort(ALL(S));
    rep(i,N) cout << S[i];
    cout << endl;
}


Measured memory_bytes: 764
def cross(x, y):
    return (x.conjugate() * y).imag

def is_parallel(x, y):
    if abs(cross(x, y)) < 1e-10:
        return True
    return False

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    a = complex(x2, y2) - complex(x1, y1)
    b = complex(x4, y4) - complex(x3, y3)    
    if is_parallel(a, b):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7672
#!/usr/bin/env python

n, m = map(int, input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

class UnionFind():
    def __init__(self, n): 
        self.n = n 
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def root(self, x): 
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # 圧縮経路
            return self.par[x]
            # return root(par[x]) # 圧縮しない場合

    def same(self, x, y): 
        return self.root(x) == self.root(y)

    def unite(self, x, y): 
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry: 
            return

        # par[rx] = ry # naiveな連結

        # 低い木を高い方にくっつける。
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.sizes[ry] += self.sizes[rx]
        else:
            self.par[ry] = rx
            self.sizes[rx] += self.sizes[ry]

        # rx木とry木の高さが同じならば、rx木を深くする。
        if self.rank[rx] == self.rank[ry]:
            self.rank[rx] += 1

    def size(self, x): 
        '''
        xが属するグループのサイズを返す
        (連結成分の大きさ)
        '''
        return self.sizes[self.root(x)]

    def connected(self):
        '''
        連結成分の数
        '''
        return len(set(self.par))

uf = UnionFind(n)
for i in range(m):
    uf.unite(a[i], b[i])
for i in range(n):
    _ = uf.root(i)

ans = uf.connected()-1
print(ans)


Measured memory_bytes: 23124
N,K=map(int,input().split())
ans=0
mod=(10**9)+7
def ABC(N,K):
    mod=(10**9)+7
    a=((K-1)*K)//2
    b=(K*(2*N-K+1))//2
    s=b-a+1
    return s%mod

for i in range(K,N+2):
    ans+=ABC(N,i)

print(ans%mod)


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

int main(){
    int n;  cin >> n;
    vector<int> vec(n), dp(n, 0);
    for(int i=0;n>i;i++){
        cin >> vec[i];
    }
    dp[1]=abs(vec[1]-vec[0]);
    for(int i=2;n>i;i++){
        dp[i]=min(dp[i-1]+abs(vec[i-1]-vec[i]), dp[i-2]+abs(vec[i-2]-vec[i]));
    }
    cout << dp[n-1];
}

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

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(LL i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, k;
	cin >> n >> k;
	VI a(n);
	REP(i, n)cin >> a[i];

	SORT(a);

	VI c;
	int i = 0;
	while (i < n) {
		int elem = a[i], cnt = 0;
		while (i < n && a[i] == elem) { cnt++; i++; }
		c.PB(cnt);
	}
	SORT(c);
	REVE(c);

	int sum = 0;
	REP(i, min(k, SZ(c))){
		//cout << c[i] << endl;
		sum += c[i];
	}
	cout << n - sum << endl;
}

Measured memory_bytes: 2168
#include <stdio.h>

int main(void) {
	int a,s,i,n;
	while (scanf("%d",&a) , a != 0){
		s = 0;
		for (i = 1;i <= a / 4;i++){
			scanf("%d",&n);
			s+=n;
		}
		printf("%d\n",s);
	}
	return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	lint ans=accumulate(a.begin(),a.end(),0LL);
	int pre=-1;
	rep(i,n){
		if(a[i]-pre>1){
			puts("-1");
			return 0;
		}
		if(pre!=-1 && pre+1==a[i]){
			ans-=pre;
		}
		pre=a[i];
	}
	printf("%lld\n",ans);

	return 0;
}


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

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

  long long  l[100];

  l[0] = 2;
  l[1] = 1;

  for(int i = 2;i <= n;i++){
    l[i] = l[i-1]+l[i-2];
  }

  cout << l[n] <<endl;
}


Measured memory_bytes: 256
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<queue>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,k,a[200002],b[200002];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(int j=1;j<=k;++j)
	{
		for(int i=1;i<=n;++i)
		{
			++b[max(1ll,i-a[i])];
			--b[min(n+1,i+a[i]+1)];
		}
		for(int i=1;i<=n;++i)
		{
			a[i]=b[i]+a[i-1];
			b[i]=0;
		}
		bool flag=true;
		for(int i=1;i<=n;++i)
		{
			if(a[i]!=n)
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			break;
		}
	}
	for(int i=1;i<=n;++i)
	{
		cout<<a[i]<<' ';
	}
	return 0;
}


Measured memory_bytes: 6732