akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> v[10];
    rep(i,s.size()){
        int k=s[i]-'0';
        v[k].push_back(i);
    }
    rep(i,10){
        sort(v[i].begin(),v[i].end());
    }
    ll ans=0;

    rep(i,10){
        rep(j,10){
            rep(k,10){
               if(v[i].size()==0||v[j].size()==0||v[k].size()==0){
                   continue;
               }
               int t1 = v[i][0];
               int t2;int t3;
               auto tt=upper_bound(v[j].begin(),v[j].end(),t1);
               if(tt==v[j].end())continue;
               else {
                   int g=tt-v[j].begin();
                   t2=v[j][g];
               }
//               if(i==j){
//                   if(v[i].size()==1)continue;
//                   else{
//                       t2=v[i][1];
//                   }
//               }else{
//                  auto tt=upper_bound(v[j].begin(),v[j].end(),j);
//                   if(tt==v[j].end()){continue;}
//                   else{
//                       int c=tt-v[j].begin();
//                       t2=v[j][c];
//                   }
//               }
               auto c3 = upper_bound(v[k].begin(),v[k].end(),t2);
               if(c3==v[k].end()){continue;}
               else{
                  // cout<<i<<" "<<j<<" "<<k<<endl;
                   ans++;
               }








            }
        }
    }
    cout<<ans<<endl;








    
return 0;
}


Measured memory_bytes: 512
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
D =[[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    D[a].append(b)
    D[b].append(a)

c = sorted(list(map(int,input().split())))
vcost = [-1]*(N+1)
vcost[1]=c.pop()
ans = 0
def dfs(i):
    global ans
    for j in D[i]:
        if vcost[j]==-1:
            vcost[j]=c.pop()
            ans += vcost[j]
            dfs(j)
dfs(1)
print(ans)
print(*vcost[1:])

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

int main() {
  int q1,b,c1,c2,q2;
  while(cin >> q1 && q1) {
    cin >> b >> c1 >> c2 >> q2;
    int ans1, ans2;
    ans1 = ans2 = -1;
    for(int i = q2; i >= 1; --i) {
      int remain = b - c1*i;
      if(remain < 0) continue;
      int normal = remain/c2;
      if(i + normal >= q1) {
	ans1 = i;
	ans2 = normal;
	break;
      }
    }
    if(ans1 == -1) cout << "NA" << endl;
    else cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define rep(n,m) for(int i = n; i < m; i++)

int main(void) {
	string str;
	cin >> str;
	int a = -1;
	a = str.find("AC");
	if (a >= 0) {
		cout << "Yes" << endl;

	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])

cs int G = 3;
cs int ff = 2e6 + 1;
cs int inf = 1e9 + 1;
cs int base = 2333;
cs int mod = 1e9 + 7;

int n, a[ff], top, ans;
signed main()
{
	cin >> n;
	rep(i, 1, n) cin >> a[i];
	int s = 0;
	rep(i, 1, n) (ans += a[i] * s % mod) %= mod, (s += a[i]) %= mod;
	cout << ans;
}

Measured memory_bytes: 5144
n,a = map(int, input().split())
x = list(map(int, input().split()))

# dp[i][k][j]
# i枚の中から、k枚選んで、和がj
dp = [[[0 for j in range(2501)]for k in range(n+1)] for i in range(n+1)]

for i in range(n+1):
    dp[i][0][0]=1

for i in range(1,n+1):
    for k in range(1,n+1):
        for j in range(2501):
            if j-x[i-1]>=0:
                dp[i][k][j]=dp[i-1][k-1][j-x[i-1]]+dp[i-1][k][j]
            else:
                dp[i][k][j]=dp[i-1][k][j]

ans = 0
for i in range(1,n+1):
    ans += dp[n][i][i*a]


print(ans)

Measured memory_bytes: 95196
n = int(input())
s = []
for i in range(n):
  s.append(input())

cnt = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for si in s:
  if si[0] in cnt:
    cnt[si[0]] += 1

res = 0
res += cnt['M'] * cnt['A'] * cnt['R']
res += cnt['M'] * cnt['A'] * cnt['C']
res += cnt['M'] * cnt['A'] * cnt['H']
res += cnt['M'] * cnt['R'] * cnt['C']
res += cnt['M'] * cnt['R'] * cnt['H']
res += cnt['M'] * cnt['C'] * cnt['H']
res += cnt['A'] * cnt['R'] * cnt['C']
res += cnt['A'] * cnt['R'] * cnt['H']
res += cnt['A'] * cnt['C'] * cnt['H']
res += cnt['R'] * cnt['C'] * cnt['H']

print(res)


Measured memory_bytes: 9776
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
const ll key = 998244353;
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
int main() {
	ll per[300001];
	per[0] = 1;
	for (ll i = 1; i <= 300000; i++) {
		per[i] = (per[i - 1] * i)%key;
	}
	ll invper[300001];
	invper[0] = 1;
	for (ll i = 1; i <= 300000; i++) {
		invper[i] = mod_pow(per[i], key - (ll)2,key);
	}
	ll n, a, b, k;
	cin >> n >> a >> b >> k;
	ll sum = 0;
	for (ll i = 0; i <= n; i++) {
		ll r =k - a * i;
		if (r>=0&&r%b == 0) {
			ll t = r / b;
			if (t <= n) {
				ll sum1 = ((per[n] * invper[i]) % key)*invper[n - i] % key;
				ll sum2 = ((per[n] * invper[t]) % key)*invper[n - t] % key;
				sum = (sum+(sum1 * sum2) % key)%key;
			}
		}
	}
	cout << sum << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define forn(i , n) for(int i=0;i<n;i++)



bool isPrime(int num) {
    if (num <= 3) {
        return num > 1;
    } else if (num % 2 == 0 || num % 3 == 0) {
        return false;
    } else {
        for (int i = 5; i * i <= num; i += 6) {
            if (num % i == 0 || num % (i + 2) == 0) {
                return false;
            }
        }
        return true;
    }
}


int main(){
    int t;
    cin >> t;
    
    
    int counter = 0;
    while(t--){
        int n;
        
        cin >> n;
        
        
        if(isPrime(n)){
            counter++;
        }
    }
    
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3084
#! /bin/bash

read n

case ${#n} in
 0)
  a=0
  ;;
 1)
  a=$n
  ;;
 2)
  a=9
  ;;
 3)
  a=$(( n - 90 ))
  ;;
 4)
  a=909
  ;;
 5)
  a=$(( n - 9090 ))
  ;;
 6)
  a=90909
  ;;
esac

echo $a


Measured memory_bytes: 376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << en; cout << endl;}
#define shop(n,x) {for(int i = 0; i < n; i++) cout << x << en; cout << endl;}
#define ff first
#define ss second
#define sq(x) (x*x)
#define endl '\n'
#define en " "
#define pb push_back
#define mpair make_pair
ll mod=1000000007;
double pi=3.1415926536;
ll n;
ll dp[200000][4];
ll cost (ll a[], ll b[], ll c[], ll idx, ll prev)
{
	if(dp[idx][prev] != -1)
		return dp[idx][prev];
	if(idx >= n)
		return 0;
	ll p = 0;
	if(prev == 1)
		p = max(b[idx] + cost(a, b, c, idx + 1, 2), c[idx] + cost(a, b, c, idx + 1, 3));
	else if(prev == 2)
		p = max(a[idx] + cost(a, b, c, idx + 1, 1), c[idx] + cost(a, b, c, idx + 1, 3));
	else if(prev == 3)
		p = max(a[idx] + cost(a, b, c, idx + 1, 1), b[idx] + cost(a, b, c, idx + 1, 2));
	
	return dp[idx][prev] = p;
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// go fast 		check		//		CHECK -> if()   else if()
		
		ll x=0, m=0, y=0, d=1, k=mod;
		cin >> n;
		ll a[n], b[n], c[n];
		for(int i = 0; i < n; i++)
			cin >> a[i] >> b[i] >> c[i];

		for(int i = 1; i <= 3; i++)
		{
			memset( dp, -1, sizeof(dp) );
			x = max(x, cost(a, b, c, 0, i));
		}
		cout << x << endl;	
	}
}

Measured memory_bytes: 16640
import sys
sys.setrecursionlimit(10**5)
n = int(input())
t = {i:{} for i in range(n)}
ans = [-1]*n


for _ in range(n-1):
    u ,v, w = map(int, input().split())
    t[u-1][v-1] = w
    t[v-1][u-1] = w
 
    
def dfs(x):
    for y in t[x]:
        del t[y][x]
        ans[y] = ans[x] if t[x][y] % 2 == 0 else 1 - ans[x]
        if len(t[y]) > 0:
            dfs(y)
 
 
ans[0] = 0
dfs(0)
for i in range(n):
    print(ans[i])


Measured memory_bytes: 94624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

LLI first[100003],second[100003];

LLI gcd(LLI a, LLI b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}
  
LLI lcm(LLI a, LLI b)  
{  
    return (a*b)/gcd(a, b);  
} 

int main()
{
    LLI n,m;
    cin >> n >> m;
    LLI o = lcm(n,m);
    string s,t;
    cin >> s >> t;
    first[0] = 1;
    second[0] = 1;
    for(LLI i = 1 ; i < n ; i++) {
        first[i] = i*(o/n)+1;
        // cout << first[i] << " ";
    }
    // cout << "\n";
    for(LLI i = 1 ; i < m ; i++) {
        second[i] = i*(o/m)+1;
        // cout << second[i] << " ";
    }
    // cout << "\n";
    int flag = 0;
    LLI i = 0,j = 0;
    while(1) {
        if(i >= n || j >= m) {
            break;
        }
        if(first[i] == second[j]) {
            // cout << first[i]-1 << " " << second[j]-1 << " " << s[i] << " " << t[j] << "\n";
            if(s[i] != t[j]) {
                flag = 1;
            }
            i++;
            j++;
        } else if(first[i] < second[j]) {
            i++;
        } else {
            j++;
        }
    }
    if(flag == 0) {
        cout << o;
    } else {
        cout << -1;
    }
    return 0;
}

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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n;
    int a[100000+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), compare_int);
    
    int ans=0;
    int ptr=0;
    while(ptr<n){
        int num=a[ptr], cnt=0;
        while(ptr<n && a[ptr]==num)ptr++, cnt++;
        ans+=cnt%2;
    }
    
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
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 long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}

int main()
{
	int n;
	int ans=0;
	
	cin >> n;
	int bef;
	map<int,int>a;
	for(int i=0;i<n;i++){
		cin >>bef;
		a[bef]+=0;
		a[bef]++;
	}
	for(auto itr=a.begin();itr!=a.end();itr++ ){
		if(itr->first >itr->second){
			ans+=itr->second;
		}else{
			ans+=(itr->second-itr->first);
		}
	}
	
	cout<<ans<<endl;

	
}

Measured memory_bytes: 4736
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
const int maxn=4e3+5;
long long n,r[maxn],r2[maxn],g[maxn],g2[maxn],b[maxn],b2[maxn],sum;
string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			r[i+1]++;
		}
		else if(s[i]=='B'){
			b[i+1]++;
		}
		else{
			g[i+1]++;
		}	
		r[i+1]+=r[i];
		b[i+1]+=b[i];
		g[i+1]+=g[i];
	}
	for(int i=n-1;i>=0;i--){
		if(s[i]=='R'){
			r2[i+1]++;
		}
		else if(s[i]=='B'){
			b2[i+1]++;
		}
		else{
			g2[i+1]++;
		}
		r2[i+1]+=r2[i+2];
		b2[i+1]+=b2[i+2];
		g2[i+1]+=g2[i+2];
	}
	for(int i=2;i<n;i++){
		if(s[i-1]=='B'){
			sum+=g2[i+1]*r[i-1]+g[i-1]*r2[i+1];
		}
		else if(s[i-1]=='R'){
			sum+=g2[i+1]*b[i-1]+g[i-1]*b2[i+1];
		}
		else{
			sum+=b2[i+1]*r[i-1]+b[i-1]*r2[i+1];
		}
		for(int j=1;i+j<=n&&i-j>0;j++){
			if(s[i-1]!=s[i+j-1]&&s[i+j-1]!=s[i-j-1]&&s[i-j-1]!=s[i-1]){
				sum--;
			}
		}
	}
	cout<<sum;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     int a,b=0,c;
     cin>>a;
     c=a;
     while(c>0){
        b+=c%10;
        c/=10;
     }
     if(a%b==0)
        cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3628
import itertools

while True:
    ans = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        exit()
        
    for i in range(1,n+1):
        for j in range(i+1, n+1):
            k = x - i -j
            if k > j and k <= n:
                ans += 1
    
    print(ans)


Measured memory_bytes: 5628
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
string s3[3] = {
"aab",
"c.b",
"cdd"};
string s4[4] =
{"aacd",
 "bbcd",
 "cdaa",
 "cdbb"};
string s5[5] =
{"..abc",
 "..abc",
 "ffeed",
 "ggj.d",
 "hhjkk"};
string s7[7] = 
{"....cba",
 "....cba",
 "....def",
 "....def",
 "hhii..g",
 "jjkk..g",
 "llmmnn."};

int n;
char ans[1011][1011];
int B = 1;
void add(string s[], int k)
{
	for (int i=0; i<k; i++) for (int j=0; j<k; j++) ans[B+i][B+j] = s[i][j];
	B += k;
}
int main()
{
	cin>>n;
	if (n%2==0&&n>2)
	{
		for (int i=1; i<=n/2; i++)
		{
			int x = i;
			ans[x+x-1][x+x-1] = ans[x+x-1][x+x] = 'a';
			ans[x+x][x+x-1] = ans[x+x][x+x] = 'b';
		}
		for (int i=1; i<=n/2; i++)
		{
			int x = i;
			int c = (x+x)%n+1;
			ans[x+x-1][c] = ans[x+x][c] = 'c';
			ans[x+x-1][c+1] = ans[x+x][c+1] = 'd';
		}
		for (int i=1; i<=n; i++)
		{
			for (int j=1; j<=n; j++)
			{
				if (!ans[i][j]) putchar('.');
				else putchar(ans[i][j]);
			}
			puts("");
		}
	}
	else if (n%3==0)
	{
		for (int i=0; i<n; i++)
		{
			for (int j=0; j<n; j++)
			{
				if (i/3==j/3) putchar(s3[i%3][j%3]);
				else putchar('.');
			}
			puts("");
		}
	}
	else
	{
		for (int i=0; i<=n; i++)
		{
			for (int j=0; j<=n; j++)
			{
				if (n>=4*i+5*j&&(n-4*i-5*j)%7==0)
				{
					int t = (n-4*i-5*j)/7;
					while (i--) add(s4, 4);
					while (j--) add(s5, 5);
					while (t--) add(s7, 7);
					for (int i=1; i<=n; i++)
					{
						for (int j=1; j<=n; j++)
						{
							if (!ans[i][j]) putchar('.');
							else putchar(ans[i][j]);
						}
						puts("");
					}
					return 0;
				}
			}
		}
		assert(n==2);
		puts("-1");
	}
	return 0;
}

Measured memory_bytes: 2176
n = int(input())
a = []
d = []
#

a = [input() for _ in range(n)]
d = [{} for _ in range(n)]


for i in range(n):
  for j in range(len(a[i])):
    if(not (a[i][j] in d[i])):
      d[i][a[i][j]] = 0
    d[i][a[i][j]] += 1

b = [chr(i) for i in range(97, 97+26)]
ans = ""
for j in range(len(b)):
  min = 100
  for i in range(n):
    if(not (b[j] in d[i])):
      d[i][b[j]] = 0
    if(d[i][b[j]] < min):
      min = d[i][b[j]]

  if(min != 100):
    string = b[j]*min
    ans += string

print(ans)

Measured memory_bytes: 3188
n,k = map(int,input().split())
s = k if k%2==1 else k//2
l = (n-s)//s+1
n1=(n-s)//k+1
n2=(n-k)//k+1
if l%2==0:
    print(l*(n1**2+n2**2)//2)
else:
    print((l//2)*(n1**2+n2**2)+n1**2)

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

int main(){
  char b;cin >> b;
  if (b == 'A')cout << "T" <<endl;
  if (b == 'G')cout << "C" <<endl;
  if (b == 'T')cout << "A" <<endl;
  if (b == 'C')cout << "G" <<endl;
}


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

int main()
{
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n;
  int st = 0;
  int x;
  char p;
  bool isBalanced = true;
  
  cin >> n;

  while (n--) {
    cin >> p >> x;
    cin.ignore();
    if (p == '(') {
      while (x--) st++;
    } else {
      while (x--) {
        if (st == 0) {
          isBalanced = false;
        } else {
          st--;
        }
      }
    }
  }
  if (st == 0 && isBalanced) cout << "YES" << endl;
  else cout << "NO" << endl;
}
    



Measured memory_bytes: 3116
N = int(input())
A = [input() for _ in [0]*N]

for i,a in enumerate(A):
    b = a.split(".")
    if len(b)==1:
        A[i] = int(a)*10**9
        continue
    c = b[1]
    n = len(c)
    c += "0"*(9-n)
    A[i] = int(b[0] + c)

cnt = [[0]*40 for _ in [0]*40]
B = [(0,0)]*N
for k,a in enumerate(A):
    i = 0
    j = 0
    while a%2==0:
        a//=2
        i+=1
    while a%5==0:
        a//=5
        j+=1
    B[k] = (i,j)
    cnt[i][j] += 1

for i in range(1,40):
    i = 39-i
    for j in range(40):
        j = 39-j
        cnt[i][j] += cnt[i+1][j]

for i in range(40):
    i = 39-i
    for j in range(1,40):
        j = 39-j
        cnt[i][j] += cnt[i][j+1]

ans = 0
for i,j in B:
    me = int(i>=9 and j>=9)
    ans += cnt[max(0,18-i)][max(0,18-j)]-me

print(ans//2)

Measured memory_bytes: 30980
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-10 21:52:47
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    vector<vector<int>> c(3);
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            int d;
            cin >> d;
            c[i].push_back(d);
        }
    }

    vector<int> a(3), b(3);
    string ans = "No";
    for (a[0] = 0; a[0] <= 100; a[0]++) {
        for (a[1] = 0; a[1] <= 100; a[1]++) {
            for (a[2] = 0; a[2] <= 100; a[2]++) {
                int ok = 1;
                for (int j = 0; j < 3; j++) {
                    if (c[0][j] - a[0] != c[1][j] - a[1] ||
                        c[1][j] - a[1] != c[2][j] - a[2]) {
                            ok = 0;
                    }
                }

                if (ok) ans = "Yes";
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

    vector<int> odd;
    vector<int> even;
    int a;
    for(int i=0;i<n;i++){
        cin >> a;
        if(i%2==0) odd.push_back(a);
        else even.push_back(a);
    }
    if(n%2==0){
        for(int i=even.size()-1;i>=0;i--){
            cout << even[i] << " ";
        }
        for(int j=0;j<odd.size();j++){
            cout << odd[j] << " ";
        }
    }else{
        for(int i=odd.size()-1;i>=0;i--){
            cout << odd[i] << " ";
        }
        for(int j=0;j<even.size();j++){
            cout << even[j] << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 3188
/*
 * 2306.cc: Rabbit Party
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 100;

const int INF = 1 << 30;

/* typedef */

typedef set<int> si;

/* global variables */

int n, m;
int fns[MAX_N][MAX_N];
bool used[MAX_N];

/* subroutines */

int calc_sum() {
  int sum = 0;
  for (int i = 0; i < n; i++)
    if (used[i]) {
      int minf = INF;
      for (int j = 0; j < n; j++)
	if (i != j && used[j] && minf > fns[i][j]) minf = fns[i][j];
      if (minf < INF) sum += minf;
    }
  return sum;
}

int rec(int u, int k, si &vs) {
  if (k == 0) return calc_sum();
  if (u >= n) return 0;

  int maxsum = 0;
  for (int v = u; v <= n; v++)
    if (! used[v]) {
      bool ng = false;
      for (si::iterator sit = vs.begin(); sit != vs.end(); sit++)
	if (! fns[v][*sit]) {
	  ng = true;
	  break;
	}
      if (ng) continue;

      used[v] = true;
      vs.insert(v);
      int sum = rec(v + 1, k - 1, vs);
      vs.erase(v);
      used[v] = false;

      if (maxsum < sum) maxsum = sum;
    }

  return maxsum;
}

/* main */

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

  for (int i = 0; i < m; i++) {
    int u, v, f;
    cin >> u >> v >> f;
    u--, v--;
    fns[u][v] = fns[v][u] = f;
  }

  int maxsum = 0;
  for (int i = 2; i * (i - 1) / 2 <= m; i++) {
    si vs;
    int sum = rec(0, i, vs);
    if (maxsum < sum) maxsum = sum;
  }

  printf("%d\n", maxsum);
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define ll long long
#define sz(a) int((a).size())
#define fr(i,n) for(int i=0;i<n;i++) 
#define rf(i,n) for(int i=1;i<=n;i++) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MAX INT_MAX 
#define f first
#define s second
using namespace std;
#define M 1000000007
int dp[100001];
int vis[100001];
void dfs(int node, vector<vector<int> > &v);
int main()
{
    int n,m;
    cin>>n>>m;
    std::vector<vector<int> > v(n+1);
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    // for(int i=1;i<n;i++)
    // {
    //     for(int j=0;j<v[i].size();j++)
    //         cout<<v[i][j]<<" ";
    //     cout<<endl;
    // }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
            dfs(i,v);
    }
    cout<<(*max_element(dp,dp+n+1))<<endl;
    return 0;
}

void dfs(int node, vector<vector<int> > &v)
{
    if(vis[node]==0)
        vis[node]=1;
    for(int i=0;i<v[node].size();i++)
    {
        if(vis[v[node][i]]==0)
            dfs(v[node][i],v);

        dp[node] = max(dp[node],1+dp[v[node][i]]);
    }
}

Measured memory_bytes: 12956
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long 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 FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }



  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<numeric>
using namespace std;

int main(void)
{
	int N, M, X;
	cin >> N >> M >> X;
	

	vector<int> cost(N+1, 0);
	for(int i=0; i<M; i++){
		int A;
		cin >> A;

		cost[A] = 1;
	}

	int left = accumulate(cost.begin(), cost.begin()+X, 0);
	int right = accumulate(cost.begin()+X+1, cost.end(), 0);

	cout << min(left, right) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

string S;

int main(void)
{
	cin >> S;
	int A = S[0] - '0';
	int B = S[1] - '0';
	int C = S[2] - '0';
	int D = S[3] - '0';
	if (A + B + C + D == 7) {
		cout << A << '+' << B << '+' << C << '+' << D << "=7" << endl;
		return 0;
	}
	if (A + B + C - D == 7) {
		cout << A << '+' << B << '+' << C << '-' << D << "=7" << endl;
		return 0;
	}
	if (A + B - C + D == 7) {
		cout << A << '+' << B << '-' << C << '+' << D << "=7" << endl;
		return 0;
	}
	if (A + B - C - D == 7) {
		cout << A << '+' << B << '-' << C << '-' << D << "=7" << endl;
		return 0;
	}
	if (A - B + C + D == 7) {
		cout << A << '-' << B << '+' << C << '+' << D << "=7" << endl;
		return 0;
	}
	if (A - B + C - D == 7) {
		cout << A << '-' << B << '+' << C << '-' << D << "=7" << endl;
		return 0;
	}
	if (A - B - C + D == 7) {
		cout << A << '-' << B << '-' << C << '+' << D << "=7" << endl;
		return 0;
	}
	if (A - B - C - D == 7) {
		cout << A << '-' << B << '-' << C << '-' << D << "=7" << endl;
		return 0;
	}
	return 0;
}


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

int main()
{
    int a, b;

    cin >> a >> b;

    if ((a + b) % 2 == 0)
    {
        cout << (a + b) / 2;
    }
    else
    {
        cout << (a + b + 1) / 2;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, p[100000], ans = 0, tmp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	for (int i = 0; i < n; i++) {
		if (i + 1 == p[i]) {
			tmp = p[i];
			p[i] = p[i + 1];
			p[i + 1] = tmp;
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
  int n,k,i,j,l,v[60];
  cin >> n >> k;
  for (i=1;i<=n;i++) cin >> v[i];
  
  int s,sb=0,ans=0;
  vector<int> vs,vv;
  for (i=0;i<=min(n,k);i++){
    if (i>0){
      vs.push_back(v[i]);
      sb+=v[i];
    }
    s=sb;
    vv=vs;
    for (j=0;i+j<=min(n,k);j++){
      if (j>0){
        vv.push_back(v[n-j+1]);
        s+=v[n-j+1];
      }
      int us=s;
      sort(vv.begin(),vv.end());
      for (l=0;l<vv.size() && l<k-i-j && vv[l]<0;l++) us-=vv[l];
      if (ans<us) ans=us;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    double r;
    cin >> r;
    double p = 3.1415926535;
    printf("%.10f\n", r*2*p);
    return 0;
}


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

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

    ll a[n];
    ll odd = 0;
    ll even = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }

    if(odd % 2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int a,b; cin>>a>>b;
	if((a*b)%2){
		puts("Yes");
	}
	else{
		puts("No");
	}
}


Measured memory_bytes: 256
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def BinarySearch(num, List):
    if len(List) == 0:
        print("Erorr : list has no element")
        return
    left,right = 0,len(List)
    while left < right:
        mid  = (left+right)//2
        if num < List[mid]:#
            right = mid
        else:
            left = mid + 1
    return right


def main():
    x,n = na()
    ps = sorted(na())
    if n==0:
        print(x)
        return
    cnt = 0
    while 1:
        right = BinarySearch(x-cnt, ps)
        if ps[right-1] != x-cnt:
            print(x-cnt)
            return
        right = BinarySearch(x+cnt, ps)
        if ps[right-1] != x+cnt:
            print(x+cnt)
            return
        cnt += 1
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 61956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,P[100005];
  string a;
  cin >> N >> K;
  cin >> a;
  int sum = 0,cnt = 0;
  for(int i = 0;i<N-1;i++){
    if(a[i+1] == a[i]) sum++;
    else cnt++;
  }

  if(K>cnt/2) sum = N-1;
  else sum+=K*2;
  cout << sum << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;

int main()
{
  int n, k;
  string s;
  cin >> n >> k >> s;

  //  transform(s.begin()), s.end(), s.begin(), tolower);
for (int i =0; i < n; i++) {
  if (i != k - 1)
	cout << s[i];
  else
	cout << (char)(s[i] + 0x20);
 }

cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair< ll, ll> pll;


ll n, k;
ll a[505];
ll b[505];
ll c[505];
bool ok(ll g)
{
        //for(ll i=1;i<=n;i++) b[i] = a[i];
        vector< ll > v;
        for(ll i=1;i<=n;i++) {
                v.pb(a[i]%g);
        }
        sort(v.begin(), v.end());
        b[v.size()]=0;
        for(ll i=v.size()-1;i>=0;i--) {
                b[i] = b[i+1] + (g - v[i]);
                if(v[i]==0) b[i] -= g;
        }
        ll cst = 0;
        for(ll i=0;i<v.size()-1;i++) {
                cst += v[i];
                if(cst > k) break;
                if(cst == b[i+1]) return true;
        }
        return false;
}
int main()
{
        cin >> n>>k;
        ll s=0;
        for(ll i=1;i<=n;i++) {
                cin >> a[i];
                s+=a[i];
        }
        vector< ll> v;
        for(ll i=1;i*i <= s;i++){
                if(s%i==0) {
                        v.pb(i);
                        v.pb(s/i);
                }
        }
        sort(v.rbegin(), v.rend());
        for(auto &i : v) {
                if(ok(i)) {
                        cout << i << "\n"; return 0;
                }
        }
        return 0;
}


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

int main() {
	int N;
	cin >>N;
	vector<int> V(N);
	int C;
	for(int i=0;i<N;i++){
		cin >>V.at(i);
	}
	int ans=0;
	for(int i=0;i<N;i++){
		cin >>C;
		V.at(i)=V.at(i)-C;
		if(V.at(i)>0){
			ans += V.at(i);
		}
	}
	cout <<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1100
#define MAX_W 11000


int n, mimi = MAX_W;
bool used[MAX];
pair<int,int> w[MAX];

int hoge(int x,int sum, int mi,int count){
	if(used[x]){
		return min(sum+mi*(count-2), mi + sum + (count+1)*mimi);
	} else {
		used[x] = true;
		return hoge(w[x].second,sum+w[x].first,min(mi,w[x].first),count+1);
	}
}

int main(){
	int W, sum = 0;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>W;
		w[i] = make_pair(W,i);
		mimi = min(W, mimi);
	}
	
	sort(w, w + n);
	
	for(int i = 0; i < n; i++){
		if(!used[i]) sum +=  hoge(i,0,w[i].first,0);
	}
	
	cout<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 3124
n,*t=map(int,open(0).read().split())
*z,=zip(t[::2],t[1::2])
s=set((a+b)%2for a,b in z)
if len(s)>1:
  print(-1)
  exit()
s,*_=s
d=[2**(38-i)for i in range(39)]+[1]*(s<1)
print(len(d),*d)
for a,b in z:
  x=y=0
  o=''
  for i in d:
    if abs(a-x)>abs(b-y):
      f=a-x>0
      o+='LR'[f]
      x+=i*f or-i
    else:
      f=b-y>0
      o+='DU'[f]
      y+=i*f or-i
  print(o)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, L;
  cin >> N >> L;
  string ans;
  ans = "";
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int j = 0; j < N; j++) {
    ans += vec.at(j);
  }
  cout << ans << endl;
}

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

int main() {
    int a, b;

    int sum = 0;

    cin >> a >> b;
    int d[b];

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

    for(int i = 0; i < b; i++){
        sum += d[i];
    }

    if (a - sum < 0) {
        cout << -1 << endl;
    } else {
        cout << a - sum;
    }


}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxNode = 55, maxLim = 25;
template<const int nbNode, const int nbEdge> struct Graph {
	int tot, head[nbNode], to[nbEdge << 1], next[nbEdge << 1];
	Graph() { memset(head, -1, sizeof(head)); }
	void AddEdge(int u, int v) {
		to[++tot] = v;
		next[tot] = head[u];
		head[u] = tot;
	}
};
Graph<maxNode, maxNode> Tree;
int nbNode, limNum, fa[maxNode], dep[maxNode];
ll setCover[1 << 20];
void dfs(int now, int from) {
	dep[now] = dep[from] + 1;
	fa[now] = from;
	for (int pt = Tree.head[now]; ~pt; pt = Tree.next[pt])
		if (Tree.to[pt] != from)
			dfs(Tree.to[pt], now);
}
int count1_(int num) {
	int ret = 0;
	for (int wei = 0; wei < limNum; ++wei)
		if ((1 << wei) & num)
			++ret;
	return ret;
}
int count2_(ll num) {
	int ret = 0;
	for (int wei = 0; wei < nbNode - 1; ++wei)
		if ((1ll << wei) & num)
			++ret;
	return ret;
}
signed main() {
	scanf("%d", &nbNode);
	for (int i = 1; i < nbNode; ++i) {
		int uNode, vNode;
		scanf("%d%d", &uNode, &vNode);
		Tree.AddEdge(uNode, vNode);
		Tree.AddEdge(vNode, uNode);
	}
	scanf("%d", &limNum);
	dfs(1, 0);
	for (int i = 1; i <= limNum; ++i) {
		int uNode, vNode;
		scanf("%d%d", &uNode, &vNode);
		if (dep[uNode] < dep[vNode])
			swap(uNode, vNode);
		while (dep[uNode] > dep[vNode]) {
			setCover[1 << (i - 1)] |= 1ll << (uNode - 2);
			uNode = fa[uNode];
		}
		while (uNode != vNode) {
			setCover[1 << (i - 1)] |= 1ll << (uNode - 2);
			setCover[1 << (i - 1)] |= 1ll << (vNode - 2);
			uNode = fa[uNode];
			vNode = fa[vNode];
		}
	}
	//边的编号，定义为这个边深度较低的点的编号 - 2 
	setCover[0] = 0;
	for (int state = 1; state < (1 << limNum); ++state) {
		int last = state & (-state);
		if (last == state) continue ;
		setCover[state] = setCover[state ^ last] | setCover[last];
	}
	ll ans = 0;
	for (int state = 1; state < (1 << limNum); ++state) {
		int notCover = nbNode - count2_(setCover[state]) - 1;
		ll fu = ((count1_(state)) & 1) ? 1 : -1;
		ans += fu * (1ll << notCover);
	}
	printf("%lld\n", (1ll << (nbNode - 1)) - ans);
	return 0;
}

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

int main() {
  int N;
  int sum_A =0, sum_B =0;
  cin >> N;  
  vector<int> vec(N);
  
  for (int i =0;i< N; i++){
    cin >> vec.at(i);
  }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
  
  if (N%2 == 0){
    for (int i = 0; i < N; i +=2) {
      sum_A += vec.at(i);
      sum_B += vec.at(i+1);
    }
    }
    
  if (N%2 != 0){
    for (int i = 0; i < N-1; i +=2) {
      sum_A += vec.at(i);
      sum_B += vec.at(i+1);
      }
    sum_A += vec.at(N-1);
  }  
    
      cout << sum_A - sum_B << endl;
} 

Measured memory_bytes: 256
import java.io.*;

public class Main {

	public static void main(String[] args) throws Exception {
		int[] height = new int[10];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		for(int i=0;i<10;i++){
			int a = Integer.parseInt(in.readLine());
			height[i] = a;
		}
		int length = height.length;
		for(int i=0;i<length;i++){
			for(int j=(i+1);j<length;j++){
				if(height[i]<height[j]){
					int temp = height[j];
					height[j] = height[i];
					height[i] = temp;
				}
			}
		}
		for(int i=0;i<3;i++){
			System.out.println(height[i]);
		}

	}

}

Measured memory_bytes: 16880
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> l[i] >> r[i];
        ans += r[i] - l[i] + 1;
    }
    cout << ans << endl;


}

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

long long gcd(long long a, long long b) {
	return a == 0 ? b : gcd(b % a, a);
}

int main() {
	long long n, m;
	cin >> n >> m;

	long long l = 1;
	long long pk = -1;
	bool ok = true;
	for (long long i = 0; i < n; ++i) {
		long long a;
		cin >> a;

		long long g = gcd(l, a);
		l = (l * a) / g;
		
		if (l > 2 * m) {
			ok = false;
			break;
		}

		long long k = 0;
		while (a % 2 == 0) {
			a /= 2;
			++k;
		}

		if (pk == -1) {
			pk = k;
		} else if (pk != k) {
			ok = false;
			break;
		}
	}

	if (!ok) {
		cout << 0;
		return 0;
	}

	long long ans = m / l;
	if ((m % l) >= (l / 2)) {
		++ans;
	}

	cout << ans;
	
	return 0;
}
	

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    LL ans = 1000000000;
    REP(i,s.size()-t.size()+1){
        LL cnt = 0;
        REP(j,t.size())if(t[j] != s[i+j])cnt++;
        ans = min(ans,cnt);
    }
    PUTS(ans);
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string S, T;
    int ans = 0;
    cin >> S >> T;
    for(int i=0; i<S.length();++i){
        if(S[i]==T[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	
 double A,B;
scanf("%lf %lf",&A,&B);

if((A>=1)&&(B<=10^100)&&(B!=0)){
if(A>B){

printf("GREATER");}
 if(A<B){
 
printf("LESS");}
if(A==B){

printf("EQUAL");}
}
return 0;
}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

ll cnt = 0; 

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 

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

  set <ll>  s;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
    s.insert(a[i]);
  }

  mint TMP = k*(k-1)/2;
  
  mint ans = 0;

  vector<ll> c(n);

  copy(ALL(a), c.begin());
  sort(ALL(c));
  
  rep(i ,n){
    mint m = lower_bound(ALL(c), a[i])-c.begin();
    //cout<<m<<endl;
    ans += TMP * m;
  }
  
  //cout << m*(m-1)/2 << " " << k*(k-1)/2<<endl;

  BIT b(2000);
  rep(i, n){
    ans += k * (i - b.sum(a[i]));
    b.add(a[i], 1LL);
  }
  
  cout << ans.x << endl;
 
  
}


Measured memory_bytes: 384