akhauriyash/Code-Regression huggingface dataset:
// AtCoder Beginner Contest 088 - Problem B: Card Game for Two (https://abc088.contest.atcoder.jp/tasks/abc088_b)
#include <bits/stdc++.h>

using namespace std;

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

    vector<int> as(N);

    for (int i = 0; i < N; ++i)
        cin >> as[i];

    sort(as.begin(), as.end(), greater<int>());

    int xs[] { 0, 0 };

    for (int i = 0, k = 0; i < N; ++i, k = 1 - k)
        xs[k] += as[i];

    cout << xs[0] - xs[1] << endl;

    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<ll> h;
  ll tmp;
  rep(i,n) {
    cin >> tmp;
    h.push_back(tmp);
  }
  if (k != 0) {
    sort(h.begin(),h.end());
  	rep(i,k) h.pop_back();
  }
  int size = h.size();
  ll count = 0;
  rep(i,size) count += h[i];
  cout << count;
  
  return 0;
}

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

int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(abs(a-c)<=d)
		printf("Yes");
	else if(abs(a-b)<=d && abs(b-c)<=d)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include <string.h>
int main(){
char A[11],B[11],C[11];
scanf("%s%s%s",A,B,C);
if(A[strlen(A)-1]==B[0]&&B[strlen(B)-1]==C[0]){
printf("YES\n");
}else{
printf("NO\n");
}
return 0;
}

Measured memory_bytes: 128
n = int(input())

a = [[0 for _ in range(10)] for __ in range(10)]

for i in range(1, n+1):
    a[int(str(i)[0])][i%10] += 1

ans = 0

for i in range(1,10):
    for j in range(10):
        if i != j:
            ans += a[i][j]*a[j][i]

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

ans = ans

print(ans)


Measured memory_bytes: 40300
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    char s[30]={},t[30]={};
    int i;
    scanf("%s",s);
    for(i=0; i<3; i++){
        t[i]=s[i];
    }
    printf("%s",t);
    return 0;
}

Measured memory_bytes: 1736
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int ans,r,x,q;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin >>x;
	if(x==1)cout<<"1\n";
	else{
	for(int i=2;i<=(int)sqrt(x);i++){
		r=2;q=0;
		while(q<=x){
		    if(pow(i,r)>x)break;
		    else{
			q=pow(i,r);
			r++;}
		}
		ans=max(q,ans);
	}
	cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
#include <cmath>
#include <cstdio>
using namespace std;
#define MPI  3.14159265358979323846

struct Dice{
	int d[6];
	void input();
	void rotation(int&, int&, int&, int&);
	void roll(char);
	string c1 = "WWWWSWW", c2 = "RRRR";
	bool equal(int*);
};

void Dice::rotation(int& a, int& b, int& c, int& d){
	int p = a; a = b; b = c; c = d; d = p;
}

void Dice::roll(char c){
	if (c == 'W')rotation(d[0], d[2], d[5], d[3]);
	if (c == 'S')rotation(d[0], d[4], d[5], d[1]);
	if (c == 'E')rotation(d[0], d[3], d[5], d[2]);
	if (c == 'N')rotation(d[0], d[1], d[5], d[4]);
	if (c == 'R')rotation(d[1], d[2], d[4], d[3]);
}

void Dice::input(){
	for (int i = 0; i < 6; i++){
		cin >> d[i];
	}
}

bool Dice::equal(int* a){
	bool flag1=true;
	int count;
	for (int i = 0; i < c1.size(); i++){
		count = 0;
		if (a[0] == d[0]){
			for (int i2 = 0; i2 < c2.size(); i2++){

				flag1 = true;
				for (int j = 1; j < 6; j++){
					if (a[j] != d[j]){ flag1 = false; break; }
					//else cout << a[j] << d[j] << endl;
				}
				if (flag1)break;
				else {
					count++;
					roll(c2[i2]);
				}

			}
			if (count != c2.size()) break;
		}
		roll(c1[i]);
	}
	return flag1;
}


int main(){

	Dice Dice1, Dice2;
	Dice1.input();
	Dice2.input();

	if (Dice1.equal(Dice2.d)==true){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}


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

typedef long long LL;
const int MAXN=3e6+5;
const int MAXM=1e5+5;
const int mod=1e9+7;

LL s,num[20],sum[20];
int len,factor[MAXN];

void update(LL &a,LL b){
	a+=b;
	if (a>mod) a-=mod;
}

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

void exgcd(LL a,LL b,LL &x,LL &y){
	if (b==0){x=1; y=0;}
    else{exgcd(b,a%b,y,x); y-=x*(a/b);}
}

LL power(LL a,LL b){
	LL c=1;
	while(b){
		if (b%2==1) c=(c*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return c;
}

void prepare(){
	num[0]=sum[0]=0;
	num[1]=sum[1]=9;
	for(int i=2;i<=15;i++){
		num[i]=num[i-1]*10;
		sum[i]=sum[i-1]+num[i]*i;		
	}
	len=0;
	for(LL i=1;i*i<=s;i++){
		if (s%i!=0) continue;
		factor[++len]=i;
		if (i*i!=s) factor[++len]=s/i;
	}
}

LL calc(int l,int r,LL c){
    c-=(sum[r-1]-sum[l]);
    if (c<0 || c>num[r]*r+num[l]*l) return 0;
    
    LL a=l,b=r,d=gcd(a,b);
	if (c%d!=0) return 0;

	c/=d; a/=d; b/=d;
	LL x,y; exgcd(a,b,x,y);

	LL llim,rlim;

	if ((c*x)%b==0) llim=(-c*x/b+1);
	else llim=(LL)ceil(-1.0*c*x/b);            
	llim=max(llim,(LL)ceil(1.0*(c*y-num[r])/a));    
            
	if ((c*y)%a==0) rlim=c*y/a-1;
	else rlim=(LL)floor(1.0*c*y/a);
	rlim=min(rlim,(LL)floor(1.0*(num[l]-c*x)/b));
            
	if (llim>rlim) return 0;
	else return (rlim-llim+1)%mod;
}

int main(){
	scanf("%lld",&s);
	prepare();
	LL ans=0;
	for(int i=1;i<=12;i++){	
		for(int j=i+1;j<=12;j++){
			update(ans,calc(i,j,s));
		}
	}
	//std::cout<<ans<<std::endl;
	for(int i=1;i<12;i++){
		if (s%i!=0) continue;
        if (num[i]*i<s) continue;
		LL cnt=((num[i]-s/i+1)%mod+mod)%mod;
		//cout<<i<<' '<<cnt<<endl;
		update(ans,cnt);
	}
	//cout<<ans<<endl;
	update(ans,(s/12)%mod);
	int kkk=0;
	for(int i=1;i<=len;i++){
		if (factor[i]>s/12) continue;		
		update(ans,(power(10,s/factor[i]-1)*9)%mod),kkk++;
		update(ans,mod-factor[i]);
		//cout<<factor[i]<<endl;
	}
	//cout<<kkk<<endl;
	if (s==0) ans=0;
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

sum_water = sum(A)

tmp=sum_water
for j in range((N-1)//2):
    tmp-=A[j*2+1]*2
print(tmp, end="")
print(" ", end="")

for i in A[:-1]:
    tmp = 2*i - tmp
    print(tmp, end="")
    print(" ", end="")

Measured memory_bytes: 14092
N, K = map(int, input().split())
ans = 0
# bを全探索して組み合わせの数を求める
for b in range(1, N+1):
    # 繰り返される数
    times = (N//b)
    # 最後に付け加える数
    last = N % b
    ans += times * max(0, b-K) + max(0, last - K + 1)
if K == 0:
    print(N*N)
else:
    print(ans)


Measured memory_bytes: 39408
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    long[] a = new long[n+2];
    foreach (i; 0 .. m) {
        tmp = readln.split.to!(int[]);
        int l = tmp[0] - 1, r = tmp[1];
        ++a[l];
        --a[r];
    }
    foreach (i; 0 .. n+1) {
        a[i+1] += a[i];
    }
    a.count(m).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.typecons;

Measured memory_bytes: 3708
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

ll gcd(const ll sx, const ll sy) {
    ll x = min(sx, sy);
    ll y = max(sx, sy);
    ll tmp;
    while (x > 0) {
        tmp = y;
        y = x;
        x = tmp % x;
    }
    return y;
}

ll lcm(const ll x, const ll y) {
    return x / gcd(x, y) * y;
}

int calc_two_count(ll x) {
    int count = 0;
    while (x > 0 && x % 2 == 0) {
        x /= 2;
        count++;
    }
    return count;
}

vector<ll> a;

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

    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] % 2 != 0) {
            cout << "0" << endl;
            return 0;
        }
    }

    ll two_count = calc_two_count(a[0]);
    a[0] >>= two_count;
    for (int i = 1; i < N; i++) {
        if (calc_two_count(a[i]) != two_count) {
            cout << "0" << endl;
            return 0;
        }
        a[i] >>= two_count;
    }

    ll l = 1;
    for (int i = 0; i < N; i++) {
        l = lcm(l, a[i]);
        if (l > M) {
            cout << "0" << endl;
            return 0;
        }
    }

    // cout << l << endl;

    ll x = l << (two_count - 1);
    ll ans = 0;
    while (x <= M) {
        ans++;
        x += 2 * (l << (two_count - 1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,m,parent[N],ans;

int find(int a){return a == parent[a] ? a : parent[a] = find(parent[a]);}
void merge(int a, int b){parent[find(a)] = find(b), --ans;}

int main(){
    read2i(n,m);
    lp(i,1,n) parent[i] = i;
    ans = n;
    while(m--){
        int a,b,c;
        read3i(a,b,c);
        if(find(a) != find(b)) merge(a, b);
    }
    cout <<ans;
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define MAX 1000000000000000000
#define test int t; cin>>t;
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt(){
    ll x;
    cin>>x;
    return x;
}

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    generate(all(a),nxt);
    ll sum = 0;
    ll maxSofar = a[0];
    for(int i = 1; i<n; i++){
        sum+=(a[i]<maxSofar) ? (maxSofar-a[i]) : 0;
        maxSofar = max(maxSofar,a[i]);
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int cnt=0;

    int ans = 1;

    while(true){
        if (ans >= n) break;
        ans *= 2;
    }

    if( ans > n) out(ans/2);
    else out(ans);

}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a;
    rep(i,n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    int ans = abs(a[n-1]-a[0]);
    cout << ans <<endl;
    return 0;
}




















































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e16;
typedef long long ll;
ll mod = 1e9+7;
long double fast_exp(long double a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long double res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res);
	   if(b%2 == 1)
		  res = (res*a);
	   return res;
 
    }
}


int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	string s;
	cin>>s;

	if(s == "SUN")
		cout<<7<<endl;
	else if(s == "SAT")
		cout<<1<<endl;
	else if(s =="FRI")
		cout<<2<<endl;
	else if(s =="THU")
		cout<<3<<endl;
	else if(s =="WED")
		cout<<4<<endl;
	else if(s =="TUE")
		cout<<5<<endl;
	else cout<<6<<endl;


	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int a, b;
    scanf("%d %d", &a, &b);
    a -= b;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    int lo = 0;
    int hi = 1000000000;
    int ans;
    while(lo <= hi){
        int mid = (lo + hi)/2;
        long long nd = 0;
        for(int i = 0; i < n; i++){
            long long rem = max(0ll, h[i] - 1ll * mid * b);
            nd += (rem + a - 1) / a;
            //printf("%lld\n", nd);
        }
        //printf("%d : %lld\n", mid, nd);
        if(nd <= mid){
            ans = mid;
            hi = mid - 1;
        }
        else lo = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	
	int n, l; cin >> n >> l;
	vector<string> v(n);
	for(int i=0; i<n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	for(int i=0; i<n; i++) {
		cout << v[i];
	}
	cout << '\n';
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int A[N];
  
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  int ans=0;
  int len;
  int maxim;
  int nokori;
  
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        len=A[i]+A[j]+A[k];
        maxim=max(A[i],max(A[j],A[k]));
        nokori=len-maxim;
        if(maxim<nokori and A[i]!=A[j] and A[i]!=A[k] and A[j]!=A[k]){
          ans++;
        }
      }
    }
  }
  cout<<ans;
}
        
      

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

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var list = new List<int[]>();
            while (true)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToList();
                if (tmp[0] == 0 && tmp[1] == 0) break;

                list.Add(tmp.OrderBy(s => s).ToArray());
            }

            foreach (var item in list)
            {
                Console.WriteLine("{0} {1}", item[0], item[1]);
            }
        }
    }
}

Measured memory_bytes: 10544
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

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

    string s;
    cin >> s;

    int num = 0;
    rep(i, s.size()) { num += (s[i] == 'R' ? 1 : -1); }

    cout << (num >= 1 ? "Yes" : "No") << endl;

    return 0;
}


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

const int N = 200005;

int n, k, a[N], pivot;

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

	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (a[i] == 1) pivot = i;
	}

	int low = 1, high = n;
	while(low < high) {
		int mid = (low + high) >> 1;
		if (1LL * mid * k - mid + 1 >= pivot) high = mid;
		else low = mid + 1;
	}

	int rem = (n - low * k + low);
	// 1 ...
	for (int i = 0; i <= n; ++i) {
		if (1LL * i * k - i + 1 >= rem) {
			printf("%d\n", low + i);
			return 0;
		}
	}
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  map<int,int> ma;
  lol ans=1;
  lol o=m;
  while(o%2==0){
    ma[2]++;
    o/=2;
  }
  for(lol i=3;i*i<=m;i+=2){
    while(o%i==0){
      o/=i;
      ma[i]++;
    }
  }
  for(auto l=ma.begin();l!=ma.end();l++){
      ans*=pow(l->fi,(l->se/n));
  }
  if(n==1) cout <<m<<'\n';
  else cout <<ans<<'\n';
  return (0);
}


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

class UnionFindTree{
public:
    vector<int> v;
    vector<int> rank;
 
    UnionFindTree(int n){
        v = vector<int>(n);
        rank = vector<int>(n, 0);
        for(int i=0; i<n; i++) v[i]=i;
    }
    int Find(int x){
        if(v[x] != x){
            v[x] = Find(v[x]);
        }
        return v[x];
    }
    void Union(int a, int b){
        a = Find(a);
        b = Find(b);
        if(a == b) return;
        if(rank[a] < rank[b]){
            v[a] = b;
        }else{
            v[b] = a;
            if(rank[a] == rank[b]){
                rank[a]++;
            }
        }
    }
};

int main(){
    int n,w,h;
    cin >> n >> w >> h;
    vector<pair<int,int> > x(n), y(n);
    int wallside = 0;
    for(int i=0; i<n; i++){
        int tx,ty;
        cin >> tx >> ty;
        x[i] = make_pair(tx, i);
        y[i] = make_pair(ty, i);
        if(tx==1 || tx==w || ty==1 || ty==h) wallside = 1;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    UnionFindTree uft(n);
    for(int i=0; i<n-1; i++){
        if(x[i].first == x[i+1].first){
            uft.Union(x[i].second, x[i+1].second);
        }
        if(y[i].first == y[i+1].first){
            uft.Union(y[i].second, y[i+1].second);
        }
    }
    set<int> group;
    for(int i=0; i<n; i++){
        group.insert(uft.Find(i));
    }
    int ans = n-1;
    if((int)group.size() != 1) ans += group.size() -wallside;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main(void){
    int A,B,C;
    int temp_num;
    
    cin>>A;
    cin>>B;
    cin>>C;
    
    temp_num=A;
    A=B;
    B=temp_num;
    
    temp_num=A;
    A=C;
    C=temp_num;
    
    cout<<A<<' '<<B<<' '<<C;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int a,b; cin>>a>>b;
	int c=b-a,jud=0;
	for(int i=c;i>0;i--) jud+=i;
	cout<<jud-b<<endl;
	return 0;
}


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


int main() {
	long long n;
	cin >> n;
	long long ans=0;
	long long ret=10;
	while(n>=ret){
		ans += (n/ret);
		ret *= 5;
	}
	if(n == 0 || n % 2 == 1){
		cout << 0 << endl;
	}else{
		cout << ans << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int x;
	int i=1;
	while(1){
		cin>>x;
		if(x==0){
			break;
		}
		cout<<"Case"<<" "<<i<<":"<<" "<<x<<endl;
		
		i++;
	}
	return 0;
}


Measured memory_bytes: 3048
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n=int(input())
aa=LLI(n)

def main():
    ans=sum(sum(ar) for ar in aa)//2
    fin=set()
    for w in range(n):
        aaw=aa[w]
        for u in range(n):
            if u==w:continue
            aau=aa[u]
            for v in range(u):
                if v==w:continue
                d=aau[w]+aaw[v]
                if d<aau[v]:
                    print(-1)
                    exit()
                if d==aau[v] and (u,v) not in fin:
                    ans-=d
                    fin.add((u,v))
    print(ans)

main()


Measured memory_bytes: 50524
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N; cin >> N;
  int ans = VERYBIG;
  for(int i = 1; i*i <= N; i++){
    if(N % i != 0) continue;
    int p = N/i;
    ans = min(ans, i+p-2);
  }
  cout << ans << endl;
}

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

int main(void) {
    double D,T,S; cin >> D >> T >> S;
    double cl = (double)(D/S);
    if(cl<=T) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    ll sum=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        sum^=a[i];
    }
    for (int i = 0; i < n; ++i) {
        ll ans=sum^a[i];
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 4672
A, B = map(int, input().split())
cnt=0
for i in range(A, B+1) :
    str_i=str(i)
    rev_i=str_i[::-1]
    t=len(str_i)//2
    if len(str_i)%2==1 and str_i[:t+1] == rev_i[:t+1] :
        cnt=cnt+1
print(cnt)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                if len(players) > 1:
                    players.popleft()
            else:
                players.rotate(-1)

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8512
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
    char s[11], t[11];
    scanf("%s %s", s, t);
    int num = strlen(s);
    int ans =  1;
    for(int i=0;i<num;i++){
        if(s[i] != t[i]){
            ans--;
            break;
        }
    }
    if (ans == 1) printf("Yes");
    else printf("No");
    return 0;
}

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

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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    
    mint sum = 2;
    sum = sum.pow(n);

    mint fact_a = 1;
    for (int i = 0; i < a; i++) {
        fact_a *= (n - i);
    }

    mint A = fact_a * c.ifact[a];

    mint fact_b = 1;
    for (int i = 0; i < b; i++) {
        fact_b *= (n - i);
    }
    mint B = fact_b * c.ifact[b];
    
    cout << sum - A - B - 1 << endl;
    return 0;
}



Measured memory_bytes: 6192
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	initial = [5]string{"M", "A", "R", "C", "H"}
	m       = map[string]int{}
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	for sc.Scan() {
		switch string(sc.Text()[0]) {
		case "M", "A", "R", "C", "H":
			m[string(sc.Text()[0])]++
		}
	}

	fmt.Println(combination())
}

func combination() int {
	var count int

	for i := 0; i < len(initial)-2; i++ {
		for j := i + 1; j < len(initial)-1; j++ {
			for k := j + 1; k < len(initial); k++ {
				count += m[initial[i]] * m[initial[j]] * m[initial[k]]
			}
		}
	}

	return count
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int MAX_N = 100050;
int n, m;
queue<int> adj[MAX_N];

bool isValid(deque<int>& path) {
	int x = path.front();
	int y = path.back();
	return adj[x].empty() && adj[y].empty();
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> m;
	rep(i,0,m) {
		int a, b;
		cin >> a >> b;
		adj[a].push(b);
		adj[b].push(a);
	}
	deque<int> path;
	vector<bool> vis(n+1);
	vis[1] = true;
	vis[adj[1].front()] = true;
	path.push_back(1);
	path.push_back(adj[1].front());
	adj[1].pop();

	while(!isValid(path)) {
		int x = path.front();
		int y = path.back();
		queue<int>& p = adj[x];
		queue<int>& q = adj[y];
		while(!p.empty()) {
			int f = p.front();
			p.pop();
			if(vis[f]) continue;
			path.push_front(f);
			vis[f] = true;
			break;
		}
		while(!q.empty()) {
			int f = q.front();
			q.pop();
			if(vis[f]) continue;
			path.push_back(f);
			vis[f] = true;
			break;
		}
	}

	cout << path.size() << '\n';
	for(auto it = path.begin(); it != path.end(); ++it) {
		cout << *it << ' ';
	}
	return 0;
}


Measured memory_bytes: 68480
k=int(input())
queue=[i for i in range(1,10)]
if k <10:
    print(k)
else:
    l=0
    while l+9 < k:
        x=queue.pop(0)
        if x%10 != 0:
            queue.append(10*x+x%10-1)
            l+=1
        if l+9==k:
            break
        queue.append(10*x+x%10)
        l+=1
        if l+9==k:
            break
        if x%10 != 9:
            queue.append(10*x+x%10+1)
            l+=1
    print(queue[-1])


Measured memory_bytes: 5840
n,m,k = map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

aa = [0]
bb = [0]

for i in range(n):
	aa.append(a[i]+aa[i])

for i in range(m):
	bb.append(b[i]+bb[i])

ans=0
j=m
for i in range(n+1):
	if aa[i]>k:
		break
	while bb[j]>k-aa[i]:
		j-=1
	ans=max(i+j,ans)
print(ans)

Measured memory_bytes: 47500
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 100001;
int n, q;
int a[N];
int pr[N];
int pref[N][2];
int getcnt(int l, int r) {
    if (r < l) return 0;
    else return upper_bound(a, a + n, r) - lower_bound(a, a + n, l);
}   
int getsum(int l, int r) {
    if (r < l) return 0;
    else return pr[r + 1] - pr[l];
}   
int getsum(int l, int r, bool t) {
    if (r < l) return 0;
    else return pref[r + 1][t] - pref[l][t];
}   
int getbetter(int x, int m) {
    if (a[m] == x) {
        return 0;
    }
    else if (a[m] < x) {
        int r = x - a[m];
        return getcnt(a[m] + 1, x + r - 1);
    }
    else {
        int r = a[m] - x;
        return getcnt(x - r, a[m] - 1);
    }   
}   
void get1(int x, int k, int &wl, int &wr) {
    if (k == 0) {
        wl = wr = -1;
        return;
    }   
    int p = upper_bound(a, a + n, x) - a;
    int l = -1, r = p;
    while (l < r - 1) {
        int m = (l + r) >> 1;
        if (getbetter(x, m) >= k) l = m;
        else r = m;
    }   
    wl = r;
    l = p - 1, r = n;
    while (l < r - 1) {
        int m = (l + r) >> 1;
        if (getbetter(x, m) >= k) r = m;
        else l = m;
    }   
    wr = l;
}   
void get2(int k, int &l, int &r) {
    l = n - k;
    r = n - 1;
}   
bool check(int x, int k) {
    int l1, r1, l2, r2;
    get1(x, k >> 1, l1, r1); get2((k + 1) >> 1, l2, r2);
    return r1 < l2;
}   
int x[N];
int per[N], ans[N];
bool comp(int i, int j) {
    return x[i] < x[j];
}   
signed main() {
    #ifdef HOME
        freopen("input.txt", "r", stdin);
    #else 
        ios_base::sync_with_stdio(0);
        cin.tie(0);    
    #endif
    cin >> n >> q;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < q; ++i) cin >> x[i];
    for (int i = 0; i < n; ++i) {
        pref[i + 1][i&1] = pref[i][i&1] + a[i];
        pref[i + 1][(i&1)^1] = pref[i][(i&1)^1];
        pr[i + 1] = pr[i] + a[i];
    }   
    for (int i = 0; i < q; ++i) per[i] = i;
    sort(per, per + q, comp);
    int r = n + 1;
    for (int ii = 0; ii < q; ++ii) {
        int i = per[ii];
        while (r && !check(x[i], r - 1)) --r;
        int l = r - 1;
        int l1, r1, l2, r2;
        get1(x[i], l >> 1, l1, r1); get2((l + 1) >> 1, l2, r2);
        int p;
        if (l1 == -1) {
            p = n - 2;
        }   
        else {
            p = l1 - 1;
        }
        bool t;
        if (l & 1) {
            t = (p+1)&1;
        }
        else {
            t = p&1;
        }   
        ans[i] = getsum(l2, r2) + getsum(0, p, t); 
    }   
    for (int i = 0; i < q; ++i) {
        cout << ans[i] << '\n';
    }   
    #ifdef HOME
        cerr << "TIME : " << (double)clock()/CLOCKS_PER_SEC<<'\n';
    #endif
}   

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

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define INF 1e9


ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

 
int main(){
    ll a,b; cin >> a >> b;
    
    cout << lcm(a, b) << endl;
    
    
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
    int R,G,B,N,ans=0;
    cin >> R >> G >> B >> N;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            if(R*i+G*j>N) break;
            if((N-(i*R+j*G))%B==0){
            ans+=1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n,m;
  while(cin>>n>>m, n+m){
    int (*b)[1300]=new int[10002][1300];
    int r,q;
    for(cin>>r;r>0;r--){
      int t,p,s,l;
      cin >> t >> p >> s >> l;
      while(t<1280) b[s][t++]+=(l!=0?l:-1);
    }
    for(cin>>q;q>0;q--){
      int t1,t2,m,a=0;
      cin >> t1 >> t2 >> m;
      while(t1<t2) a+=(b[m][t1++]>0?1:0);
      cout << a << endl;
    }
    delete [] b;
  }
  return 0;
}

Measured memory_bytes: 1052
import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
InsertionSort(a);
out.flush();
}
}

static void InsertionSort(int[] a){
getValue(a);
for(int i=1;i<a.length;i++){
int j=i-1;
int tmp=a[i];
while(j>=0&&a[j]>tmp){
a[j+1]=a[j];
a[j]=tmp;
j--;
}
getValue(a);
}
}

private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
}

Measured memory_bytes: 23976
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    string s;
    cin >> s;
    repi(i,s.size(),1){
        if(s[i] == s[i - 1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<vector<int> > abc(n, vector<int>(3));
    rep(i, n)rep(j, 3) cin >> abc[i][j];

    vector<vector<int> > dp(n, vector<int> (3));
    rep(i, 3) dp[0][i] = abc[0][i];
    srep(i, 1, n) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i][j], dp[i - 1][k] + abc[i][j]);
            }
        }
    }
    int ans = 0;
    rep(i, 3) chmax(ans, dp[n - 1][i]);
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 14088
def fanction(n):
    listIn = []
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            cnt_in = 0
            while tmp % i ==0:
                cnt_in += 1
                tmp //= i
            listIn.append([i, cnt_in])
 
    if tmp != 1:
        listIn.append([tmp, 1])
 
    return listIn
    
N = int(input())
 
arr = fanction(N)
 
tmp = 1
count = 0
for a, b in arr:
    while 'true':
        if b >= tmp:
            b -= tmp
            count += 1
            tmp += 1
        else:
            tmp = 1
            break
 
print(count)

Measured memory_bytes: 63320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      Boolean[][] checkCards = {
        {false,false,false,false,false,false,false,false,false,false,false,false,false,},
        {false,false,false,false,false,false,false,false,false,false,false,false,false,},
        {false,false,false,false,false,false,false,false,false,false,false,false,false,},
        {false,false,false,false,false,false,false,false,false,false,false,false,false,} };
      // StringBuilder result = new StringBuilder();
      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int a,b;

      for(int i = 0; i < n; i++) {
        lines = br.readLine().split(" ");
        a = suitToInt(lines[0]);
        b = Integer.parseInt(lines[1]);
        checkCards[a][b-1] = true;
      }

      for(int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 13; j++ ) {
          if(!checkCards[i][j]) System.out.println(intToSuit(i) + " " + (j+1));
        }
      }
    }
  }

  public static int suitToInt( String suit ) {
    switch( suit ) {
      case "S": return 0;
      case "H": return 1;
      case "C": return 2;
      default : return 3;
    }
  }
  public static String intToSuit( int r ) {
    switch( r ) {
      case 0  : return "S";
      case 1  : return "H";
      case 2  : return "C";
      default : return "D";
    }
  }
}


Measured memory_bytes: 24244
#include<stdio.h>
#include<string.h>
 
int main(void){
  
  int ans,i,x;
  char str[100];
 
  memset(str,'a',sizeof(str));
  ans=0;
  while(~scanf("%s",str)){
    for(i=0;i<strlen(str);i++)
      if(str[i]<='9' && str[i]>='0'){
	for(x=0;str[i]<='9'&&str[i]>='0'&&i<strlen(str);i++){
	  x*=10;
	  x+=str[i]-'0';
	}
	i--;
	ans+=x;
      }
    
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 0
/*ITS FUCKING O(N) now
GET ACCEPTED FOR FUCK'S SAKE*/


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

long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;

#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int main()
{long long int a,b,c,k;
	cin>>a>>b>>c>>k;
  if(k<=a)
  {
  	cout<<k;
  }
  else if(k>a&&k<=a+b)
  {
  	cout<<a;
  }
  else if(k>a+b&&k<=a+b+c)
  {
  	cout<<a+a+b-k;
  }

    return 0;
}

Measured memory_bytes: 3556
#include <cstdio>
#include <algorithm>

int main() {
  int W, a, b;
  scanf("%d %d %d", &W, &a, &b);

  if (a > b) std::swap(a, b);

  if (a + W < b) {
    printf("%d\n", b-(a+W));
  } else {
    puts("0");
  }

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	vector<ll> f(n + 1, 0);
	REP(i, n) {
		for(int j = i + 1; j <= n; j += (i + 1)) {
			f[j]++;
		}
	}
	ll result = 0;
	REP(i, n) { result += (i + 1) * f[i + 1]; }
	cout << result << endl;
}


Measured memory_bytes: 81380
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()

for i in range(N-K):
    if A[i] >= A[i+K]:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 33064
#include <stdio.h>
int main(void) {
	int d, i;
	
	while(scanf("%d", &d)!=EOF){
		int sum=0;
		for(i=d;i<=600-d;i+=d){
			sum+=i*d*i;
		}
		
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 596
import Control.Applicative
import Control.Monad
import Data.List

f :: Int -> Int -> Int
f a b = max (length $ show a) (length $ show b)

main :: IO ()
main = do
    n <- readLn :: IO Int
    let a1 = do
        s <- [1 .. floor (sqrt (fromIntegral n))]
        guard $ n `mod` s == 0
        return s
    let a2 = fmap (\d -> f d (n `div` d)) a1
    print $ minimum a2

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3+2;
int nums[MAXN];
int main() {
  int n,k;
  cin>>n>>k;
  for (int i=0; i<n; i++) {
    cin>>nums[i];
  }
  
  sort(nums, nums+n);
  
  int ans = 0;
  for (int i=0; i<k; i++) {
    ans += nums[i];
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
  int n,m; cin >> n >> m;
  vector<bool> vis(n + 1, false);
  bool ans = false;

  rep(i,m) {
    int a,b; cin >> a >> b;
    assert(a >= 1 && a < b && b <= n);
    if(a == 1) {
      if(vis[b]) {
        ans = true;
      }
      vis[b] = true;
    }
    else if(b == n) {
      if(vis[a]) {
        ans = true;
      }
      vis[a] = true;
    }
  }

  if(!ans) cout << "IM";
  cout << "POSSIBLE" << endl;

  return 0;
}



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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    //string S;
    cin >> N;
    vector<string> S(N);
    REP(i,N){
        cin >> S.at(i);
    }

    sort(S.begin(), S.end());

    vector<ll> vec(5);
    
    REP(i,5){
        vec.at(i) = 0;
    }
    REP(i,N){
        if(S.at(i)=="AC"){
            vec.at(0)++;
        }
        else if(S.at(i)=="WA"){
            vec.at(1)++;
        }
        else if(S.at(i)=="TLE"){
            vec.at(2)            ++;
        }
        else{
            vec.at(3)++;
        }
    }

    cout << "AC x " << vec.at(0) << endl;
    cout << "WA x " << vec.at(1) << endl;
    cout << "TLE x " << vec.at(2) << endl;
    cout << "RE x " << vec.at(3) << endl;
}


Measured memory_bytes: 6368