akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.first < another.first;
}
 
int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e;
    //std::cin>> word;
    std::cin>> a;
 
    for( int i = 0; i < a; i++ )
    {
        std::cin>> b;
 
        if( word != "DENIED" )
        {
            if( b % 2 == 0 )
            {
                if( b % 3 == 0 || b % 5 == 0 )
                {
                    word = "APPROVED";
                }
                else
                {
                    word = "DENIED";
                }
            }
        }
    }
 
    if( word == "aa" )
    {
        word = "APPROVED";
    }
 
    std::cout<< word;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
ll inf = 1000000000 + 7;



int main() {
	string S, T;
	char a[100], b[100];

	cin >> S >> T;
	bool ok = true;
	rep(i, 100) {
		a[i] = ' ';
		b[i] = ' ';
	}


	rep(i, S.size()) {
		
		if (a[S[i] - 'a'] == ' ' && b[T[i] - 'a'] == ' ') {
			a[S[i] - 'a'] = T[i];
			b[T[i] - 'a'] = S[i];

		}

		else if(a[S[i] - 'a'] != T[i] || b[T[i] - 'a'] != S[i]){
				ok = false;

		}

	}

	if (ok == false)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;


	return 0;
}

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

int main(void){
    int n;cin>>n;
    int ans = 0;
    rep(i,n){
        int a;cin>>a;
        ans += a-1;
    }
    cout << ans << endl;
    return 0;
}


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

int sp[10][2];
int m[10][10];
int dx[] = {-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2},
    dy[] = {2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1},
    dn = 12;
int N;

bool is_alive(int x, int y, int n)
{
  int sx = sp[n][0], sy = sp[n][1];
  return x >= sx -1 && x <= sx + 1 && y >= sy - 1 && y <= sy + 1;
}

bool dfs(int x, int y, int n)
{
  if(n == N)
    return true;
  if(!is_alive(x, y, n))
    return false; 
  for(int i = 0; i < dn; i++)
  {
    int tx = x + dx[i], ty = y + dy[i];
    if(!(tx >= 0 && tx < 10 && ty >= 0 && ty < 10))
      continue;
    if(dfs(tx, ty, n + 1))
      return true;
  }
  return false;
}

int main()
{
  int sx, sy;
loop:
  cin >> sx >> sy;
  if(!sx)
    return 0;
  sx--; sy--;
  cin >> N;
  for(int i = 0; i < N; i++)
  {
    cin >> sp[i][0] >> sp[i][1];
    sp[i][0]--; sp[i][1]--;
  }
  for(int i = 0; i < dn; i++)
  {
    int x = sx + dx[i], y = sy + dy[i];
    if(dfs(x, y, 0))
    {
      cout << "OK" << endl;
      goto loop;
    }
  }
  cout << "NA" << endl;
  goto loop;
}

Measured memory_bytes: 1152
from itertools import product

INF = 1000000007

def mat2_mul(X, Y):
	z = [[0, 0], [0, 0]]
	for (i, j, k) in product(range(2), range(2), range(2)):
		z[i][j] += X[i][k] * Y[k][j]
	return z

def mat2_pow(X, n):
	if n == 0:
		return [[1, 0], [0, 1]]
	elif n % 2:
		return mat2_mul(X, mat2_pow(X, n - 1))
	else:
		half_pow = mat2_pow(X, n / 2)
		return mat2_mul(half_pow, half_pow)

def fib(n):
	if n == 0:
		return 0
	else:
		f = [[0, 1], [1, 1]]
	return mat2_pow(f, n - 1)[1][1]


N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
ans, start = 1, 0
tmp = []

for i in range(len(a)):
	if a[i] - a[i - 1] == 1:
		print(0)
		exit()

for k in a:
	tmp.append(fib(k - start) % INF)
	start = k + 1

for j in tmp:
	ans *= j
	ans %= INF

ans *= fib(N - start + 1)
print(ans % INF)


Measured memory_bytes: 7096
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long a = tmp[0], b = tmp[1];

    if (a * b <= 0)
    {
        "Zero".writeln;
    }
    else if (a < 0 && b < 0 && (b - a) % 2 == 0)
    {
        "Negative".writeln;
    }
    else
    {
        "Positive".writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
signed main(void){
    int n;cin>>n;
    vector<int>V(n+1);rep(i,n)cin>>V[i];
    V[n]=INF;
    int q;cin>>q;
    int ans=0;
    rep(i,q){
        int x;cin>>x;
        if(*lower_bound(all(V),x)==x)ans++;
    }
    cout<<ans<<endl;
}
        



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

typedef long long ll;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define D(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

template<class T> void insertion_sort(vector<T>& v)
{
    cout_h(v);
    for (int i = 1; i < v.size(); i++) {
        T key = v[i];
        int j = i - 1;
        while (j >= 0 && v[j] > key) {
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = key;
        cout_h(v);
    }
}

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

    ll N; cin >> N;
    vector<int> v(N); rep(i, N) cin >> v;

    insertion_sort(v);    
}



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

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

int n, x, y, a[111], b[111], c[111], d[111];
int center = 400;
int dp[111][333][1111];

void maxUpdate(int& a, int b) { a = max(a, b); }

int main() {
	cin >> n;
	cin >> x >> y;
	
	for_(i,0,n) cin >> a[i] >> b[i] >> c[i] >> d[i];
	
	memset(dp, -1, sizeof(dp));
	dp[0][x][y + center] = 0;
	
	for_(i,0,n) for_(xi,0,333) for_(yi, 0, 1111) {
		if (dp[i][xi][yi] == -1) continue;
		
		maxUpdate(dp[i + 1][xi][yi], dp[i][xi][yi]);
		
		if (xi - a[i] >= 0) maxUpdate(dp[i + 1][xi - a[i]][yi + b[i]], dp[i][xi][yi]);
		
		maxUpdate(dp[i + 1][xi][yi - c[i]], dp[i][xi][yi] + d[i]);
	}
	
	int ans = 0;
	for_(xi,0,333) for_(yi,center,1111) maxUpdate(ans, dp[n][xi][yi]);
	cout << ans << endl;
}

Measured memory_bytes: 163532
X, Y = map(int, input().split())

if X == 1 and Y == 1:
  c = 400000
else:
  c = 0

if X == 1:
  a = 300000
elif X == 2:
  a = 200000
elif X == 3:
  a = 100000
else: 
  a = 0

if Y == 1:
  b = 300000
elif Y == 2:
  b = 200000
elif Y == 3:
  b = 100000
else: 
  b = 0


print(a + b +c)

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


void decode(char *str, int n){
	int i;
	int len;
	// アルファベットのみX文字ずらす
	len = strlen(str);
	for(i=0;i<len;i++)
		if(str[i] >= 'A' && str[i] <= 'Z')
			str[i] = (str[i] - 'A' + n) % 26 + 'A';
	return;
}

int main()
{
 
	int N;
  scanf("%d", &N);
 
    char s[10000];
    // 整数の入力
 
    // 文字列の入力
    scanf("%s",s);
  int num = strlen(s);
  int i=0;
  decode(s, N);
  printf("%s",s);

    return 0;
}


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


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    dl = d[:N//2]
    du = d[N//2:]
    print(du[0] - dl[-1])
    return


# Generated by 1.1.4 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
    d = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15604
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double complex<long double>
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#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 repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;


signed main() {
	int n;
	map<int, int> ma;
	cin >> n;
	vector<int> A(n);
	rep(i, n) {
		cin >> A[i];
	}


	rep(i, 1 << n) {
		int cal = i;
		int cand = 0;
		rep(j, n) {
			if (cal & 1LL) {
				cand += A[j];
			}
			cal >>= 1;
		}
		ma[cand]++;

	}

	int q;
	cin >> q;
	rep(i, q)
	{
		int m;
		cin >> m;
		if (ma[m]) {
			cout << "yes\n";
		}
		else {
			cout << "no\n";
		}
	}
	return 0;
}


Measured memory_bytes: 3044
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,sr,sb,i,j,disb[200005],disr[200005],px[200005],py[200005],fab[200005],winr[200005],visr[200005],ans;
vector<int> bib[200005],bir[200005];
void dfsb(int x,int fa)
{
	fab[x]=fa;
	ff(bib[x],it){
		if(*it==fa)continue;
		disb[*it]=disb[x]+1;
		dfsb(*it,x);
	}
}
int check(int x,int y)
{
	if(fab[x]==y||fab[y]==x) return 0;
	if(fab[x]==fab[y]) return 0;
	if(fab[fab[x]]==y) return 0;
	if(fab[fab[y]]==x) return 0;
	return 1;
}
void bfsr(int x)
{
	queue<int> qx;
	qx.push(x);
	memset(disr,0x3f,sizeof(disr));
	disr[x]=0;
	while(!qx.empty()){
		int x=qx.front();qx.pop();
		visr[x]=1;
		ff(bir[x],it){
			int y=*it,z=disr[x]+1;
			if(disr[y]>z&&disb[y]>z){
				disr[y]=z;
				qx.push(y);
			}
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&sr,&sb);
	fz1(i,n-1){
		scanf("%d%d",&px[i],&py[i]);
	}
	fz1(i,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		bib[x].push_back(y);
		bib[y].push_back(x);
	}
	dfsb(sb,0);
	fz1(i,n-1){
		if(check(px[i],py[i])){
			winr[px[i]]=winr[py[i]]=1;
		}
		else{
			bir[px[i]].push_back(py[i]);
			bir[py[i]].push_back(px[i]);
		}
	}
	bfsr(sr);
	fz1(i,n){
		if(visr[i]&&winr[i]){
			puts("-1");
			return 0;
		}
		if(visr[i]){
			ans=max(ans,disb[i]*2);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);
    string s;
    cin >> s;
    ll q;
    cin >> q;
    bool isHead = true;
    rep(i, q){
        ll t, f;
        string c;
        cin >> t;
        if(t == 1){
            isHead = !isHead;
        }
        if(t == 2){
            cin >> f >> c;
            if(isHead){
                if(f == 1){
                    s.insert(0, c);
                }else{
                    s += c;
                }
            }else{
                if(f == 2){
                    s.insert(0, c);
                }else{
                    s += c;
                }
            }
        }
    }
    if(!isHead){
        reverse(all(s));
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
int f[5050],a[5050],n,k,sum=0;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)scanf("%d",&a[i]),a[i]=min(a[i],k),sum+=a[i];
    sort(a+1,a+n+2),f[0]=1;
    for(int i=n+1;i;--i){
        bool check=true;
        for(int j=k-1;j>=k-sum&&j>=0;--j)if(f[j]){check=false;break;}
        if(check){printf("%d",i-1);return 0;}
        for(int j=k;j>=a[i];--j)f[j]|=f[j-a[i]];
        sum-=a[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

	auto start = high_resolution_clock::now(); 

	int n ;
	cin >> n;
	vector<int> h(n);
	for(int i = 0 ; i < n; i++)
		cin >> h[i];

	int flag = 1;
	for(int i = n-2; i>=0; i--){
		if (h[i] <= h[i+1])
			continue;
		else if (h[i] == h[i+1] + 1)
			h[i]--;
		else{
			flag = 0;
			break;
		}
	}
	cout << (flag == 0?"No":"Yes");

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


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

using namespace std;
typedef long long ll;

#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--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

void solve() {
    ll N;
    cin >> N;
    vector<ll> c(N+1, 0), d(N+1, 0), A(N), B(N);
    REP(i, N) {
        cin >> A[i];
        c[A[i]]++;
    }
    REP(i, N) {
        cin >> B[i];
        d[B[i]]++;
    }

    FOR(i, 1, N) {
        if (c[i] + d[i] > N)
        {
            cout << "No" << endl;
            return;
        }
        c[i] += c[i-1];
        d[i] += d[i-1];
    }

    ll x = 0;
    FOR(i, 1, N) {
        chmax(x, c[i] - d[i-1]);
    }
    cout << "Yes" << endl;
    REP(i, N) {
        if(i) cout << " ";
        cout << B[(i + N - x) % N];
    }
    cout << endl;
}

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

Measured memory_bytes: 9588
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    string s,t;
    cin>>s>>t;
    unordered_map<char,int> d1,d2;
    for(char i:s){
        d1[i]++;
    }
    for(char i:t){
        d2[i]++;
    }
    vector<int> ss,tt;
    for(auto it:d1){
        ss.push_back(it.second);
    }
    for(auto it:d2){
        tt.push_back(it.second);
    }
    sort(All(ss));
    sort(All(tt));
    if(ss==tt){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

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

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = (int)S.size();

  int i = 0;
  while (i < N) {
    if (S.at(i) != '1') break;
    i++;
  }

  if (i < K) {
    cout << S.at(i) << endl;
  } else {
    cout << "1" << endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int cnt = 0;
  bool done = false;
  int now = 1;
  for (int i = 0; i < N; i++) { // すべての要素をなぞるのが最大
    int next = a.at(now - 1);
    if (next == 2) { // 2に到達
      cnt = i + 1;
      done = true;
      break;
    }
    now = next;
  }
  if (done) {
    cout << cnt << endl;
  } else {
    cout << -1 << endl;
  }
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		x -= a;
		int c = x / b;
		System.out.println(x - (b * c));
	}

}


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

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

using namespace std;

using ll = long long;

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
        --a[i];
    }

    function<int(int, int)> dist = [&](int x, int y) {
        return x > y ? m - x + y : y - x;
    };

    map<int, int> n_begin, n_end;
    map<int, ll> lose;
    ll initial_cost = 0;
    ll cut = 0;
    int count = 0;

    REP(i, n - 1) {
        ++n_begin[a[i]];
        ++n_end[a[i + 1]];
        if (a[i] > a[i + 1]) {
            cut += (m - a[i]) - 1;
            ++count;
        }
        initial_cost += dist(a[i], a[i + 1]);
        lose[a[i + 1]] += dist(a[i], a[i + 1]);
    }

    ll cut_max = cut;

    REP(i, m - 1) {
        count -= n_end[i];
        cut += -lose[i] + n_end[i];

        count += n_begin[i];
        cut += count - n_begin[i];

        cut_max = max(cut_max, cut);
    }

    ll result = initial_cost - cut_max;

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 16256
n, k = map(int, input().rstrip().split())
pl = [0 for _ in range(n)]

for i in range(k):
    _ = input().rstrip()
    l = list(map(int, input().rstrip().split()))
    for v in l:
        pl[v - 1] += 1

r = sum(v == 0 for v in pl)
print(r)


Measured memory_bytes: 9184
solve :: Int -> Int -> Int -> Int
solve k a b = a + (b - a) * d + m
  where
    (d,m) = (k - a + 1) `divMod` 2

main :: IO ()
main = do
    [k,a,b] <- map read . words <$> getLine :: IO [Int]
    print $ if a + 2 < b
               then solve k a b else k + 1

Measured memory_bytes: 508
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1e18
using namespace std;
typedef long long ll;

int main(){
  ll N, T; cin >> N >> T;
  ll bt = 0;
  ll ans = T;
  bool water = false;
  rep(i, 0, N){
    ll t;  cin >> t;
    ans += min(T, t-bt);
    bt = t;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

ll a,b,n;

int main() {
	qr(a); qr(b); qr(n);
	n=min(b-1,n);
	pr2((ll)floor((long double)a*n/b));
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define maxn (int)1e5+100
#define M 1000000007
#define pb push_back
int n;
long long int dp[maxn][3];
vector <int> v[maxn];
bool odw[maxn];

//1 to czarny

void dfs(int x)
{
	odw[x]=true;
	dp[x][1]=dp[x][0]=1;
	for (int i=0; i<(int)v[x].size(); i++)
	{
		if(!odw[v[x][i]])
		{
			dfs(v[x][i]);
			dp[x][1]=(dp[x][1]*dp[v[x][i]][0])%M;
			dp[x][0]=(dp[x][0]*(dp[v[x][i]][1]+dp[v[x][i]][0]))%M;
		}
	}
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(1);
	printf("%lld\n", (dp[1][0]+dp[1][1])%M);
}


Measured memory_bytes: 12288
require 'prime'

class Fractional
    attr_reader :mod

    def initialize(max, mod)
        @max = max
        @mod = mod
        @frac     = { 0 => 1, 1 => 1 }
        @frac_inv = { 0 => 1, 1 => 1 }
        @inv      = {         1 => 1 }

        pre_calc(max)
    end

    def pre_calc(max)
        2.upto(max) do |i|
            @frac[i] = @frac[i - 1] * i % @mod;
            @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
            @frac_inv[i] = @frac_inv[i - 1] * @inv[i] % @mod
        end
    end

    def at(i)
        @frac[i]
    end

    def inv_at(i)
        @frac_inv[i]
    end
end

class Combination
    def initialize(fraction)
        @fraction = fraction
    end

    def calc(n, r)
        return 0 if n < r
        return 0 if (n < 0 || r < 0)

        denom_inv = (@fraction.inv_at(r) * @fraction.inv_at(n - r) % @fraction.mod)
        return @fraction.at(n) * denom_inv % @fraction.mod
    end
end

MOD = 10 ** 9 + 7 
n, m = gets.chomp!.split(' ').map(&:to_i)

# 1種類の素因数の数は 2**50 > 10 ** 9 なので高々50追加であれば x + y は 10 ** 5 + 50を超えない
f = Fractional.new(10 ** 5 + 50, MOD)
c = Combination.new(f)

total = 1
primes = Prime.prime_division(m)
primes.each do |prime, num|
    # 同一素数の数
    x = num
    # 仕切りの数
    y = (n-1)

    total = total * c.calc(x + y, x) % f.mod
end

puts total


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

int main(){
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) || 
       (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ||
       (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])){
           cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
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;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N; cin >> N;
    ll out=0;
    for(ll i=2;i*i<=N;i++){
        if(N%i!=0) continue;
        ll c=0;
        ll o=1;
        while(N%i==0){
            N /= i;
            c++;
            if(o==c){
                o++;
                c=0;
            }
        }
        //cerr << o << "\t" << c << endl;
        o--;
        out += o;
    }
    if(N!=1){
        out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll A, B, N;

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

    if (N >= B - 1) {
        cout << A * (B-1) / B << endl;
    } else {
        cout << A * N / B << endl;
    }

    return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	int cnt = 0;
	int sum = 1;
	while(sum < b) {
		sum--;
		sum += a;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream> 
 
using namespace std;
 
int main() 
{
	long long n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	n--;
	for (long long pos = 0; pos <= n; pos++) 
	{
		long long from = a + c * pos - d * (n - pos);
		long long to = a + d * pos - c * (n - pos);
		if (from <= b && b <= to) 
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
r, c = map(int, input().split())
d = [list(input()) for i in range(r)]
bom = [(x,y) for (x,i) in enumerate(d) for (y,j) in enumerate(i) if j == '#']
temp, result = [], "Yes"
for b in bom:
    pattern = [(b[0],b[1]+1), (b[0], b[1]-1), (b[0]+1, b[1]), (b[0]-1, b[1])]
    if sum([1 if x in bom else 0 for x in pattern]) == 0:
        result = "No"
        break
print(result)

Measured memory_bytes: 3188
k,n = map(int,input().split())
a=list(map(int,input().split()))
a.sort
x=0
for i in range(n-1):
  if a[i+1]-a[i]>x:
    x=a[i+1]-a[i]
if a[0]+k-a[n-1]>x:
  x=a[0]+k-a[n-1]
print(k-x)

Measured memory_bytes: 32252
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
double x,h;
int main(){
  while(cin>>x>>h){
    if(x==0&&h==0)break;
    printf("%.6f\n",x*x+4.0*(0.5*x*sqrt(pow(x*0.5,2.0)+h*h)));
  }
  return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
int main(void)
{
    int a,b;

    scanf("%d %d",&a,&b);

    if(a<b)
         printf("a < b\n");
    if(a>b)
         printf("a > b\n");
    if(a==b)
         printf("a == b\n");

    return 0;

}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i=0; i<(n); i++)//第一引数の変数をカウンタ変数としてn回回す
//repはカウンタ変数が1ずつ増える場合にしか使えない
using veci = vector<int>;
using vecd = vector<double>;
int sq(int a){
  return a*a;
}
int main(){//受け取った配列を昇順にソートして、ｋだけ貪欲にとる
  int n, k;
  cin >> n >> k;
  int a[60];
  rep(i, n){
    cin >> a[i];
  }
  sort(a, a+n, [](int a, int b){ return a>b;});
  int ans=0;
  rep(i, k){
    ans += a[i];
  }
  cout << ans << endl;
}
    

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

#ifdef _DEBUG
#define LOCAL
#endif

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

ll n, p;

vpll fact(ll n) {
	vpll res;
	for (int i = 2; (ll) i * i <= n; i++) {		
		if (n % i == 0) {
			int deg = 0;
			while (n % i == 0) {
				deg++;
				n /= i;
			}
			res.pb(mp(i, deg));
		}
	}
	if (n != 1) res.pb(mp(n, 1));
	return res;
}

void solve() {
	vpll v = fact(p);		
	dbg(v);
	ll ans = 1;
	for (auto z : v) {
		ll cur = z.second / n;
		fo(1, cur) ans *= z.first;
	}
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	
	scanf("%lld %lld", &n, &p);
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
ll eight[1000005], nine[1000005], ten[1000005];

int main(void) {
	int n; cin >> n;
	eight[0] = nine[0] = ten[0] = 1;
	for(int i=1;i<=1000000;i++) {
		eight[i] = eight[i-1] * 8;
		eight[i] %= MOD;
		nine[i] = nine[i-1] * 9;
		nine[i] %= MOD;
		ten[i] = ten[i-1] * 10;
		ten[i] %= MOD;
	}
	ll ans = ten[n] - 2 * nine[n] + eight[n];
	ans %= MOD;
	if(ans < 0 ) ans += MOD;
	cout << ans << endl;
	return 0;
}



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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

using pll = pair<ll,ll>;
ll mod = 1000000007;

void reduce(ll &x, ll &y){
    if(x < 0){
        x *= -1;
        y *= -1;
    }
    //x >= 0
    if(x == 0){
        y = 1;
    }else if(y == 0){
        x = 1;
    }else{
        auto g = __gcd(abs(x),abs(y));
        x /= g;
        y /= g;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, nz = 0;
    int i;
    cin >> n;
    vl pot2; ll p2 = 1;
    for(i=0;i<=n;i++){
        pot2.push_back(p2);
        p2 = (p2*2)%mod;
    }

    map<pll, int> cnt;
    ll x, y;
    for(i=0;i<n;i++){
        cin >> x >> y;
        if(x == 0 && y == 0){
            nz++;
            continue;
        }
        reduce(x,y);
        cnt[{x,y}]++;
    }
    ll ans = 1;
    set<pll> used;
    for(auto kv : cnt){
        tie(x,y) = kv.first;
        int n1 = kv.second;
        ll x2 = y;
        ll y2 = -x;
        reduce(x2,y2);
        if(used.count({x2,y2}) == 0){
            int n2 = cnt[{x2,y2}];
            ll tmp = pot2[n1];
            if(n2 > 0){
                tmp += pot2[n2] - 1;
                tmp %= mod;
                if(tmp < 0) tmp += mod;
            }
            ans *= tmp;
            ans %= mod;
            used.insert({x2,y2});
        }
        used.insert({x,y});
    }
    ans = (ans + nz - 1)%mod;
    if(ans < 0) ans += mod;
    
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

int main(void){
    for(int n; cin >> n, n;){
        vs signal(n);
        bool out = false, nox = true;
        rep(i, n){
            cin >> signal[i];
            if(i != 0 && signal[i - 1] == signal[i]){
                out = true;
            }
            if(signal[i] == "x") nox = false;
        }
        rep(i, n){
            if(i % 2 && signal[i] != "x"){
                int left = signal[i - 1] != "x" ? toInt(signal[i - 1]):-inf;
                int right = i + 1 < signal.size() ? signal[i + 1] != "x" ? toInt(signal[i + 1]):-inf:-inf;
                if(left < toInt(signal[i]) && right < toInt(signal[i]));
                else out = true;
            }
        }
        if(out){
            cout << "none" << endl;
            continue;
        }
        if(nox){
            cout << "ambiguous" << endl;
            continue;
        }

        int lb = -inf, ub = inf;
        rep(i, n){
            if(signal[i] == "x"){

                if(i % 2){
                    int left = 0 <= i - 1 ? (toInt(signal[i - 1]) + 1):-inf;
                    int right = i + 1 < signal.size() ? (toInt(signal[i + 1]) + 1):-inf;
                    lb = max(lb, max(left, right));
                }
                else{
                    int left = 0 <= i - 1 ? (toInt(signal[i - 1]) - 1):inf;
                    int right = i + 1 < signal.size() ? (toInt(signal[i + 1]) - 1):inf;
                    ub = min(ub, min(left, right));
                }
            }
        }

        if(ub == lb){
            cout << lb << endl;
        }
        else if(lb < ub){
            cout << "ambiguous" << endl;
        }
        else{
            cout << "none" << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 1300
#include<stdio.h>

int main(void){
	int n,k,s[14]={},h[14]={},c[14]={},d[14]={},i;
	char l;
	scanf("%d",&n);
	for(i=1;i<=n+1;i++){
		scanf("%c %d\n",&l,&k);
		if(l=='S'){
			s[k]++;
		}
		if(l=='H'){
			h[k]++;
		}
		if(l=='C'){
			c[k]++;
		}
		if(l=='D'){
			d[k]++;
		}
	}
	for(i=1;i<=13;i++){
		if(s[i]==0){
			printf("S %d\n",i);
		}
	}
	for(i=1;i<=13;i++){
		if(h[i]==0){
			printf("H %d\n",i);
		}
	}
	for(i=1;i<=13;i++){
		if(c[i]==0){
			printf("C %d\n",i);
		}
	}
	for(i=1;i<=13;i++){
		if(d[i]==0){
			printf("D %d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
        int dp[] = new int[100005];
        dp[0] =0;

        for(int i=1; i<=n; i++){
            int min = Integer.MAX_VALUE;
            for(int j=0; j<a.length; j++){
                if(i>=a[j]){
                    min = Math.min(min,Math.min(dp[i-1]+1,dp[i-a[j]]+1));
                }
            }
            dp[i] = min;
        }
        System.out.println(dp[n]);
    }
}


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

int main() {
  int N;
  int M;
  
  cin >> N >> M;
  vector<int> A(N);
  int a_sum = 0;
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
    a_sum += A.at(i);
  }
  
  int ans = 0;
  for (int i=0; i<N; i++) {
    if (A.at(i)*4*M>=a_sum) {
      ans++;
    }
    else {
      continue;
    }    
  }
  
  if (ans>=M) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t
#include <math.h>

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

int get_int3(int64_t *a1, int64_t *a2, int64_t *a3) {
  scanf("%lld %lld %lld", a1, a2, a3);
  return 0;
}

int main(void) {
    int64_t a, b, limit;
    get_int3(&a, &b, &limit);

    int64_t x = min(limit, b-1);
    int64_t ans = floor(a*x/b) - a * floor(x/b);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1708
# summer vacations, number of assignments
N, M = list(map(int, input().split()))
# each entry in A represents number of days to do the assignment
A = list(map(int, input().split()))

number_of_days_required = sum(A)
maximum_hangout_days = N - number_of_days_required
if maximum_hangout_days >= 0:
    print(maximum_hangout_days)
else:
    print(-1)

Measured memory_bytes: 10032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//vector <vector<ll>> adj;
void pk()
{   
    ll n;
    cin>>n;
    if(n>=30)
       cout<<"Yes";
    else cout<<"No";
}
int main() 
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
	ll t=1;
    //cin>>t;
    while(t--)
    {
        pk();
    }
} 

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


int main()
{
  char b;
  cin >> b;
  if (b =='A') {
    cout << 'T' << endl;
  } else if (b == 'C') {
    cout << 'G' << endl;
  } else if (b == 'G') {
    cout << 'C' << endl;
  } else {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,c[100005],p,a,b;
string s;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>p>>s;
        if(c[p]==-1)continue;
        else if(s=="AC"){a++;b+=c[p];c[p]=-1;}
        else c[p]++;
    }
    cout<<a<<" "<<b;
    return 0;
}

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

int main() {
	long long n;
	vector<char> ans;
	scanf("%lld", &n);
	while(n){
		int d = n % 26;
		if(d > 0) ans.push_back(96 + d);
		else ans.push_back('z');
		if(n % 26 == 0) n--;
		n /= 26;
	}
	for(int i = (int)ans.size() - 1;i >=0;i--) printf("%c",ans[i]);
	printf("\n");
	return 0; 
}


Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int rootN = (int)Math.round(Math.sqrt(N));

        int count=0;
        for(int i=1;i<N;i++){
            for(int j=1;j<=N/i;j++){
                if(i*j<N){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N = 1e3 + 5;
const int M = 1e9 + 7;
int a[N];

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    if(b - a == c - b)
        cout << "YES";
    else
        cout << "NO";
}


Measured memory_bytes: 896
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll A[3] = {};
    cin >> A[0] >> A[1] >> A[2];

    if (A[0] + A[1] + A[2] >= 22)
    {
        puts("bust");
    }
    else
    {
        puts("win");
    }
    return 0;
}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll n;
ll base[52][52];
void multiply(ll a[52][52],ll b[52][52]) 
{ 
    ll mul[n][n]; 
    for (ll i = 0; i < n; i++) 
    { 
        for (ll j = 0; j < n; j++) 
        { 
            mul[i][j] = 0; 
            for (ll k = 0; k < n; k++) 
                mul[i][j]=((mul[i][j]%mod)+((a[i][k]%mod)*(b[k][j]%mod))%mod)%mod; 
        } 
    } 
    for (ll i=0; i<n; i++) 
        for (ll j=0; j<n; j++) 
            a[i][j] = mul[i][j];
} 
ll power(ll F[52][52],ll m)
{
	ll bas[52][52];
	ll i,j;
	for(i=0; i<n; i++)
		for(j=0; j<n; j++)
			bas[i][j]=base[i][j];
	if(m==1)
	{
		ll sum=0;
		for(i=0; i<n; i++)
		{
			for(j=0; j<n; j++)
				sum=((sum%mod)+(F[i][j]%mod))%mod;
		}
		return sum;
	}
	power(F,m/2);
	multiply(F,F);
	if(m%2==1)
		multiply(F,bas);
	ll sum=0;
	for(i=0; i<n; i++)
	{
		for(j=0; j<n; j++)
		{
//			cout<<F[i][j]<<" ";
			sum=((sum%mod)+(F[i][j]%mod))%mod;
		}
//		cout<<endl;
	}
//	cout<<endl;
	return sum;
}
int main()
{
	boost
	ll k;
	cin>>n>>k;
	ll i,j;
	for(i=0; i<n; i++)
		for(j=0; j<n; j++)
			cin>>base[i][j];
	ll ans=power(base,k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1536
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<>();
    for (int i = 0; i < N; i++) {
      set.add(sc.nextInt());
    }
    if (set.size() == N) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 100004