akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
N = len(s)
se = set(s)
ans = INF
for x in se:  # xとの距離を調べる
	tmp = 0
	ans = min(ans, max([len(l) for l in s.split(x)]))

print(ans)


Measured memory_bytes: 60652
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=5050;
const ll INF=1e16;
int n,A,B,a[N];
ll ans,f[N][N];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d%d",&n,&A,&B);
	FOR(i,1,n) scanf("%d",&a[i]);
	FOR(i,0,n)FOR(j,0,n) f[i][j]=INF;
	f[0][0]=0;ans=INF;
	FOR(i,1,n){
		FOR(j,0,i-1){
			if(a[j]<a[i]){
				f[i][j]=min(f[i][j],f[i-1][j]+A);
				f[i][i]=min(f[i][i],f[i-1][j]);
			}
			else
				f[i][j]=min(f[i][j],f[i-1][j]+B);
		}
	}
	FOR(i,1,n) ans=min(ans,f[n][i]);
	cout<<ans<<'\n';
}

Measured memory_bytes: 198912
#include "bits/stdc++.h"
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 200000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
string S[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int B[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//double Perf[NM];

ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//ll lcm(ll a, ll b) {
//    return a / (gcd(a, b) % MOD) * (b % MOD);
//}

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program



void solve() {
    ll  N;
    cin >> N;

    bool flag = true;
    static std::map<std::string, int> count;
    ll maxcnt = 0;

    for (ll i = 0; i < N; i++) {
        cin >> S[i];
        count[S[i]]++;
        if (maxcnt < count[S[i]]) {
            maxcnt = count[S[i]];
        }
    }

    for (auto itr = count.begin(); itr != count.end(); ++itr) {
        if (itr->second == maxcnt) {
            cout << itr->first << endl;
        }
    }

    return;

}



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







Measured memory_bytes: 25472
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

const long long MOD = 1e9 + 7;

int main()
{	
 	//freopen("in.txt","r",stdin);
 	//freopen("out.txt","w",stdout);
    long long n;
    scanf("%I64d", &n);
    long long sum = 1;
    for (long long i = 2; i <= n; i++)
    {
        sum = (sum * i) % MOD;
    }
    printf("%I64d\n", sum);
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e3 + 5;

int x,n;
bool a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>x>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		a[x]=true;
	}
	for(int i=0;i<=100;i++){
		if(x<=i || (!a[x-i] && x-i>0)){
			cout<<x-i<<'\n';
			return 0;
		}
		if(!a[x+i]){
			cout<<x+i<<'\n';
			return 0;
		}
	}
	return 0;
}

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int m = max({a,b,c});
  int t = m;
  for(int i = 0;i<k;i++){
    m *= 2;
  }

  cout << a + b + c + m - t << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn],b[maxn],c[maxn];
int n;

int FindLastSmaller(int key)
{
    int l=0,r=n-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(a[mid]>=key) r=mid-1;
        else l=mid+1;
    }
    return r;
}

int FindFirstLarger(int key)
{
    int l=0,r=n-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(c[mid]>key) r=mid-1;
        else l=mid+1;
    }
    return l;
}

int main()
{
    cin>>n;
    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;i++) cin>>c[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ll ans=0;
    for(int i=0;i<n;i++){
        ll p1=FindLastSmaller(b[i]);
        ll p2=FindFirstLarger(b[i]);
        ans+=(p1+1)*(n-p2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int add = A + B;
		int sub = A - B;
		int multi = A * B;

		int max = add;
		if (max < sub)
			max = sub;
		if (max < multi)
			max = multi;
		System.out.println(max);
		sc.close();
	}
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//入力データを変数で受け取る
		int k = sc.nextInt(); //x,y,zの最大値
		int s = sc.nextInt(); //x,y,zの合計値

		//入力データを処理して、結果を出力
		int count = 0;

		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				int z = s - x - y;
				if(z >= 0 && z <= k) {
					count++;
				}
			}
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 35620
n=int(input())
li = [list(map(int,input().split())) for i in range(n)]

f = 0

for i in range(n):
    if li[i][0] == li[i][1]:
        f = f+1
        if f == 3:
            print("Yes")
            break
    else:
        f = 0

if f != 3:
    print("No")

Measured memory_bytes: 9180
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
#include<deque>
#include<cstdlib>
#include<ctime>
using namespace std;

const int MAX_STATE = 1<<19, MOD = 1e5;
int H, W, dp[2][3][MAX_STATE][2] = {};

int main(){
	char fld[21][21]; fill_n((char*)fld,21*21,-1);
	cin>>H>>W;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		cin>>fld[i][j];
		if(fld[i][j]=='J') fld[i][j] = 0;
		else if(fld[i][j]=='O') fld[i][j] = 1;
		else if(fld[i][j]=='I') fld[i][j] = 2;
		else fld[i][j] = 3;
	}
	fld[H][0] = 0;
	if(fld[0][0]==3) for(int i=0;i<3;i++) dp[0][i][0][0] = 1;
	else dp[0][(int)fld[0][0]][0][0] = 1;

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			for(int joi=0;joi<3;joi++){
				for(int s=0;s<(1<<(W-1));s++){
					for(int flg=0;flg<2;flg++){
						int dp_c = dp[(i*W+j)&1][joi][s][flg];
						if(dp_c==0) continue;
						dp[(i*W+j)&1][joi][s][flg] = 0;
						for(int njoi=0;njoi<3;njoi++){
							if(fld[i+(j+1)/W][(j+1)%W]!=3 && fld[i+(j+1)/W][(j+1)%W]!=njoi)
								continue;
							int nflg = flg, ns = s;
							if((j+1)%W<W-1 && ((ns>>((j+1)%W))&1)==1){
								if(njoi==2) nflg = 1;
								ns = ns^(1<<((j+1)%W));
							}
							if(i<H-1 && j<W-1 && joi==0 && njoi==1 && fld[i+1][j]>=2){
								ns = ns|(1<<j);
							}
							dp[(i*W+j+1)&1][njoi][ns][nflg] += dp_c%MOD;
						}
					}
				}
			}
		}
	}
	printf("%d\n",dp[(H*W)&1][0][0][1]%MOD);
	return 0;
}

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

long long A, B, N;

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

	long long x;
	if(B>N) {
		x = N;
	} else {
		x = (N/B) * B - 1;
	}

	cout << (A*x/B) - A*(x/B) << endl;
}


Measured memory_bytes: 3620
import sys

n, x, *lst1 = map(int, sys.stdin.read().split())
res1 = res2 = 0
lst2 = [0] + lst1
lst1.append(0)
for i in range(n):
  tmpsum = lst2[i] + lst2[i + 1]
  if tmpsum > x:
    res1 += tmpsum - x
    lst2[i + 1] -= tmpsum - x

for i in range(n, 0, -1):
  tmpsum = lst1[i] + lst1[i - 1]
  if tmpsum > x:
    res2 += tmpsum - x
    lst1[i - 1] -= tmpsum - x  
print(min(res1, res2))

Measured memory_bytes: 14092
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    while(N--) {
        vector<int> acc(6, 0); // acc[5] is sentinel.
        int ans = 0;
        for(int r = 0; r < 5; ++r) {
            for(int c = 0; c < 5; ++c) {
                int v;
                cin >> v;
                if(v == 0) acc[c] = 0;
                else ++acc[c];
            }
            stack<pair<int,int> > stk;
            for(int i = 0; i <= 5; ++i) {
                int len = 0;
                while(!stk.empty() && stk.top().first >= acc[i]) {
                    len += stk.top().second;
                    ans = max(ans, len*stk.top().first);
                    stk.pop();
                }
                stk.push(make_pair(acc[i], len+1));
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
using namespace std;
int main() {
      string str; cin>>str;
      int len=str.length();
      bool arr[26] ={};
      for (int i = 0; i < 26; ++i)
      {
          //cout<<arr[i]<<" ";
      }
      for (int i = 0; i < len; ++i)
      {
          char tempchar=str[i];
          int tempascii=int(tempchar);     
        // cout<<tempascii<<" ";
          if(arr[tempascii-97]==false){arr[tempascii-97]=true;}
      }
     for (int i = 0; i < 26; ++i)
          {
        if(arr[i]==false){cout<<char(97+i); 
            break;
          }  
          else if(arr[i]==true && i==25){cout<<"None";}   
        }


     return 0;
}

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


const int INF = 1e9+7;

int main(){
    long long n,k;
    cin>>n>>k;
    
    long long arr[n],dp[n];
    
    memset(dp,INF,sizeof(dp));
    
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    dp[0]=0;
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(arr[j]-arr[i]));
            }
        }
    }
    cout<<dp[n-1]<<endl;

}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

ll f(ll n)
{ 
  if (n == 1) return 1;
  return ((n * f(n - 1)) % MOD);
}

void solve()
{
  int n, m;
  cin >> n >> m;
  if ( abs(n - m) > 1)
  {
    cout << 0;
    return;
  }
  ll ans = 1 + (n == m);
  ans *= f(n);
  ans %= MOD;
  ans *= f(m);
  ans %= MOD;
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}


Measured memory_bytes: 5156
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiWayIf #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [n,k] <- r'
    ps <- sort <$> r'
    print $ sum $ take k ps


Measured memory_bytes: 4260
#include <iostream>
#include <deque>
#include <tuple>
using namespace std;

typedef pair<int, int> ii;
const int MAX = 1010;
const int INF = 1000000000;
 
int main() {
    int H, W, sy, sx, gy, gx;
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    int dist[MAX][MAX];
    char maze[MAX][MAX];
    bool vis[MAX][MAX];
    deque<ii> q;
    scanf("%d%d%d%d%d%d", &H, &W, &sy, &sx, &gy, &gx);
    sy--; sx--; gy--; gx--;
    for (int h = 0;h < H;h++){
        for (int w = 0;w < W;w++){
            dist[h][w] = INF;
            vis[h][w] = false;
            scanf(" %c", &maze[h][w]);
        }
    }
    q.push_front(ii(sx, sy));
    dist[sy][sx] = 0;
    while(!q.empty()) {
        int x, y;
        tie(x, y) = q.front();
        q.pop_front();
        if (vis[y][x]) continue;
        vis[y][x] = true;
        if (x == gx && y == gy) break;
        for(int i = 0;i < 4;i++) {
            int cx = x + dx[i], cy = y + dy[i];
            if(cx < 0 || cx >= W || cy < 0 || cy >= H) continue;
            if(maze[cy][cx] == '#') continue;
            if (dist[y][x] < dist[cy][cx]){
                dist[cy][cx] = dist[y][x];
                q.push_front(ii(cx, cy));
            }
        }
        for(int h = -2; h <= 2; h++){
            for(int w = -2; w <= 2; w++){
                int cx = x + w, cy = y + h;
                if(cx < 0 || cx >= W || cy < 0 || cy >= H) continue;
                if(maze[cy][cx] == '#') continue;
                if (dist[y][x] + 1 < dist[cy][cx]){
                    dist[cy][cx] = dist[y][x] + 1;
                    q.push_back(ii(cx, cy));
                }
            }
        }
    }
    if (dist[gy][gx] == INF) cout << -1 << endl;
    else cout << dist[gy][gx] << endl;
}

Measured memory_bytes: 9588
# ABC C - Go to school


N = int(input())
A = list(map(int, input().split()))
Q = []

for i in range(N):
    Q.append(1)

for i in range(N):
    Q[A[i]-1] = i + 1

for i in range(N):
    print(Q[i], end = ' ')

print()

Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	cin >> str;
	if (str.size() == 1) {
		cout << "Bad" << endl; return 0;
	} else {
		for (int i = 1; i < str.size(); i++) {
			if (str[i] == str[i - 1]) {
				cout << "Bad" << endl;return 0;
			}
		}
	}
	cout << "Good" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){
 
    int n,t,a;
    cin>>n>>t>>a;
    
    int h[n];
    for (int i=0; i<n; i++) {
        cin>>h[i];
    }
    
    int temp[n];
    for (int i=0; i<n; i++) {
        temp[i]=abs(t*1000-h[i]*6-a*1000);
    }
    
    int ans=temp[0];
    
    int x=0;
    
    for (int i=1; i<n; i++) {
        
        if(temp[i]<ans){
            ans=temp[i];
            x=i;
           
        }
        }
    
    cout<<x+1<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

ab = [list(map(int, input().split())) for x in range(n)]

ends = [0 for x in range(10**5 + 1)]
for a, b in ab:
    ends[a] += b

for i, e in enumerate(ends):
    k -= e
    if k <= 0:
        print(i)
        break


Measured memory_bytes: 30300
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_((i), __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar  8 21:00:01 JST 2020
 **/

signed main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int one = n / 3 + (n % 3 >= 1);
    int two = n / 3 + (n % 3 >= 2);
    int zer = n / 3;
    assert(one + two + zer == n);
    int cur_one = 1;
    vector<int> color(n, -1);
    auto dfs = [&](auto f, int v, int prv) -> void {
        for (int s : g[v]) {
            if (s == prv) continue;
            color[s] = 3 - color[v];
            cur_one += color[s] == 1;
            f(f, s, v);
        }
    };
    color[0] = 1;
    dfs(dfs, 0, -1);
    int cur_two = n - cur_one;
    if (cur_one <= zer) {
        int rem_zer = zer - cur_one;
        int rem_one = one;
        REP(i, n) {
            if (color[i] == 1) {
                color[i] = 0;
            } else {
                if (rem_zer-- > 0) {
                    color[i] = 0;
                } else if (rem_one-- > 0) {
                    dump(rem_one);
                    color[i] = 1;
                }
            }
        }
    } else if (cur_two <= zer) {
        int rem_zer = zer - cur_two;
        int rem_two = two;
        REP(i, n) {
            if (color[i] == 2) {
                color[i] = 0;
            } else {
                if (rem_zer-- > 0) {
                    color[i] = 0;
                } else if (rem_two-- > 0) {
                    color[i] = 2;
                }
            }
        }
    } else {
        int x = 0, y = 0;
        REP(i, n) {
            if (color[i] == 1) {
                if (x++ >= one) {
                    color[i] = 0;
                }
            } else {
                if (y++ >= two) {
                    color[i] = 0;
                }
            }
        }
    }
    //
    dump(color);
    REP(k, 3) {
        int acc = k == 0 ? 3 : 0;
        REP(i, n) {
            if (color[i] == k) {
                color[i] += acc;
                acc += 3;
            }
        }
    }
    vector<int> tmp = color;
    sort(tmp.begin(), tmp.end());
    REP(i, n) {
        assert(tmp[i] == i + 1);
    }
    for (Int x : color) cout << x << " ";
    cout << endl;
}


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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110000];
ll f(ll ans,ll x){
  if(x==0)return ans;
  else return f(ans*2%mod,x-1);
}

main(){
  ll n;
  cin>>n;
  rep(i,0,n)cin>>a[i];
  sort(a,a+n);
  bool b=true,c=true,d=true;

  for(ll i=1;i<n;i+=2){
    if(a[i]!=a[i-1]){b=false;break;}
  }
  for(ll i=2;i<n;i+=2){
    if(a[i]!=a[i-1]){c=false;break;}
  }
  if(a[n-2]!=a[n-1])d=false;
  if(b&&d)cout<<f(1,n/2)%mod;
  else if(c&&d)cout<<f(1,n/2)%mod;
  else cout<<0;
  //cout<<a[n-1]<<a[n-2];
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int d[100];
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	for (int i = 0; i < my; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		d[za]++, d[zb]++;
	}
	for (int i = 0; i < mx; i++)printf("%d\n", d[i]);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;
#define INF (1 << 30)
#define INFLL (1LL << 60)
#define rep(i, n) for(int i=0; i<(n); ++i)

int funcOnce(string bin, int div)
{
	int deci = 0;
	rep(i, bin.size()) deci = (deci * 2 + bin[i] - '0') % div;
	return deci;
}
vector<int> funcOnceNote(string bin, int div)
{
	int deci = 0;
	int D = bin.size();
	vector<int> imod(D);
	rep(i, D) {
		deci = (deci * 2 + bin[i] - '0') % div;
		imod[D - i - 1] = deci;
	}
	return imod;
}

int main()
{
	int N; cin >> N;
	string X; cin >> X;
	bitset<200000> bsx(X);
	int bitcnt = bsx.count();

	string binn(N, '0');
	binn[0] = '1';

	int xmodp1, xmodm1; 
	vector<int> imodp1, imodm1;

	xmodp1 = funcOnce(X, bitcnt + 1);
	imodp1 = funcOnceNote(binn, bitcnt + 1);
	if (bitcnt > 1) {
		xmodm1 = funcOnce(X, bitcnt - 1);
		imodm1 = funcOnceNote(binn, bitcnt - 1);
	}

	vector<int> ans(N, 0);
	rep(i, N) {
		int mod, xmod;
		if (X[i] == '1') {
			mod = bitcnt - 1;
			if (mod < 1) continue;
			xmod = (mod + xmodm1 - imodm1[i]) % mod;
		}
		else {
			mod = bitcnt + 1;
			xmod = (xmodp1 + imodp1[i]) % mod;
		}
		++ans[i];
		while (xmod > 0) {
			bitset<20> bs(xmod);
			xmod = xmod % bs.count();
			++ans[i];
		}
	}

	rep(i, N) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

int findroot(vector<int> &f,int a){
  if(f[a]==a) return a;
  else return f[a]=findroot(f,f[a]);
}

int unite(vector<int> &f,int a, int b){
  int ra=findroot(f,a);
  int rb=findroot(f,b);
  f[ra]=rb;
  return 0;
}

int main(){
  int N,M,K;
  cin >> N >> M >> K;
  vector<int> f(N);
  for(int i=0;i<N;i++) f[i]=i;
  vector<int> nf(N,0);
  
  int a,b;
  for(int i=0;i<M;i++){
    cin >> a >> b;
    a--;b--;
    unite(f,a,b);
    nf[a]++;nf[b]++;
  }

  //cout << "##" << endl;
  
  vector<vector<int> > blk(N);
  int c,d;
  for(int i=0;i<K;i++){
    cin >> c >> d;
    c--;d--;
    blk[c].push_back(d);
    blk[d].push_back(c);
  }

  vector<int> nff(N,0);
  for(int i=0;i<N;i++){
    nff[findroot(f,i)]++;
  }

  int ans;
  for(int i=0;i<N;i++){
    ans=nff[f[i]]-nf[i]-1;
    for(auto bi:blk[i]){
      if(f[i]==f[bi]) ans--;
    }
    cout << ans << " ";
  }

  cout << endl;
  
  return 0;
}


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

int main(){
	ll mod = 1e9 + 7;
	ll n, k; cin >> n >> k;
	ll arr[n];
	for(ll i = 0; i < n; ++i){
		cin >> arr[i];
	}
	ll ans = 0;
	for(ll i = 0; i < n; ++i){
		ll cnt = 0;
		for(ll j = i + 1; j < n; ++j){
			if(arr[i] > arr[j]){
				cnt++;
			}
		}
		ll tmp = k;
		ans += ((cnt * ((tmp * (tmp + 1) / 2)  % mod)) % mod);
		ans %= mod;
		cnt = 0;
		for(ll j = 0; j < i; ++j){
			if(arr[i] > arr[j]){
				cnt++;
			}
		}
		tmp = k - 1;
		ans += ((cnt * ((tmp * (tmp + 1) / 2)  % mod)) % mod);
		ans %= mod;
	}
	cout << ans;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	uint64_t N;
	cin >> N;
	vector<uint64_t> ride(5);
	vector<uint64_t> city(6);

	for (auto&i:ride) {
		cin >> i;
	}

	city.at(0) = N;
	uint64_t tmp;
	uint64_t cnt = 0;
	while (!city.at(5)) {
		for (int i = 4; i >= 0; i--) {
			tmp = min(city.at(i), ride.at(i));
			city.at(i + 1) += tmp;
			city.at(i) -= tmp;
		}
		cnt++;

		/*for (auto&i : city) {
			cout << i << " ";
		}
		cout << "\n";*/
	}
	tmp = *min_element(ride.begin(), ride.end());;

	uint64_t tmp2 = N - city.at(5) + tmp-1;
	cnt += (tmp2 / tmp);

	cout << cnt << "\n";

	return 0;
}

/*
10000000007
5
3
2
7
11
*/

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
    int a, b, x, y;
    scanf("%d%d%d%d", &a, &b, &x, &y);
    printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    REP(i,N+1) {
        REP(j,N+1) {
            int b = N - i*R - j*G;
            if (b%B == 0 && b >= 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = 1e16;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	int A[N+1];
	rep(i,N+1) cin >> A[i];
	int num = 1;
	bool ok = true;
	int maxi[N+1];
	rep(i,N+1){
		maxi[i] = num;
		if(num > INF) num = INF;
		if(maxi[i] > INF) maxi[i] = INF;
		num -= A[i];
		num *= 2;
		if(num < 0) ok = false;
	}
	if(!ok) cout << -1 << endl;
	else{
		int ans = 0;
		int cnt = 0;
		for(int i=N;i>=0;i--){
			cnt += A[i];
			if(maxi[i] < cnt) cnt = maxi[i];
			ans += cnt;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 5216
#include <iostream>

int main(void){
  int a,b;
  std::cin >> a >> b;

  if(a <= 0 && 0 <= b)
    std::cout << "Zero" << std::endl;
  else if(b<0 && ((b-a)%2)==0)
    std::cout << "Negative" << std::endl;
  else
    std::cout << "Positive" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int m, n;
	int sum = 0;
	vector<int>listv, listc;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int v;
		cin >> v ;
		listv.push_back(v);
	//	listc.push_back(c);
	}

	for (int i = 0; i < n; i++) {
		int c;
		cin >> c;
		//listv.push_back(v);
		listc.push_back(c);
	}


	for (int i = 0; i < n; i++) {
		if (listv[i] > listc[i]) {
			sum += (listv[i] - listc[i]);
		}
	}

	cout << sum << endl;


	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  ll n,sum = 0; cin >> n;
  vector<ll> a(n),s(2*n+2,0);
  rep(i, n){
    cin >> a[i];
    sum += a[i];
  }
  rep(i, 2*n) s[i+2] = s[i] + a[(i%n)];//累積和

  int m = n/2;
  rep(i, n){
    ll ans = sum;

    /*rep(j, m){
      int index = (i+1+2*j)%n;
      ans -= 2*a[index];
    }*/
    //これだと和をとるのにO(n/2)かかるから、和を取る部分を累積和使ってO(1)化する

    ans -= 2*(s[i+1+2*m]-s[i+1]);

    std::cout << ans << '\n';
  }
}


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

int main(){
  int i ,j ,n;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    int prime[n+1]; // 素数
    for( i=2 ; i<=n ; i++ ){ // 自然数を列挙
      prime[i] = 1;
    }
    
    i = 2;
    while( i <= n ){
      if( prime[i] == 1 ){ // 素数なら
	j = i*2;
	while( j <= n ){
	  prime[j] = 0;
	  j += i;
	}
      }
      i++;
    }
    for( i=n ; i>0 ; i-- ){
      if( prime[i] == 1 && prime[i-2] == 1 ){
	cout << i-2 << ' ' << i << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll ar[100001][4],n;
ll dp[100001][4];
ll fun(ll row,ll blk)
{
    if(row==n-1){
        return ar[row][blk];
    }
    if(dp[row][blk]!=0){
        return dp[row][blk];
    }
    ll v1,v2;
    if(blk==1){
        v1=ar[row][blk]+fun(row+1,2);
        v2=ar[row][blk]+fun(row+1,3);
    }
    if(blk==2){
        v1=ar[row][blk]+fun(row+1,1);
        v2=ar[row][blk]+fun(row+1,3);
    }
    if(blk==3){
        v1=ar[row][blk]+fun(row+1,1);
        v2=ar[row][blk]+fun(row+1,2);
    }
    dp[row][blk]=max(v1,v2);
    return dp[row][blk];
}
int main()
{
    ll i,j;
    cin>>n;
    for(i=0;i<n;i++){
        for(j=1;j<=3;j++){
            scanf("%lld",&ar[i][j]);
        }
    }
    j=max(fun(0,1),max(fun(0,2),fun(0,3)));
    cout<<j<<endl;

    return 0;
}


Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Group[] groups = new Group[N];
        for (int i = 0; i < N; i++) {
            int X = scan.nextInt();
            int Y = scan.nextInt();
            long P = scan.nextLong();
            groups[i] = new Group(X, Y, P);
        }
        int limit = pow(2, N);
        long[][] distX = new long[limit][N];
        long[][] distY = new long[limit][N];
        for (int i = 0; i < limit; i++) {
            for (int j = 0; j < N; j++) {
                distX[i][j] = Math.abs(groups[j].x);
                distY[i][j] = Math.abs(groups[j].y);
                for (int k = 0; k < N; k++) {
                    if (((i >> k) & 1) == 1) {
                        distX[i][j] = Math.min(distX[i][j], Math.abs(groups[j].x - groups[k].x));
                        distY[i][j] = Math.min(distY[i][j], Math.abs(groups[j].y - groups[k].y));
                    }
                }
            }
        }
        long[] ans = new long[N+1];
        Arrays.fill(ans, Long.MAX_VALUE);
        limit = pow(3, N);
        for (int i = 0; i < limit; i++) {
            int posX = 0;
            int posY = 0;
            int t = i;
            int c = 1;
            int count = 0;
            while (0 < t) {
                if (t % 3 == 1) {
                    posX += c;
                    count += 1;
                }
                if (t % 3 == 2) {
                    posY += c;
                    count += 1;
                }
                t /= 3;
                c *= 2;
            }
            long current = 0;
            for (int j = 0; j < N; j++) {
                current += Math.min(distX[posX][j], distY[posY][j])*groups[j].p;
            }
            ans[count] = Math.min(ans[count], current);
        }
        for (int i = 0; i <= N; i++) {
            System.out.println(ans[i]);
        }
    }
    private int pow(int base, int count) {
        if (count == 0) {
            return 1;
        }
        if (count % 2 == 1) {
            return base * pow(base, count - 1);
        }
        int t = pow(base, count / 2);
        return t * t;
    }
    class Group {
        int x;
        int y;
        long p;
        Group(int x, int y, long p) {
            this.x = x;
            this.y = y;
            this.p = p;
        }
    }
}


Measured memory_bytes: 45848
#include <iostream>
#include <memory>

int gcd(int a, int b) {
  while (true) {
    if (a < b)
      std::swap(a, b);
    if (b == 0)
      return a;
    a %= b;
  }
  return a;
}

int gcd3(int a, int b, int c) { return gcd(gcd(a, b), c); }

int main(int argc, char *argv[]) {
  int k;
  std::cin >> k;
  long sum = 0;
  for (int a = 1; a <= k; ++a)
    for (int b = 1; b <= k; ++b)
      for (int c = 1; c <= k; ++c)
        sum += gcd3(a, b, c);
  std::cout << sum << std::endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

vector <int> card1, card2;

int main(void){
	int a, b, tmp;
	int res = 0;
	cin >> a >> b;
	for (int i = 0; i < a; i++){
		cin >> tmp;
		card1.push_back(tmp);
	}
	for (int i = 0; i < b; i++){
		cin >> tmp;
		card2.push_back(tmp);
	}
	card1.push_back(1050);
	card2.push_back(5000);
	
	for (int del = 0; del < b; del++){
		int acnt = 0;
		for (int i = del; i < b;){
			if (a == acnt || b == i){
				res = max(res, i-del);
				break;
			}
			if (card1[acnt] == card2[i]) { 
				acnt++; 
				i++;
			}
			else acnt++;
		}
	}
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 944
N = int(input())

Hlist = list(map(int, input().split()))
max_counter = 0
counter = 0
for i in range(N - 1):
    if Hlist[i + 1] <= Hlist[i]:
        counter += 1
    else:
        max_counter = max(counter, max_counter)
        counter = 0
print(max(counter, max_counter))


Measured memory_bytes: 14252
l, r = gets.split.map(&:to_i)

ans = 2018
divided_zero = false

l.upto(r - 1) do |i|
  break if divided_zero == true

  (i + 1).upto(r) do |j|
    p = i % 2019 * j % 2019

    if p == 0
      ans = 0
      divided_zero = true
      break
    elsif p <= ans
      ans = p
    end
  end
end

puts ans


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    int ans = 1;

    REP(b, 1, X + 1) {
        int t = b;
        REP(p, 2, X + 1) {
            t *= b;
            if (t <= X) {
                ans = max(ans, t);
            } else {
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int A, B;
    int H;
    int M;
    cin >> A >> B >> H >> M;
    double min_angle, hour_angle, angle;
    double _ans, ans;
    min_angle = M * 6;
    hour_angle = H * 30 + M * 0.5;
    angle = abs(min_angle - hour_angle);
    _ans = A*A + B*B - 2*A*B*cos(angle*M_PI/180);
    //cout << fixed << setprecision(15) << cos(angle) << endl;
    ans = sqrt(_ans);
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define up(i,a,b) for(register int i=a;i<=b;i++)
#define Auto(i,x) for(register int i=h[x];i;i=e[i].nxt)
#define cntsize(a) (sizeof(a) / 1024.0 / 1024.0)
#define re register
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
struct ios{
	template <typename ty> inline ios& operator >> (ty &x){
		x = 0;register char c=getchar();int f=1;
		for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
		for(;isdigit(c);c=getchar()) x = (x<<1) + (x<<3) + (c^48);
		x *= f;return *this;
	}
	template <typename ty> inline ios& operator << (ty x){
		if(x < 0) putchar('-') , x=-x;
		if(x > 9) *this << x/10;
		putchar(x%10+48);return *this;
	} 
	inline ios& operator << (char x){putchar(x);return *this;}
}io;
const int N = 2e7;
const ll mod = 998244353;
ll fac[N],inv[N];
inline ll ksm(ll a, ll b)
{
	ll ret = 1;
	for(;b;b>>=1, a=a*a%mod) if(b&1) ret = (ret * a) % mod;
	return ret;
}
inline ll C(ll n, ll m)
{
	return fac[n] * inv[m] % mod * inv[n-m] % mod;
//	return fac[n] * ksm(fac[m],mod-2) % mod * ksm(fac[n-m],mod-2) % mod;
}
ll n,a,b,k;
int main()
{
	io >> n >> a >> b >> k;
	fac[0] = 1;for(ll i=1;i<=N-5;i++) fac[i] = (fac[i-1] * i) % mod;
	inv[N-5] = ksm(fac[N-5],mod-2);
	inv[0] = 1;
	for(ll i=N-6;i>=1;i--) inv[i] = (inv[i+1] * (i+1)) % mod;
	ll ans = 0;
	for(ll R=0;R*a<=k && R<=n;R++)
	{
		if((k - R * a) % b == 0)
		{
			ll B = (k - R * a) / b;
			if(B > n) continue;
			ans = (ans + C(n,R) * C(n,B) % mod) % mod;
		}
	}
	io << ans;
	return 0;
}

Measured memory_bytes: 312704
#include <iostream>
using namespace std;
int main ()
{
    int a,b,c,d,e,f,g,h;
    cin>>a>>b>>c>>d;
    e=c-(d-b);
    f=d+(c-a);
    g=a-(d-b);
    h=b+(c-a);
    cout<<e<<" "<<f<<" "<<g<<" "<<h<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int check(char s[])
{
	int i,l;
	l=strlen(s);
	
	for (i=0;i<=l/2+1;i++)
	{
		if (s[i]!=s[l-1-i])
			return 0;
	}
	
	return 1;

}
int main()
{
	char flag,s1[100001],s2[100001];
	int i,j,l,ans;
	scanf("%s",s1);
	j=0;
	l=strlen(s1);
	for (i=0;i<l;i++)
	{

		if (s1[i]!='x')
		{
			s2[j]=s1[i];
			j++;
		}
	}
	s2[j]='\0';
	flag=check(s2);
	if (flag)
	{
		ans=0;
		i=0;
		j=l-1;
		while (i<j)
		{
			if (s1[i]==s1[j])
			{
				i++;
				j--;
			}
			else 
			{
				if (s1[i]=='x')
				{
				    i++;
					ans++;
				}
			    else if (s1[j]=='x')
				{
				    j--;
					ans++;
				}
			}

		}
		printf("%d\n",ans);
		
	}
	else printf("-1\n");
	return 0;


}



Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int n, car[10], i;
	
	i = 0;
	
	while (scanf("%d", &n) != EOF){
		if (n != 0){
			car[i++] = n;
		}
		else {
			printf("%d\n", car[--i]);
		}
	}
	
	return (0);
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<10 && b <10)cout<<a*b<<endl;
  else cout<<-1<<endl;

}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
            a = 0.5 * a
            b += a
        elif a % 2 == 0:
            a = 0.5 * a
            b += a
    elif i % 2 == 1:
        if b % 2 == 1:
            b -= 1
            b = 0.5 * b
            a += b
        elif b % 2 == 0:
            b = 0.5 * b
            a += b

print(int(a), int(b))

Measured memory_bytes: 3064
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> set = new HashSet<Integer>();
        for(int i = 0; i < N; i++) set.add(sc.nextInt());
        System.out.println(set.size());
        sc.close();

    }

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n,k;cin>>n>>k;
    v p(n);in(p,n);
    sort(all(p));
    int ans=0;
    f(i,k)
    ans+=p[i];
    cout<<ans<<endl;
    return 0;
}

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

int N, X;
int m[1100];

int main() {
	cin >> N >> X;
	for (int i = 0; i < N; ++i) cin >> m[i];
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		sum = sum + m[i];
	}

	int rest = X - sum;

	int min = 5000;
	for (int i = 0; i < N; ++i) {
		if (min > m[i]) min = m[i];
		}

	int ans = N + rest / min;
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>

int gcd(int x, int y);
int main()
{
    int x, y;
    std::cin >> x;
    std::cin >> y;
    std::cout << gcd(x, y) << std::endl;
    return 0;
}
int gcd(int x, int y)
{
    if(x < y){
        std::swap(x, y);
    }
    if(x%y == 0){
        return y;
    }
    gcd(x%y, y);
}

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

from collections import Counter
cnt = Counter(A)

ans = 0
for v in cnt.values():
    ans += v*(v-1)//2
for i in A:
    a = cnt[i]
    dif = a*(a-1)//2 - (a-1)*(a-2)//2
    print(ans-dif)

Measured memory_bytes: 32364
#include <bits/stdc++.h>
using namespace std;
long long k=1,c,a,b;
int main() {
cin>>a>>b;
c=__gcd(a,b);
for(int i=2;i<=sqrt(c);i++)
{
  if(c%i==0){
    while(c%i==0){ 
   c=c/i;
}
  k++;
}
}
if(c==1)
cout<<k ;
else
cout<<k+1;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
public class Hello{
    public static void Main(){
        var a = ReadLine().Split(' ').Select(int.Parse).ToArray();
        if(a[0] < a[1] && a[1]< a[2]){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 18348
//分步:乘法原理
//不同时发生:加法原理
#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
const int mod=1e9+7;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

ll qpow(ll a,ll b){
    ll res=1;
    while( b ){
        if( b&1 ) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if( a<b ) swap(a,b);
    ll r=a%b;
    while( r!=0 ){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int n;
int main()
{
    scanf("%d",&n);
    map<ll,map<ll,ll> >x;
    map<ll,map<ll,bool> > c;
    vector<pair<ll,ll> >ab(maxn);
    ll res=0,A=0,B=0;
    for(int i=0;i<n;i++){
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if( a==0 && b==0 ) res++;
        else if(a==0) A++;
        else if(b==0) B++;
        else{
            if( a<0 ){//(-5)/2与5/(-2) 的不能匹配一样:2/(-5),(-5)/2,所以避免下面的计算一楼,先将他们统一
                a*=-1;
                b*=-1;
            }
            ll g=gcd(a,b);
            a/=g;b/=g;
            x[a][b]++;
            ab[i]=make_pair(a,b);
        }
    }

    ll ans=(qpow(2,A)+qpow(2,B)-1+mod)%mod;//ans1表示(A==0 || B==0)时的情况数,因为0/1,1/0不能配对,所以用加法,可是算了两次不选的情况,所以-1是去掉多一次不选的情况
    //e.g.A==0:0/1 0/2 0/3 0/5; B==0:1/0,0/4,0/5,0/6,可以画出共有31种情况
    //一下同理

    for(int i=0;i<ab.size();i++){
        ll a=ab[i].first,b=ab[i].second;
        if( c[a][b] ) continue;
        c[a][b]=true;c[-b][a]=true;c[b][-a]=true;
        ll ans2=(qpow(2,x[a][b])%mod + qpow(2,x[-b][a])%mod + qpow(2,x[b][-a])%mod - 2 + mod)%mod;
        ans = (ans*ans2)%mod;
    }
    ans = (ans-1+mod)%mod;//-1删除除了(0,0)都没有的情况
    ans = (ans+res)%mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 174744