akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

vector<int> vect;

int least_bit_set(int x){
    return x & (-x);
}

vector<int> eliminate(vector<int>& values){
    int i = 0;
    while(true){
        if(i >= sz(values)){
            return values;
        }
        int j = i;
        for(int k=i+1; k<sz(values); k++){
            if(least_bit_set(values[k]) < least_bit_set(values[j]))
                j = k;
        }
        swap(values[i], values[j]);
        for(int k=i+1; k<sz(values); k++){
            if(least_bit_set(values[k]) == least_bit_set(values[i]))
                values[k] ^= values[i];
        }
        i++;
    }
}

bool in_span(int x, vector<int> &v){
    for(int y: v){
        if((least_bit_set(y) & x) != 0){
            x ^= y;
        }
    }
    return x==0;
}

void solve(){
    vect.clear();
    int n; cin>>n;
    int a[n];
    bool s[n];
    For(i, 0, n){
        cin>>a[i];
    }
    string ss; cin>>ss;
    For(i, 0, n){
        s[i] = (ss[i]=='1');
    }
    reverse(s, s+n); reverse(a, a+n);
    bool fl = true;
    For(i, 0, n){
        if(!s[i]){
            vect.pb(a[i]);
            continue;
        }
        else{
            vector<int> x = vect;
            vector<int> eli = eliminate(x);
            if(!in_span(a[i], eli)){
                fl = false;
                break;
            }
        }
    }
    if(fl){
        cout<<0;
    }
    else{
        cout<<1;
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



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

;

int main(){
    ll a;
    double b;
    cin >> a >> b;
    b=b*1000;
    int B = (b /10);

    ll ans = a * B / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val boin = listOf<Char>('a', 'e', 'i', 'o', 'u')
    val c = read()[0]
    
    println(if(boin.contains(c)) "vowel" else "consonant")
    
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 35772
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int cnt[SIZE];
void solve() {
    int N;
    R(N);
    LL an=0;
    FOR(i,1,N){
        int x;
        R(x);
        cnt[x]++;
        an+=x;
    }
    int Q;
    R(Q);
    REP(i,Q){
        int x,y;
        R(x,y);
        an-=(LL)cnt[x]*x;
        an+=(LL)cnt[x]*y;
        cnt[y]+=cnt[x];
        cnt[x]=0;
        W(an);
    }
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 4048
def run(N, K, h):
    h = sorted(h)
    diff = [h[i+1] - h[i] for i in range(N-1)]
    diff_all = max(h) - min(h)
    r_diff_sum = [0]
    for d in diff:
        r_diff_sum.append(r_diff_sum[-1] + d)
    l_diff_sum = [0]
    for d in reversed(diff):
        l_diff_sum.append(l_diff_sum[-1] + d)
    ret = diff_all
    # 右から何個を除外するか
    for i in range(N - K + 1):
        ret = min(ret, diff_all - r_diff_sum[i] - l_diff_sum[N - K - i])
    return ret


def main():
    N, K = map(int, input().split())
    h = []
    for _ in range(N):
        h.append(int(input()))
    print(run(N, K, h))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20304
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

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

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int fa[200010];

int find(int x)
{
	if (x!=fa[x]) fa[x]=find(fa[x]);
	return fa[x];
}

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,m;scanf("%d%d",&n,&m);
	for (int i=1;i<=n+m;i++) fa[i]=i;
	for (int i=1;i<=n;i++)
	{
		int k;scanf("%d",&k);
		for (int j=0;j<k;j++)
		{
			int x;scanf("%d",&x);
			int p=find(i),q=find(x+n);if (p!=q) fa[p]=q;
		}
	}
	for (int i=2;i<=n;i++) if (find(1)!=find(i)) {puts("NO");return 0;}
	puts("YES");
	return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    map<ll,ll> a;
    ll num;
    rep(i,n){
        cin>>num;
        a[num]++;
    }
    int ans=0;
    for(auto &b:a){
        ans+=b.second%2;
    }
    cout<<ans;
}

Measured memory_bytes: 9840
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>b){
		cout<<"a > b\n";
	}else if(a<b){
		cout<<"a < b\n";
	}else{
		cout<<"a == b\n";
	}
	return 0;
}


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


int main() {

    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" <<  endl;
    return 0;
}

Measured memory_bytes: 256
import math

# Input the amount of money Takahashi paid
N = int(input())

# Find nearest integer price more than or equal to X/1.08
X = math.ceil(N / 1.08)

# Check if the "taxed price" is equal to N yen
if math.floor(X * 1.08) == N:
	print(X)
else:
	print(":(")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<ll,ll>;
using vv = vector<vector<ll>>;
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;
const long long mod = 1000000007;

int main(void){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    int t=0;
    for(int i=0;i<n;i++){
	if(i%2==0) t += a[i];
	else t -= a[i];
    }
    cout << t << endl; 
    return 0;
}


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

def merge(x, y):
    return (x + y) / 2

for _ in range(n-1):
    vn = sorted(vn)
    x = vn.pop(0)
    y = vn.pop(0)
    vn.append(merge(x, y))

print(vn[0])

Measured memory_bytes: 3060
N,M = map(int,input().split())
A = [set() for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    A[a-1].add(b-1)
    A[b-1].add(a-1)

print("POSSIBLE" if A[0] & A[N-1] != set() else "IMPOSSIBLE")


Measured memory_bytes: 67664
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n = int(input())
x = list(map(int, input().split()))

ave = sum(x) / len(x)
p = Decimal(str(ave)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
squared = sum([i*i for i in x])

print(n*p*p - 2*p*sum(x) + squared)

Measured memory_bytes: 5204
a,b,c,k = (int(x) for x in input().split())

if abs(a-b) > 10 ** 18:
    print('Unfair')
elif a == b:
    print(0)
elif k % 2 == 0:
    print(a-b)
elif k % 2 == 1:
    print(b-a)

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

long long c[19];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long d; cin >> d;
    c[0] = 1;
    for (int i = 0; i < 18; i++) {
        c[i+1] = c[i] * 10;
    }
    auto f = [&](auto g, int i, int len, long long curr, long long remain) -> long long {
        if (len - i - 1 <= i) {
            curr *= (remain == 0);
            if (len - i - 1 == i) return curr * 10;
            else return curr;
        }
        long long diff = c[len - i - 1] - c[i];
        long long mod = c[i] * 10;
        long long cmod = (((remain % mod + mod) % mod) / c[i]) % 10;
        long long ret = 0;
        // plus
        cmod = (10 - cmod) % 10;
        ret += g(g, i+1, len, curr*(10-cmod-(i==0)), remain - cmod*diff);
        // minus
        cmod = 10 - cmod;
        ret += g(g, i+1, len, curr*(10-cmod), remain + cmod*diff);
        return ret;
    };
    long long ans = 0;
    for (int i = 0; i < 20; i++) {
        ans += f(f, 0, i, 1, d);
    }
    cout << ans << "\n";
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, X, T;
    cin >> N >> X >> T;

    cout << ((N-1)/X  + 1) * T << endl;
    return 0;
}

Measured memory_bytes: 3556
import math

a, b = map(int, input().split())

a_low = math.ceil(a/0.08)
a_high = math.floor((a+1)/0.08)-1

b_low = math.ceil(b/0.1)
b_high = math.floor((b+1)/0.1)-1

if a_high<b_low or b_high<a_low:
  print(-1)
else:
  print(max(a_low, b_low))


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int a,b,c,tmp;
    scanf("%d %d %d",&a,&b,&c);
    
    if (a > b)
    {
        tmp = b;
        b = a;
        a = tmp;
    }
    if (b > c)
    {
        tmp = c;
        c = b;
        b = tmp;
    }
    if (a > b)
    {
        tmp = b;
        b = a;
        a = tmp;
    }
    
    printf("%d %d %d\n",a,b,c);
    return 0;
}



Measured memory_bytes: 2044
from time import time
from random import randrange

def calc():
    s = 0
    last = [-1] * 26
    for i, t in enumerate(A):
        s += S[i][t]
        last[t] = i
        for j, c in enumerate(C):
            s -= c * (i - last[j])
    return s

sTime = time()
D = int(input())
C = [int(a) for a in input().split()]
S = [[int(a) for a in input().split()] for _ in range(D)]
A = [randrange(26) for _ in range(D)]
ans = calc()
while time() - sTime < 1.8:
    d = randrange(D)
    i = A[d]
    for k in range(d)[::-1]:
        if A[k] == i:
            prev = k
            break
    else:
        prev = -1
    for k in range(d + 1, D):
        if A[k] == i:
            prev_ne = k
            break
    else:
        prev_ne = D
    for j in range(26):
        t = S[d][j] - S[d][i]
        for k in range(d)[::-1]:
            if A[k] == j:
                new = k
                break
        else:
            new = -1
        for k in range(d + 1, D):
            if A[k] == j:
                new_ne = k
                break
        else:
            new_ne = D
        t += C[j] * (d - new) * (new_ne - d) - C[i] * (d - prev) * (prev_ne - d)
        if t > 0:
            A[d] = j
            ans += t
            prev, prev_ne = new, new_ne

print(*[a + 1 for a in A], sep = "\n")

Measured memory_bytes: 81124
n=int(input())
*l,=map(int, input().split())
solv=0
max=max(l) +1
count=[0 for i in range(max)]
for i in l:
    for j in range(i,max,i):
        count[j] += 1
for k in l:
    if count[k] == 1:
        solv += 1
print(solv)

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

import sys
import math
import itertools

debug = False

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


def gcd(a, b):

    c = min(a, b)
    d = max(a, b)
    r = 0    
    while True:
        r = d % c
        if r == 0:
            break
        d = c
        c = r

    return c

def lcm(a, b):
    g = gcd(a, b)
    return (a * b) // g


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # error?
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())

    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    

    (a, b) = [int(e) for e in lines[0].split(" ")]

    return (a, b)


def solve(a, b):

    
    return lcm(a, b)


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

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;


int main() {
  ll n,k;
  cin>>n>>k;

  vector<ll>g(n);
  vector<ll>c(n);
  vector<ll>u(n,-1);
  ll Ans=-INF;

  rep(i,n){
    ll p;
    cin>>p;
    p--;
    g[i]=p;
  }
  rep(i,n)cin>>c[i];

  rep(i,n){
    //cout<<i<<endl;
    ll ans=-INF;
  //  if(u[i]==1)continue;

    vector<ll> v;
    ll now=i;
    ll cnt=0;
    ll s=0;
    u[now]=1;

    while(1){
      s+=c[now];
  now=g[now];
  v.push_back(c[now]);
//cout<<"c"<<c[now]<<endl;
      cnt+=1;
      u[now]=1;
    if (now==i)break;
    }


    vector<ll> sv(10005,0);
    rep(j,v.size()){
      sv[j+1]=sv[j]+v[j];
    }
    rep(j,v.size()){
      sv[v.size()+j+1]=sv[v.size()+j]+v[j];
    }
    ll t=k/cnt;
    t--;
    ll q=k-(t*cnt);
  //  cout<<"s"<<s<<endl;
    //cout<<"cnt"<<cnt<<endl;

    if(s>0){
    //  cout<<"q"<<q<<endl;

      rep(j,q){
        ans=max(ans,sv[j+1]);
    //    cout<<"sv"<<sv[j+1]<<endl;
      }
      ans+=t*s;
    }

    else{
    //  ll q=k-(t*cnt);
    rep(j,q){
      ans=max(ans,sv[j+1]);
    //  cout<<"sv"<<sv[j+1]<<endl;

      }
    }
    Ans=max(Ans,ans);

  }

cout<<Ans;


}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
/* mt19937 mrand(random_device{}()); 
int rnd(int x) { return mrand() % x;}*/
ll powmod(ll a,ll b) {ll res=1;a%=mod;  for(;b>0;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
const int N=105;
int _;
double n,m;

int dp[N][N],a[N][N];
int main() {
		scanf("%lf",&m);
		double n=3.1415;
		printf("%.2f",m*2*n);
}

Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+15
#define MOD 1000000007
using namespace std;

pair<int, pair<int,int> > dp[3001][3001];

int main(){
    string s,t;
    cin >> s >> t;
    
    int ls = s.length();
    int lt = t.length();
    
    for(int i=0; i<=ls; i++){
        for(int j=0; j<=lt; j++){
            
            dp[i][j] = make_pair(0, make_pair(0,0) );

        }
    }
    
    for(int i=1; i<=ls; i++){
        for(int j=1; j<=lt; j++){
            if(s[i-1]==t[j-1]){
                dp[i][j].first=dp[i-1][j-1].first+1;
                dp[i][j].second = make_pair(i-1,j-1);
            }else{
                if(dp[i-1][j].first>=dp[i][j-1].first){
                    dp[i][j].first = dp[i-1][j].first;
                    dp[i][j].second = make_pair(i-1,j);
                }else{
                    dp[i][j].first=dp[i][j-1].first;
                    dp[i][j].second = make_pair(i,j-1);
                }
            }
        }
    }
   
//    cout<<dp[ls][lt].first<<endl;
    
    string ans="";
    pair<int, int> temp = make_pair(ls,lt);
    while(!(temp.first==0 && temp.second==0)){
        if(s[temp.first-1]==t[temp.second-1]){
            ans = s[temp.first-1] + ans;
        }
        
        temp = dp[temp.first][temp.second].second;
    
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 105856
"""
与えられた長さNのtをt'にする方法
各iについて、t'のi文字目はtのi,i+1文字目のどちらかである

単一文字のt'に持っていく最小操作回数

文字間差分の最大値が最も小さい文字が強い
"""

S = input()
# S = "whbrjpjyhsrywlqjxdbrbaomnw"
Sset = set(S)
ans = 1000
for s in Sset:
    string  = s+S+s
    diff = 0
    tmp = 0
    for i,st in enumerate(string): 
        if s == st:
            diff = max(diff, i-tmp) #差のmax
            tmp = i
    ans = min(ans,diff)
print(ans-1)


Measured memory_bytes: 3060
S=input()
N=len(S)
for i in range(N-1):
  if S[i]==S[i+1]:
    print(i+1,i+2)
    exit()
  if i!=N-2:
    if S[i]==S[i+2]:
      print(i+1,i+3)
      exit()
print(-1,-1)

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

# table[i] := 得点がi+1の時、あと何回連続でコインの表を出せばすぬけ君が勝つか
table = [None] * k

# 得点がpの時あと何回連続でコインの表を出せばすぬけ君が勝つかを求める関数
def dfs(p):
    if p >= k:
        return 0
    elif table[p-1] != None:
        return table[p-1]
    return 1 + dfs(p * 2)

ans = 0
for i in range(n, 0, -1):
    ans += pow(0.5, dfs(i))
print(ans/n)

Measured memory_bytes: 3828
from functools import reduce
X,Y = map(int,input().split())
x = (-X+2*Y) /3
y = (2*X-Y) /3
#ans=0のときをどっかで書く。indentめんどいからどうする？
MOD = 10**9+7
if int(x) == x and int(y) == y and x>=0 and y>=0 :
  sum1 = int(x+y)
  bunbo = min([int(x),int(y)])
  n1 = reduce(lambda a,b : (a*b) % MOD  ,range(sum1,sum1-bunbo,-1),1)
  n2 = reduce(lambda a,b : (a*b) % MOD ,range(bunbo,1,-1),1)
  n2inv = pow(n2,MOD-2,MOD) 
  print((n1*n2inv) % MOD)
else:
  print(0)

Measured memory_bytes: 38896
//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define output2darr(n,m,in) if(in==0){loop(i,0,n-1,1){loop(j,0,m-1,1)cout<<a[i][j]<<" ";cout<<endl;}}else{loop(i,1,n,1){loop(j,1,m,1)cout<<a[i][j]<<" ";}cout<<endl;}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void AcDegaYe()
{
    int n;
    cin>>n;
    if(n>=30)
    {
        cout("Yes");
        return;
    }
    cout("No");
}
int main()
{   
    fastio

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

    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

/*typedef struct {
	int login_student;
	int login_time;
} pc_t;*/

int pc_num,student_num;
/*pc_t pc[1000];*/
short student_used[10000][1260];
short student_used2[10000][1260];

int main(void) {
	int kiroku_num;
	int query_num;
	int i,j;
	int k_zikoku,k_pc,k_student,k_type;
	int q_start,q_end,q_student;
	while(1) {
		scanf("%d%d",&pc_num,&student_num);
		if(pc_num==0 && student_num==0)break;
		memset(student_used,0,sizeof(student_used));
		memset(student_used2,0,sizeof(student_used2));
		scanf("%d",&kiroku_num);
		for(i=0;i<kiroku_num;i++) {
			scanf("%d%d%d%d",&k_zikoku,&k_pc,&k_student,&k_type);
			k_pc--;k_student--;
			if(k_type==1) {
				/*pc[k_pc].login_student=k_student;
				pc[k_pc].login_time=k_zikoku;*/
				student_used[k_student][k_zikoku]++;
			} else {
				student_used[k_student][k_zikoku]--;
			}
		}
		for(i=0;i<student_num;i++) {
			for(j=540;j<1260;j++) {
				student_used[i][j]+=student_used[i][j-1];
				if(student_used[i][j]>0)student_used2[i][j]=1;
				student_used2[i][j]+=student_used2[i][j-1];
			}
		}
		scanf("%d",&query_num);
		for(i=0;i<query_num;i++) {
			scanf("%d%d%d",&q_start,&q_end,&q_student);
			q_student--;
			printf("%d\n",student_used2[q_student][q_end-1]-
				student_used2[q_student][q_start-1]);
		}
	}
	return 0;
}

Measured memory_bytes: 48000
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

ll n;
ll dp[1000005];

int solve(ll a[], int i)
{
	if (i == n - 1)
	{
		return 0;
	}
	if (i > n - 1)
	{
		return INT_MAX;
	}

	if (dp[i] != -1)
	{
		return dp[i];
	}

	int value;
	value = min(abs(a[i + 1] - a[i]) + solve(a, i + 1), abs(a[i + 2] - a[i]) + solve(a, i + 2));

	return dp[i] = value;
}

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

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

using ll = long long;
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int n, m;
   while (cin >> n >> m, n) {
      vector<int> v(n);
      int sum = 0;
      for (int &x : v) {
         cin >> x;
         sum += x;
      }
      sort(v.begin(), v.end(), greater<int>());
      for (int i = m-1; i < v.size(); i+=m) {
         sum -= v[i];
      }
      cout << sum << endl;
   }

   return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#if LOCAL
#include "../cout.hpp"
#endif
using namespace std;

#define forn(i,n) for (unsigned i = 0; i < n; ++i)
#define fors(i,n,s) for (unsigned i = 0; i < n; i += 2) 

typedef unsigned long long ull;

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

    unsigned n;
    cin >> n;

    unsigned div4 = 0, div2 = 0;
    forn(i, n) {
	unsigned a;
	cin >> a;
	if (a % 4 == 0) {
	    div4++;
	} else if (a % 2 == 0) {
	    div2++;
	}
    }
    bool ok = true;
    unsigned i = 0;
    if(!div2 && div4) i++;
    while(i < n) {
	if (div2) {
	    i++;
	    div2--;
	} else if (div4) {
	    i += 2;
	    div4--;
	} else {
	    ok = false;
	    break;
	}
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut s: String = read();

    s.pop();
    if s.len() % 1 == 0 {
        s.pop();
    }

    while !(&s[0..s.len() / 2] == &s[s.len() / 2..]) {
        s.pop();
        s.pop();
    }
    println!("{}", s.len());
}

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


Measured memory_bytes: 4476
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;

		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	int n;
	cin>>n;
	cout<<(n-2)*180<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    string s;
    cin >> s;
    string ans = "ABC";
    if(s == "ABC") ans = "ARC";
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int a, b, c, x, amount, ans = 0;
    cin >> a >> b >> c >> x;

    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                amount = (i * 500) + (j * 100) + (k * 50);
                if (amount == x) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int check[10][2000];
int sum[10][2000] = {0};
int num[10];

int search(int a, int b) {

	if(b == 0) return sum[b][a];
	if(check[b][a] != -1) return check[b][a]; 
	
	int ret = 0;
	for(int i = min(a, num[b]); i >= 0; i--) {
	//cout << "called search(" << a-i << ", " << b-1 << ")" << endl;
		ret = max(ret, search(a-i, b-1) + sum[b][i] );
	}

	//cout << a << ", " << b << "returned " << ret << endl;
	check[b][a] = ret;
	return ret;
	
}


int main() {

	//ifstream cin("in/03.in");
	//ofstream cout("OUTPUT.txt");

	int N, K;
	int genre, price;
	
	vector< vector<int> > C;
	C.resize(10);
	
	
	cin >> N >> K;
	
	for(int i = 0; i < N; i++) {
		cin >> price >> genre;
		C[genre-1].push_back(price);
	}
	
	for(int i = 0; i < 10; i++) {
		sort(C[i].begin(), C[i].end(), greater<int>() );
		num[i] = C[i].size();
	}
	
	for(int i = 0; i < 10; i++) {
		for(int j = 1; j <= num[i]; j++) {
			sum[i][j] = sum[i][j-1] + C[i][j-1] + (2 * (j-1));
		}
	}
	
	for(int i = 0; i < 10; i++) {
		for(int j = 0; j < 2000; j++) {
			check[i][j] = -1;
		}
	}
	
	/* for(int i = 0; i < 10; i++) {
		for(int j = 0; j <= num[i]; j++) {
			cout << sum[i][j] << " ";
		}
		cout << endl;
	} */
	
	cout << search(K, 9) << endl;

	return 0;

}

Measured memory_bytes: 1356
N=int(input())
S=input()
def solve(x):
  global S,N
  for i in range(N-1):
    if (x[i+1]=='W')^(S[i+1]=='x'):
      x.append('S' if x[i]=='W' else 'W')
    else:
      x.append('S' if x[i]=='S' else 'W')
  if (x[0]=='W')^(S[0]=='x'):
    x.insert(0,'S' if x[1]=='W' else 'W')
  else:
    x.insert(0,'S' if x[1]=='S' else 'W')
  if x[:2]==x[-2:]:
    print(''.join(x[1:-1]))
    exit()

solve(list('SS'))
solve(list('SW'))
solve(list('WS'))
solve(list('WW'))
print(-1)

Measured memory_bytes: 93348
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
#define log loga
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int32_t MOD=MOD1;

int count1(int val1,int val2,vector<vector<char>> v)
{
      int n=v.size();
      int m=v[0].size();
      int cnt=0;
      rep(i,0,n)
      {
            rep(j,0,m)
            {
                  if((1<<i)&val1)continue;
                  if((1<<j)&val2)continue;
                  if(v[i][j]=='#')cnt++;
            }
      }
      return cnt;
}
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
            int n,m,k;
            cin>>n>>m>>k;
            vector<vector<char>>  v(n,vector<char>(m,'.'));
            
            rep(i,0,n)rep(j,0,m)cin>>v[i][j];
            int lim1=(1<<n);
            int lim2=(1<<m);
            int ans=0;

            rep(i,0,lim1)
            {
                  rep(j,0,lim2)
                  {
                      if(count1(i,j,v)==k)ans++;
                  }
            }

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

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;

	cout<<max(a-b,0LL);






	cout<<endl;
} 


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
ans = ""
ans += "R" * (tx-sx)
ans += "U" * (ty-sy)
ans += "L" * (tx-sx)
ans += "D" * (ty-sy)

ans += "D"
ans += "R" * (tx-sx+1)
ans += "U" * (ty-sy+1)
ans += "L"
ans += "U"
ans += "L" * (tx-sx+1)
ans += "D" * (ty-sy+1)
ans += "R"
print(ans)


Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 100000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    i = 0
    while time.time() < 1.8+start:
        nt = [i for i in t]
        r = random.randrange(1,n+1)
        nt[i] = r
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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



int main(void){
    string o,e;
    cin >> o >> e;
    string a = o + e;
    int length1 = o.size();
    int length2 = e.size();
    for(int i=0;i<=length1;i++){
        a[2*i] = o[i];
    }
   for(int i=0;i<=length2;i++){
       a[2*i+1] = e[i];
   }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    static int j = 0;
    while (a <= b) {
        if (c % a == 0) j++;
        a++;
    }
    printf("%d\n", j);
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, a[101010];

int main(){
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		ans = (ans ^ a[i]);
	}
	
	if(ans == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

void merge( long int *, int, int, int );
int mergeSort( long int *, int, int );

int count=0;

int main()
{
  int i, n;
  long int *S;

  scanf("%d", &n);
  S = malloc( n * sizeof(long int));
  for( i=0; i<n; i++ ) scanf("%d", &S[i]);

  *S = mergeSort( S, 0, n );

  for( i=0; i<n-1; i++ ) printf("%d ", S[i]);
  printf("%d\n", S[n-1]);

  printf("%d\n", count);

  return 0;
}



void merge( long int *A, int left, int mid, int right )
{
  int i, j, k, n1, n2, *L, *R;
  long int INFTY=10000000000;
  
  n1 = mid - left;
  n2 = right - mid;

  L = malloc( (n1+1) * sizeof(int));
  R = malloc( (n2+2) * sizeof(int));
  
  for( i=0; i<n1; i++ ) L[i] = A[left + i];
  for( i=0; i<n2; i++ ) R[i] = A[mid + i];
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
    
  for( k=left; k<right; k++ )
    {
      if( L[i] <= R[j] )
	{
	  A[k] = L[i];
	  i = i + 1;
	}
      else
	{
	  A[k] = R[j];
	  j = j + 1;
	}
      count++;
    }
}

      
int mergeSort( long int *A, int left, int right )
{
  int mid;
  
  if( left+1 < right )
    {
      mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }

  return *A;
}



Measured memory_bytes: 66504
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int N, ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int cur = 0, n = i;
        while (n > 0) {
            n /= 10;
            cur++;
        }
        if (cur & 1) {
            ans++;
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define f first
#define s second
using namespace std;
bool v[100000],ac[100000];
int main(){
  int n;
  cin>>n;
  pair<char,int>a[n];
  int c=0,cc=0;
  pair<int,int>b[n];
  r(i,n){
    cin>>a[i].f>>a[i].s;
    if(a[i].f=='y'){
      b[cc].f=a[i].s;
      b[cc++].s=i;
    }
    else ac[i]=1;
  }
  stable_sort(b,b+cc);
  r(i,cc)if(!v[b[i].s]){

    for(int j=b[i].s;j<n;v[j]=1,j++)if(a[j].s>=b[i].f&&ac[j])break;

    for(int j=b[i].s;j>=0;v[j]=1,j--)if(a[j].s>=b[i].f&&ac[j])break;

    c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3136
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

void cal(string &s, Pii &x){
    int n = s.size();
    int &now = x.first;
    rip(i,n,0){
        if(s[i] == '(') ++ now;
        else --now;
        chmax(now, 0);
    }
    int &ow = x.second;
    reverse(all(s));
    rip(i,n,0){
        if(s[i] == ')') ++ ow;
        else --ow;
        chmax(ow, 0);
    }
    return;
}

int main(){
    int n; cin >> n;
    vector<string> da(n);
    rip(i,n,0) cin >> da[i];
    vector<Pii> li1(0), li2(0),li3(0);
    rip(i,n,0){
        Pii now = {0, 0};
        cal(da[i], now);
        if(now.first > now.second) {
            swap(now.first,now.second);
            now.second *= -1;
            li1.push_back(now);
        }
        else if(now.first < now.second){
            now.second *= -1;
            li2.push_back(now);
        }
        else{
            li3.push_back(now);
        }
    }
    sort(all(li1));
    sort(all(li2));
    int now = 0;
    rip(i, li1.size(), 0){
        if(now < li1[i].first){
            cout << "No" << endl;
            return 0;
        }
        else{
            now -= li1[i].first + li1[i].second;
        }
    }
    rip(i,li3.size(),0){
        if(now < li3[i].second) {
            cout << "No" << endl;
            return 0;
        }
    }
    int now2 = 0;
    rip(i, li2.size(), 0){
        if(now2 < li2[i].first){
            cout << "No" << endl;
            return 0;
        }
        else{
            now2 -= li2[i].first + li2[i].second;
        }
    }
    if(now == now2) cout << "Yes" << endl;
    else cout << "No\n";
}

Measured memory_bytes: 42396
#include <bits/stdc++.h>
  
using namespace std;
 
#define endl "\n"
#define JAM(x) cout<< #x <<" = "<<x<<"\n"
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { ll a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
 
 
//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPI;
 
const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;
const double PI=acos(-1.0);




long long int power(long long int a,long long int b)
{
    a %= MOD;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if(n==1)
    return 0;
    int i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}



/*_______________________________________________*/





int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double d,s,t;
    cin>>d>>t>>s;
    if(d/s>t)
    cout<<"No\n";
    else
    {
        cout<<"Yes\n";
    }
    
    
}


Measured memory_bytes: 3728
import numpy as np
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
np_A = np.array(A)

# 全体を求める
tmp_all = np.array(A)
unique = np.unique(tmp_all)
# print("unique:", unique)
ans_all = 0
for u in unique:
    count_u = c[u]
    # print(f"u:{u}, count_u:{count_u}")
    if count_u < 2:
        continue
    # (count_u) C 2
    tmp = int(count_u*(count_u-1)/2)
    ans_all += tmp
# print("all", ans_all)


# kごとのケースを求めて、全体から引く
for i in A:
    print(ans_all - c[i] + 1)


Measured memory_bytes: 34164