akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define un unsigned
#define lo long
#define in int
#define sh short
#define fo for
using namespace std;
in n;
un lo lo a[200100],b[200100],ha,hb,tt[200100];
un lo lo ra[200100],rb[200100];
un lo lo Base=1900210023LL,Modu=3200120091LL;
template<typename T,typename V,int &N>
struct Hasher{
	void Hashing(V arr[],T &res,T bas,T mod){
		for(int i=0;i<N;i++)
			res=((res*bas)%mod+(T)(arr[i]))%mod;
		return;
	} 
	void DeleteHash(V val,T &res,T HighestValue,T mod){
		res=(res+mod-((T)(val)*HighestValue)%mod)%mod;
	}
	void AddHash(V val,T &res,T bas,T mod){
		res=((res*bas)%mod+(T)(val))%mod;
	}
};
in main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	fo(in i=0;i<n;i++) cin>>a[i];
	fo(in i=0;i<n;i++) ra[i]=a[i];
	fo(in i=0;i<n;i++) tt[i]=(a[i]^a[(i+1)%n]);
	fo(in i=0;i<n;i++) a[i]=tt[i];
	fo(in i=0;i<n;i++) cin>>b[i];
	fo(in i=0;i<n;i++) rb[i]=b[i];
	fo(in i=0;i<n;i++) tt[i]=(b[i]^b[(i+1)%n]);
	fo(in i=0;i<n;i++) b[i]=tt[i];
	Hasher<un lo lo,un lo lo,n> haxi;
	haxi.Hashing(a,ha,Base,Modu);
	haxi.Hashing(b,hb,Base,Modu);
	long long hv=1LL;
	fo(in i=1;i<n;i++)
		hv=(hv*Base)%Modu;
	fo(in i=0;i<n;i++){
		if(ha==hb){
			cout<<i<<' '<<(ra[i]^rb[0])<<endl;
		}
		haxi.DeleteHash(a[i],ha,hv,Modu);
		haxi.AddHash(a[i],ha,Base,Modu);
	} 
	return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
 
  vector<double> exp(n);
  for(int j=0; j<k; j++){
  exp[0] += (p[j]+1)/2.0;
  }
  
  for(int m=0; m<n-k; m++){
    exp[m+1] = exp[m]+(p[m+k]-p[m])/2.0;
  }
  
  sort(exp.begin(), exp.end());
  
  cout << fixed << setprecision(15);
  
  cout << exp[n-1] << endl;
  
}

Measured memory_bytes: 5596
from collections import deque

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

#print(N, Q, ab, px)
class Tree:
    def __init__(self):
        # n番目のノードの値
        self.value = [0 for _ in range(N+1)]
        # n番目の, 親から含めたノードの値
        self.total_value = [0 for _ in range(N+1)]
        # n番目のノードの一つ下の辺リスト
        self.edge = [[] for _ in range(N+1)]

    def build(self, a, b):
        #print("Tree build ", a, " ", b)
        self.edge[a].append(b)
        self.edge[b].append(a)


    def add(self, p, x):
        # 木の値を更新していく
        self.value[p] += x

    # 値を親から子に向かって更新する
    def reflesh(self):
        stack = deque()
        stack.append((1, 0))
        while stack:
            st = stack.pop()
            node, parent = st[0], st[1]
            children = self.edge[node]
            for child in children:
                if child == parent:
                    continue
                #print("c n", child, node)
                self.value[child] += self.value[node]
                stack.append((child, node))


tree = Tree()
for ab_ in ab:
    tree.build(*ab_)

for px_ in px:
    tree.add(*px_)

tree.reflesh()
#print(" ".join([str(tree.value[x]) for x in range(1,N+1)]))
print(" ".join([str(tree.value[x]) for x in range(1,N+1)]))
#for i in range(1,N+1):
    #print(tree.edge[i], end=",")
#    print(tree.value[i], end=" ")

Measured memory_bytes: 144188
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int C[N];
bool R[N];

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	int n, m; cin >> n >> m;
	R[1] = 1;
	for (int i = 1; i <= n; i++) C[i] = 1;
	while (m--) {
		int x, y; cin >> x >> y;
		R[y] |= R[x];
		C[x]--, C[y]++;
		R[x] &= C[x] > 0;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) ans += R[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4004
from math import *

def main():
    N, M = map(int, input().split())
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M//j for j in divisor_set)
    print(int(max(divisor_set, key=lambda x: x if special_value >= x else -1)))

    return

if __name__ == "__main__":
    main()

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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define IOS			ios::sync_with_stdio(0), cin.tie(0)


int32_t main() {

	IOS;

	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;

	return 0;
}


Measured memory_bytes: 3648
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val r = nextInt()
    val g = nextInt()
    println(2*g-r)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

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

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

int n, org[22];
map<pii,ll>mp[22][22];

ll gao(int l,int r,int a,int b){
    if (l+1==r) return 0;
    if (l+2==r) return org[l+1]*(ll)(a+b);
    if (mp[l][r].count({a,b})) return mp[l][r][{a,b}];
    ll res=1e100;
    for (int i=l+1;i<=r-1;++i){
        ll t=gao(l,i,a,a+b)+org[i]*(ll)(a+b)+gao(i,r,a+b,b);
        res=min(res,t);
    }
    return mp[l][r][{a,b}]=res;
}

int main(){
    cin>>n;
    for (int i=1;i<=n;++i)
        cin>>org[i];
    cout<<gao(1,n,1,1)+org[1]+org[n]<<endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){


  int n;
  cin >> n;
  set<string> se;
  REP(i,n){
    string s;
    cin >> s;
    se.insert(s);
  }
  cout << se.size() << endl;



  

  return 0;
}


Measured memory_bytes: 19256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    string s,ans;
    cin >> s;
    for(int i = 0;;i+=2){
        if(!s[i])break;
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main ()
{
    char set[4][10] = 
        {
            "dream","dreamer","erase","eraser"
        };
    
    
    char s[100000];
    fgets(s,100000,stdin);
    
    
    int pt = 0;
    int end = strlen(s) - 1;
    while(pt < end) 
        {
            int i = 0;
            for(i = 0; i < 4; i++) 
                {
                    
                    if(strncmp(set[i],s + end - pt - strlen(set[i]),strlen(set[i])) == 0)
                        {
                            
                            pt += strlen(set[i]);
                            break;
                        }
                }
            if(i == 4)
                {
                    printf("NO");
                    return 0;
                }
            
        }
    
    printf("YES");
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, Q;
vector<int> G[200200];
int sum[200200];

void dfs(int v, int p, int s){
    sum[v] += s;
    s = sum[v];
    for(int i = 0; i < (int)G[v].size(); i++){
        if(G[v][i] != p){
            dfs(G[v][i], v, s);
        }
    }
}

signed main(){
    cin >> N >> Q;
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < Q; i++){
        int p, x;
        cin >> p >> x;
        p--;
        sum[p] += x;
    }
    dfs(0, -1, 0);
    for(int i = 0; i < N; i++){
        printf("%lld", sum[i]);
        if(i < N - 1)printf(" ");
    }
    printf("\n");

    return 0;
}
/*


*/

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


def solve(L: int):
    print(L ** 3 / 27)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)

h,w = list(map(int, stdin.readline().rstrip().split()))
if(h == 1 or w == 1):
	print(1)
else:
	print(ceil((h/2)*w))


Measured memory_bytes: 4976
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		Map<Integer, Integer> map = new TreeMap<>();
		for(int i = 0;i < N;i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			if(map.get(A[i])!=null) {
				map.put(A[i], B[i]+map.get(A[i]));
			}else {
				map.put(A[i], B[i]);
			}
		}
		sc.close();
		long sumKey = 0;
		long sumValue = 0;
		for(Map.Entry<Integer, Integer> entry : map.entrySet()) {
			for(int i = 0;i < entry.getValue();i++) {
				sumKey += entry.getKey();
				sumValue++;
				if(sumValue == M) {
					System.out.println(sumKey);
					return;
				}
			}
		}
	}
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll k,n; cin>>k>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n-1){
    chmax(ans,abs(a[i]-a[i+1]));
  }
  chmax(ans,abs(a[0]+(k-a[n-1])));
  cout<<k-ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int n, s, o;
void rec(int d, int k, int x){
  if(d > n) return;
  else if(d == n){
    if(x == s) ++o;
  }else{
    for(int i = k+1; i <= 9;++i){
      rec(d + 1, i, x + i);
    }
  }
}
int main(){
  cin >> n >> s;
  while(n != 0){
    o = 0;
    rec(0, -1, 0);
    cout << o << endl;
    cin >> n >> s;
  }
  return 0;
}


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

int main()
{
    int n;cin>>n;
    int k;cin>>k;
    int x,c=0;
    REP(i,k){cin>>x;c|=1<<x;}
    for(int i=0;i<(1<<n);i++)
    {
        if((i|c)!=c)continue;
        cout<<i<<":";
        
        for(int j=0;j<n;j++)
        {
            if((i>>j)&1)cout<<" "<<j;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>
#include <tuple>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<=b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pair_t;
#define MOD 1000003

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  1桁目取得

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て

typedef tuple<string,int,int> mytuple;////mytupleというtuple型

int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
bool comp(const pair_t &a, const pair_t &b) {
	return a.first < b.first;
}


bool mycompare1 (const mytuple &lhs, const mytuple &rhs){
	return get<1>(lhs) < get<1>(rhs);
}



int main() {

	int n,N,sum=0;
	cin>>n;
	N=n;
/*
	vector<mytuple> X;
	string rest;
	int score;
	rep(i,n) {
		cin >>rest>>score;
		X.push_back(make_tuple(rest,-score,i));
	}
	sort( X.begin(),X.end());//scoreでsort
	rep(i,n)
		cout << (get<2>(X[i]))+1<< endl;
*/
	while(n>0){
	sum+=n%10;
	n=n/10;
	}
	
	if(N%sum==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;

}




int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}


Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp
h = {}
g = {}
s.size.times do |i|
  if h[s[i]]
    if h[s[i]].count(t[i]) == 0
      h[s[i]] << t[i]
    end
  else
    h[s[i]] = [t[i]]
  end
  if g[t[i]]
    if g[t[i]].count(s[i]) == 0
      g[t[i]] << s[i]
    end
  else
    g[t[i]] = [s[i]]
  end
end
puts h.flatten(-1) == g.invert.flatten(-1) ? 'Yes' : 'No'

Measured memory_bytes: 2632
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C )
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
light = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    binstr = list(reversed(format(i, '010b')))
    lightnum = 0
    for j in range(m):
        cnt = 0
        K = light[j][0]
        for k in range(1,K+1):
            s = light[j][k]
            if binstr[s-1] == '1':
                cnt += 1
        if p[j] == cnt%2:
            lightnum += 1
    if lightnum == m:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

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

	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<pair<int, int> > ans;
	int total = 0;

	if (a[0] > 0) {
		int cur = a[0];
		for(int i = 1; i < n - 1; i++) {
			ans.push_back(mkp(cur, a[i]));
			cur = cur - a[i];
		}
		ans.push_back(mkp(a[n - 1], cur));
		total = a[n - 1] - cur;
	} else if (a[n - 1] < 0) {
		int cur = a[n - 1];
		for (int i = n - 2; i >= 0; i --) {
			ans.push_back(mkp(cur, a[i]));
			cur = cur - a[i];			
		}
		total = cur;
	} else {
		int index = -1;
		int cur = a[0];
		for (int i = n - 2; i >= 1; i--) {
			if (a[i] < 0) {
				index = i;
				break;
			}
			ans.push_back(mkp(cur, a[i]));
			cur = cur - a[i];
		}

		ans.push_back(mkp(a[n - 1], cur));
		cur = a[n - 1] - cur;



		for (int i = index; i >= 1; i--) {
			ans.push_back(mkp(cur, a[i]));
			cur = cur - a[i];

		}
		total = cur;
	} 
	cout << total << endl;
	for (auto c : ans) {
		cout << c.first << " " << c.second << endl;
	}

	return 0;
}

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> compress(vector<T> v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	return v;
}

template<typename T>
int index(const vector<T> &v, T i) { return lower_bound(v.begin(), v.end(), i) - v.begin(); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int n; cin >> n&&n;) {
		vector<string> v(n);
		vector<char> c;
		rep(i, 0, n) {
			cin >> v[i];
			reverse(all(v[i]));
			rep(j, 0, v[i].size()) {
				if (v[i][j] >= '0'&&v[i][j] <= '9')continue;
				c.push_back(v[i][j]);
			}
			c.insert(c.end(), v[i].begin(), v[i].end());
		}
		vector<char> zip = compress(c);
		dump(zip);

		int mp[128];
		memset(mp, -1, sizeof(mp));
		rep(i, 0, 10)
			mp[i + '0'] = i;


		unordered_set<char> head;
		rep(i, 0, n) {
			if (v[i].size() > 1) {
				head.emplace(v[i].back());
			}
		}

		char used[10];
		memset(used, 0, sizeof(used));
		function<int(int, int)> dfs = [&](int idx, int num) {
			int add = 0;
			rep(i, 0, 10) {
				int digit = add;
				add = 0;
				bool flag = false;
				rep(j, 0, n - 1) {
					if (v[j].size() <= i)continue;
					if (mp[v[j][i]] == -1) {
						flag = true;
						break;
					}
					digit += mp[v[j][i]];
				}
				if (flag)
					break;
				add += digit / 10;
				digit %= 10;
				if (v[n - 1].size() > i) {
					if (mp[v[n - 1][i]] == -1)
						break;
					if (digit != mp[v[n - 1][i]])
						return 0;
				}
				else {
					if (digit > 0 || add > 0)
						return 0;
					else
						break;
				}
			}
			if (zip.size() > idx + 1) {
				int ret = 0;
				rep(i, 0, 10) {
					if (used[i])continue;
					if (i == 0 && head.count(zip[idx + 1]))continue;
					used[i] = zip[idx + 1];
					mp[zip[idx + 1]] = i;
					ret += dfs(idx + 1, i);
					mp[zip[idx + 1]] = -1;
					used[i] = 0;
				}
				return ret;
			}
			else {
				return 1;
			}
		};
		int ans = 0;
		rep(i, 0, 10) {
			if (used[i])continue;
			if (i == 0 && head.count(zip[0]))continue;
			used[i] = zip[0];
			mp[zip[0]] = i;
			ans += dfs(0, i);
			mp[zip[0]] = -1;
			used[i] = 0;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
int a[100005];
int t[100005];
int x,y;
ll s=0;
int main(){
	int n,k;
	cin >> n ;
	for(int i=0;i<n;i++){
		cin >> x;
		t[x]++;
		s+=x;
	}
	cin >> k;
	for(int i=0;i<k;i++){
		cin >> x >> y;
		if(t[x]>0){
			s+=(y-x)*t[x];
			t[y]+=t[x];
			t[x]=0;
			
		}
		cout << s <<endl;
	}
	
//	cin >> k;	
//	for(int i=0;i<k;i++){
//		cin >> x >> y;
//		if(t[x]>0) {
//			t[x]=0;
//			t[y]+=t[x];
//			s=s+(y-x)*t[x];
//		}	
//		cout << s <<endl;
//	}	
	return 0;
}

//1000000000000001




Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    rep(i, m) cin >> c[i];
    vector<vector<ll>> dp(m + 1, vector<ll>(n + 1, INF));
    rep(i, m + 1) dp[i][0] = 0;

    rep(i, m) {
        rep(j, n + 1) {
            chmin(dp[i + 1][j], dp[i][j]);
            if (j - c[i] >= 0) {
                chmin(dp[i + 1][j], dp[i + 1][j - c[i]] + 1);
            }
        }
    }

    cout << dp[m][n] << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dp[1010][1010];
signed main(void)
{
  string s, t;
  cin >> t >> s;
  const int n = s.size(), m = t.size();
  REP(i, n+1) REP(j, m+1) {
    if(i == 0) dp[i][j] = j;
    else if(j == 0) dp[i][j] = i;
    else {
      if(s[i-1] == t[j-1]) {
        dp[i][j] = min({dp[i-1][j-1], dp[i-1][j]+1, dp[i][j-1]+1});
      } else {
        dp[i][j] = min({dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1]+1});
      }
    }
  }
  /*
  cout << "    ";
  REP(i, m) cout << t[i] << " ";
  cout << endl;
  REP(i, n+1) {
    if(i) cout << s[i-1] << " ";
    else cout << "  ";
    REP(j, m+1) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  cout << dp[n][m] << endl;
  return 0;
}

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

def cal(n, len=1):
    if (n // 10)  < 1:
        return len
    len+=1
    return cal(n/10, len)

n = int(input())

count = 0
for i in range(1,n+1):
    len = cal(i)
    if len % 2 == 1:
        count+=1
    
print(count)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	long long R = 0;
	long long G = 0;
	long long B = 0;
	for (int n = 0; n < S.size(); ++n) {
		if ('R' == S[n]) {
			++R;
		}
		else if('G'==S[n]){
			++G;
		}
		else {
			++B;
		}
	}
	//cout << R<<G<<B << endl;
	long long ans = R * G * B; 
	//cout << ans << endl;
	for (int i = 0;i<N;++i) {
		for (int j = i+1;j<N;++j) {
			int k = 2 * j - i;
			if (k >= N) {
				continue;
			}
			if (S[i]==S[j]) {
				continue;
			}
			if (S[i]==S[k]) {
				continue;
			}
			if (S[j]==S[k]) {
				continue;
			}
			--ans;
		}
	}
	cout << ans <<endl; 
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

void show_array(int A[], int N){
    int i;
    for(i = 0; i < N; i++){
        printf("%d", A[i]);
        if(i < N - 1){
            putchar(' ');
        }
        else{
            putchar('\n');
        }
    }
}

void exchange(int A[], int i, int j){
    int tmp;
    tmp = A[i];
    A[i] = A[j];
    A[j] = tmp;
}

int selection_sort(int A[], int N){
    int i, j;
    int cnt = 0;
    int idx_min;
    for(i = 0; i < N; i++){
        idx_min = i;
        for(j = i; j < N; j++){
            if(A[idx_min] > A[j]){
                idx_min = j;
            }
        }
        if(i != idx_min){
            exchange(A, i, idx_min);
            cnt += 1;
        }
    }
    return cnt;
}

int main(void){
    int N, i, cnt;
    int A[100];

    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    cnt = selection_sort(A, N);

    show_array(A, N);
    printf("%d\n", cnt);

    return 0;

}


Measured memory_bytes: 2112
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 300010, M = 2000005;
ll x, y;
int solve()
{
	in2(x, y);
	for (int i = 0; i <= x; i++)
	{
		ll k = (i * 2) + ((x - i) * 4);
		if (k == y)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int ret = solve();
	return 0;
}
/*

*/


Measured memory_bytes: 3684
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class BMinorChange {
public:
  static void solve(istream &cin, ostream &cout) {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) {
      if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
  }
};


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


Measured memory_bytes: 3884
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		//System.out.println(s.length());
		if(s != null && s.length()>=4){
		
			if(s.substring(0,4).equals("YAKI")){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23508
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N+1);
  a[0] = 0;

  rep(i, N){
    cin >> a[i+1];
  }

  // 周回する回数を見る
  ll cnt = 0;
  ll t = a[1];
  vector<bool> x(N+1, true);
  x[1] = false;
  while(1){
    cnt++;
    K--;
    if(K==0){
      print(t);
      return 0;
    }
    if(x[t]){
      x[t] = false;
      t = a[t];
    } else {
      break;
    }
    
  }  

  // tをはじめとしてループを探す
  ll s = t;
  vector<ll> b;
  b.push_back(t);
  t = a[t];
  while(s != t){
    b.push_back(t);
    t = a[t];  
  }

  ll b_size = b.size();
  K = K + b_size;
  ll y = K%b_size; // 0からb_size-1までの値が出る
  print(b[y]);

}


Measured memory_bytes: 5840
#include<cstdio>
using namespace std;
int H,W,h,w;
void structure(int id){
	switch(id){
		case 0:{
			const unsigned int HLJ=19260817*981;
			int HLL=HLJ%998244853;
			for(int i=0;i<H;i++){
    				for(int j=0;j<W;j++){
    					printf("%d%c",
    					((i%h)||(j%w))?
    					(
    					(((i+1)%h)||((j+1)%w))
    					?(0)
    					:(-HLL-1)
    					):HLL,(j+1)!=W?' ':'\n');
				}
    			}
		}break;
		case 1:{
			int EVA=25252;
			if(H%h){
				for(int i=1;i<=H;i++){
					if(i%h)for(int j=1;j<=W;j++)
						printf("%d%c",EVA,j!=W?' ':'\n');
					else for(int j=1;j<=W;j++)
						printf("%d%c",-EVA*(h-1)-1,j!=W?' ':'\n');
				}
			}else{	
				for(int i=1;i<=H;i++){
					for(int j=1;j<=W;j++)
					if(j%w)
						printf("%d%c",EVA,j!=W?' ':'\n');
					else
						printf("%d%c",-EVA*(w-1)-1,j!=W?' ':'\n');
				}
			}
		}break;
	}
}
#include<algorithm>
#include<ctime>
int main(){
	srand(time(0));
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h||W%w)puts("Yes"),structure(1);
	else puts("No");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s, t;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> s >> t;
    int ans = 1e9;
    for(int i = 0; i < s.size() - t.size() + 1; i++)
    {
    	int cnt = 0;
    	for(int j = 0; j < t.size(); j++) cnt += s[i + j] != t[j];
    	ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3568
h,w=map(int,input().split())
s=[input() for i in range(h)]

dx=[0,1,0,-1]
dy=[1,0,-1,0]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            cnt=0
            for k in range(4):
                nx=i+dx[k]
                ny=j+dy[k]

                if 0<=nx<=h-1 and 0<=ny<=w-1:
                    if s[nx][ny]=='#':
                        cnt=1
            if cnt!=1:
                print('No')
                exit()

print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int N, C;
  cin >> N >> C;
  vector<vector<int>> D(C, vector<int>(C));
  rep(i,C)rep(j,C) cin >> D[i][j];
  vector<vector<int>> c(N, vector<int>(N));
  rep(i,N)rep(j,N){
    cin >> c[i][j];
    c[i][j]--;
  }
  int ans=1e9;
  vector<vector<int>> color(3, vector<int>(C));
  rep(i,N)rep(j,N) color[(i+j)%3][c[i][j]]++;
  rep(i,C)rep(j,C)rep(k,C){
    if(i==j || j==k || k==i)
      continue;
    int sum=0;
    rep(l,C)
      sum += D[l][i]*color[0][l];
    rep(l,C)
      sum += D[l][j]*color[1][l];
    rep(l,C)
      sum += D[l][k]*color[2][l];
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	int L_total = 0;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		L_total += L[i];
		if (L_total > X) {
			cout << i + 1;
			return 0;
		}
		else if (L_total == X) {
			cout << i + 2;
			return 0;
		}
	}
	cout << N + 1;
	return 0;
}

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

using namespace std;

int main() {
    int players, startscore, questions, input, playerScores[100000];
    cin >> players >> startscore >> questions;
    for (int i = 0; i < players; i++) {
        playerScores[i] = 0;
    }
    for (int i = 0; i < questions; i++) {
        cin >> input;
        playerScores[input - 1]++;
    }
    for (int i = 0; i < players; i++) {
        if (startscore + playerScores[i] - questions <= 0) {
            cout << "No\n";
        }
        else cout << "Yes\n";
    }

}


Measured memory_bytes: 1024
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)
 
N=gets.to_i

dict=[]

N.times do |i|
  s,pi=gets.split
  pi=pi.to_i
  dict << [s,-pi,i+1]
end
puts dict.sort.map{|a,b,c| c}

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

int a[393];//???????????????
int dp[394];//??????n??§???????????§?????????
int main(){
    int b;cin>>b;
    for(int c=0;c<b;c++){
	int d,e,f;
	cin>>d>>e>>f;
	for(d--;d<e;d++){
	    a[d]=max(a[d],f);
	    }
	}
   for(int i=0;i<393;i++){
       for(int j=i+1;j<=393;j++){
	   dp[j]=max(dp[j],dp[j-(i+1)]+a[i]);
	   }
       }	
    int n;cin>>n;
    vector<int>V;
    while(n--){
	int m;cin>>m;
	if(dp[m])V.push_back(dp[m]);
	else {puts("-1");return 0;}
	}
    for(int i:V)cout<<i<<endl;	
    }

Measured memory_bytes: 3140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

    int n;
    cin >> n;

    int now = -1;
    ll acc = 0;
    REP(i, n) {
        int a;
        cin >> a;
        if (now == -1) now = a;
        if (now > a) {
            acc += now - a;
        }
        if (now < a) {
            now = a;
        }
    }

    cout << acc << endl;
    return 0;
}


Measured memory_bytes: 3660
def main():
    import bisect
    n=int(input())
    a=[int(input()) for _ in [0]*n]
    b=[[a[i],i] for i in range(n)]
    b.sort()
    cnt=1
    ans=1
    for i in range(1,n):
        if b[i-1][1]<b[i][1]:
            cnt+=1
            ans=max(cnt,ans)
        else:
            cnt=1
    print(n-ans)
main()

Measured memory_bytes: 39420
/* 二分ヒープ */
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int *heap, h, i;

  /* 二分ヒープ用の領域を動的に確保 */
  scanf("%d", &h);
  heap = (int *)malloc( sizeof(int) * (h+1) );

  /* 二分ヒープの節点の情報を読み込む */
  for( i = 1; i<=h; i++ )
    scanf("%d", &heap[i]);

  /* 二分ヒープの各節点の情報を出力 */
  for( i = 1; i<=h; i++ )
    {
      printf("node %d: key = %d, ", i, heap[i]);
      if( i/2 >= 1 )
	printf("parent key = %d, ", heap[i/2]);
      if( i*2 <= h )
	printf("left key = %d, ", heap[i*2]);
      if( i*2+1 <= h )
	printf("right key = %d, ", heap[i*2+1]);
      printf("\n");
    }

  return 0;
}



Measured memory_bytes: 2048
import sys
input = sys.stdin.readline

import numpy as np

MOD = 10**9 + 7
N = int(input())
A = np.array(input().split(), dtype=np.int64)

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

U = N+10
x = np.arange(U,dtype=np.int64); x[0] = 1
fact = cumprod(x)

x = np.arange(1,U+1,dtype=np.int64)[::-1]; x[0] = pow(int(fact[-1]),MOD-2,MOD)
fact_inv = cumprod(x)[::-1]

inv = np.zeros_like(fact)
inv[1:] = fact[:-1] * fact_inv[1:] % MOD

wt_left = np.zeros(N,dtype=np.int64)
wt_left[1:] = (fact[N] * inv[2:N+1] % MOD).cumsum() % MOD
wt = wt_left + wt_left[::-1] + fact[N]

answer = (wt * A % MOD).sum() % MOD
print(answer)

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a == b) cout << "Draw" << endl;
  else {  
  	if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    
    else if(a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define sswap(x, y) do{ char t[13]; strcpy(t, x); strcpy(x, y); strcpy(y, t); }while(0)

void quick(char s[][13], int left, int right){
  int pl = left, pr = right;
  char x[13];  strcpy(x, s[(left+right)/2]);
  do{
    while(strcmp(s[pl], x) < 0)  pl++;
    while(strcmp(s[pr], x) > 0)  pr--;
    if(pl <= pr){
      sswap(s[pr], s[pl]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(s, pl, right);
  if(pr > left)   quick(s, left, pr);
}

int main(){
  int n;  scanf("%d", &n);
  char s[100005][13];  
  for(int i=1; i<=n; i++){
    scanf("%s", s[i]);
    for(int j=0; j<9; j++)
      for(int k=j+1; k<10; k++)
	if((int)s[i][j] > (int)s[i][k]){
	  char t = s[i][j];
	  s[i][j] = s[i][k];
	  s[i][k] = t;
	}
  }
  quick(s, 1, n);
  long ans = 0, idx = 1;  
  while(idx <= n){
    long same = 1;
    while(strcmp(s[idx], s[idx+same]) == 0)  same++;
    ans = ans + same*(same-1) / 2;
    idx += same;
  }

  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 3000
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  if((B - A)%2 == 0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
  return 0;
}


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

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        //input
        int N = NextInt();
        long[] A = LineLong();
        for (int i = 1; i < N; i++) A[i] += A[i - 1];
        Dictionary<long, long> dic = new Dictionary<long, long>();
        for (int i = 0; i < N; i++)
        {
            if (!dic.ContainsKey(A[i])) dic[A[i]] = 0;
            dic[A[i]]++;
        }
        if (dic.ContainsKey(0)) dic[0]++;
        long ans = 0;
        foreach (var d in dic)
        {
            if (d.Value < 2) continue;
            ans += d.Value  * (d.Value - 1) / 2;
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 44220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
   int N,X;
   cin>>N>>X;
   vector<int>A(N);
   rep(i,N){
       cin>>A[i];
   }
   sort(A.begin(),A.end());
   int ans=0;
   rep(i,N){
       if(A[i]<=X){
           ans++;
           X-=A[i];
           if(X!=0&&i+1==N){
               ans--;
           }
       }
       else{
           break;
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3584
/*
  第4回ユニリタプログラミングコンテスト～練習サイト～
  C言語用
  ファイル名 qA.c
  作成者 228 金子幸裕 2017/06/14 17:30
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

int main( void )
{
    int na, nb, nc;

    scanf( "%d %d %d" , &na, &nb, &nc );

    if ( ( na == 5 || na == 7 ) &&
         ( nb == 5 || nb == 7 ) &&
         ( nc == 5 || nc == 7 ) &&
         ( na + nb + nc == 17 ) )
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }


    printf("\n");

    return ( 0 );

}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

const int INF = 2<<20;

int main(){
	int w[] = {2, 3, 5};
	int v[] = {380, 550, 850};
	int disn[] = {5, 4, 3};
	double disp[] ={0.2, 0.15, 0.12};

	int lowest[55];
	fill(lowest, lowest+55, INF);
	lowest[0] = 0;

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 50; j++){
			for(int k = 1; j + w[i]*k <= 50; k++){
				int n = k - k%disn[i];
				lowest[j+w[i]*k] = min(lowest[j+w[i]*k], lowest[j]+v[i]*(k-n)+(int)(v[i]*n*(1.0-disp[i])));
			}
		}
	}

	int n;
	while(cin >> n, n){
		n/=100;
		cout << lowest[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int n,t,e;
	int kari;
	int tokei[100];
	int para = 0;
	cin >> n >> t >> e;
	for (int i = 0; i < n; i++) {
		cin >> kari;
		if (t / kari > 0) {
			tokei[i] = t % kari;
			tokei[i] = min(tokei[i], kari-tokei[i]);
		} else {
			tokei[i] = kari - t;
		}
		if (tokei[i] <= e) {
			para = i+1;
		}
	}
	if (para > 0) {
		cout << para << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int sum = 0;
            int[] count = new int[1002];

            for (int i = 2; i <= n; i++) {
                int x = i;
                for (int j = 2; j <= x; j++) {
                    while (x % j == 0) {
                        x /= j;
                        count[j]++;
                    }
                }
            }

            long ans = 1;
            long MOD = 1000000007;

            for (int i = 2; i <= n; i++) {
                ans *= count[i] + 1;
                ans %= MOD;
            }

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


Measured memory_bytes: 23764
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
index = 0
count = 0
for i in range(n-1, -1, -1):
    if count % 2 == 0:
        b[index] = a[i]
        index += 1
    else:
        b[-index] = a[i]
    count += 1

print(" ".join(list(map(str, b)))) 



Measured memory_bytes: 28740
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    if(v<=w){
        cout << "NO" << endl;
    }
    else {
       if(abs(a-b)<=(ll)(v-w)*t){
           cout << "YES" << endl;
       } 
       else{
           cout << "NO" << endl;
       }
    }
    return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author cthanh
 *
 */
public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\?????????
		    String str = br.readLine();
		    double r =  Double.parseDouble( str);
		    double men = (double) r *r *Math.PI;
		    double syu = (double) r*2* Math.PI;
		   // System.out.println(Math.PI);
		    System.out.printf( "%.6f %.6f",men , syu );


	}

}

Measured memory_bytes: 24480
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    char s;
    cin >> s;
    s++;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ss = n.times.map{gets.chomp.chars}
ans = []
n.times do |i|
	if i == 0
		ans = ss[0]
	else
		hash = Hash.new(0)
		ss[i].each do |c|
			hash[c] += 1
		end
		ans.size.times do
			temp = ans.shift
			if hash[temp] > 0
				hash[temp] -= 1
				ans.push(temp)
			end
		end
	end
end

puts ans.sort.join("")

Measured memory_bytes: 3836