akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long


class ACatsAndDogs {
public:
    void solve(std::istream &in, std::ostream &out) {
      int a, b, x;
      in >> a >> b >> x;
      out << (a <= x && a + b >= x ? "YES" : "NO") << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  ACatsAndDogs solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long f(int x);

int main(void)
{
    int i;

    int delta;
    long ans;

    while (scanf("%d", &delta) != EOF) {
        ans = 0;
        for (i = delta; i < 600; i += delta) {
            ans += delta * f(i);
        }
        printf("%ld\n", ans);
    }

    return 0;
}

long f(int x)
{
    return x * x;
}

Measured memory_bytes: 596
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
print(K*(K-1)**(N-1))

Measured memory_bytes: 3888
import sys
X = int(input())
 
size    = [100, 101, 102, 103, 104, 105]
value   = [100, 101, 102, 103, 104, 105]
N       = len(size)
MAX_N   = 1000000
 

knapsack_size = X
if knapsack_size >= MAX_N:
    sys.exit(1)
total   = [0 for _ in range(MAX_N)]
choice  = [-1 for _ in range(MAX_N)]
for i in range(N):
    for j in range(size[i], knapsack_size+1):
        repack_total = total[j-size[i]] + value[i]
        if repack_total > total[j]:
            total[j] = repack_total
            choice[j] = i
i = knapsack_size
while choice[i] >= 0:
    i -= size[choice[i]]
if X == total[knapsack_size]:
    print(1)
else:
    print(0)


Measured memory_bytes: 21912
#include<iostream>
using namespace std;
int main()
{
  int n,i,x,l[1000],d=0,dem=1;
  cin >> n >> x;
  for (i=0; i<n; i++) cin >> l[i];
  for (i=0; i<n; i++)
    {
       d += l[i];
       if (d>x) break;
       dem++;
    }
  cout << dem;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int x = n / 100, y = n % 100;
    if (1 <= x && x <= 12 && 1 <= y && y <= 12)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (x > 12 && 1 <= y && y <= 12)
    {
        cout << "YYMM" << endl;
    }
    else if (1 <= x && x <= 12 && y > 12)
    {
        cout << "MMYY" << endl;
    }
    else if (x == 0 && 1 <= y && y <= 12)
    {
        cout << "YYMM" << endl;
    }
    else if (y == 0 && 1 <= x && x <= 12)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    ll n;
    cin>>n;
    ll ans=0;
    ans+=(n/500*1000);
    n%=500;
    cout<<ans+n/5*5<<endl;






    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c,d;
	cin>>a >>b >>c;
	d=c-(a-b);
	if(d>0)
	{cout<<d;}
	if(d<=0)
	{
		cout<<"0";
	}
	return 0;
}

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

const int N = 2e5 + 5;
typedef long long ll;

char a[N];
int n, cnt[N], mod = 2019, p[N], val[N];
ll ans;

int main() {
	cin>>(a + 1);
	n = strlen(a + 1);
	p[0] = 1;
	for(int i = 1; i <= n; i++)
		p[i] = p[i - 1]*10%mod;
	cnt[0] = 1;
	for(int i = n; i; i--) {
		val[i] = (val[i + 1] + (a[i] - '0')*p[n - i])%mod;
		ans += cnt[val[i]];
		cnt[val[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int h,w;
  cin >> h >> w;
  string ans = "Yes";
  string temp = "";
  string t[h][w];
  string m[h+2][w+2];
  
  for(int i = 0;i < h;i++){
    cin >> temp;
  	for(int j = 0;j < w;j++){
    	t[i][j] = temp.substr(j,1);
    }
  }
  
  for(int i = 0;i < h+2;i++){
  	for(int j = 0; j < w+2 ;j ++){
      if(i == 0 || i == h+1) {m[i][j] = ".";}
      else if(j == 0 || j == w+1) {m[i][j] = ".";}
      else{
		m[i][j] = t[i-1][j-1];
      }
    }
  }
//      for(int i = 0;i < h+2;i++){
//  	for(int j = 0; j < w+2 ;j++){
//      cout << m[i][j] << " ";
//    }
//        cout << endl;
//      }
  
  
    for(int i = 1;i < h;i++){
  	for(int j = 1; j < w ;j++){
      if(m[i][j] == "#"){
      	if(m[i][j-1] == "." && m[i][j+1] == "." && m[i-1][j] == "." && m[i+1][j] == "."){
        	ans = "No";
          	cout << ans << endl;  
			return 0;
        }
      }
    }
    }
  

cout << ans << endl;  
return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int sec, min, hour;
        
        sec = sc.nextInt();

        hour = sec / 3600;
        min = (sec%3600) / 60;
        sec = sec % 60;

        System.out.println(hour+":"+min+":"+sec);
    }
}


Measured memory_bytes: 26284
import sys

a, b, c, d = list(map(int, input().split()))

if b < c or d < a:
  print(0)
  sys.exit()

if a < c:
  if b < d:
    print(b - c)
    sys.exit()
  else:
    print(d - c)
else:
  if b < d:
    print(b - a)
  else:
    print(d - a)


Measured memory_bytes: 2940
# NTL_1_A - Prime Factorization
def prime_factorization(x: int) -> dict:
    """
    Prime factorization of a number (trial division)
    
    Args: x (int): a number to be resolved
    Return: ret (dict): {prime factor: power}
    
    e.g., n = 2^a * 3^b -> {2: a, 3: b}
    """
    max_prime, ret = 0, {}
    cnt = 0
    while x % 2 == 0:  # divide x by 2 as much as possible
        x //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        ret[max_prime] = cnt

    cnt = 0
    for i in range(3, int(x ** 0.5) + 1, 2):
        cnt = 0
        while x % i == 0:
            x //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            ret[max_prime] = cnt

    if x > 2:  # when x is prime greater than 2
        max_prime = x
        ret[max_prime] = 1
    return ret


def main():
    N = int(input())
    facts = prime_factorization(N)
    ans = f"{N}: "
    for prime, cnt in facts.items():
        ans += f"{prime} " * cnt
    print(ans[:-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 5664
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


ll a, b;

main(){
	while(cin >> a >> b){
		cout << __gcd(a, b) << " " << a/__gcd(a, b)*b << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int a[MAXN],b[MAXN],n;
long long ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d",a+i,b+i);
	long long add=0;
	for(int i=n;i>0;--i){
		if((a[i]+add)%b[i]==0)continue;
		long long o=b[i]-(a[i]+add)%b[i];
		add+=o;
		ans+=o;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  uli n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0){
    ou((b-a)/2);
    return 0;
  }
  else{
    ou((b-a-1)/2+min(a-1,n-b)+1);
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

typedef long long ll;

const int N_MAX = 100000;

int N, M;
int A[N_MAX];

multiset<int> st;

void erase_one(multiset<int> &st, int v) {
  auto it = st.find(v);
  if (it != st.end()) st.erase(it);
}

void solve() {
  REP(i, N) st.insert(A[i]);
  REP(i, M) {
    int ax = *st.rbegin();
    erase_one(st, ax);
    st.insert(ax >> 1);
  }

  ll ans = 0;
  ITR(st, it) {
    ans += *it;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) scanf("%d", A + i);
}

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


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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  vector<int> a(100);
  int64_t answer=0;
  int p,q,r=0;
  rep(i,N){
    p=i+1;
    q=p%10;
    if(q!=0){
    	while((p/10)!=0)
          p=p/10;
      a[10*p+q]++;
    }
  }
  rep(i,10)
    answer+=a[11*i]*a[11*i];
  rep(i,10){
    rep(j,10){
      if(i!=j)
        answer+=a[10*i+j]*a[10*j+i];
    }
  }
  cout<<answer;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split();
            string A = l[0], B = l[1], C = l[2];

            Console.WriteLine(A[A.Length-1]==B[0]&&B[B.Length-1]==C[0]?"YES":"NO");
        }
    }
}


Measured memory_bytes: 11092
n, m = list(map(int, input().split()))
x =  list(map(int, input().split()))

if n >= m:
    print(0)
    exit(0)

x = sorted(x)
sub = [x[i+1] - x[i] for i in range(len(x) - 1)]
sub = sorted(sub)
ans = 0

for i in range(m - n):
    ans += sub[i]
print(ans)


Measured memory_bytes: 13968
#include "bits/stdc++.h"

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define inp(x) (cin>>x,x)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

//#define lint long long
typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx9[9] ={ 0,1,1,1,0,0,-1,-1,-1 },
dy9[9] ={ 1,1,0,-1,0,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;
	
	lint x,y;cin>>x>>y;
	int i;
	for (i=0;x<=y;++i){
		x*=2;
	}co(i);
	gc();
}

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

int main()
{
	int n,x,ans=1;

	
	cin>>n>>x;

	vector<int> L(n+1);
	vector<int> vec(n+5);

	vec[0] = 0;

	for(int i=0;i<n;i++)
	{
		cin>>L[i];
	}

	for(int j = 1;j<=n+1;j++)
	{
		vec[j]=vec[j-1] + L[j-1];
		if(vec[j] > x)
		{
			break;
		}
		else if(vec[j] == x)
		{
			ans++;
			break;
		}
      if(j==n+1 && vec[j] < x)
      {
        ans--;
      }
		ans++;
      	
	}

	cout<<ans<<endl;
  	

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/
lint euc(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b) return euc(b, a);
	lint r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}


int main() {
	lint A, B, C, D;
	cin >> A >> B >> C >> D;
	lint ans1 = 0;
	lint ans2 = 0;
	ans1 += ((B / C) + (B / D) - (B / ((C * D / euc(C, D)))));
	ans1 = B - ans1;
	A--;
	ans2 += ((A / C) + (A / D) - (A / ((C * D / euc(C, D)))));
	ans2 = A - ans2;
	cout << ans1-ans2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>v;
int main()
{
    int a,b,t;
    cin >> a >> b >> t;
    double T = t + 0.5;
    int A =  T / a;
    int Output =  A * b;
    cout << Output;
    return 0;
}


Measured memory_bytes: 256
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}

ll n,a,b,blast[MAX],arr[MAX];

bool check(ll t){
	ll curr = 0;
	FOR(i,0,n){
		ll now = max(0LL, arr[i]-t*b);
		curr+=(now+a-1)/a;
	}
	return curr<=t;
}


int main(){
	base();
	cin>>n>>a>>b;
	FOR(i,0,n){
		cin>>arr[i];
	}
	a-=b;
	ll t,l=0,r=2e9;
	while(l<r){
		t = (l+r)/2;
		if (check(t)) r=t;
		else l=t+1;
	}
	cout<<r<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    ll X;
    cin>>X;
    ll ans=0;
    ans=(X/500)*1000;
    X-=(X/500)*500;
    ans+=(X/5)*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define ll long long
using namespace std;
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int N=1e5+5;
const int P=998244353;
const int d=1000000000000000000ll%P;
vector<int>A[N],B[N],C[N];
int n,m,mx,f[N],a[N],b[N],f1[N],f2[N],f3[N],vi[N];
void Add(int &x,int y){
	x+=y,x-=x>=P?P:0;
}
ll fsp(ll x,int y){
	ll ans=1;
	while(y){
		if(y&1)	ans=ans*x%P;
		x=x*x%P,y>>=1;
	}
	return ans;
}
int main(){
	n=read();
	mx=max(mx,m=read());	while(m--){
		int x=read(),y=read();
		if(x>y)	swap(x,y);	
		A[x].push_back(y);
	}
	mx=max(mx,m=read());	while(m--){
		int x=read(),y=read();
		if(x>y)	swap(x,y);	
		B[x].push_back(y);
	}
	mx=max(mx,m=read());	while(m--){
		int x=read(),y=read();
		if(x>y)	swap(x,y);	
		C[x].push_back(y);
	}
	for(int i=n;i;i--){
		int k=0,si=A[i].size();
		for(int j=0;j<si;j++)	vi[f1[A[i][j]]]=1;
		while(vi[k])	++k;
		f1[i]=k;
		for(int j=0;j<si;j++)	vi[f1[A[i][j]]]=0;
	}
	for(int i=n;i;i--){
		int k=0,si=B[i].size();
		for(int j=0;j<si;j++)	vi[f2[B[i][j]]]=1;
		while(vi[k])	++k;
		f2[i]=k;
		for(int j=0;j<si;j++)	vi[f2[B[i][j]]]=0;
	}
	for(int i=n;i;i--){
		int k=0,si=C[i].size();
		for(int j=0;j<si;j++)	vi[f3[C[i][j]]]=1;
		while(vi[k])	++k;
		f3[i]=k;
		for(int j=0;j<si;j++)	vi[f3[C[i][j]]]=0;
	}
	for(int i=1;i<=n;i++)	Add(a[f1[i]],fsp(d,i));
	for(int i=1;i<=n;i++)	Add(b[f2[i]],fsp(d,i));
	int k=sqrt(mx)*2;
	for(int i=0;i<=k;i++)	
		for(int j=0;j<=k;j++)
			Add(f[i^j],1LL*a[i]*b[j]%P);
	for(int i=0;i<=k;i++)	a[i]=f[i],f[i]=0,b[i]=0;
	for(int i=1;i<=n;i++)	Add(b[f3[i]],fsp(d,i));
	for(int i=0;i<=k;i++)	
		for(int j=0;j<=k;j++)
			Add(f[i^j],1LL*a[i]*b[j]%P);
	printf("%d\n",f[0]);
	return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

pll digit(ll n) {
  ll base;

  ll k = 1;
  ll ksum = 1;
  ll dg = 1;
  for (ll i = 1; i <= 15; i++) {
    k *= 26;
    if (n < (ksum + k)) {
      dg = i;
      base = n - ksum;
      break;
    }
    ksum += k;
  }
  return make_pair(dg, base);
}

string calc1(ll n) {
  string ans = "";

  auto p = digit(n);

  ll dg = p.first;
  ll base = p.second;

  ll k = 1;
  for (ll i = dg; i >= 1; i--) {
    k = 1;
    for (ll j = 0; j < i - 1; j++) {
      k *= 26;
    }

    ll c = base / k;
    ll ch = 'a' + c;
    ans += ch;

    base -= k * c;
  }

  return ans;
}

string calc2(ll n) {
  string ans = "";

  ll x = n - 1;

  for (;;) {
    ll q = x / 26;
    ll r = x % 26;

    char ch = 'a' + r;
    ans = ch + ans;

    if (x < 26) {
      break;
    }

    x = q - 1;
  }

  return ans;
}

int main() {
  ll N;
  scanf("%lld", &N);

  // cout << calc1(N) << endl;
  cout << calc2(N) << endl;
}


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

using namespace std;

const int MOD = 1000000007;

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<vector<long long>> dp(N, vector<long long>(N, 0));
        dp[0][N-1] = 1;
        for(int i=0;i<M;i++){
            vector<vector<long long>> next(N, vector<long long>(N, 0));
            for(int j=0;j<N;j++){
                for(int k=0;k<N-j;k++){
                    int start = j+1;
                    int stay = N-start-k;
                    next[j+stay][k] += start * dp[j][k];
                    next[j+stay][k] %= MOD;
                    next[j][k] += stay * dp[j][k];
                    next[j][k] %= MOD;
                    if(k > 0){
                        next[j][k-1] += k * dp[j][k];
                        next[j][k-1] %= MOD;
                    }
                }
            }
            dp = next;
        }
        cout << dp[N-1][0] << endl;
    }
}

Measured memory_bytes: 1728
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto as = readln.split.to!(long[]);

    long[] cs, ss;
    cs.length = N;
    ss.length = N;

    long s, sx;
    foreach (i, a; as) {
        s += a;
        if (i < K-1) continue;
        if (i >= K) s -= as[i-K];
        cs[i-K+1] = s;
    }
    foreach (a; as) if (a > 0) sx += a;
    s = 0;
    foreach (i, a; as) {
        if (a > 0) s += a;
        if (i < K-1) continue;
        if (i >= K && as[i-K] > 0) s -= as[i-K];
        ss[i-K+1] = sx - s;
    }

    long r;
    foreach (i; 0..N-K+1) r = max(r, ss[i], ss[i] + cs[i]);
    writeln(r);
}

Measured memory_bytes: 7448
#include <bits/stdc++.h>
using namespace std;
#define rip(a,b,c) for(int (a)=(c);(a)<(b);(a)++)
const long long INF= 1LL << 60;
int main(){
    //入力始まり
    int A,B;
    cin >> A >> B;
    //入力終わり

    
    for(int price=0;price<10000;price++){
        int num=price*0.08;
        int secondnum=price*0.10;
        if((num==A)&&(secondnum==B)){
            cout << price << endl;
            return 0;
        }
    }

    cout << -1 << endl;


}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 55;

ll choose [MAX_N][MAX_N];

int main () {
  choose[0][0] = 1;
  for (int i = 1; i < MAX_N; i++) {
    choose[i][0] = 1;
    for (int j = 1; j < MAX_N; j++) {
      choose[i][j] = choose[i - 1][j - 1] + choose[i - 1][j];
    }
  }

  int n, p;
  cin >> n >> p;

  int c0 = 0, c1 = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    if (x % 2 == 0) c0++;
    else c1++;
  }

  ll oddw = 0;
  for (int i = p; i <= c1; i += 2) {
    oddw += choose[c1][i];
  }

  ll ans = oddw * (1LL << c0);
  cout << ans << endl;
}


Measured memory_bytes: 3636
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        # 確かめるのはnの平方根までで大丈夫
        if not is_prime[i]:  # すでにfalseなら次のiへ
            continue
            """
            bool(not False)はTrueになる
            """
        for j in range(i * 2, n + 1, i):
            # iずつ大きくなる(つまりiの倍数をみる)
            is_prime[j] = False
            # i自身を除くiの倍数を全てFalseにする
    return [i for i in range(n + 1) if is_prime[i]]
    # Trueのものだけ列挙して返す


N = int(input())
prime_numbers = primes(55555)
ans = []
for p in prime_numbers:
    if p % 5 == 1:
        ans.append(p)
print(" ".join(map(str, ans[:N])))


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

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

int judge(vector<int>& card)
{
    if ((card[0] < card[1]) &&
        (card[1] < card[2]))
    {
        return 1;
    }
    return 0;
}

int main()
{
    vector<int> card(3);
    REP(i, 3)
    cin >> card[i];
    int K;
    cin >> K;

    if(judge(card))
    {
        cout << "Yes" << endl;
        return 0;
    }

    for(int i = 0; i < K; i++)
    {
        if (card[2] <= card[0] ||
            card[2] <= card[1])
        {
            // 青のカードが赤のカードより小さかったら倍にする
            card[2] *= 2;
        }
        else if (card[1] <= card[0])
        {
            // 緑のカードが赤のカードより小さかったら倍にする
            card[1] *= 2;
        }

        if (judge(card))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3556
def abc073_c():
    from collections import Counter
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a_count = Counter(a)
    ans = 0

    for num in a_count:
        if a_count[num] % 2:
            ans += 1
    print(ans)


abc073_c()

Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

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

  int cnt = 0;
  int height = 0;

  for (int i = 0; i < n; i++) {
    if (height < h[i]) {
      cnt += h[i] - height;
      height = h[i];
    } else {
      height = h[i];
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 10000000
#define LEN 12
int n;
char dic[MAX][LEN];

long long makekey(char *str){
  long long k=0,p=1,i;
  int len=strlen(str);
  for(i=0;i<len;i++){
    if(str[i]=='A') k+=1*p;
    else if(str[i]=='C') k+=2*p;
    else if(str[i]=='G') k+=3*p;
    else if(str[i]=='T') k+=4*p;
    p*=5;
  }
  return k;
}
int insert(char *str){
  long long key,place;
  int i;
  key=makekey(str);
  for(i=0;;i++){
    place= (key%MAX)+(i*(1+key%(MAX-1)));
    if(strcmp(str,dic[place])==0) return 1;
    else if(strlen(dic[place])==0) {
      strcpy(dic[place],str);
      return 0;
    }
  }
  return 0;
}
int find(char *str){
  long long key,place;
  int i;
  key=makekey(str);
  for(i=0;;i++){
    place=(key%MAX)+(i*(1+key%(MAX-1)));
    if(strcmp(str,dic[place])==0) return 1;
    else if(strlen(dic[place])==0) return 0;
  }
  return 0;
}

int main(){
  int i;
  char com[10],str[LEN+1];
  for(i=0;i<MAX;i++) dic[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(str);
    }else if(com[0]=='f'){
      if(find(str)==1) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 118924
#include <iostream>
#include <set>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  int d, a;
  set<int> s;
  for(int i=0; i<k; i++){
    cin >> d;
    for(int j=0; j<d; j++){
      cin >> a;
      s.insert(a);
    }
  }
  cout << n-s.size();
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] d = new int[N];

      for (int i = 0; i < d.length; ++i) {
        d[i] = in.nextInt();
      }

      int sum = 0;

      for (int i = 0; i < d.length; ++i) {
        for (int j = i + 1; j < d.length; ++j) {
          sum += d[i] * d[j];
        }
      }

      System.out.println(sum);
    }
  }
}

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

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

	if(N >= 400 && N<= 599){
		cout << 8 << endl;
	}else if(N >= 600 && N<= 799){
		cout << 7 << endl;
	}else if(N >= 800 && N<= 999){
		cout << 6 << endl;
	}else if(N >= 1000 && N<= 1199){
		cout << 5 << endl;
	}else if(N >= 1200 && N<= 1399){
		cout << 4 << endl;
	}else if(N >= 1400 && N<= 1599){
		cout << 3 << endl;
	}else if(N >= 1600 && N<= 1799){
		cout << 2 << endl;
	}else{
		cout << 1 << endl;
	}
}


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

int main() {
    int n,k;
    cin >> n >> k;
    if(k*2 - 1 <= n){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
M = 1e+18
a,b,c,k = gets.chomp.split(' ').map(&:to_i)

if (a - b).abs > M then
  puts 'Unfair'
else
  if k % 2 == 0 then
    puts (a - b).to_s
  else
    puts (b - a).to_s
  end
end

Measured memory_bytes: 1788
#include<iostream>

using namespace std;

int main(void){
    int x;
    int i = 0;
    while(true){
        cin >> x;
        i++;
            if(x == 0){
                break;
            }
        cout << "Case " << i << ": " << x << endl;
    
    }
    return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
ll fac[maxn];
ll inv[maxn];

ll power(ll base,ll n)
{
    ll r=1;
    while(n)
    {
        if(n%2) r=r*base%mod;
        base=base*base%mod;
        n/=2;
    }
    return r;
}

void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*(i);
        fac[i]%=mod;
    }
    inv[maxn-1]=power(fac[maxn-1],mod-2);
    for(int i=maxn-2;i>=0;i--)
    {
        inv[i]=inv[i+1]*(i+1);
        inv[i]%=mod;
    }
}

ll C(ll m,ll n)
{
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    //cout<<C(2,5)<<'\n';
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    int l=b+1;
    //int row=1;
    /*ll temp1=C(0,col+row-2);
    temp1%=mod;
    ll temp2=C(w-col,w+h-2);
    temp2%=mod;
    ll ans=temp1*temp2;
    ans%=mod;*/
    //cout<<ans<<'\n';
    ll sum=0;
    ll ans=0;
    for(int i=1;i<=h-a;i++)
    {
        ll zong=i+l-2;
        ll temp=C(1ll*(i-1),zong);
        temp-=sum;
        temp=(temp+mod)%mod;
        sum+=temp;
        sum%=mod;
        //cout<<temp<<'\n';
        //cout<<w-b<<'\n';
        //cout<<h+w-i-l<<'\n';
        ll temp2=C(w-l,h+w-i-l);
        temp=temp*temp2%mod;
        ans+=temp;
        ans%=mod;
    }
    cout<<ans<<'\n';



}


Measured memory_bytes: 6712
#include<stdio.h>
#include<string.h>
#define N 100000
int min(int a, int b)
{return a < b ? a : b;}

typedef struct{
  char name[100];
  int t;
}data;

data Q[N+1];
int head,tail,n;

void enqueue(data x){
  Q[tail] = x;
  if( tail == N)
    tail = 1;
  else
    tail++;
}

data dequeue(){
  data x = Q[head];
  if( head == N)
    head = 1;
  else
    head++;
  return x;
}

int main(){
  int a=0,b,i,q;
  data data;
  scanf("%d%d", &n, &q);
  for(i = 1;i <= n; i++)
    scanf("%s%d", Q[i].name, &Q[i].t);

  head = 1;
  tail = n+1;

  while(1){
    if( head == tail) break;
    data = dequeue();
    b = min(q, data.t);
    data.t -= b;
    a += b;
    if(data.t > 0)
      enqueue(data);
    else
      printf("%s %d\n", data.name, a);
  }

  return 0;
}




Measured memory_bytes: 11852
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;

int main(){
  long x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  if (x/d>=k) {
    cout<<x-k*d;
  } else {
    long l=x%d,m=x/d;
    if((k-m)%2==0){
      cout<<l;
    } else {
      cout<<d-l;
    }
  }
  
}


/* きょむ〜 */


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vll h(n);
    rep(i, n) cin >> h[i];
    vll dp(n + 10);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
const ll limit = 100010;

struct Edge{
	int to; ll cost;
	Edge(){}
	Edge(int to,ll cost): to(to),cost(cost){}
};

vector<Edge> tree[limit];
ll depth[limit];    //Kからの距離

void dfs(int v, int p, ll d){
    depth[v] = d;
    for(auto e : tree[v]){
        if(e.to == p) continue;
        dfs(e.to, v, d+e.cost);
    }
}

int main(){
    ll N;
    cin >> N;
    rep(i,N-1){
        ll a,b,c; cin >> a >> b >> c;
        tree[a].push_back(Edge(b, c));
        tree[b].push_back(Edge(a, c));
    }
    ll Q,K; cin >> Q >> K;
    vector<ll> ans(Q+1);
    dfs(K,-1,0);
    rep(i,Q){
        int x,y; cin >> x >> y;
        ans[i] = depth[x] + depth[y];
    }
    rep(i,Q) cout << ans[i] << endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long

using namespace std;

bool pal(string s) {
	string t(s.rbegin(), s.rend());
	return s == t;
}

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = s.length();
	string s1 = s.substr(0, n/2);
	string s2 = s.substr(n/2+1, n/2);
	cout << (pal(s) && pal(s1) && pal(s2) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define ld long double
using namespace std;

const int maxn = 2e5+100;
const int mod = 1e9+7;
const int INF = 3e18+315;
int a,b;

int32_t main()
{
  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  cin >> a >> b;
  if(a*b % 2 == 1)
    cout << "Yes";
  else if(a*b*3 % 2 == 1)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}



Measured memory_bytes: 256
N = int(input())
S = str(input())
_ = input()

l = []
i = 0

while(i < N):
    if i == N-1:
        l.append(1)
        i += 1
        continue

    if S[i] == S[i + 1]:
        l.append(2)
        i += 2
    else:
        l.append(1)
        i += 1

acc = 1
for j in range(len(l)):
    if j == 0:
        if (l[j] == 1):
            acc *= 3
            continue
        else:
            acc *= 6
            continue

    if l[j-1] == 1:
        acc *= 2
    else:
        if (l[j] == 1):
            acc *= 1
        else:
            acc *= 3

print(acc % 1000000007)


Measured memory_bytes: 3064
#include<stdio.h>
int main() {

	int x,n,i,f=0,a,b,c,p[101];

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

	for (i = 0; i <= n - 1; i++) {
		scanf("%d", &p[i]);
	}
	a = x-1;
	b = x+1;

	for (i = 0; i <= n - 1; i++) {
		if (x == p[i]) {
			f = 1;
		}
	}
	if (f == 1) {
		while (f == 1) {
			f = 0;
			for (i = 0; i <= n - 1; i++) {
				if (a == p[i]) {
					f = 1;
				}
			}
			if (f == 0) {
				c = a;
				break;
			}
			f = 0;
			for (i = 0; i <= n - 1; i++) {
				if (b == p[i]) {
					f = 1;
				}
			}
			if (f == 0) {
				c = b;
				break;
			}
			
			a-=1;
			b+=1;
			
		}
		printf("%d", c);
	}
	else {
		printf("%d", x);
	}

	return 0;

}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int H, W, S;
int U[34][34];
int total;
i_i dp[34][34][34][34];
int sum[35][35];


int f(int h1, int h2, int w1, int w2) {
    int ret = sum[h2][w2];
    ret -= sum[h1-1][w2];
    ret -= sum[h2][w1-1];
    ret += sum[h1-1][w1-1];
    return ret;
}


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> H >> W >> S;
        total = 0;
        if(H == 0) break;
        for(int h = 1; h <= H; h++) {
            for(int w = 1; w <= W; w++) {
                cin >> U[h][w];
                total += U[h][w];
            }
        }
        for(int i = 0; i <= 34; i++) {
            sum[i][0] = 0;
            sum[0][i] = 0;
        }
        for(int h = 1; h <= H; h++) {
            for(int w = 1; w <= W; w++) {
                sum[h][w] = sum[h-1][w] + sum[h][w-1] - sum[h-1][w-1] + U[h][w];
            }
        }
        for(int dh = 1; dh <= H; dh++) {
            for(int dw = 1; dw <= W; dw++) {
                for(int h1 = 1; h1 + dh - 1 <= H; h1++) {
                    int h2 = h1 + dh - 1;
                    for(int w1 = 1; w1 + dw - 1 <= W; w1++) {
                        int w2 = w1 + dw - 1;
                        dp[h1][h2][w1][w2] = {-INF, 0};
                        //cerr << h1 << " " << h2 << " " << w1 << " " << w2 << " " << f(h1, h2, w1, w2) << endl;
                        if(total - f(h1, h2, w1, w2) <= S) {
                            dp[h1][h2][w1][w2] = {1, S - total + f(h1, h2, w1, w2)};
                        }
                        for(int h3 = h1 + 1; h3 <= h2; h3++) {
                            i_i now;
                            now.first = dp[h1][h3-1][w1][w2].first + dp[h3][h2][w1][w2].first;
                            now.second = min(dp[h1][h3-1][w1][w2].second, dp[h3][h2][w1][w2].second);
                            if(now.first > dp[h1][h2][w1][w2].first) dp[h1][h2][w1][w2] = now;
                            else if(now.first == dp[h1][h2][w1][w2].first && now.second > dp[h1][h2][w1][w2].second) dp[h1][h2][w1][w2] = now;
                        }
                        for(int w3 = w1 + 1; w3 <= w2; w3++) {
                            i_i now;
                            now.first = dp[h1][h2][w1][w3-1].first + dp[h1][h2][w3][w2].first;
                            now.second = min(dp[h1][h2][w1][w3-1].second, dp[h1][h2][w3][w2].second);
                            if(now.first > dp[h1][h2][w1][w2].first) dp[h1][h2][w1][w2] = now;
                            else if(now.first == dp[h1][h2][w1][w2].first && now.second > dp[h1][h2][w1][w2].second) dp[h1][h2][w1][w2] = now;
                        }
                    }
                }
            }
        }
        cout << dp[1][H][1][W].first << " " << dp[1][H][1][W].second << endl;
    }
    return 0;
}


Measured memory_bytes: 8000
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL <<60;  
     
long long gcn(long long x,long long y){
  if(x%y==0){
    return y;  
  }
  else{
    return gcn(y,x%y);
  }
}
int main(void){
  long long tmp;
  long long i,j,k;
  long res=0;

  cin>>tmp;
  
  if(tmp==1){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }
  
 // cout<<res<<endl;
  return 0;
}

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

bool is_consistent(const int k, const int a, const int b)
{
    return b + (a ? 1 : 0) <= k && k <= b + a/2;
}

bool solve()
{
    int N;
    cin >> N;

    vector<int> a(N);
    for (int& x : a)
        cin >> x;

    const int k = *max_element(begin(a), end(a));
    const int min = *min_element(begin(a), end(a));
    if (min == k)
        return is_consistent(k, N, 0) || is_consistent(k+1, 0, N);
    else if (min == k-1)
        return is_consistent(k, int(count(begin(a), end(a), k)),
                int(count(begin(a), end(a), k-1)));
    else
        return false;
}

int main()
{
    cout << (solve() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int d, t, s;

int main() {

	cin >> d >> t >> s;

	if (d <= t * s)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
int a[3],k;
cin>>a[0]>>a[1]>>a[2]>>k;
sort(a,a+3);
for(int i=0;i<k;i++)
a[2]*=2;
cout<<a[0]+a[1]+a[2];
system("pause");
return 0;
}

Measured memory_bytes: 504
use std::cmp::max;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    let mut cnt = 1;
    let mut cnts = vec![];
    let mut uprights = 0;

    for i in 0..n - 1 {
        if s[i] != s[i + 1] {
            if cnt != 0 {
                if s[i] == '0' {
                    uprights += 1;
                }
                cnts.push(cnt);
                cnt = 0;
            }
        }
        cnt += 1;
    }
    if cnt != 0 {
        cnts.push(cnt);
    }
    if s[n - 1] == '0' {
        uprights += 1;
    }

    if uprights <= k {
        println!("{}", n);
        return;
    }

    let mut max_i = 0;

    if s[0] == '0' {
        max_i = max(max_i, cnts.iter().take(2 * k).sum());
        cnts.remove(0);
    }

    if s[n - 1] == '0' {
        max_i = max(max_i, cnts.iter().rev().take(2 * k).sum());
        let last = cnts.len() - 1;
        cnts.remove(last);
    }

    if cnts.len() > 2 * k {
        let mut v = vec![0; cnts.len() + 1];

        for i in 0..cnts.len() {
            v[i + 1] = v[i] + cnts[i];
        }

        for (i, j) in (2 * k + 1..v.len()).enumerate() {
            if i % 2 == 0 {
                max_i = max(max_i, v[j] - v[j - (2 * k + 1)]);
            }
        }
    }

    println!("{}", max_i);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6396
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int a, b, c;

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

	if (a == b&&b == c)
	{
		printf("Yes\n");
	}

	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 200100;
int R[maxn];
int main()
{
    int n;
    cin >> n;
    for(int i = 0 ; i < n; i++)
        cin >> R[i];
    int maxr = R[1] - R[0];
    int minv = R[0];
    for(int i = 1; i < n; i++)
    {
        minv = min(minv, R[i - 1]);
        maxr = max(maxr, R[i] - minv);
    }
    cout << maxr << endl;
    return 0;
}



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

using namespace std;
 
int main()
{
       string s;
       getline(cin, s);
       if(s == "")
            return 0;   
        int n = s.size();
        for(int i=0; i<n; ++i){
               if('A' <= s[i] && s[i] <= 'Z'){
                   if(s[i]=='A') s[i]='X';
                   else if(s[i]=='B') s[i]='Y';
                        else if(s[i]=='C') s[i]='Z';
                             else s[i]=s[i]-3;  }
        }
        cout<<s<<endl; 
        return 0;
}

Measured memory_bytes: 1176