akhauriyash/Code-Regression huggingface dataset:
a,b,c=map(int,input().split())
cnt=0
if a%2==1 or b%2==1 or c%2==1:print(0)
elif a==b==c:print(-1)
else:
    while a%2==b%2==c%2==0:
        aa,bb,cc=(b+c)//2,(a+c)//2,(b+c)//2
        a,b,c=aa,bb,cc
        cnt+=1
    print(cnt)

Measured memory_bytes: 3064
use std::cmp::max;


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

    let mut ans = 0;
    let mut counter = 0;
    for c in s.chars() {
        if "ACGT".contains(c) {
            counter += 1;
            ans = max(ans, counter);
        } else {
            counter = 0;
        }
    }

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005,M=1000005;
int n,m,p[N],c[N],val[N],f[M+N];
int main()
{
	scanf("%d%d",&n,&m); m/=100;
	clr(f,7); f[0]=0;
	for(int i=1;i<=n;i++) scanf("%d%d",&p[i],&c[i]),c[i]/=100;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=p[i];j++) val[j]=i*j;
		val[p[i]]+=c[i];
//		for(int j=1;j<=p[i];j++) cout<<val[j]<<" "; cout<<endl;
		for(int j=M;j>=0;j--){
			int mn=1e9;
			for(int k=1;k<=p[i];k++)
			  if(j-val[k]>=0)
			    mn=min(mn,f[j-val[k]]+k);
			f[j]=min(f[j],mn);
		}
//		for(int j=0;j<=m;j++) cout<<f[m]<<' '; cout<<endl;
	}
	int ans=1e9;
	for(int i=m;i<=M;i++) ans=min(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}

set<int>ng={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};

signed main()
{
	IOS();
	vector<int>ans;
	while(1){
		int N;
		cin>>N;
		if(N==0)break;
		vector<int>a(N);
		for(int i = 0;i < N;i++){
			cin>>a[i];
		}
		sort(all(a));
		int mi = INF;
		rep(i,0,N-1)chmin(mi,a[i+1]-a[i]);
		ans.push_back(mi);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



int main(){

ll N,A,B;
cin>>N>>A>>B;

ll tmp = N/(A+B);
if(N%(A+B)==0){
    cout<<tmp*A<<endl;
    return 0;
}

if(N-tmp*(A+B)>=A){
    cout<<tmp*A+A<<endl;
}
else{
    cout<<tmp*A+N-tmp*(A+B)<<endl;
}


}


Measured memory_bytes: 256
#include <iostream>

int main() {
  char c;
  std::cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    std::cout << "vowel" << "\n";
  } else {
    std::cout << "consonant" << "\n";
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000

int n,A[N];
int makeCombination(int);
int solve(int ,int);

int main(){
    
    int i,j,q,B[N];
    scanf("%d",&n);
    for(i = 0; i < n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i = 0; i < q;i++){
        scanf("%d",&B[i]);
    }

    i=0;
        for(j = 0;j < q;j++){
                if(solve(i,B[j])==1){
            printf("yes\n");
        }
        else {
            printf("no\n");
        }
        
    }
   

    return 0;
}
/*
int makeCombination(int x){
    int i;

    for(i = 0;i < n-1; i++){
        S[i] = 0;
        makeCombination(0);
    }

    makeCombination(i);
    if(i == n){
        printf("%d",S[i]);
        return 0;
    }

    makeCombination(i+1){
        S[i] = 1;
        makeCombination(i+1);
        S[i] = 0;
    }
}
*/

int solve(int i,int m){
    int res;
    if(m==0){
        return 1;
    }
    if(i >= n){
        return 0;
    }

    if((solve(i + 1,m) || solve(i + 1,m - A[i]))==1){
        return 1;
    }
    else{
        return 0;
    }
}


Measured memory_bytes: 2108
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time

def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]


yn = ['Yes', 'No']
YN = ['YES', 'NO']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True

def primes(n):
    is_prime = [1] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = 0
    return is_prime


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
             return False
    return True


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def coprime(a, b):
    return gcd(a, b) == 1


def main():
    Q = I()
    l = [0] * Q
    r = [0] * Q
    MX = 10**5+1

    for i in range(Q):
        l[i], r[i] = MI()

    primes_nums = primes(MX)
    likes_2017 = [int(i % 2 == 1 and primes_nums[i] and primes_nums[(i+1)//2]) for i in range(MX)]
    likes_2017_acc = list(accumulate(likes_2017))
    # print(likes_2017)

    for i in range(Q):
        ans = likes_2017_acc[r[i]] - likes_2017_acc[l[i]-1]
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52184
s = input()
mod = 10**9 + 7

dp = [[0] * 13 for _ in range(2)]
tmp = 0
for si in s:
    if(si != '?'):
        tmp = (tmp*10 + int(si)) % 13
    else:
        tmp = tmp*10 % 13

dp[0][tmp] = 1
exp10 = 1
pointer = 0
for i,si in enumerate(s[::-1]):

    if(si!='?'):
        exp10 = exp10 * 10 % 13
        continue

    pointer = 1 - pointer
    for j in range(13):
        dp[pointer][j] = 0

    for j in range(13):
        for k in range(10):
            dp[pointer][(j + exp10*k)%13] += dp[1-pointer][j]

    for j in range(13):
        dp[pointer][j] %= mod

    exp10 = exp10 * 10 % 13

print(dp[pointer][5])


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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

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

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
    string S;
    cin >> S;
    string ans = S.substr(0, S.length() - 8);
    print(ans);
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n,k,q;
cin >> n >> k >> q;

vector<int> ten(n,k);

rep(i,q){
    int a;
    cin >> a;
    ten[a-1]++;
}

rep(j,n) ten[j] = ten[j] - q;

rep(j,n){
    if(ten[j] <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll N;
ll M;
string s;
vector<ll > input1;  
vector<vector <ll > > input2;

int main(){
    
    //cin >> N;
    double W, H, x , y;
    cin >> W >> H >> x >> y;
    
    if(W == H){
        cout << fixed << setprecision(9)  << W * H / 2.0;

        if(W / 2 == x && H / 2 == y){
            cout << " 1"  << endl;
        }else{
            cout << " 0"  << endl;
        }

    }else{
        cout << fixed << setprecision(9)  << W * H / 2.0;
        
        if(W / 2 == x && H / 2 == y){
            cout << " 1"  << endl;
        }else{
            cout << " 0"  << endl;
        }
    }
} 


Measured memory_bytes: 256
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
ll mod=1e9+7;
int main()
{
IOS
ll n;
cin>>n;
ll sum=0;
sum+=(n*(n+1));
sum--;
for(ll i=2;i*i<=n;i++)
{
    for(ll j=i;j*i<=n;j++)
    {
        if(i==j)
        sum+=i*j;
        else
            sum+=(2*i*j);
    }
}
cout<<sum;
return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b&&b==c) cout << 1 << endl;
  else if (a==b||b==c||c==a) cout << 2 << endl;
  else cout << 3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    int res = 0;
    for (int i = 1; i <= n; i++) {
        int c = 0;
        if (i % 2 == 0) continue;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) c++;
        }
        if (c == 8) res++;
    }
    cout << res << endl;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    string S; cin >> S;
    
    ll ans = INF;
    
    REP(i, 26) {
        ll num = 0;
        string s = S;
        while (count(ALL(s), i + 'a') != s.length()) {
            num++;
            
            string t = "";
            ll n = s.length();
            REP(j, n - 1) {
                if (s[j] == i + 'a') t += s[j];
                else t += s[j + 1];
            }
            s = t;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct {
	int num;
	char name[10];
}QUEUE;

int main() {
	int i, time = 0, n, q, head = 0, tail;
	char s[10];
	QUEUE a[500000];
	scanf("%d", &n);
	scanf("%d", &q);
	for (i = 0; i < n; i++) {
		scanf("%s %d", a[i].name, &a[i].num);
	}
	tail = n;
	i = 1;
	while (head != tail) {
		if (a[head].num > q) {
			a[head].num -= q;
			a[tail] = a[head];
			time += q;
			head++;
			tail++;
		}
		else {
			time += a[head].num;
			printf("%s %d\n", a[head].name, time);
			i++;
			head++;
		}
	}
	return 0;
}





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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vvl order(n,vl(n-1));
	FOR(i,0,n) FOR(j,0,n-1) {
		ll x; cin >> x;
		order[i][j] = x-1;
	}
	
	auto id = [&](ll i, ll j) {
		if (i > j) swap(i,j);
		return i*n+j;
	};
	
	vl indeg(n*n);
	vvl adj(n*n);
	FOR(i,0,n) {
		FOR(k,0,n-2) {
			ll a = id(i,order[i][k]);
			ll b = id(i,order[i][k+1]);
			adj[a].pb(b);
			indeg[b]++;
		}
	}
	
	vl depth(n*n);
	queue<ll> q;
	FOR(a,0,n*n) if (!indeg[a]) q.push(a);

	while (sz(q)) {
		ll a = q.front();
		q.pop();
		for (ll b: adj[a]) {
			depth[b] = max(depth[b], depth[a]+1);
			if (!--indeg[b]) q.push(b);
		}
	}

	ll res = *max_element(all(depth)) + 1;
	if (accumulate(all(indeg),0LL)) res = -1;
	cout << res << endl;
}



Measured memory_bytes: 66944
#include <iostream>
#include <cmath>

using namespace std;

long long mpow(int a, int b);
int f(long long n);

int main()
{
	int n, m;
	cin >> n >> m;
	
	int t = mpow(10, f(m)) * n + m;
	for (int i = 1; i <= sqrt(t); i++) {
		if (i * i == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}

long long mpow(int a, int b)
{
	long long t = a;
	long long ans = 1;
	for (int i = 0; i < 31; i++) {
		if ((b & 1) == 1) {
			ans *= t;
		}
		t *= t;
		b >>= 1;
	}

	return ans;
}

int f(long long n)
{
	int ans = 0;
	while (n != 0) {
		n /= 10;
		ans++;
	}

	return ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long int
int main()
{
    ll  n;
    cin>>n;
    ll arr[n+3],brr[n+3],crr[n+3];
    for(ll i=1;i<=n;i++)
        cin>>arr[i];
    for(ll i=1;i<=n;i++)
        cin>>brr[i];
       for(ll i=1;i<=n-1;i++)
        cin>>crr[i];
    ll sum=brr[arr[1]];

    for(ll i=2;i<=n;i++)
    {
        sum=sum+brr[arr[i]];

        if(arr[i]==arr[i-1]+1)
        {
            sum+=crr[arr[i-1]];
        }
      
    }
    cout<<sum;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    if(n % k) cout << 1 << endl;
    else    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> b(N);
  for(int i=0; i<N-1; i++) cin >> b[i];
  
  int ans = b[0] + b[N-2];
  for(int i=0; i<N-1; i++)
    ans += min(b[i], b[i+1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static ArrayList<Integer> list = new ArrayList<>();
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] a = new long[n];
		for (i = 0; i < a.length; i++) {
			a[i] = parseLong(sc.next());
		}
		sc.close();
		HashSet<Long> set = new HashSet<>(n);
		boolean f=true;
		for (i = 0; i < n; i++) {
			if(set.contains(a[i])) {
				f=false;
				break;
			} else {
				set.add(a[i]);
			}
		}
		out.println(f?"YES":"NO");
	}
}


Measured memory_bytes: 58016
def resolve():
    '''
    code here
    '''
    W, H, x, y = [int(item) for item in input().split()]

    if 2*x == W and 2*y == H:
        res = 1
    else:
        res = 0

    print(W*H/2, res)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
//gcd,lcmセット
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*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

long long fac[MAX], finv[MAX], inv[MAX];

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main() {
    map<string, int> cnt;
    int n,mx;
    string s;
    cin>>n;
    mx=0;
    REP(i,n){
        cin>>s;
        cnt[s]++;
        mx=max(mx,cnt[s]);
    }
    for(auto p:cnt){
        auto k=p.first;
        auto v=p.second;
        if(v==mx){
            cout<<k<<endl;
        }
    }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
namespace IO{
	const int L=1<<15;char ibuf[L|1],*iS=ibuf,*iT=ibuf,obuf[L|1],*oS=obuf,*oT=obuf+L,c,st[66];int tp=0,f;
	inline char gc(){if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);return (*iS++);}
	inline void flush(){fwrite(obuf,sizeof(char),oS-obuf,stdout);oS = obuf;}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){ll x=0;f=1,c=gc();for(;!isdigit(c);c=gc())if(c=='-')f=-1;for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);return x*f;}
	inline void write(ll x){if(!x) pc('0');if(x<0) pc('-'),x=-x;while(x) st[++tp]=x%10+'0',x/=10;while(tp) pc(st[tp--]);}
	inline void writeln(ll x){write(x);pc('\n');}
	inline void wri(ll x){write(x),pc(' ');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}using IO::read;using IO::write;using IO::writeln;using IO::wri;//using IO::gc;using IO::pc;
#define rd read
const int maxn = 8e5+122;
const int maxm = maxn;
struct Edge{
	int to,nxt;
	Edge(){}
	Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxm];
int first[maxn],nume;
void Addedge(int a,int b){
	edge[nume] = Edge(b,first[a]);
	first[a] = nume++;
}
bool vis[maxm];
bool mark[maxm];
int ans[maxn];
int root[2],pos[maxn];
int n,fa[2][maxn],size[2][maxn];
void dfs(int u){
	for(int e=first[u];~e;e=first[u]){
		first[u]=edge[first[u]].nxt;
		if(!vis[e]){
			vis[e] = vis[e^1] = true;
			dfs(edge[e].to);
			mark[e] = false;
			mark[e^1] = true;
		}
	}
}
int main(){
	n = rd();
	rep(k,0,2)
	Rep(i,1,n){
		fa[k][i] = rd();
		if(fa[k][i] == -1) root[k] = i;
		else size[k][fa[k][i]]++;
	}
	Rep(i,1,n){
		if((size[0][i]&1) != (size[1][i]&1)){
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	mem(first,-1);nume = 0;
	rep(k,0,2)
	Rep(i,1,n){
		if(i!=root[k]){
			Addedge(k*n+i,k*n+fa[k][i]);
			Addedge(k*n+fa[k][i],k*n+i);
		} else{
			Addedge(k*n+i,2*n+1);
			Addedge(2*n+1,k*n+i);
		}
	}
	Rep(i,1,n){
		if((size[0][i]&1)==0){
			pos[i] = nume;
			Addedge(i,i+n);
			Addedge(i+n,i);
		}
	}
	dfs(2*n+1);
	Rep(i,1,n){
		if(size[0][i]&1){
			ans[i] = 0;
		} else{
			ans[i] = mark[pos[i]] ? 1 : -1;
		}
	}
	puts("POSSIBLE");
	Rep(i,1,n) wri(ans[i]);
	return 0;
}

Measured memory_bytes: 28800
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto N = to!ulong(tokens[0]);

	ulong[] a, b, c;
	foreach (i; 0..N)
	{
		auto tokens2 = split(my_readln());
		{
			a ~= to!ulong(tokens2[0]);
			b ~= to!ulong(tokens2[1]);
			c ~= to!ulong(tokens2[2]);
		}
	}

	ulong[3][] bn;
	bn.length = N;
	bn[0][0]  = a[0];
	bn[0][1]  = b[0];
	bn[0][2]  = c[0];

	foreach (i; 0..N-1)
	{
		bn[i+1][0] = max(bn[i][1], bn[i][2]) + a[i+1];
		bn[i+1][1] = max(bn[i][0], bn[i][2]) + b[i+1];
		bn[i+1][2] = max(bn[i][0], bn[i][1]) + c[i+1];
	}

	writeln(max(max(bn[N-1][0], bn[N-1][1]), bn[N-1][2]));
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}

Measured memory_bytes: 10236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[10],k;
    for(int i=1;i<=5;i++)
        cin>>a[i];
    cin>>k;
    bool flag=true;
    for(int i=1;i<=5;i++)
        for(int j=i+1;j<=5;j++)
    {
        if(abs(a[i]-a[j])>k) flag=false;
    }
    cout<<(flag?"Yay!":":(")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define pll pair<ll,ll>
#define inf 1000000000000000000
using namespace std;

int n;
vector<vector<ll>> a;

vector<vector<ll>> mult(vector<vector<ll>> m1, vector<vector<ll>> m2){
	vector<vector<ll>> ans;
	for(int i = 0; i < n; i++){
		vector<ll> temp(n);
		ans.pb(temp);
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			for(int k = 0; k < n; k++){
				ans[i][j] += m1[i][k] * m2[k][j];
				ans[i][j] %= mod;
			}
		}
	}
	return ans;
}

vector<vector<ll>> power(ll k){
	if(k == 1){
		return a;
	}
	vector<vector<ll>> ans = power(k / 2);
	ans = mult(ans, ans);
	if(k % 2){
		ans = mult(ans, a);
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	ll k;
	cin>>k;
	for(int i = 0; i < n; i++){
		vector<ll> temp;
		a.pb(temp);
		for(int j = 0; j < n; j++){
			int temp;
			cin>>temp;
			a[i].pb(temp);
		}
	}
	vector<vector<ll>> ans = power(k);
	ll sum = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			sum += ans[i][j];
		}
		sum %= mod;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	vector<int> dir(4);
	for(int i=0;i<N;i++){
		if(S[i] == 'W')dir[0]++;
		else if(S[i] =='N')dir[1]++;
		else if(S[i] == 'E')dir[2]++;
		else if(S[i] == 'S')dir[3]++;
	}
	//xとyを独立に考える
	rep(i,4){
		if(dir[i]){
			if(dir[(i+2)%4]==0){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S, T;
  cin>>S>>T;
  int Sarr[S.size()+1], Tarr[T.size()+1];
  for(int i=0;i<=S.size();++i) Sarr[i] = 0;
  for(int i=0;i<=T.size();++i) Tarr[i] = 0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='A') Sarr[i+1] = 1;
    else Sarr[i+1] = 2;
  }
  for(int i=0;i<T.size();++i) {
    if(T[i]=='A') Tarr[i+1] = 1;
    else Tarr[i+1] = 2;
  }
  for(int i=1;i<=S.size();++i) Sarr[i] += Sarr[i-1];
  for(int i=1;i<=T.size();++i) Tarr[i] += Tarr[i-1];
  int Q;
  cin>>Q;
  bool ans[Q];
  int a, b, c, d;
  for(int i=0;i<Q;++i) {
    cin>>a>>b>>c>>d;
    if(((Sarr[b]-Sarr[a-1])-(Tarr[d]-Tarr[c-1]))%3==0) ans[i] = true;
    else ans[i] = false;
  }
  for(int i=0;i<Q;++i) {
    if(ans[i]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}



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

const ll MAX = 1299709;

int main(void) {
  vector<bool> isp(MAX + 1, true);
  isp[0] = isp[1] = false;
  REP(i, 0, MAX + 1) if(isp[i]) for(ll j = i + i; j <= MAX; j += i) isp[j] = false;
  vector<ll> prime;
  REP(i, 0, MAX + 1) if(isp[i]) prime.push_back(i);

  ll N;
  while(cin >> N, N) {
    if(binary_search(prime.begin(), prime.end(), N)) {
      cout << 0 << endl;
    } else {
      auto t = lower_bound(prime.begin(), prime.end(), N);
      cout << (*t - *(t - 1)) << endl;
    }
  }
}



Measured memory_bytes: 3860
while True:
    m,f,r = map(int,input().split())

    if m == f == r == -1:
        break
    
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= (m + f) < 80:
        print('B')
    elif 50 <= (m + f) < 65:
        print('C')
    elif 30 <= (m + f) < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif (m + f) < 30:
        print('F')

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

long long calc(long long x){
    long long A = 0;
    while(x > 0){
        A += x; 
        x--; 
    }
    return A;
}

int main(){
    int N;
    cin >> N;
    string S[N];
    long long ans = 0;
    for(int i = 0; i < N; i++){
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }
    sort(S, S+N);
    long long temp = 0;
    string check = S[0];
    long long cnt = 0;
    for(int i = 1; i < N; i++){
        if(check == S[i]){
            cnt++;
        }else{
            check = S[i];
            temp = calc(cnt);
            ans += temp;
            temp = 0;
            cnt = 0;
        }
    }
    temp = calc(cnt);
    ans += temp;

    cout << ans << endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>

#include <cstdio>
#include <cstdlib>
using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << (((a < c && c < b) || (b < c && c < a)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int W[101], N;

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

	int ans = 2147483647;
	for (int i = 1; i < N; i++) {
		int S1 = 0, S2 = 0;
		for (int j = 0; j < i; j++) {
			S1 += W[j];
		}
		for (int k = i; k < N; k++) {
			S2 += W[k];
		}
		ans = min(ans, S1 - S2 < 0 ? S2 - S1 : S1 - S2);
	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	pair<int,int> ab[n];
	for (int i=0; i<n; i++) cin >> ab[i].first >> ab[i].second;
	sort(ab,ab+n);
	multiset<int> vals;
	int ct=0;
	int tt = 0;
	for (int i=1; i<=m; i++){
		if (ct==n) goto llk;
		while (ab[ct].first <= i){ vals.insert(ab[ct].second); ct++; if (ct==n) break;}
		
		llk:
		if (vals.empty()) continue;
		auto it = vals.end(); it--;
		tt += *(it); 
		vals.erase(it);
	}
	cout << tt;
}

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

using namespace std;

#define ll long long
#define int ll

typedef pair<int, int> pii;
typedef pair<ll, ll> pll; 

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;  
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it )\
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(aint(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 
#define all(c) c.begin(), c.end() 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

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

int lcm(int fir, int sec){
    return (fir*sec)/(gcd(fir, sec));
}

const int MOD = 1988;
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(26) << f << '\n';

// sort(arr, arr+n, greater<int>());

const int maxN = 1e4 + 12;
// const int maxVal = pow(2, 11);

int arr[maxN];

signed main(){
	int n;
	cin>>n;
	for (int i = 0; i < n; ++i){
		cin>>arr[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i){
		while(arr[i]%2==0){
			ans++;
			arr[i]/=2;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()
zero = S.count('0')
one = S.count('1')

print(min(zero, one)*2)

Measured memory_bytes: 39152
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		int[] B = new int[N];
		long ans = 0;
		for(int i = 0; i < N + 1; i++) A[i] = sc.nextInt();
		for(int i = 0; i < N; i++) B[i] = sc.nextInt();

		for(int i = 0; i < N; i++) {
			/* B[i] */
			// A[i]
			long killi = (A[i] >= B[i]) ? B[i] : A[i];
			ans += killi;
			A[i] -= killi; B[i] -= killi;

			// A[i + 1]
			long killii = (A[i + 1] >= B[i]) ? B[i] : A[i + 1];
			ans += killii;
			A[i + 1] -= killii; B[i] -= killii;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 65648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.NothingToLearn
{
    class ABC112_A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            if (n == 1)
            {
                WriteLine("Hello World");
            }
            else
            {
                int a = ReadInt();
                int b = ReadInt();
                WriteLine(a + b);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

  int n, i, ranknumber, number;
  int card[4][14];
  char rank, dummy, dummya, dummyb, outrank;

  for(ranknumber = 0; ranknumber <=3; ranknumber++){
    for(number = 1; number <= 13; number++){
      card[ranknumber][number] = 0;
    }
  }

  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    scanf("%c", &dummya);
    scanf("%c%c%d",&rank,&dummy,&number);
    if(rank == 'S'){
      ranknumber = 0;
    }else if(rank == 'H'){
      ranknumber = 1;
    }else if(rank == 'C'){ 
      ranknumber = 2;
    }else if(rank == 'D'){
      ranknumber = 3;
    }

    card[ranknumber][number] = 1;

  }

  for(ranknumber = 0; ranknumber < 4; ranknumber++){
    for(number = 1; number <= 13; number++){
      if(card[ranknumber][number] == 0){
	if (ranknumber == 0){
	  outrank = 'S';
	}else if(ranknumber == 1){
	  outrank = 'H';
	}else if(ranknumber == 2){
	  outrank = 'C';
	}else if(ranknumber == 3){
	  outrank = 'D';
	}

	printf("%c %d\n", outrank, number);
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
// transform(a.begin(), a.end(), a.begin(), ::toupper);
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  
  
  if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
  
  
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    while True:
        exists_odd = False
        for i in range(n):
            if a[i] % 2 == 1:
                exists_odd = True
                break
            a[i] /= 2
        else:
            ans += 1
        if exists_odd:
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define w(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;
int main(){
	fast();
	int n,x,t;
	cin>>n>>x>>t;
	int q = n/x;
	if(n%x){
		cout<<(q+1)*t<<endl;
		return 0;
	}
	cout<<q*t<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int m, n;
    cin >> m >> n;
    
    if (m==n)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int gcd(int x,int y){
  if(x<y){
    int a;
    a = y;y = x; x = a; 
  }
  while(y>0){
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}
 
int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  printf("%d\n",gcd(x,y));
 
  return 0;
}


Measured memory_bytes: 2736
/* test code */
#include <iostream>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	ll count[n+1]={};
	rep(i,n){
		cin>>a[i];
		count[a[i]]++;
	}
	ll ans[n+1]={};
	ll sum = 0;
	for(int i=1;i<n+1;i++){
		ans[i] = count[i]*(count[i]-1)/2;
		sum+=ans[i];
	}
	for(int i=1;i<n+1;i++){
		cout << sum - count[a[i-1]] + 1 << endl;
	}
}


Measured memory_bytes: 7296
from sys import stdin,setrecursionlimit
setrecursionlimit(10**6)
def S(): return stdin.readline().rstrip()

def f(ls,stock,save):
    if len(ls)<1:
        return int(stock)+save
    else:
        stock += ls.pop(0)
        sum = 0    
        if 0<len(ls):
            buff = ls[:]
            sum += f(buff,'0',save+int(stock))
        buff = ls[:]
        sum += f(buff,stock,save)
        return sum

s = S()
ls = list(s)
ans = f(ls,'0',0)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  ll N,M,ans=0;
  cin>>N>>M;
  ll X[M],Y[M-1];
  for(ll i=0;i<M;i++) cin>>X[i];
  sort(X,X+M);
  for(ll i=0;i<M-1;i++) Y[i]=X[i+1]-X[i];
  sort(Y,Y+M-1);
  for(ll i=0;i<M-N;i++) ans+=Y[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
def f_d():
    n, k = map(int, input().split())
    s = input()
    g = 1
    for i in range(1, n):
        if s[i]!=s[i-1]:
            g += 1
    g = g - 2*k
    g = 1 if g<=0 else g
    print(n-g)

if __name__ == "__main__":
    f_d()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
int D,N;
cin>>D>>N;
if(N==100){
    if(D==0)cout<<101;
    else if(D==1)cout<<10000+100;
    else cout<<1000000+10000;
}
else if(D==0)cout<<N;
else if(D==1)cout<<N*100;
else cout<<N*10000;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W;
	
	scanf("%d %d", &H, &W);
	
	char C[101][101];
	int i;
	for(i = 0; i < H; i++) {
		scanf("%s", C[i]);
	}
	for(i = 0; i < H; i++) {
		printf("%s\n%s\n", C[i], C[i]);
	}
	return 0;
}

Measured memory_bytes: 128
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

n = ip()                              #入力整数1つ
d,x= (int(i) for i in input().split())      #入力整数横2つ
#k,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a =[]
for i in range(n):
    a.append(ip())
s = 0
for i in range(n):
    if d%a[i]:s+=d//a[i] + 1
    else: s+=(d//a[i])
print(s+x)

Measured memory_bytes: 5272
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7;

int cnt[N];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		cnt[t]++;
		ans += t;
	}
	int q;
	cin >> q;
	while(q--) {
		int b, c;
		cin >> b >> c;
		ans -= (ll) cnt[b] * b;
		ans += (ll) cnt[b] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << ans << endl;
	}
	
}





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

int main() {
  int N;
  char S;
  bool isFour = false;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == 'Y') isFour = true;
  }
  if(isFour) cout << "Four" << endl;
  else cout << "Three" << endl;
}
      
      


Measured memory_bytes: 256
#include <stdio.h>
const int MOD = 1e9+7;
const int MAXV = 2048;
int ipow(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b&1) res = (1LL*res*a)%MOD;
        a = (1LL*a*a)%MOD;
        b /= 2;
    }
    return res;
}
int solve(int N, int K)
{
    int divisor[MAXV];
    int value[MAXV];
    int count = 0;
    {
        int i;
        for(i=1; i*i<N; ++i)
            if(N%i==0)
                divisor[count++] = i;
        if(i*i==N) divisor[count++] = i;        
        for(--i; i>0; --i)
            if(N%i==0)
                divisor[count++] = N/i;     
    }
    for(int i=0; i<count; ++i)
    {
        value[i] = ipow(K, (divisor[i]+1)/2);
        for(int j=0; j<i; ++j)
            if(divisor[i]%divisor[j] == 0)
            {
                value[i] -= value[j];
                if(value[i] < 0) value[i] += MOD;
            }
    }
    int ans = 0;
    for(int i=0; i<count; ++i)
    {
        if(divisor[i] % 2 == 0) divisor[i] /= 2;
        ans = (ans + 1LL * value[i] * divisor[i]) % MOD;
    }
    return ans;
}


int main()
{
    int N, K;
    scanf("%d%d", &N, &K);
    printf("%d\n", solve(N, K));

}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    int ans = INF;

    rep(div, 1 << (H - 1)) {
        int g = 0;
        vector<int> id(H);
        rep(i, H) {
            id[i] = g;
            if (div >> i & 1) g++;
        }
        g++;

        int cur = g - 1;
        vector<int> now(g, 0);
        auto add = [&](int j) {
            rep(i, H) {
                now[id[i]] += S[i][j] - '0';
                if (now[id[i]] > K) return false;
            }
            return true;
        };
        rep(j, W) {
            if (!add(j)) {
                cur++;
                rep(i, g) now[i] = 0;
                if (!add(j)) {
                    cur = INF;
                    break;
                }
            }
        }
        chmin(ans, cur);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3612
/**
*   @Author : MeGA
*   @InitTime :01/24/20 12:17:43
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif
     int n;
     scanf("%d",&n);
     vector<int>v(n);
     for(int i=0;i<n;i++){
        scanf("%d",&v[i]);
     }
     sort(v.begin(),v.end());
     double res=v[0]+v[1];
     res/=2.0;
     for(int i=2;i<n;i++){
        res=v[i]+res;
        res/=2;
     }
     printf("%.5f",res);



}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,ans=0;
  cin >> n;
  map<int,int> m;
  for(int i=0; i<n; i++) {
    int a;
    cin >> a;
    m[a]++;
  }
  for(auto p:m) {
    if(p.second%2) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

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

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   string s;
   int N,Q;
   cin >> N >> Q;
   cin >> s;
   int L = s.size();
   vector<int> T(L+1);
   for(int i=0;i<L-1;i++){
      T[i+1] = T[i];
      if(s[i] == 'A' && s[i+1] == 'C'){
         T[i+1]++;
      }
   }
   for(int i=0;i<Q;i++){
      int L,R;cin >> L >> R;
      int ans = T[R-1] - T[L-1];
      cout << ans << endl;
   }
return 0;
}


Measured memory_bytes: 1408
/*
  Contest 080
  B - Harshad Number
  Rakesh Kumar --> 13/09/2020
 */

#include <bits/stdc++.h>

using ull = unsigned long long int;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    ull n = 0;
    std::cin >> n;
    int t = 0;
    for (char c : std::to_string(n))
        t += c - '0';
    if (n % t)
        std::cout << "No" << std::endl;
    else
        std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 3668
# _*_ coding:utf-8 _*_
#  Atcoder_YahooMinnanoProcon_Contest-C
#  TODO https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c

def solveProblem(operation,bis2moneyone,onemoney2bis):
	if (onemoney2bis-bis2moneyone) <= 1:
		# This case all hit pocket
		answer=operation+1
	else:
		# まず、お金と交換できるまでのビスケットが起点になる
		answer = bis2moneyone
		# たたいて後から出来る操作数
		remainOperation = operation - ( bis2moneyone - 1)
		# ビスケット⇔お金の操作可能数。
		changeMoney2Bis = remainOperation // 2
		# その分ビスケット→お金→ビスケットにしたときの差が増やせる
		answer = answer + changeMoney2Bis * ( onemoney2bis - bis2moneyone)
		# さらに操作が可能か。可能であればプラスする
		answer = answer + remainOperation % 2

	return answer


if __name__ == '__main__':
	K,A,B = map(int,input().strip().split(' '))
	solution = solveProblem(K,A,B)
	print("{}".format(solution))


Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    ll  a, b, x;
    scanf("%lld%lld%lld", &a, &b, &x);

    printf("%lld\n", b/x-(a==0? (-1): (a-1)/x));


    return 0;
}




Measured memory_bytes: 128