akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 110;
int N,T[maxn],V[maxn];
double ans;

double dfs(const int i, const double maxv2)
{
    const double a = 1;
    if (i == 0)
        return 0;
    double maxv1;
    if (maxv2 >= V[i] || maxv2+a*T[i] >= V[i])
        maxv1 = V[i];
    else
        maxv1 = maxv2+a*T[i];
    const double v1 = dfs(i-1,maxv1);
    double lo = v1, hi = min(maxv1, v1+a*T[i]);
    FOR(_,0,100) {
        const double mid = (lo+hi)/2;
        const double t1 = (mid-v1)/a;
        const double t2 = T[i]-t1;
        if (mid-a*t2 <= maxv2)
            lo = mid;
        else
            hi = mid;
    }
    const double maxv = lo;
    const double v2 = min(maxv,maxv2);
    const double t1 = (maxv-v1)/a;
    const double t2 = (maxv-v2)/a;
    ans += (v1+maxv) * t1 / 2;
    ans += maxv * (T[i]-t1-t2);
    ans += (v2+maxv) * t2 / 2;
    return v2;
}

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    while (cin >> N) {
        ans = 0;
        FOR(i,1,N+1)
            cin >> T[i];
        FOR(i,1,N+1)
            cin >> V[i];
        dfs(N,0);
        printf("%f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        uf.union(u, v)
    else:
        if uf.same(u, v):
            print(1)
        else:
            print(0)

Measured memory_bytes: 83804
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define forn for(long long int i=0;i<n-1;i++)
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;

const int MAXR = 1000005;
ll         tests=          1;

using namespace std;
int binarySearch(int arr[], int l, int r, int x)
{
	if (r >= l) {
		int mid = l + (r - l) / 2;
		if (arr[mid] == x)
			return mid;
		if (arr[mid] > x)
			return binarySearch(arr, l, mid - 1, x);
		return binarySearch(arr, mid + 1, r, x);
	}
	return l;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
// ll ctr=1;
// ll vis[10001];
// ll color[10001];
// vector<ll>v[10001];
// void dfs(ll node,ll colr)
// {
// 	vis[node]=1;
// 	for(ll i=0;i<v[node].size();i++)
// 	{
//        if(!vis[v[node][i]])
//        {
//        	  if(color[v[node][i]]!=colr)
//        	  	ctr++;
//        	dfs(v[node][i],color[v[node][i]]);
//        }
// 	}
// }
 // for(ll i=2;i<=n;i++)
    // {
    //       ll x;
    //      cin>>x;
    //    v[i].push_back(x);
    //    v[x].push_back(i);
    // }
    // fr(i,1,n)
    // {
    // 	cin>>color[i];
    // }
    // ll result=0;
    // dfs(1,color[1]);
    // result+=ctr;
    // cout<<result;
   // for(ll i=1;i<=n;i++)
   // {
   // 	   cout<<i;
   // 	for(ll j=0;j<v[i].size();j++)
   // 	{
   // 		cout<<"-"<<v[i][j];
   // 	}
   // 	cout<<endl;
   // }
int main()
{
    #ifndef ONLINE_JUDGE
	{
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
  #endif
 ll  n,k;
    cin>>n>>k;
    ll a[n+1];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i+1];
    }
    map<ll,ll>m;
    
    int po=a[1];
    vector<ll> vc;
    vc.pb(1);
    while(m[po]!=1)
    {
        m[po]=1;
        vc.pb(po);
        po=a[po];
    }
    int ii=0;
    for(int i=0;i<vc.size();i++)
    {
        if(vc[i]==po)
        {
            ii=i;
            break;
        }
    }
    if(k<vc.size())
    {
        cout<<vc[k];
    }
    else
    {
        k-=ii;
        k%=vc.size()-ii;
        k+=ii;
        cout<<vc[k];
    
    }

}


Measured memory_bytes: 18432
#include <iostream>
#include <cstring>

using namespace std;

int bexp(int a, int x, int p) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return a * bexp(a, x - 1, p) % p;
    }
    int t = bexp(a, x / 2, p);
    return t * t % p;
}

int inv(int a, int p) {
    return bexp(a, p - 2, p);
}

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

    int lag[p+1];
    memset(lag, 0, sizeof(lag));
    lag[0] = 1;
    for (int i = 0; i < p; i++) {
        for (int j = p; j >= 0; j--) {
            lag[j] = ((j == 0 ? 0 : lag[j-1]) + lag[j] * (p - i)) % p;
        }
    }

    int b[p];
    memset(b, 0, sizeof(b));
    for (int i = 0; i < p; i++) {
        int a;
        cin >> a;

        int q = lag[p];
        lag[p] = 0;
        for (int j = p - 1; j >= 0; j--) {
            int t = (lag[j] + q * i) % p;
            lag[j] = q;
            q = t;
        }

        int k = 0;
        q = 1;
        for (int j = 0; j < p; j++) {
            k = (k + lag[j] * q) % p;
            q = q * i % p;
        }
        k = a * inv(k, p) % p;

        for (int j = 0; j < p; j++) {
            b[j] = (b[j] + k * lag[j]) % p;
        }

        for (int j = p; j >= 0; j--) {
            lag[j] = ((j == 0 ? 0 : lag[j-1]) + lag[j] * (p - i)) % p;
        }
    }

    for (int i = 0; i < p; i++) {
        cout << b[i] << (i == p - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
 	val (a, b) = readLine()!!.split(" ").map { it.toInt() }
  
    println(
        (0..1010).filter {
            (it * 0.08).toInt() == a && (it * 0.10).toInt() == b
        }.min() ?: "-1"
    )
}

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

int zettaiti(int k){
  if(k>=0){
    return k;
  }
  else return -k;
}
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(zettaiti(a-c)<=d){
    cout << "Yes" << endl;
    return 0;
  }
  if(zettaiti(a-b)<=d && zettaiti(b-c)<=d){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 1, n = sc.nextInt();
        while (i <= n) {
            int x = i;
            if (x % 3 == 0) {
                System.out.printf(" %d", i);
            } else {
                while (x >= 1) {
                    if (x % 10 == 3) {
                        System.out.printf(" %d", i);
                        break;
                    }
                    x /= 10;
                }
            }
            i++;
        }
        System.out.printf("\n");
    }
}

    




Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
int cnt[5];
int main ()
  {
   string s;
   cin >> s;
   int i, cnt2 = 0, num;
   for(i = 0; i < 4; i++)
     {
      num = s[i] - 64;
      cnt[num]++;
      if(cnt[num] == 1) cnt2++;
     }
  if(cnt2 == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  }

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

class P
{
    static void Main()
    {
        int[] N = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Math.Max(Math.Min(N[3], N[1]) - Math.Max(N[2], N[0]),0));
    }
}

Measured memory_bytes: 13268
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=1000+10,maxn=1000000+10,inf=0x3f3f3f3f;

int pre[N],vis[N];
vi v[N],ans;
void bfs(int u)
{
    queue<int>q;q.push(u);vis[u]=1;
    while(!q.empty())
    {
        int x=q.front();q.pop();
        for(int y:v[x])
        {
            if(y==u)
            {
                vi te;
                for(int p=x;p!=u;p=pre[p])te.pb(p);
                te.pb(u);
                if(te.size()<ans.size())ans=te;
                return ;
            }
            if(!vis[y])
            {
                pre[y]=x;
                vis[y]=1;
                q.push(y);
            }
        }
    }
}
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int a,b;scanf("%d%d",&a,&b);
        v[a].pb(b);
    }
    ans.resize(N);
    for(int i=1;i<=n;i++)
    {
        memset(vis,0,sizeof vis);
        memset(pre,0,sizeof pre);
        bfs(i);
    }
    if(ans.size()==N)puts("-1");
    else
    {
        printf("%d\n",ans.size());
        for(int x:ans)printf("%d\n",x);
    }
    return 0;
}
/********************

********************/


Measured memory_bytes: 256
def dice(d, n):
    if n == 1:
        return d[1] + d[2] + d[4] + d[3]
    if n == 2:
        return d[0] + d[3] + d[5] + d[2]
    if n == 3:
        return d[0] + d[1] + d[5] + d[4]
    if n == 4:
        return d[0] + d[4] + d[5] + d[1]
    if n == 5:
        return d[0] + d[2] + d[5] + d[3]
    if n == 6:
        return d[1] + d[3] + d[4] + d[2]

d1 = input().split()
d2 = input().split()

for i in range(6):
    if d1[0] == d2[i] and d1[5] == d2[5-i] and dice(d2, i+1) in dice(d1, 1)*2:
        print('Yes')
        break
    if i == 5:
        print('No')


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int val;
    int code;
}a[100009];
int cmp(node a,node b)
{
    return a.val<b.val;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),a[i].code=i;
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
        printf("%d ",a[i].code);
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)
#define uniq(v) sort((v).begin(),(v).end()); (v).erase(unique((v).begin(),(v).end()),(v).end());
#define steprap(i,n,s) for(int (i)=0;i<(s)*(n);(i)+=(s))
#define rap(i,n) steprap((i),(n),1)

using intV = std::vector<int>;

using namespace std;
namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);
	int gcm(int a,int b);
	int lcm(int a,int b);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
	int gcm(int a,int b){
		int p=max(a,b);
		int q=min(a,b);
		int r;
		while(true){
			if(p%q==0){
				return q;
			}
			r = p%q;
			p=q;
			q=r;
		}
	}
}

using namespace std;
// using StringMap = std::vector<std::vector<char>> map(h+2,vector<char>(w+2,'#'));
namespace tmp {
    template <typename T> bool inArry(T x,vector<T> v);
    template <typename T> void input(int n,vector<T> &v);

    template <typename T> bool inArry(T x,vector<T> v){
        int l = v.size();
        for(int i=0;i<l;i++){
            if(x==v[i]){
                return true;
            }
        }
        return false;
    }
    
    template <typename T> void input(int n,vector<T> &v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
    }
}

using namespace std;

signed main (){
	int a,b;
	char op;
	cin >> a>>op>>b;
	if(op=='+'){
		cout<<a+b<<endl;
	}else{
		cout<<a-b<<endl;
	}
	return 0;
}


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

using namespace std;
using ll = long long;

ll diff(ll a, ll b, ll c) {
    return max(max(a, b), c) - min(min(a, b), c);
}

ll solve(ll h, ll w) {
    if(h%3==0 or w%3 == 0) return 0;

    ll ans = min(h,w);
    for(ll i=1; i<h;i++) {
        ll s1 = i * w;
        ll s2 = (h-i) * (w/2);
        ll s3 = h*w - s1 - s2;
        ans = min(ans, diff(s1,s2,s3));
    }

    for(ll i=1; i<w;i++) {
        ll s1 = i * h;
        ll s2 = (w-i) * (h/2);
        ll s3 = h*w - s1 - s2;
        ans = min(ans, diff(s1,s2,s3));
    }
    return ans;
}

int main() {
    ll h,w; cin >> h >> w;
    cout << solve(h,w) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char s[3];
  char s1[10],s2[10],s3[10];
  scanf("%s %s %s",s1,s2,s3);
  s1[0] -='a'-'A';
  s2[0] -='a'-'A';
  s3[0] -='a'-'A';
  printf("%c%c%c\n",s1[0],s2[0],s3[0]);
}

Measured memory_bytes: 128
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".in", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);

	int n;
	string s;
	
	cin >> n >> s;

	if (count(s.begin(), s.end(), 'R')*2>s.size())
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[5];
bool cmp(ll x,ll y)
{
    return x<y;
}
int main()
{
    ll q,h,s,d,n,d1;
    int i,j,k1,k2;
    ios::sync_with_stdio(false);
    cin>>q>>h>>s>>d;
    cin>>n;
    a[0]=q*8;
    a[1]=h*4;
    a[2]=s*2;
    a[3]=d;

    ll MIN = 800000005;
    for(i=0;i<4;i++)
    {
        if(a[i]<MIN){MIN=a[i];k1=i;}
    }
    //cout<<MIN<<endl;
    MIN = 800000005;
    for(j=0;j<4;j++)
    {
        if(a[j]<MIN&&j!=k1){MIN=a[j];k2=j;}
    }
    //cout<<MIN<<endl;
    //sort(a,a+4,cmp);
    if(k1==0)
    {
        cout<<4*q*n<<endl;
    }
    else if(k1==1)
    {
        cout<<2*h*n<<endl;
    }
    else if(k1==2)
    {
        cout<<s*n<<endl;
    }
    else{
        if(n%2==0)
        {
            cout<<(n/2)*d<<endl;
            //continue;
        }
        else
        {
            if(k2==0)
            {
                cout<<4*q+(n/2)*d<<endl;
            }
            else if(k2==1)
            {

                cout<<2*h+(n/2)*d<<endl;
            }
            else
            {
                cout<<s+(n/2)*d<<endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N],cnt[N];
int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
      int n;
      Int(n);

      ll s=0ll;
      for(int i=1;i<=n;++i){
        Int(a[i]);
        s+=a[i];
        ++cnt[a[i]];
      }
      int q;
      Int(q);

      while(q--){
        int x,y;
        Int(x,y);
        s-=cnt[x]*1ll*x;
        s+=cnt[x]*1ll*y;
        
        cnt[y]+=cnt[x];
        cnt[x]=0;

        printf("%lld\n", s);
      }


        //printf("Case %d: ",++te);
    }
    return 0;
}






Measured memory_bytes: 4536
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		int x = inint();
		out.println(x<1200 ? "ABC" : "ARC");
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 23764
import java.util.*;
public class Main {
	public static void main(String[] args){
    //データ取り込み
		Scanner sc = new Scanner(System.in);
		//String S = sc.next();
    //int B = sc.nextInt();
    //System.out.println();
		int N = sc.nextInt();
		
		System.out.println(N/3);
	}
}

Measured memory_bytes: 21716
import math
while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    l = list(map(int, input().split()))
    m = sum(l)
    m = m / n
    for i in l:
        a += math.pow(i-m, 2)
    a /= n
    a = math.sqrt(a)
    print(a)



Measured memory_bytes: 5692
n,l=map(int,input().split())
t=[]

for i in range(1,n+1):
  t.append(l+i-1)
  
if 0 in t:
  print(sum(t))
elif l >= 0:
  print(sum(t[1:]))
else:
  print(sum(t[:-1]))
  

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

int main() {

    string s; cin >> s;
    const int p = 26;
    vector<int> num(p, 0);
    for (int i = 0; i < s.size(); i++) {
        num[s[i] - 'a']++;
    }
    bool different = true;
    for (int i = 0; i < p; i++) {
        if (num[i] == 2) different = false;
    }
    if (different) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

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

template <class T>
struct BIT{
	int n;
	vector<T> x;
	BIT(int n_ = 0) : n(n_), x(n + 1, 0){}
	int size() const{ return n; }
	T sum(int r) const{
		T S = 0;
		for(r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
		return S;
	}
	T sum(int l, int r) const{ return sum(r) - sum(l); }
	void add(int k, const T &a){
		for(; k < n; k |= k + 1) x[k] += a;
	}
	void set(int k, const T &a){ add(k, a - sum(k, k + 1)); }
	int lower_bound(T x){
		int ng = -1, ok = n - 1;
		while(abs(ng - ok) > 1){
			int mid = (ng + ok) / 2;
			if(sum(0, mid + 1) >= x) ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

BIT<ll> bit(100000);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	cin >> s;
	int N = s.size();

	for(int i = 0; i < N; i++){
		if(s[i] == '1') bit.add(i, 1);
	}

	vector<int> v;
	int cnt = 1;
	for(int i = 1; i < N; i++){
		if(s[i] != s[i - 1]){
			v.push_back(cnt);
			cnt = 1;
		}
		else{
			cnt++;
		}
	}
	v.push_back(cnt);
	if(v.size() == 1){
		cout << N << endl;
		return 0;
	}
	if(v.size() == 2){
		cout << max(v[0], v[1]) << endl;
		return 0;
	}

	int len = N;
	for(int k = N; k >= 1; k--){
		int l = N - k;
		int r = k;
		int sum = bit.sum(l, r);

		if(sum == 0 || sum == len){
			cout << k << endl;
			return 0;
		}
		len -= 2;
	}
	cout << 1 << endl;
}


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

def main():
    N, M = map(int, input().split())
    dist = [[float('inf') for i in range(N)] for j in range(N)]
    
    r = [[-1 for i in range(N)] for j in range(N)]
    
    for i in range(N): dist[i][i] = 0
    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1; b -= 1
        dist[a][b] = c
        dist[b][a] = c
        
        r[a][b] = i
        r[b][a] = i
        
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if dist[i][j] > dist[i][k]+dist[k][j]:
                    dist[i][j] = dist[i][k]+dist[k][j]
                    r[i][j] = r[k][j]
        
    ans = set()    
    for a in r: ans.update(set(a))    
    print(M-len(ans)+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0; i < n ; i++ ) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for ( int i = 1; i < n; i++ ){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl; 
   
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

template<class T> struct Seg { 
	const T ID = 0; // comb(ID,b) must equal b
	T combine(T a, T b) { return a+b; } 
	int n; vector<T> seg;
	void init(int _n) { n = _n; seg.assign(2*n,ID);}

	void update(int p, T value) {	// set value at position p
		seg[p += n] += value;
		for (p /= 2; p; p /= 2) seg[p] = combine(seg[2*p], seg[2*p+1]);
	}
    
	T query(int l, int r) {	 // sum on interval [l, r]
		T ra = ID, rb = ID; 
		for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
			if (l&1) ra = combine(ra,seg[l++]);
			if (r&1) rb = combine(seg[--r],rb);
		}
		return combine(ra,rb);
	}
};

int main() {
    // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, Q; cin >> N >> Q;

	Seg<int> seg; seg.init(N+1);
	vi cur (N+1, N);

	vi cols (N);
	F0R(i, N) cin >> cols[i];

	vector<vector<pii>> queries (N);
	F0R(i, Q) {
		int l, r; cin >> l >> r; --l; --r;
		queries[l].push_back({r, i});
	}

	vi ans (Q);
	R0F(l, N) {
		seg.update(cur[cols[l]], -1);
		seg.update(l, 1);
		cur[cols[l]] = l;
		for (pii q : queries[l]) {
			int r = q.first;
			int i = q.second;
			ans[i] = seg.query(l, r);
		}
	}
	F0R(i, Q) print(ans[i]);
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e6+23;

int h[N], H[N];

void solve() {
  int n; scanf("%d", &n);
  int g; scanf("%d", &g);
  ++h[g];
  for (int a, i = 1; i < n; ++i) {
    scanf("%d", &a);
    ++h[a];
    g = __gcd(g, a);
  }
  if (g != 1) {
    puts("not coprime");
    return;
  }
  for (int i = 2; i < N; ++i) {
    for (int j = i; j < N; j += i) {
      H[i] += h[j];
    }
    if (H[i] > 1) {
      puts("setwise coprime");
      return;
    }
  }
  puts("pairwise coprime");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 11596
#include<stdio.h>
#define N 500000
#define YOSHI 2000000000

void merge(int[],int,int,int);
void mergeSort(int[],int,int);

int count = 0;
int R[N / 2 + 2],L[N / 2 + 2];

int main(){
    int A[N],i,n;
    
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d",&A[i]);
    }
    mergeSort(A,0,n);
    for(i = 0;i < n;i++){
        if(i > 0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",count);
    return 0;
}

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

void merge(int A[],int left,int mid,int right){
    int i,j,k;
    int n1 = mid - left;
    int n2 = right - mid;
    
    for(i = 0;i < n1;i++){
        L[i] = A[left + i];
    }
    
    for(i = 0;i < n2;i++){
        R[i] = A[mid + i];
    }
    
    L[n1] = R[n2] = YOSHI;
    i = 0;
    j = 0;
    
    for(k = left;k < right;k++){
        count++;
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }
        else{
            A[k] = R[j++];
        }
    }
}





Measured memory_bytes: 5676
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program
{
    internal static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var dic = new Dictionary<String, int>();

        for (int i = 0; i < N; i++) {
            var S = ReadLine();
            if (dic.ContainsKey(S)) {
                dic[S]++;
            } else {
                dic.Add(S, 1);
            }
        }

        var M = int.Parse(ReadLine());

        for (int i = 0; i < M; i++) {
            var T = ReadLine();
            if (dic.ContainsKey(T)) {
                dic[T]--;
            } else {
                dic.Add(T, -1);
            }
        }

        if (dic.Values.Max() > 0) {
            WriteLine(dic.Values.Max());
        } else {
            WriteLine(0);
        }
    }
}


Measured memory_bytes: 13152
#include <iostream> 
#include <algorithm> 
#include <cstring> 
#include <cstdio>
#include <vector> 
#include <queue> 
#include <cstdlib> 
#include <iomanip>
#include <cmath> 
#include <ctime> 
#include <map> 
#include <set> 
using namespace std; 
#define lowbit(x) (x&(-x)) 
#define max(x,y) (x>y?x:y) 
#define min(x,y) (x<y?x:y) 
#define MAX 100000000000000000 
#define MOD 1000000007
#define pi acos(-1.0) 
#define ei exp(1) 
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f3f 
#define mem(a) (memset(a,0,sizeof(a))) 
typedef long long ll;
ll n;
ll a[55];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=50;i++)
    {
        a[i]=n/50+i-1;
    }
    n%=50;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=50;j++)
        {
            a[j]--;
        }
        a[i]+=51;
    }
    printf("50\n");
    for(int i=1;i<=50;i++)
    {
        if(i!=1) printf(" ");
        printf("%lld",a[i]);
    }
    printf("\n");
    return 0;
}

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

using namespace std;

void print(vector<int> &A, int N){
    string sep = "";
    for(int i = 0; i < N; i++){
	cout << sep << A.at(i);
	sep = " ";
    }
    cout << endl;
}

void insertionSort(vector<int> &A, int N) // N個の要素を含む0-オリジンの配列A
{
    for(int i = 0; i < N; i++){ // i が 1 から N-1 まで
	int v = A.at(i);
	int j = i - 1;
	while(j >= 0 && A.at(j) > v){
	    A.at(j+1) = A.at(j);
	    A.at(j) = v;
	    j--;
	}
	print(A, N);
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);

    for(int i = 0; i < N; i++){
	cin >> A.at(i);
    }

    insertionSort(A, N);
}



Measured memory_bytes: 3144
/*input
5
3 8 7 5 5
*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

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

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  cin >> n;
  vector < ll > v;
  for(int i = 0; i < n; i ++) {
    ll x;
    cin >> x;
    v.push_back(x * 2);
  }
  vector < ll > ans;
  for(int i = 0; i < n; i ++) {
    if(!i) {
      ans.push_back(v[i]);
    } else {
      ans.push_back(v[i] - ans[i - 1]);
    }
  }
  ll u = ans[n - 1];
  ll x = u / 2;
  vector < ll > ans2;
  ans2.push_back(x);
  for(int i = 0; i < n; i ++) {
    if(i % 2 == 0) {
      ans2.push_back(ans[i] - x);
    } else {
      ans2.push_back(ans[i] + x);
    }
  }
  for(int i = 0; i < n; i ++) {
    cout << ans2[i], sp;
  }
  return 0;
}

Measured memory_bytes: 3828
from collections import Counter

def cmb(n, r, mod=10**9+7):
    return n * (n - 1) // 2



N = int(input())
ball_com = [0] * (N + 1)
balls = list(map(int, input().split()))
balls_counter = Counter(balls)
for key , val in balls_counter.items():
    ball_com[key - 1] = cmb(val, 2)

cmb_sum = sum(ball_com)
for ball in balls:
    print(cmb_sum - ball_com[ball - 1] + cmb(balls_counter[ball] - 1, 2))


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

using namespace std;

int n,m;
int fa[100050];
vector<int> edge[100050],tr[100050];
int id[100050];
int a[100050],b[100050];
long long dp[100050];
long long su[100050];
bool vi[100050];

bool cmp(int A,int B)
{
	return a[A] < a[B];
}

int find_fa(int u)
{
	return fa[u] == u ? u : fa[u] = find_fa(fa[u]);
}

void dfs(int pos)
{
	for(auto v : tr[pos])
	{
		dfs(v);
		su[pos] += su[v];
	}
	su[pos] += b[pos];
	dp[pos] = su[pos] + a[pos];
	for(auto v : tr[pos])
		dp[pos] = min(dp[pos],su[pos] - su[v] + max(a[pos] * 1ll,dp[v]));
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n; ++ i)
		scanf("%d%d",&a[i],&b[i]),a[i] = max(0,a[i] - b[i]),id[i] = i;
	sort(id + 1,id + 1 + n,cmp);
	for(int i = 1;i <= m; ++ i)
	{
		int u,v; scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	for(int i = 1;i <= n; ++ i) fa[i] = i;
	for(int i = 1;i <= n; ++ i)
	{
		int x = id[i];
		vi[x] = 1;
		for(auto v : edge[x])
			if(vi[v] && find_fa(v) != find_fa(x))
			{
				int f = find_fa(v);
				tr[x].push_back(f);
				fa[f] = x;
			}
	}
	dfs(id[n]);
	printf("%lld\n",dp[id[n]]);
}

Measured memory_bytes: 18172
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

const mod = 998244353
const facNum = 300001
const INF = 2 << 31

func main() {
	sc := newScanner(os.Stdin)
	N, K := sc.i(), sc.i()
	P := sc.is(N)
	sort.Slice(P, func(i, j int) bool {
		return P[i] < P[j]
	})
	ans := 0
	for i := 0; i < K; i++ {
		ans += P[i]
	}
	fmt.Println(ans)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//------------------------------

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1776
n,m = [ int(s) for s in input().split() ]
  
v1 = [ [0] * m for i in range(n) ]
v2 = [0] * m

for i in range(n):
    v1[i] = [ int(s) for s in input().split() ]

for i in range(m):
    v2[i] = int(input())

for i in range(n):
    total = 0
    for j in range(m):
        total += v1[i][j] * v2[j]
    print(total)


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

using namespace std;

int main(void){
    
    vector<int> m, f, r;
    int count = 0;
    while(1){
        int a, b, c;
        cin >> a >> b >> c;
        if(a == -1 && b == -1 && c == -1) break;
        m.push_back(a);
        f.push_back(b);
        r.push_back(c);
        count++;
    }
    
    for(int i = 0;i < count;i++){
        if(m[i] == -1 || f[i] == -1) cout << 'F' << endl;
        else if(m[i]+f[i] >= 80) cout << 'A' << endl;
        else if(m[i]+f[i] >= 65) cout << 'B' << endl;
        else if(m[i]+f[i] >= 50) cout << 'C' << endl;
        else if(m[i]+f[i] >= 30 && r[i] >= 50) cout << 'C' << endl;
        else if(m[i]+f[i] >= 30) cout << 'D' << endl;
        else cout << 'F' << endl;
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> A(n);
    REP(i, n) cin >> A[i];
    ll ans = 0;
    REP(i, n) {
        ans += A[i]/2;
        if (A[i] % 2 == 1 && A[i+1] > 0) {
            A[i+1] -= 1;
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var x = sc.nextLong();
		var k = sc.nextLong();
		var d = sc.nextLong();
		x = Math.abs(x);
		if (x == 0) {
			if (k % 2 == 0) {
				System.out.println(0);
			} else {
				System.out.println(d);
			}
		} else {
			var risouMaxK = x / d + 1;
			if (risouMaxK > k) {
				System.out.println(Math.abs(x - k * d));
			} else {
				if (risouMaxK % 2 == 0 && k % 2 == 0
						|| risouMaxK % 2 != 0 && k % 2 != 0) {
					System.out.println(Math.abs(x - risouMaxK * d));
				} else {
					var risouMaxK2 = x / d;
					System.out.println(Math.abs(x - risouMaxK2 * d));
				}

			}
		}

	}
}

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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vvll vector<vll>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18+5
#define inf 1e9+5
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

template <typename T> T max(T a, T b, T c){ return max(a, max(b, c));}
template <typename T> T min(T a, T b, T c){ return min(a, min(b, c));}

int M = 1e9+7; //check
ll fact[1000006];
 
ll gcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main() {
	_69e27;
	int x, y;
	scanf("%d %d", &x, &y);
	fact[0] = 1;
	Loop(i, 1, 1000006) fact[i] = fact[i-1]*i % M;

	int a = -1, b = -1;
	loop(i, 1000006)
	{
		int j = x - i;
		if(j < 0) break;
		j /= 2;
		if(2*j+i == x && 2*i+j == y)
		{
			a = j, b = i;
			break;
		}
	}
	if(a < 0 || b < 0) return printf("0"), 0;
	ll n = fact[a + b];
	ll inv1, y2, g, inv2;
	g = gcd(fact[a], M, inv1, y2);
	g = gcd(fact[b], M, inv2, y2);
	ll ans = (((n * inv1) % M ) * inv2) % M;
	while(ans < 0) ans += M;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
vector<ll> g[5010];
int p[5011];
ll w[5011];
int vis[5011];
int cnt;
int main(){
	 int n,k;
	 scanf("%d%d",&n,&k);
	 for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	 for(int i=1;i<=n;i++)scanf("%lld",&w[i]);
	 for(int i=1;i<=n;i++){
	 	if(vis[i])continue;
	 	int t=i;
	 	while(!vis[t]){
	 		g[cnt].push_back(w[t]);
	 		vis[t]=1;
          	t=p[t];
		}
		cnt++;
	 }
	 ll res=-1e18;
	 //cout<<res<<endl;
	 for(int i=0;i<cnt;i++){
	 	//cout<<i;
	 	ll sum=0;
	 	ll ean=0;
	 	for(int j=0;j<g[i].size();j++)
	 	sum+=g[i][j];
	 	//cout<<sum<<endl;
	 	int t,y;
	 	if(g[i].size()>=k){
	 		t=0,y=k;
		}
		else{
		 	t=k/g[i].size();
	 		y=k%(g[i].size());
	 		if(y==0){
	 		t--;y=g[i].size();
		 	}
		 	else{
		 		y+=g[i].size();t--;
			}
		}
	 	if(sum>=0)
	 	ean+=t*sum;
	 	ll maxn=-1e18;
	 	for(int j=0;j<g[i].size();j++){
	 		ll summ=0;
	 		for(int kk=0;kk<y;kk++){
	 			int s=kk+j;
	 			s=s%g[i].size();
	 			summ+=g[i][s];
	 			//cout<<g[i][s]<<endl;
	 			if(summ>=maxn)maxn=summ;
	 			//cout<<summ<<endl;
			 }
		 }
		 ean+=maxn;
		 if(ean>=res)res=ean;
	 }
	 cout<<res<<endl;
}

Measured memory_bytes: 4072
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;


struct UnionFind{
    vector<int> par;
    vector<int> es;
    UnionFind(int N) : par(N,-1),es(N,0) {}
    
    //初期化
    void init(int N){
        par.assign(N,-1);
        es.assign(N,0);
    }

    int find(int x){
        if(par[x]<0) return x;
        else return par[x]=find(par[x]);
    }

    int usize(int x) {return -par[find(x)];}

    int esize(int x) {return es[find(x)];}
    
    bool unite(int x,int y){
        x=find(x);
        y=find(y);
        es[x]++;
        if(x==y) return false;

        if(usize(x)<usize(y)) swap(x,y);
        par[x]+=par[y];
        es[x]+=es[y];
        par[y]=x;
        return true;
    }

    bool same(int x,int y) {return find(x)==find(y);}

};
template<class T >
struct Edge {
  int src, to;
  T cost;

  Edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  Edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

};

template<class T>
T Kruskal(vector<Edge<T>> &edges,int V){
    sort(edges.begin(),edges.end(),[](const Edge<T> &a,const Edge<T> &b){
        return (a.cost<b.cost);
    });
    UnionFind tree(V);
    T ans=0;
    for(auto &e:edges){
        if(tree.unite(e.src,e.to)){
            ans+=e.cost;
        } 
    }
    return ans;
}

signed main(){
    int V,E;
    cin>>V>>E;
    vector<Edge<int>> k;
    for(int i=0;i<E;i++){
        int s,t,w;
        cin>>s>>t>>w;
        k.emplace_back(s,t,w);
    }
    cout<<Kruskal(k,V)<<endl;
}


Measured memory_bytes: 4544
//
//  main.cpp
//  A - Snuke's favorite YAKINIKU
//
//  Created by wenhan on 2017/9/23.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace  std;
int main() {
    char s[15];
    cin>>s;
    if(strstr(s,"YAKI")==s)
        printf("Yes\n");
    else
        printf("No\n");
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256