akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repl(i, a, b) for (ll i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = b; i >= (a); --i)
#define repdl(i, a, b) for (ll i = b; i >= (a); --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1'000'000'007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int a[1000005];
int cnt[1000005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  int g = 0;
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    g = __gcd(g, a[i]);
    if (x == 1)
      continue;
    for (int j = 2; 1LL * j * j <= x; j++) {
      if (x % j == 0)
        cnt[j]++;
      while (x % j == 0)
        x /= j;
    }
    if (x != 1)
      cnt[x]++;
  }
  int ok = 1;
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    for (int j = 2; 1LL * j * j <= x; j++) {
      if (x % j == 0 && cnt[j] > 1)
        ok = 0;
      while (x % j == 0)
        x /= j;
    }
    if (cnt[x] > 1)
      ok = 0;
  }
  if (ok) {
    cout << "pairwise coprime" << endl;
  } else if (g == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 11340
from itertools import product
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())

Measured memory_bytes: 3064
/* ex4_2
   Acro  */

#include <stdio.h> 
#include <math.h>
#include <stdlib.h>
int main(void){
    int length_h,length_m,hour,minute;
    long double ans,theta;
    scanf("%d %d %d %d",&length_h,&length_m,&hour,&minute);
    /* 角度を求める */
    theta = 2*M_PI * ((minute/(long double)60) - (hour/(long double)12 + minute/(long double)(12*60)));
    /* 余弦定理 */
    ans = sqrt((long double)length_h*length_h + (long double)length_m*length_m - (long double)2*length_h*length_m*cos(theta));
    printf("%20.20Lf\n",ans);
    return 0;
}

Measured memory_bytes: 2600
def cal_price(x)
  if x == 1
    price = 300000
  elsif x == 2
    price = 200000
  elsif x == 3
    price = 100000
  else
    price = 0
  end
  return price
end

X, Y = gets.split(' ').map(&:to_i)
price = 0
price += cal_price(X)
price += cal_price(Y)
price += 400000 if X == 1 && Y == 1
puts price

Measured memory_bytes: 3836
// B - ATCoder
#include <bits/stdc++.h>
using namespace std;

int main(){
	string T = "ATCG", S; cin>>S;
	int maxi = 0;
	for(int s=0; s<S.size(); ++s){
		for(int e=s; e<S.size(); ++e){
			if(T.find(S[e])>=T.size()) break;
			maxi = max(maxi, e-s+1);
		}
	}
	cout<< maxi <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
struct edge{ ll to; ll cap; ll rev;};
const ll MAXN=110;
vector<edge> G[MAXN];
ll Start=MAXN-2, Goal=MAXN-1;
bool used[MAXN];

void addEdge0(ll from, ll to, ll cap){
    edge A={to,cap,(ll)G[to].size()};
    edge B={from,0,(ll)G[from].size()};
    G[from].push_back(A);
    G[to].push_back(B);
    return;
}//有向グラフを作る

void addEdge1(ll a, ll b, ll cap){
    edge A={b,cap,(ll)G[b].size()};
    edge B={a,cap,(ll)G[a].size()};
    G[a].push_back(A);
    G[b].push_back(B);
    return;
}//無向グラフを作る

ll dfs(ll v, ll t, ll f){
    if(v==t) return f;
    used[v]=true;
    rep(i,G[v].size()){
        edge &e=G[v][i];
        if(!used[e.to] && e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}



ll MaxFlow(){
    ll ans=0;
    while(true){
        rep(i,MAXN) used[i]=false;
        ll P=dfs(Start,Goal,INF);
        if(P==0) break;
        ans+=P;
    }
    return ans;
}

int main(){
    ll V,E; cin>>V>>E;
    Start=0;
    Goal=V-1;
    rep(i,E){
        ll a,b,c; cin>>a>>b>>c;
        addEdge0(a,b,c);
    }
    cout<<MaxFlow()<<endl;

}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

vector<ll> _dfs(ll start, const ll& depth, vector<ll>& burger)
{
    vector<ll> next_burger;
    if(start != depth)
    {
        if(start == 0)
        {
            next_burger.push_back(1);
        }
        else
        {
            next_burger.push_back(0);
            next_burger.insert(next_burger.end(), burger.begin(), burger.end());
            next_burger.push_back(1);
            next_burger.insert(next_burger.end(), burger.begin(), burger.end());
            next_burger.push_back(0);
        }
        start++;
        burger = _dfs(start, depth, next_burger);
    }
    return burger;
}

ll dfs(ll N, ll X, vector<ll> & all, vector<ll>& p)
{
    if(N==0)
    {
        if(X<=0) return 0;
        else return 1;
    }else if(X <= 1 + all[N-1])
    {
        return dfs(N-1, X-1, all, p);
    }else
    {
        return p[N-1] + 1 + dfs(N-1, X - all[N-1] - 2, all, p);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, X;
    cin >> N >> X;
    // 層の数は 2(L-1)+3
    // レベルあたりのパティの数は 2(L-1)+1
    vector<ll> all(N);
    vector<ll> p(N);
    for(size_t i=0;i<N; i++)
    {
        if(i==0)
        {
            all[0] = 1;
            p[0] = 1;
        }else
        {
            all[i] = 2 * all[i-1] + 3;
            p[i] = 2* p[i-1] + 1;
        }
    }
    //vector<ll> burger;
    //burger = dfs(N,X);
    //cerr << burger.size() << endl;
    cout << dfs(N, X, all, p) << endl; 
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			
			int[] as = new int[N];
			for(int i = 0; i < N; i++) {
				as[i] = sc.nextInt();
			}
			
			Arrays.sort(as);
			
			int sum = 0;
			for(int i = 0; i < K; i++) { sum += as[i]; }
			
			System.out.println(sum);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
     string a, b, c;
     cin >> a >> b >> c;
     a.at(0) += ('A' - 'a');
     b.at(0) += ('A' - 'a');
     c.at(0) += ('A' - 'a');
     cout << a.at(0) << b.at(0) << c.at(0); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template <long long mod>
class Combination
{
    std::vector<long long> fact, finv, inv;
public:
    Combination(int sz)
    {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for (int i = 2; i < sz; ++i)
        {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        finv[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
    }
    long long P(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fact[n] * finv[n - k] % mod;
    }
    long long H(long long n, long long k)
    {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i)
    {
        return fact[i];
    }
    long long getinv(int i)
    {
        return inv[i];
    }
    long long getfinv(int i)
    {
        return finv[i];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  int ma = 1000010;
  vll a(n);
  vll cnt(ma);
  for(int i=0;i<n;++i) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  Combination<MOD> comb(ma+1);
  vll c(ma);
  for(int i=1;i<=ma;++i) {
    c[i] = comb.getinv(i);
  }
  for(int i=1;i<=ma;++i) {
    for(int j=2*i;j<=ma;j+=i) {
      c[j] += (MOD - c[i]);
      c[j] %= MOD;
    }
  }
  ll ans = 0;
  for(int i=1;i<=ma;++i) {
    ll su1 = 0, su2 = 0;
    for(ll j=i;j<=ma;j+=i) {
      su1 += j * cnt[j];
      su2 += j * j % MOD * cnt[j] % MOD;
      su1 %= MOD;
      su2 %= MOD;
    }
    ll tmp = (su1 * su1 % MOD + MOD - su2) % MOD * comb.getinv(2) % MOD;
    ans += c[i] * tmp % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 40960
import bisect
import collections

N = int(input())
A = [int(input()) for _ in range(N)]

ans = collections.deque([A[0]])

for a in A[1:]:
    if a <= ans[0]:  # 色を増やすしかない
        ans.appendleft(a)
    else:  # 既存の色のどこかに追加
        idx = bisect.bisect_left(ans, a)
        ans[idx-1] = a
    # print(a, ans)

# print(ans)
print(len(ans))


Measured memory_bytes: 8828
#include <iostream>

using namespace std;

int main()	{
  char s[27];
  int freq[26] = {0};
  cin >> s;
  for (int i = 0; s[i] != '\0'; i++)	{
    freq[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++)	{
    if (freq[i] > 1)	{
      cout << "no";
      return 0;
    }
  }
  cout << "yes";
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int n, m, v, p, i, l, r, ind, tab[N];

bool ok(int ind) {
	if (tab[ind] + m < tab[n - p]) return false;
	LL votes = m * 1LL * v;
	votes -= m * 1LL * p;
	if (votes <= 0) return true;
	for (int i=0;i<=n-p;i++) if (i != ind) {
		int canAdd = min(m, tab[ind] + m - tab[i]);
		if (canAdd > 0) votes -= canAdd;
		if (votes <= 0) return true;
	}
	return false;
}

int main() {
scanf("%d %d %d %d", &n, &m, &v, &p);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
sort(tab, tab + n);
l = 0;
r = n - p;
while (l < r) {
	ind = (l + r) / 2;
	if (ok(ind)) r = ind; else l = ind + 1;
}
printf("%d\n", n - l);
}





Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  long long X,Y;
  cin >> X >> Y;

  int ans=0;
  while(X<=Y){
    ans++;
    X*=2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;
	private int N,Q;
	private Item[] A;

	private void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextInt();
		Q = scan.nextInt();

		A = new Item[N];

		for(int i = 0;i < N;i++) {
			A[i] = new Item(i);
		}

		for(int i= 0;i < Q;i++) {
			int com = scan.nextInt();

			if(com == 0) {
				Unite(scan.nextInt(),scan.nextInt());
			}else {
				System.out.println(Same(scan.nextInt(),scan.nextInt()));
			}
		}
		scan.close();
	}

	private void Unite(int x,int y) {

		int nx = Recursive(x);
		int ny = Recursive(y);

		if(nx != ny) {
			A[ny].next = nx;
			A[ny].base = false;
		}
	}

	private int Same(int x,int y) {
		return Recursive(x) == Recursive(y) ? 1 : 0;
	}

	private int Recursive(int num) {
		Item item = A[num];

		while(!item.base) {
			item = A[item.next];
		}

		return item.id;
	}
}

class Item{
	int id,next;
	boolean base;

	public Item(int id) {
		this.id = id;
		base = true;
		next = -1;
	}
}




Measured memory_bytes: 103280
A,B=input().split()
a=int(A[0])*10+int(A[1])
b=int(B[0])*10+int(B[1])
d=int(A[1])*10+int(A[0])
e=int(B[1])*10+int(B[0])
count_small=0
count_large=0
if a==b:
    for i in range(0,10):
        if a*1000+d+i*100>=int(A) and b*1000+e+i*100<=int(B):
            count_small+=1
    ans=count_small
else:
    for i in range(0,10):
        if a*1000+d+i*100>=int(A):
            count_small+=1
        if b*1000+e+i*100<=int(B):
            count_large+=1
    ans=(b-a-1)*10+count_small+count_large
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
  int a,b,c,x,y,ans=0;
  cin>>a>>b>>c>>x>>y;
  if(a+b>=c*2){
      int s=min(x,y);
      x-=s;
      y-=s;
      ans+=c*s*2;
      if(a*x+b*y>c*2*max(x,y))ans+=c*2*max(x,y);
      else ans+=a*x+b*y;
  }
  else ans+=x*a+y*b;
  cout<<ans<<endl;
      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s; cin>>s;
    int ans=0,n=s.size();
    for(int i=1;i<n;i++){
        string tmp=s.substr(0,n-i),j=s.substr(0,(n-i)/2);
        int t=tmp.size();
        if(tmp==j+j) ans=max(ans,t);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll xs(n);
    forn(i, n) cin>>xs[i];
    ll sum=accumulate(all(xs), 0ll);
    ll z=n*(n+1)/2;
    if (sum%z) return cout<<"NO\n", 0;
    ll k=sum/z;
    ll drops=0;
    forn(i, n) {
        ll d=xs[i]-xs[(i+1)%n]+k;
        if (d%n || d<0) return cout<<"NO\n", 0;
        drops += d/n;
    }
    assert(drops==sum/z);
    if (drops!=sum/z) cout<<"NO\n";
    else cout<<"YES\n";
}


Measured memory_bytes: 1024
s=input()
if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]:
  	print("Yes")
elif s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]:
	print("Yes")
elif s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]:
	print("Yes")
else:
  	print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> x(n);
	for(int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	
	int max = 0, min = 0;
	
	max = *max_element(x.begin(), x.end());
	min = *min_element(x.begin(), x.end());
	
	int ans = INT_MAX;
	for(int i = min; i <= max; ++i) {
		int sum = 0;
		
		for(int j = 0; j < n; ++j) {
			sum += (i - x[j]) * (i - x[j]);
		}
		
		if( ans > sum ) ans = sum; 
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#import numpy as np
import math
#from decimal import *
#from numba import njit
#@njit
def main():
    (N, M, K) = map(int, input().split())
    MOD = 998244353
    
    fact = [1]*(N+1)
    factinv = [1]*(N+1)
    for i in range(1,N+1):
        fact[i] = fact[i-1]*i % MOD
        factinv[i] = pow(fact[i], MOD-2, MOD)
    def comb(n, k):
        return fact[n] * factinv[k] * factinv[n-k] % MOD

    ans = 0
    for k in range(K+1):
        ans += (comb(N-1,k)*M*pow(M-1, N-k-1, MOD))%MOD

    print(ans%MOD)

main()


Measured memory_bytes: 24604
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      const A = readToken();
      const B = A.map!(a => (a - '1')).array;
      
      int g;
      foreach (i; 0 .. N) {
        g = gcd(g, B[i]);
      }
      int ans;
      if (g != 0) {
        foreach (i; 0 .. N) {
          // binom(N - 1, i)
          if ((B[i] / g) % 2 != 0) {
            debug {
              writeln("i = ", i);
            }
            if (((N - 1) & i) == i) {
              ans ^= 1;
            }
          }
        }
      }
      ans *= g;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 10288
#include <iostream>
using namespace std;
typedef long long ll;

const ll NMAX = 1e5+10;

int main() {
    ll N, K, a, b;
    cin >> N >> K;

    ll c[NMAX];
    for (ll i = 0; i < NMAX; i++) {
        c[i] = 0;
    }

    for (ll i = 1; i <= N; i++) {
        cin >> a >> b;
        c[a] += b;    
    }

    for (ll i = 0; i < NMAX; i++) {
        if (c[i] >= K) {
            cout << i << endl;
            break;
        }

        K -= c[i];
    }

    return 0;
}

Measured memory_bytes: 1024
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>

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

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INT_MAX = numeric_limits<int>::max() / 10;
const int INT_MIN = numeric_limits<int>::min() / 10;
typedef long long ll;
typedef pair<int, int> P;

bool r_pos[100000 + 10];
int ball_num[100000 + 10];

int N, M;

int main(int argc, char const* argv[])
{
    cin >> N >> M;
    REP(i, N) {
        ball_num[i] = 1;
    }
    r_pos[0] = true;
    int x, y;
    REP(i, M) {
        cin >> x >> y;
        x -= 1;
        y -= 1;
        if (r_pos[x]) {
            // 必ずRを移動
            if (ball_num[x] == 1) {
                r_pos[x] = false;
            }
            r_pos[y] = true;
        }
        ball_num[x] -= 1;
        ball_num[y] += 1;
    }
    int ans = 0;
    REP(i, N) {
        if (r_pos[i]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n,m;
    cin>>n>>m;
    string s[110];
    rep(i,n) cin>>s[i];
    rep(i,n) cout<<s[i]<<endl<<s[i]<<endl;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;

vector<vector<ll> > c;
const int N = 4018;

void precalc() {
    c.resize(N);
    for (int i = 0; i < N; ++i) {
        c[i].assign(i + 1, 1);
        for (int j = 1; j < i; ++j) {
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
        }
    }
}


ll getb(ll n, ll k) {
    if ((n < k) || (k < 0))
        return 0;
    return c[n][k];
}

ll power(ll x, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) 
            res = (res * x) % mod;
        x = (x * x) % mod;
        n /= 2;
    }
    return res;
}

ll solve(ll n, ll k, ll g) {
    ll res = 0;
    for (ll em = 0; em <= g; ++em) {
        ll cur = (c[g][em] * power(2, g - em)) % mod;
        ll r = n - (g - em);
        res = (res + cur * getb(r + k + g - em - 1, r)) % mod;
        //cerr << cur << " " << res << endl;
    }
    return res;
}

void solve() {
    precalc();
    ll k, n;
    cin >> k >> n;
    for (ll m = 2; m <= 2 * k; ++m) {
        ll g;
        if (m <= k + 1) {
            g = (m - 1) / 2;
        }
        else {
            g = (2 * k - m + 1) / 2;
        }
        ll res = 0;
        if (m & 1) {
            res = solve(n, k - 2 * g, g);
        }
        else {
            res = (solve(n, k - 2 * g - 1, g) + solve(n - 1, k - 2 * g - 1, g)) % mod;
        }
        cout << res << "\n";
    }
}

//#define LOCAL

int main() {
    //ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 63616
s = list(input())

a = 0
b = 0
ans = 0

for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            a += 1
    else:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
             b += 1

if len(s)%2 == 0:
    if a == (len(s))//2 and b == len(s)//2:
        ans = 1
else:
    if a == (len(s)+1)//2 and b == (len(s)-1)//2:
        ans = 1
if ans ==1:
    print("Yes")
else:
    print("No")

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

int main(){
    int N,M;
    cin >> N >> M;
    int a[M],b[M];
    int wol[N];
  	for(int i=0;i<N;i++)wol[i] = 0;
  	for(int i=0;i<M;i++){
      	cin >> a[i] >> b[i];
      	wol[a[i]-1]++;
      	wol[b[i]-1]++;
    }
  	for(int i=0;i<N;i++)cout << wol[i] <<endl;
}


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

ans = True
preT,preX,preY = 0,0,0
for i in range(N):
    t,x,y = map(int,input().split())

    if abs(x-preX)+abs(y-preY) > t - preT:
        ans=False
    if (-abs(x-preX)-abs(y-preY) + t - preT)%2==1:
        ans=False
    
    preX = x
    preY = y
    preT = t

print("Yes" if ans else "No") 

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll INF = 1e15;
vector<ll> scores[3];
ll n;
vector<int> input;
ll th[3];

int process(int i, int id1, int id2) {
	ll dist1 = std::lower_bound(scores[id1].begin() + i, scores[id1].end(), th[id1]) - (scores[id1].begin() + i);
	ll dist2 = std::lower_bound(scores[id2].begin() + i, scores[id2].end(), th[id2]) - (scores[id2].begin() + i);
	if (dist1 <= 0 && dist2 <= 0) {
		return -1;
	}
	if (dist1 < dist2) {
		th[id1] += 2;
		return id1;
	}
	else {
		th[id2] += 2;
		return id2;
	}
}

int main() {
	ll init[3];
	cin >> n >> init[0] >> init[1] >> init[2];
	input.resize(n);
	rep(i, 3) {
		scores[i].resize(n + 1);
		scores[i][0] = -init[i];
	}
	rep(i, n) {
		string s;
		cin >> s;
		if (s == "AB") {
			scores[0][i + 1] = scores[0][i] + 1;
			scores[1][i + 1] = scores[1][i] + 1;
			scores[2][i + 1] = scores[2][i];
			input[i] = 0;
		}
		if (s == "BC") {
			scores[0][i + 1] = scores[0][i];
			scores[1][i + 1] = scores[1][i] + 1;
			scores[2][i + 1] = scores[2][i] + 1;
			input[i] = 1;
		}
		if (s == "AC") {
			scores[0][i + 1] = scores[0][i] + 1;
			scores[1][i + 1] = scores[1][i];
			scores[2][i + 1] = scores[2][i] + 1;
			input[i] = 2;
		}
	}
	vector<string> ans;
	th[0] = th[1] = th[2] = 1;
	for (int i = 0; i < n;i++) {
		if (input[i] == 0) {
			auto p = process(i+1, 0, 1);
			if(p < 0){
				cout << "No" << endl;
				return 0;
			}
			if (p == 0) {
				ans.push_back("A");
			}
			else {
				ans.push_back("B");
			}
		}
		else if (input[i] == 1){
			auto p = process(i + 1, 1, 2);
			if (p < 0) {
				cout << "No" << endl;
				return 0;
			}
			if (p == 1) {
				ans.push_back("B");
			}
			else {
				ans.push_back("C");
			}
		}
		else {
			auto p = process(i + 1, 0, 2);
			if (p < 0) {
				cout << "No" << endl;
				return 0;
			}
			if (p == 0) {
				ans.push_back("A");
			}
			else {
				ans.push_back("C");
			}

		}
	}
	cout << "Yes" << endl;
	for (string c : ans) {
		cout << c << endl;
	}
	return 0;
}

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

int main() {
    string s;
    int k;
    cin >> k;
    cin >> s;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =998244353;
const int maxn = 3005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
int dp[maxn][maxn][4];
int a[maxn][maxn];
int32_t main()
{ 
  IOS

  int R, C, k;
  cin >> R >> C >> k;
  int r[k], c[k], v[k];
  for(int i = 0;i<k;i++){
    cin >> r[i] >> c[i] >> v[i];
    a[r[i]][c[i]] = v[i];
  }
  for(int i = 0;i<=R;i++){
    for(int j = 0;j<=C;j++){
      for(int p = 0;p<=3;p++) dp[i][j][p] = -1e16;
    }
  }

  for(int i =  0;i<=R;i++) dp[i][0][0] = 0;
  for(int j = 0;j<=C;j++) dp[0][j][0] = 0;
  for(int i = 1;i<=R;i++){
    for(int j = 1;j<=C;j++){
      if(a[i][j] == 0){
        for(int p = 0;p<=3;p++){
          dp[i][j][p] = max(dp[i][j][p],dp[i][j-1][p]);
        }
        for(int q = 0;q<=3;q++){
            dp[i][j][0] = max(dp[i][j][0],dp[i-1][j][q]);
        }

      }
      else{
        // case1 ignore
        for(int p = 0;p<=3;p++){
          dp[i][j][p] = max(dp[i][j][p],dp[i][j-1][p]); 
        }
        for(int q = 0;q<=3;q++){
            dp[i][j][0] = max(dp[i][j][0],dp[i-1][j][q]);
        }

        // case 2 take
        for(int p = 1;p<=3;p++){
          dp[i][j][p] = max(dp[i][j][p],dp[i][j-1][p-1] + a[i][j]); 
        }
        for(int q = 0;q<=3;q++){
            dp[i][j][1] = max(dp[i][j][1],dp[i-1][j][q] + a[i][j]);
        }

        
      }
    }
  }

  // for(int i = 1;i<=R;i++){
  //   for(int j  = 1;j<=C;j++){
  //     cout << make_pair(i,j) << endl;
  //     for(int  p = 0;p<=3;p++){
  //       cout << dp[i][j][p] << " ";
  //     }
  //     cout << endl;
  //   }
  //   cout << endl;

  // }

  int ans = 0;
  for(int i = 0;i<=3;i++) ans =  max(ans,dp[R][C][i]);
  cout << ans << endl;
  





  

  










  
    
} 



Measured memory_bytes: 360504
#include <stdio.h>
#include <math.h>

typedef struct {
  double x;
  double y;
} point_t;

void kock(int n, point_t ps, point_t pe) {
  if (n == 0)
    return;

  // (n:+p:p) = 0:0:2, 1:3:5, 2:12:17, 3:48:65
  // +p(n) = (p(n-1) - 1) * 3
  // p(n) = +p(n) + p(n-1)

  // calculate {s, t, u}
  double rad = 60 * M_PI / 180.0;
  point_t s, t, u;
  s.x = (2 * ps.x + 1 * pe.x) / 3;
  s.y = (2 * ps.y + 1 * pe.y) / 3;
  t.x = (1 * ps.x + 2 * pe.x) / 3;
  t.y = (1 * ps.y + 2 * pe.y) / 3;
  u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
  u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;
  
  kock(n - 1, ps, s);
  printf ("%.8lf %.8lf\n", s.x, s.y);
  kock(n - 1, s, u);
  printf ("%.8lf %.8lf\n", u.x, u.y);
  kock(n - 1, u, t);
  printf ("%.8lf %.8lf\n", t.x, t.y);
  kock(n - 1, t, pe);
}

int main(void){
  int n;
  point_t ps = {0, 0}, pe = {100, 0};
  
  scanf("%d", &n);
  printf("%.8lf %.8lf\n", ps.x, ps.y);
  kock(n, ps, pe);
  printf("%.8lf %.8lf\n", pe.x, pe.y);

  return 0;
}

Measured memory_bytes: 640
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s;
    int ans=0;
    for(int i=0;i<n-1;i++){
        vector<bool> used(26,false),used1(26,false);
        for(int j=0;j<=i;j++){
            used[(s[j]-'a')]=true;
        }
        for(int j=i+1;j<n;j++){
            used1[(s[j] - 'a')] = true;
        }
        int sum=0;
        rep(j,26){
            if(used[j]&used1[j])sum++;
        }
        chmax(ans,sum);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
fn main() {
    let v = read_vec::<i64>();
    let a = v[0];
    let b = v[1];
    let c = v[2];

    let x = c - a - b;
    if x < 0 {
        yn(false);
    } else {
        yn((4 * a * b) < x * x);
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long,long long>P;
int main(){
  int n;
  long long min_cost[100005];
  vector<P>node[100005];
  long long INF=1;
  for(int i=1;i<=15;i++){
    INF*=10;
  }
  cin>>n;
  for(int i=0;i<=n;i++){
    min_cost[i]=INF;
  }
  for(int i=0;i<n-1;i++){
    int a,b;
    long long cost;
    cin>>a>>b>>cost;
    node[a].push_back(P(b,cost));
    node[b].push_back(P(a,cost));
  }
  int q,k;
  cin>>q>>k;
  priority_queue<P,vector<P>,greater<P> >pq;
  pq.push(P(0,k));
  while(!pq.empty()){
    P now=pq.top();pq.pop();
    long long cost=now.first;
    int pos=now.second;
    for(int i=0;i<node[pos].size();i++){
      int next=node[pos][i].first;
      long long ncost=node[pos][i].second;
      if(cost+ncost<min_cost[next]){
	min_cost[next]=cost+ncost;
	pq.push(P(cost+ncost,next));
      }
    }
  }
  for(int i=0;i<q;i++){
    int x,y;
    cin>>x>>y;
    cout<<min_cost[x]+min_cost[y]<<endl;
  }
  return(0);
}



Measured memory_bytes: 11120
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	string s;
	cin >> s;
	if (s[2] != s[3]) {
		put("No");
		return 0;
	}
	if (s[4] != s[5]) {
		put("No");
		return 0;
	}
	put("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	return x*f;
}
const int N=1e7+7,mo=998244353;
inline int fk(int x) { return x>=mo ? x-mo : x; }
int n,fac[N],facinv[N];
int ksm(int x,int y)
{
	int res=1;
	while(y) { if(y&1) res=1ll*res*x%mo; x=1ll*x*x%mo; y>>=1; }
	return res;
}
inline int C(int x,int y) { return 1ll*fac[x]*facinv[y]%mo*facinv[x-y]%mo; }
int main()
{
	n=read();
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mo;
	facinv[n]=ksm(fac[n],mo-2);
	for(int i=n-1;i>=0;i--) facinv[i]=1ll*facinv[i+1]*(i+1)%mo;
	int ans=ksm(3,n);
	for(int k=n/2+1;k<=n;k++)
		ans=fk(ans-2ll*C(n,k)*ksm(2,n-k)%mo+mo);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	cin >> S;
	S.insert(4," ");
	cout << S << "\n";
	return 0;}

// look at my code
// my code is amazing


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

int main() {
	string s;
	char b;
	int c = 0;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (i == 0) {
			b = s[i];
		}
		else if (b != s[i]) {
			c++;
			b = s[i];
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 512
n = gets.to_i
c, p = n.times.map{gets.chomp.split}.transpose
res = Array.new(n).map{Array.new(3)}
for i in 0..(n-1)
  res[i][0] = c[i]
  res[i][1] = p[i].to_i
  res[i][2] = i + 1
end
res.sort_by{|x| [x[0], -x[1]]}.each do |r| puts r[2] end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	long long a,b;
	long long x;
	long long ans = 0;
	cin>>a>>b>>x;
	ans = b/x - a/x;
	if( a % x == 0 ) ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

int n;
int dp[100005][3];
int a[100005],b[100005],c[100005];

int solve(int idx,int prev){
    if(idx==n){
        return 0;
    }
    int &ret = dp[idx][prev];
    if(~ret)return ret;
    ret = -1*INF;
    if(prev==0){
        ret=max(ret,max(solve(idx+1,1)+b[idx],solve(idx+1,2)+c[idx]));
    }
    if(prev==1){
        ret=max(ret,max(solve(idx+1,0)+a[idx],solve(idx+1,2)+c[idx]));
    }
    if(prev==2){
        ret=max(ret,max(solve(idx+1,1)+b[idx],solve(idx+1,0)+a[idx]));
    }
    return ret;
}

int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1,sizeof dp);
    int ans = -1;
    ans = max(ans,solve(1,0)+a[0]);
    ans = max(ans,solve(1,1)+b[0]);
    ans = max(ans,solve(1,2)+c[0]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#define MOD 1000000007
#define REP(i,a,n)for(int i=(a);i<=(n);i++)
#define ADDMOD(a, b) (a)=((a)+(b))%MOD
using namespace std;
typedef pair<int, int> pii;

int N,M,L,R,X;
vector<pii> Q[301];
int dp[301][301][301];

bool check(int m, int i, int j) {
  int mi=min(i,j),mx=max(i,j);
  for(pii p : Q[m]) {
    int l=p.first,x=p.second;
    if(x==1 && !(mx < l)) return false;
    if(x==2 && !(mi < l && l <= mx)) return false;
    if(x==3 && !(l <= mi)) return false;
  }
  return true;
}

int main(void) {
  cin>>N>>M;
  REP(i,1,M) {
    cin>>L>>R>>X;
    Q[R].push_back(pii(L,X));
  }

  REP(i,0,N) REP(j,0,N) REP(k,0,N) dp[i][j][k]=0;
  dp[0][0][0]=1;

  REP(i,0,N-1) REP(j,0,N-1) REP(k,0,N-1) if(dp[i][j][k] > 0) {
    int m=max(i,max(j,k))+1;
    if(check(m,j,k)) ADDMOD(dp[m][j][k], dp[i][j][k]);
    if(check(m,k,i)) ADDMOD(dp[i][m][k], dp[i][j][k]);
    if(check(m,i,j)) ADDMOD(dp[i][j][m], dp[i][j][k]);
  }

  long ans=0;
  REP(i,0,N-1) REP(j,0,N-1) {
    ADDMOD(ans, dp[N][i][j]);
    ADDMOD(ans, dp[i][N][j]);
    ADDMOD(ans, dp[i][j][N]);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 106752
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
#define P pair<ll,ll>
#define __int64 long long
//map<string,int>::iterator it=t.begin();

ll a,b,c,k;

int main(){
	cin>>a>>b>>c>>k;
	ll ans;

	if(k%2==0){
			ans=a-b;
	}
	else{
		ans=b-a;
	}
	ll z=1000000000000000000;
	if(abs(ans)>=z)cout<<"Unfair"<<endl;
	else cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 256