akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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 (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n, x;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> x;
  vii l(n), d(n+1, 0);
  cin >> l;
  d[0] = 0;
  int ans = 1;
  rep(i, 1, n+1) {
    d[i] = d[i-1] + l[i-1];
    if (d[i] <= x) ans++;
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int n;
bool b[101];
int main()
{
	cin>>n;
	for(int i=1;i<=9;i++)
		for(int j=i;j<=9;j++)
			b[i*j]=1;
	if(b[n])cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<pair<int, int> >V(m);
    for (auto &x: V) {
        cin >> x.second >> x.first;
    }
    sort(V.begin(), V.end());
    int b = -1;
    for (auto x: V) {
        if (b <= x.second) {
            ans++;
            b = x.first;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;
int const N_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  if (!po[n]) {
    po[0] = 1;
    FOR(i, 1, n + 1) po[i] = po[i - 1] * i % MOD;
  }
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

// least common multiple
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int N;
ll A[N_MAX + 2], B[N_MAX + 1];

int main() {
  scanf("%d", &N);
  rep(i, N + 1) scanf("%lld", &A[i]);
  rep(i, N) scanf("%lld", &B[i]);

  ll sum = 0;
  ll more = 0;
  rep(i, N + 1) {
    ll a = A[i];
    ll k = B[i];
    if (more > a) {
      more = k;
      sum += a;
      continue;
    } else {
      sum += more;
      a -= more;
    }

    if (k > a) {
      sum += a;
      more = k - a;
    } else {
      sum += k;
      more = 0;
    }
  }
  printf("%lld\n", sum);
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Printf("%d\n", find(n))
}

func find(n int) int {
	var num int
	for i := 1; i <= n; i++ {
		if i%2 == 1 && divisorNumIs(i, 8) {
			num++
		}
	}
	return num
}

func divisorNumIs(n, divisor int) bool {
	life := divisor - 2
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			if n/i == i {
				life--
			} else {
				life -= 2
			}
		}
		if life < 0 {
			break
		}
	}
	return life == 0
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

bool solve(){
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];
  if(n==1) return true;
  long nn = (long)n*(n+1)/2;
  long sum = accumulate(all(vec), 0LL);
  if(sum%nn!=0) return false;
  nn = sum/nn; //操作回数になってる

  rep(i,n){
    long d = vec[(i+1)%n]-vec[i];
    if( d>nn || (nn-d)%n!=0 ) return false;
  }
  return true;
}

int main(){
  if(solve()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])

    return (n,)


def solve(n):

    # result = int((n-1)*n*0.5)
    result = (n-1)*n//2

    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)


if __name__ == '__main__':

    main()
	

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

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

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}

			page = new int[n];
			for (int i = 0; i < n; i++) {
				page[i] = sc.nextInt();
			}
			Arrays.sort(page);
			int start = 0;
			String s = "";
			for (int i = 1; i < n; i++) {
				if (page[i] != page[i - 1] + 1) {
					if (start == i - 1) {
						System.out.print(s + page[start]);
						s = " ";
					} else {
						System.out.print(s + page[start] + "-" + page[i - 1]);
						s = " ";
					}
					start = i;
				}
			}
			if (start == n - 1) {
				System.out.print(s + page[start]);
				s = " ";
			} else {
				System.out.print(s + page[start] + "-" + page[n - 1]);
				s = " ";
			}
			
			System.out.println();
		}
	}
}

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

int main() {
    int n,m;
    cin>>n>>m;
    int dp[n+1]{};
    set<int> a;
    for (int i=0;i<m;i++) {
        int t;cin>>t;
        a.insert(t);
    }
    dp[0]=dp[1]=1;
    if (a.count(1))
        dp[1]=0;
    for (int i=2;i<=n;i++) {
        if (a.count(i))
            continue;
        dp[i]=(dp[i-2]+dp[i-1])%1000000007;
    }
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 5376
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		for(int cnt = 1;cnt <= 5;cnt++){
        	if(sc.nextInt() == 0){
            	System.out.println(cnt);
              	break;
            }
        }
	}
}

Measured memory_bytes: 35756
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll INF = 1e18 + 10 ;
int main(){
    fastio 
    ll n , k ; 
    cin >> n >> k ; 
    vector<pair<ll, ll> > v(n) ; 
    set<ll> s ; 
    for(ll i = 0; i < n; i++){
        cin >> v[i].second >> v[i].first ; 
        s.insert(v[i].second) ; 
    }
    sort(v.rbegin(), v.rend()) ;
    ll types = (ll) s.size() ; 
    ll L = 1, R = min(k,types) ; 
    auto solve = [&](ll mid){
        if ( mid > k ) return 0LL ; 
        set<ll> ss ; 
        ll c = mid ; 
        ll ans = 0 ;
        vector<bool> mark(n) ; 
        for(ll i = 0; i < n && c; i++){
            if ( ss.find(v[i].second) == ss.end() ){
                ans += v[i].first ; 
                ss.insert(v[i].second) ; 
                mark[i] = true ; 
                c--;
            }
        }
        c = k - mid ; 
        for(ll i = 0; i < n; i++){
            if ( !mark[i] && c ){
                ans += v[i].first ; 
                c--;
            }
        }
        return ans + mid * mid; 
    };
    ll ans = 0 ;
    while(L <= R){
        ll mid = L + (R - L) / 2 ;
        ll a = solve(mid) ;
        ll b = solve(mid + 1) ;
        if ( mid + 1 > min(k,types) ) {
            b = solve(mid - 1) ;
            ans = max(a, b) ;
            if ( a > b ){
                L = mid + 1;
            }
            else R = mid - 1;
        }
        ans = max(a, b);
        if ( a < b ){
            L = mid + 1;
        }
        else R = mid - 1;
    }
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 8832
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    string s;
    cin >> s;
    ll ssize =s.size();
    rep(i, ssize) {
        if(s[i]!='?') continue;
        s[i]='D';
    }

    print(s);
    return 0;
}


Measured memory_bytes: 3756
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
long long k,ans;
int tot[55];
long long num[int(1e5)+5];
int main(){
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lld",&num[i]);
		for(int j=0;j<=50;j++)
			if(num[i]&(1ll<<j))
				tot[j]++;
			else
				tot[j]--;
	}
	long long F=0;
	bool fir=true; 
	for(int i=(int)floor(log2(k));i>=0;i--){
		if(fir){
			if(((1ll<<i)&k) && tot[i]<0) F|=(1ll<<i);
			else if(((1ll<<i)&k)) fir=false;
		}
		else
			if(tot[i]<0) F|=(1ll<<i);
	}
	for(int i=0;i<n;i++)
		ans+=F^num[i];
	printf("%lld\n",ans);
	return 0;
}
/*
8421
0001
0110
0011
0100
0
 -1
  1
   1
*/

Measured memory_bytes: 896
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
dp=[[0]*w for _ in range(h)]
if s[0][0]=="#":
    dp[0][0]=1
for i in range(w-1):
    if s[0][i]=="." and s[0][i+1]=="#":
        dp[0][i+1]=dp[0][i]+1
    else:
        dp[0][i+1]=dp[0][i]
for i in range(h-1):
    if s[i][0]=="." and s[i+1][0]=="#":
        dp[i+1][0]=dp[i][0]+1
    else:
        dp[i+1][0]=dp[i][0]
for i in range(1,h):
    for j in range(1,w):
        v=0
        g=0
        if s[i-1][j]=="." and s[i][j]=="#":
            v=1
        if s[i][j-1]=="." and s[i][j]=="#":
            g=1

        dp[i][j]=min(dp[i-1][j]+v,dp[i][j-1]+g)
print(dp[h-1][w-1])


Measured memory_bytes: 74356
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S; cin >> S;
  if(S=="SUN") cout << 7 << endl;
  if(S=="MON") cout << 6 << endl;
  if(S=="TUE") cout << 5 << endl;
  if(S=="WED") cout << 4 << endl;
  if(S=="THU") cout << 3 << endl;
  if(S=="FRI") cout << 2 << endl;
  if(S=="SAT") cout << 1 << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> ans(n, 0);
    rep(i, n) {
        ll ai;
        cin >> ai;
        ai *= 2;
        a[i] = ai;
    }
    ll d = a[0];
    for(int i = 1; i < n; i++) {
        if (i % 2 == 1) d -= a[i];
        else d += a[i];
    }
    ans[0] = d/2;
    for(int i = 1; i < n; i++) {
        ans[i] = a[i-1] - ans[i-1];
    }
    rep(i,n) cout << ans[i] << endl;
}



Measured memory_bytes: 2944
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 58088
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,a[100000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2){
            printf("first\n");
            return 0;
        }
    }
    printf("second\n");
}

Measured memory_bytes: 512
from functools import reduce

# judge if the list contains false. 
def is_all_true(arg):
  if isinstance(arg, bool):
    return arg
  return reduce(lambda x, y: is_all_true(x) and is_all_true(y), arg)

N, M = list(map(int, input().split()))
# list with from and to as elements.
lines_ft = []
for _ in range(M):
  _from, _to = list(map(int, input().split()))
  lines_ft.append((_from, _to))

reachable_counter = 0
# simulation of whether all the islands can be reached when each line is excluded.
for i in range(M):
  # generated per simulation.
  is_reachable = [[False if i != j else True for i in range(N)] for j in range(N)]
  # init by excluding the current lines.
  for f, t in lines_ft[:i] + lines_ft[i + 1:]:
    is_reachable[f - 1][t - 1] = True
    is_reachable[t - 1][f - 1] = True
  # simulate by a list that excludes one line.
  for k in range(N):
    for i in range(N):
      for j in range(N):
        is_reachable[i][j] = is_reachable[i][j] or (is_reachable[i][k] and is_reachable[k][j])
  # verify that there is an unreachable island.
  if not is_all_true(is_reachable):
    reachable_counter += 1

print(reachable_counter)


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

using namespace std;
using int64 = long long int;

int main()
{
	string s, t, u;
	int a, b;

	cin >> s >> t >> a >> b >> u;
	if (s == u)
	{
		a--;
	}
	else
	{
		b--;
	}

	cout << a << " " << b << endl;
}

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

int main() {
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    unsigned long ans{0};
    for(unsigned long i = 0, h; i < N; ++i){
        cin >> h;
        ans += h >= K;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> LR(K);
    rep(i, K) cin >> LR[i].first >> LR[i].second;

    sort(all(LR), [](auto l, auto r){ return l.first<r.first; });
    vll dp(N, 0), s(N+1, 0);
    dp[0] = 1;
    s[1] = 1;
    REP(i, 1, N){
        dp[i] = 0;
        rep(j, K){
            dp[i] += s[max(0ll, i-LR[j].first+1)] - s[max(0ll, i-LR[j].second)];
            dp[i] = (dp[i]+998244353)%998244353;
        }
        s[i+1] = (s[i] + dp[i]) % 998244353;
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 6376
a,b=map(int,input().split())
ans=9999999
for i in range(a,b+1):
    for j in range(i+1,b+1):
        c=i%2019
        d=j%2019
        if (c*d)%2019==0:
            print(0)
            exit()
        elif (c*d)%2019<ans:
            ans=(c*d)%2019
print(ans)

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

using namespace std;

class UnionFindDS{
private:
    vector<int> p, h, sz;   // parent, height (rank), size
    int num;
public:
    UnionFindDS(int N){
        p.assign(N,0); for (int i=0; i<N; i++) p[i] = i;
        h.assign(N,0); sz.assign(N,1);
        num = N;
    }
    int numSets(){ return num; }
    int findSet(int i){ return p[i] == i ? i : p[i] = findSet(p[i]); }
    int sizeSet(int i){ return sz[findSet(i)]; }
    bool isSameSet(int i, int j){ return findSet(i) == findSet(j); }
    void unionSet(int i, int j){
        int x = findSet(i), y = findSet(j);
        if (x == y) return;
        
        num--;
        if (h[x] > h[y]){ p[y] = x; sz[x] += sz[y]; }
        else            { p[x] = y; sz[y] += sz[x]; h[y] += (h[y] == h[x]); }
    }
};

int N, M, op, p, q;

int main(){

    ios_base::sync_with_stdio(false);

    cin >> N >> M;

    UnionFindDS uf(N);

    for (int i=0; i<M; i++){
        cin >> op >> p >> q;

        if (op == 0){
            uf.unionSet(p,q);
        }
        else{
            if (uf.isSameSet(p,q)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1328
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;

int main() {

	char b;
	cin >> b;

	if (b == 'A')cout << 'T';
	else if (b == 'T')cout << 'A';
	else if (b == 'G')cout << 'C';
	else if (b == 'C')cout << 'G';

	cout << endl;

	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    string s; cin>>s;
    int n= s.size();
    ll ans = 0, cnt =0;
    for(int i=0;i<n;i++){
        if(s[i]=='B') cnt++;
        else ans += cnt;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

struct mise{
  string S;
  int P;
  int N;
};

bool mycomp(const mise& lh, const mise& rh){
  if(lh.S==rh.S){
    return lh.P > rh.P;
  }
  else
    return lh.S < rh.S;
}
  
int main(){
  int N;
  cin >> N;
  vector<mise> rest(N);

  string S;
  int P;
  mise temp;
  for(int i=0;i<N;++i){
    cin >> temp.S >> temp.P;
    temp.N=i+1;
    rest.at(i)=temp;
  }

  sort(rest.begin(),rest.end(),mycomp);

  for(int i=0;i<N;++i) cout << rest.at(i).N << endl;
  

  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
const Int DEBUG = 0;
const Int ANS = 99799;

Int ask(Int n){
  cout<<"? "<<n<<endl;
  if(DEBUG){
    if(n<=ANS&&to_string(n)<=to_string(ANS)) return 1;
    if(n> ANS&&to_string(n)> to_string(ANS)) return 1;
    return 0;
  }
  char c;
  cin>>c;
  return c=='Y';
}

Int ans(Int n){
  cout<<"! "<<n<<endl;
  if(DEBUG) assert(ANS == n);
  exit(0);
}

signed main(){
  if(ask(1e9)){
    Int n=2e8;
    while(n){
      if(!ask(n)) ans(n*5);
      n/=10;
    }
    ans(1);
  }
  Int n=1e8;
  while(1){
    if(ask(n)) break;
    n/=10;
  }
  Int l=n,r=n*10;
  while(l+1<r){
    Int m=(l+r)>>1;
    if(ask(m*10)) r=m;
    else l=m;
  }
  ans(r);
  return 0;
}


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

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

    for (int i = 0; i < K; i++) {
        int x, y;
        cin >> x >> y;
        int dis = min(min(x-1, y-1), min(N-x, N-y));
        cout << dis % 3 + 1 << endl;
    }

    return 0;
}

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

bool sugar[3005] = {0}, water[3005] = {0};

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    sugar[c] = true;
    sugar[d] = true;
    water[100*a] = true;
    water[100*b] = true;
    for(int i=1;i<=3000;++i){
        if(sugar[i]){
            if(i+c <= 3000)sugar[i+c] = true;
            if(i+d <= 3000)sugar[i+d] = true;
        }
        if(water[i]){
            if(i+100*a <= 3000)water[i+100*a] = true;
            if(i+100*b <= 3000)water[i+100*b] = true;
        }
    }

    double maxi = 0;
    int sw = 100*a, sg = 0;
    for(int i=100*a;i<=3000;++i){
        if(water[i]){
            for(int j=0;j<=3000;++j){
                if(sugar[j] && i+j <= f && 100*j <= e*i && maxi < 100.0*j/(double)(i+j)){
                    maxi = 100.0*j/(double)(i+j);
                    sw = i + j;
                    sg = j;
                }
            }
        }
    }

    cout << sw << " " << sg << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            min = Math.min(min, num);
            max = Math.max(max, num);
        }

        sc.close();

        System.out.println(max - min);
    }
}

Measured memory_bytes: 21844
H = [[0] * 3 for i in range(3)]
A = [[0] * 3 for i in range(3)]

A[0][0],A[0][1],A[0][2] = map(int,input().split())
A[1][0],A[1][1],A[1][2] = map(int,input().split())
A[2][0],A[2][1],A[2][2] = map(int,input().split())

N = int(input())
for i in range(N):
	ball = int(input())
	for l in range(3):
		for c in range(3):
			if A[l][c] == ball:
				H[l][c] = 1
#print(H)
flag = 0
for l in range(3):
	if H[l][0] ==1 and H[l][1] ==1  and H[l][2] ==1:
		flag =1

for c in range(3):
	if H[0][c] ==1 and H[1][c] ==1  and H[2][c] ==1:
		flag =1

if H[0][0]==1 and H[1][1]==1 and H[2][2]== 1:
	flag = 1

if H[2][0]==1 and H[1][1]==1 and H[0][2]== 1:
	flag = 1

if flag == 1:
	print("Yes")
else:
	print("No")
#A[2][1] = 10
#print(A)
#print(flag)

Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int F[N][10];
    int P[N][11];
    rep(i,N){
        rep(j,10){
            cin>>F[i][j];
        }
    }
    rep(i,N){
        rep(j,11){
            cin>>P[i][j];
        }
    }
    int ans=-INF;
    for(int bit=1;bit<(1<<10);bit++){
        int co=0;
        rep(j,N){
            int sum=0;
            for(int i=0;i<10;i++){
                if(bit&(1<<i)) sum+=F[j][i];
            }
            co+=P[j][sum];
        }
        ans=max(ans,co);
    }
    cout << ans << endl;



}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define foru(i,a,n) for (int i=(a); i<=(n); i++)
#define ford(i,n,a) for (int i=(n); i>=(a); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define foreach(it, a) for (auto it = (a).begin(); it != (a).end(); it++)
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define all(x) (x).begin(),(x).end()
#define ms(s, n) memset(s, n, sizeof(s))
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define fi first
#define se second
#define bit(n, i) (((n) >> (i)) & 1)
#define bit1cnt(x) (__builtin_popcountll(x))
#define bit0dau(x) (__builtin_clzll(x))
#define bit0cuoi(x) (__builtin_ctzll(x))
#define sqr(x) ((x) * (x))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;
typedef vector<ii> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int inf = (int) 1e9;
const ll linf = (ll) 1e18;
const ld pi = acos((ld) -1);
const ld eps = 1e-9;
const int N = 202020;
int n, a, b, vt;
string ans[] = {"Alice" , "Borys" , "Draw"};
int main(){
    cin >>n >>a >>b;
    if((b-a)%2==1) vt = 1; else vt = 0;
    cout <<ans[vt];
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll x, k, d; cin>>x>>k>>d;
	x=abs(x);
	if((x/d)>=k)
	{
		ll y=x-(k*d);
		cout<<y;
	} 
	else
	{
		ll y=x/d;
		k-=y;
		x-=(y*d);
		if(k%2==0)cout<<x;
		else cout<<abs(x-d);
	} 
}

int main()
{
	solve();
}
/*




*/


Measured memory_bytes: 3640
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
#define ll long long
int main()
{
    int flag=0;
    int a,b,c,k;
    int cnt=0;
    cin>>a>>b>>c>>k;
    while(1)
    {
        if(b>a)
        {
            flag=1;
             break;
        }

        b*=2;
        cnt++;
    }
    for(int i=0;i<k-cnt;i++)
    {
        c*=2;
    }
    if(flag==1)
    {
        if(c>b)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3636
loop do
  a = gets.split
  break if a[1] == "?"
  case a[1]
    when "+"
      puts a[0].to_i + a[2].to_i
    when "-"
      puts a[0].to_i - a[2].to_i
    when "*"
      puts a[0].to_i * a[2].to_i
    when "/"
      puts a[0].to_i / a[2].to_i
  end
end

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N, K;
	cin >> N >> K;
	if ((N - 1)*(N - 2) / 2 < K) {
		cout << -1 << endl;
		return 0;
	}

	vector<pair<int, int>> edges;
	K = (N - 1) * (N - 2) / 2 - K;
	FOR(i, 1, N)edges.push_back({ 1,i + 1 });
	FOR(i, 1, N)FOR(j, i + 1, N) {
		if (K == 0)break;
		K--;
		edges.push_back({ i + 1,j + 1 });
	}
	cout << edges.size() << endl;
	for (auto p : edges)cout << p.first << " " << p.second << endl;
	return 0;
}


Measured memory_bytes: 384
#include <ctype.h>
#include <stdio.h>

int main() {
	static char s[128];
	int n, a, b, i;

	scanf("%d%d%s", &a, &b, s);
	n = a + 1 + b;
	for (i = 0; i < n; i++)
		if ((i == a && s[i] != '-') || (i != a && !isdigit(s[i]))) {
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
n,k,c = map(int,input().split())
s = input()
#左右の貪欲 init より大きい点でs[i] == o を探す
l_init = -1
r_init = n
l = []
r = []
# 前から貪欲に探すとl[i] はi+1 回目に働く日の下限である
# 後ろから貪欲に探すとR[i]はk-i 回目に働き日の上限である
# １始まりなので+1 する
for i in range(n):
  if l_init < i and s[i] == "o":
    l.append(i+1)
    l_init = i + c # interval がc 日あるのでi+c 日まで働けない
  j = n-1-i #左からの探索
  if r_init > j and s[j] == "o":
    r.append(j+1)
    r_init = j - c
#print(l[:k],r[len(r)-k:])
# i(1~k)回目に働く時に対して、l[i-1] == r[k-i]かを確かめる
for i in range(1,k+1):
  if l[i-1]  == r[k-i]:
    print(l[i-1])
  

Measured memory_bytes: 65116
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

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

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int l;
  cin >> l;
  double d = 27.0;
  cout << l * l * l / d << endl;

    return 0;
}


Measured memory_bytes: 3700
#include <stdio.h>
#include <string.h>
#include <math.h>


int main(void) {
	int n, m;
	scanf("%d %d", &n, &m);
	int ans = 1;
	int a, oldA = 0;
	long long dp[100002] = { 0 };
	long long mod = 1000000007;
	dp[0] = 0;
	dp[1] = 1;
	for (int i = 0; i < m; ++i) {
		scanf("%d", &a);
		if (oldA && a - oldA == 1) {
			ans = 0;
		}
		oldA = a;
		dp[a + 1] = -1;
	}


	if (ans) {
		for (int i = 2; i < n + 2; ++i) {
			if (dp[i] == -1) {
				dp[i] = 0;
				continue;
			}
			dp[i] += dp[i - 1] != -1 ? dp[i - 1] : 0;
			dp[i] += dp[i - 2] != -1 ? dp[i - 2] : 0;
			dp[i] %= mod;

		}
		printf("%lld", dp[n + 1]);
	}
	else
	{
		printf("0");
	}




	return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	int i;
  	cin >> i;
    cout << i*800-i/15*200 << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b) = readInputLine().split(" ").map { it.toInt() }
    if (a % 2 == 1 && b % 2 == 1) {
        println("Yes")
    } else {
        println("No")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#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;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N, A[MAX_N];

string judge() {
  int mx = -1, mn = INFI, p = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] > mx) {
      mx = A[i];
      p = 1;
    } else if (A[i] == mx) {
      p++;
    }
    mn = min(mn, A[i]);
  }

  if (mx - mn > 1) return "No";

  bool flag;
  if (mn == mx) {
    flag = mx == N - 1 || mx <= N / 2;
  } else {
    int q = N - p;
    flag = q < mx && 2 * (mx - q) <= p;
  }

  return flag? "Yes": "No";
}

void solve() {
  cout << judge() << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  solve();

  return 0;
}


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

string s, t;

void j() {
    char c = t[0];
    for (int i=1; i<t.size(); ++i) {
        t[i-1] = t[i];
    }
    t[t.size()-1] = c;
}

void c() {
    char c = t[t.size()-1];
    for (int i=t.size()-2; i>=0; --i) {
        t[i+1] = t[i];
    }
    t[0] = c;
}

void a() {
    reverse(t.begin(), t.end());
}

void e() {
    if (t.size()%2) {
        char c = t[t.size()/2];
        string a = t.substr(0, t.size()/2), b = t.substr(t.size()/2+1, t.size()/2);
        t = b + c + a;
    }
    else {
        string a = t.substr(0, t.size()/2), b = t.substr(t.size()/2, t.size()/2);
        t = b + a;
    }
}

void p() {
    rep(i, t.size()) {
        if (t[i] == '9') t[i] = '0';
        else if ('0' <= t[i] and t[i] <= '9') t[i]++;
    }
}

void m() {
    rep(i, t.size()) {
        if (t[i] == '0') t[i] = '9';
        else if ('0' <= t[i] and t[i] <= '9') t[i]--;
    }
}

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

    rep(i, n) {

        cin >> s >> t;

        reverse(s.begin(), s.end());
        rep(i, s.size()) {
            switch(s[i]) {
                case 'A': a(); break;
                case 'J': c(); break;
                case 'C': j(); break;
                case 'P': m(); break;
                case 'M': p(); break;
                case 'E': e(); break;
            }
        }

        cout << t << endl;

    }
}

Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef vector<int> vi;

void init(string& P, vi& b)
{
    int i = 0, j = -1; b[0] = -1;
    while (i < P.size())
    {
        while (j >= 0 && P[i] != P[j]) j = b[j];
        b[++i] = ++j;
    }
}

vi kmp(string& T, string& P, vi& b)
{
    vi ret(T.size());
    int i = 0, j = 0;
    while (i < T.size())
    {
        while (j >= 0 && T[i] != P[j]) j = b[j];
        ++i; ++j;
        if (j == P.size())
        {
            ret[i - j] = 1;
            j = b[j];
        }
    }
    
    return ret;
}

vi A, B, r;
int d;
int n;

void cycle() { cout << -1; exit(0); }
int next(int i) {
    if((i += d) >= r.size()) i -= r.size();
    return i;
}

int dfs(int i) {
    if(r[i] == 0) {
        B[i] = 2;
        return 0;
    }
    
    B[i] = 1;
    int l = next(i);
    if(B[l] == 1) cycle();
    if(B[l] == 2) A[i] = A[l] + 1;
    else A[i] = dfs(l) + 1;
    
    B[i] = 2;
    return A[i];
}

int main() {
    string s, t; cin >> s >> t;
    n = s.size();
    while(s.size() < t.size())
        s += s;

    d = t.size();
    s += s;
    
    vi b(t.size() + 1);
    init(t, b);
    r = kmp(s, t, b);
    for(int i = 0; i < s.size(); ++i)
        r[(i + n) % r.size()] |= r[i];

    A.resize(r.size());
    B.resize(r.size());
    
    int mx = 0;
    for(int i = 0; i < r.size(); ++i)
        if(!B[i]) mx = max(mx, dfs(i));
    
    cout << mx;
    return 0;
}

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

#define N 10010
int n, a[N], b[N];
bool isprime(int x) {
	for (int i = 2; 1ll * i * i <= x; ++i) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}
int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
bool ok(int p) {
	if (a[0] % p) {
		return false;
	}
	for (int i = 0; i <= n - 1; ++i) {
		b[i] = a[i + 1];
	}
	for (int i = n; i >= p - 1; --i) {
		(b[i - (p - 1)] += b[i]) %= p;
		b[i] = 0;
	}
	for (int i = 0; i <= n - 1; ++i) {
		if (b[i] % p) {
			return false;
		}
	}
	return true;
}

int main() {
	while (scanf("%d", &n) != EOF) {
		int G = 0; 
		for (int i = 0; i <= n; ++i) {
			scanf("%d", a + i);
			G = gcd(G, abs(a[i]));
		}
		reverse(a, a + 1 + n); 
		vector <int> res;
		for (int i = 2; 1ll * i * i <= G; ++i) {
			if (G % i == 0) {
				res.push_back(i); 
				while (G % i == 0) {
					G /= i;
				}
			}
		}
		if (G > 1) {
			res.push_back(G);
		}
		for (int i = 2; i <= n; ++i) {
			if (isprime(i) && ok(i)) {
				res.push_back(i);
			}
		}
		sort(res.begin(), res.end());
		res.erase(unique(res.begin(), res.end()), res.end());
		for (auto it : res) {
			printf("%d\n", it);
		}
	//	puts("------------");
	}
	return 0;
}


Measured memory_bytes: 384
n = int(input())
s = input()
b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

rot = []
for i in s:
  c = b.find(i)
  d = int(c) + n
  if d >= 26:
    d -= 26
  rot.append(b[d])
r = ''.join(rot)
print(r)

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


int main() {
  int x,y;
  cin >> x >>y;
  if (4*x >= y && 2*x <= y && (4*x-y)%2 == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3616
// ------------------------------------
// Date:2018/ 3/17
// Problem:theater kfda_ _ e.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1010101;

int t[MAX_N];

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

  fill_n(t, MAX_N, 0);
  CIN(N);
  REP(i, N) {
    CIN(a, b);
    t[a - 1]++;
    t[b]--;
  }
  REP(i, MAX_N) {
    t[i + 1] += t[i];
  }
  int cnt = 0;
  REP(i, MAX_N) {
    if (t[i] > 0) cnt++;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n; string s;
    cin >> n >> s;
    if (n >= 3200) {
        cout << s << endl;
    }
    else {
        cout << "red" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    vector<int> a(N);
    REP (i, N) {
        cin >> a[i];
        if ((i+1) % 2 && a[i] % 2) ans++;
    }

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

/*
cd ~/Desktop/Programming/AtCoder/contest/aising2020/aising2020_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/aising2020/aising2020_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/aising2020/aising2020_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count=0;
  for (int a=0;a<=A;a++){
    for (int b = 0; b <=B; b++){
      for (int c = 0; c <=C; c++)
      {
        if (500*a+100*b+50*c==X)
        {
          count++;
        }
      }
    }
  }
  cout<< count  << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll ans1 = a, ans2 = b;
    ans1 -= k;
    k -= a;
    if (k > 0) ans2 -= k;

    printf("%lld %lld\n", max(ans1, (lli)0), max(ans2, (lli)0));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
 
signed main(){
    int n;  cin >> n;
    for(int i = n; i != 0; i--){
        if(pow(i, 0.5) - (int)pow(i, 0.5) == 0){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 384