akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func toggle(r rune) rune {
	if r == '0' {
		return '1'
	}
	return '0'
}

func main() {
	var s string
	fmt.Scan(&s)

	sum := 0
	var now_r rune
	for i, r := range s {
		if i == 0 {
			now_r = r
		} else if r == now_r {
			now_r = toggle(r)
			sum++
		} else {
			now_r = r
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    ll ans = 0;
    
    rrep(i, n) {
        int surplus = (a[i] + ans) % b[i];
        
        if (surplus != 0) {
            ans += b[i] - surplus;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int N,A,res=1;
	cin>>N;
	int used[N]={};
	rep(i,N){
		cin>>A;
		used[A]++;
		if(used[A]>2 || used[0]>1)res=0;
	}
	rep(i,N/2)res=(res*2)%1000000007;
	cout<<res<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int sx = 0, sy = 0, st = 0;
    int t, x, y;
    bool ans = true;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> t >> x >> y;
        int remain = abs(t - st) - (abs(x - sx) + abs(y - sy));
        if (remain < 0 || remain % 2 == 1){
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
using namespace std;

int main(void){
	
	int a,b,k,i;
	cin>>a>>b>>k;
	for(i=0;i<k;i++){
		if(i%2==0){
			if(a%2==1)a--;
			b+=a/2;
			a/=2;
		}
		else{
			if(b%2==1)b--;
			a+=b/2;
			b/=2;
		}
	}
	cout<<a<<" "<<b;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

string s;
int gx, gy;

char dp[8001][8001*2][2];

string ts;
int tar;

bool f(int d, int nx, int dir){
	// cout << ts << " " << d << " " << nx << " " << dir << endl;
	if(d == ts.size()){
		if(nx == tar)return true;
		else return false;
	}
	if(dp[d][nx][dir]!=-1)return dp[d][nx][dir];
	bool can = false;

	if(ts[d] == 'T'){
		can |= f(d+1,nx,dir);
		can |= f(d+1,nx,(dir+1)%2);
	}else{
		can |= f(d+1,nx+(dir?1:-1),dir);
	}

	return dp[d][nx][dir] = can;
}

int main(){
	cin >> s >> gx >> gy;
	string xs;
	string ys;
	int mode = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i] == 'T'){mode++;mode%=2;}
		if(mode){
			ys.push_back(s[i]);
		}else{
			xs.push_back(s[i]);
		}
	}
	gx+=8000;
	gy+=8000;
	fill_n(**dp,8001*8001*2*2,-1);
	ts = xs;tar = gx;
	bool canx = f(0,8000,1);
	fill_n(**dp,8001*8001*2*2,-1);
	ts = ys;tar = gy;
	bool cany = f(0,8000,0);
	if(canx && cany){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 251008
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define id(o,p) ((o-1)*m+p)
#define inf 100000000
#define N 1000010
struct node
{
	int to,next,f;
}e[N];
char ch[1010],a[110][110];
int size,n,m,nm,maxx,S,T,g[N],he[N],dep[N],q[N],i,j,ans;
void add1(int o,int p,int q) {e[++size].to=p,e[size].next=g[o];g[o]=size,e[size].f=q;}
void add(int o,int p,int q) {add1(o,p,q);add1(p,o,0);/*printf("%d-->%d f=%d\n",o,p,q);*/}
bool bfs()
{
	for (i=0;i<=maxx;i++) dep[i]=0;
	dep[S]=1;
	int head=0,tail=0;
	q[++tail]=S;
	while (head!=tail)
	{
		int x=q[++head];
		for (int k=g[x];k;k=e[k].next)
		{
			int y=e[k].to;
			if (dep[y]==0&&e[k].f)
			{
				dep[y]=dep[x]+1;
				q[++tail]=y;
			}
		}
	}	
	return dep[T]!=0;
}
int dfs(int x,int flow)
{
	if (x==T) return flow;
	int now=0,used=0;
	for (int k=he[x];k;k=e[k].next)
	{
		int y=e[k].to;
		if (dep[y]==dep[x]+1&&e[k].f)
		{
			now=dfs(y,min(flow-used,e[k].f));
			used+=now;
			e[k].f-=now;
			e[k^1].f+=now;
			if (e[k].f) he[x]=k;
			if (used==flow) break;
		}
	}
	if (used==0) dep[x]=-1;
	return used;
}
void dinic()
{
	while (bfs())
	{
		for (int i=1;i<=maxx;i++) he[i]=g[i];
		ans+=dfs(S,inf);
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	size=1;
	nm=n*m;
	maxx=2*nm+n+m;
	for (i=1;i<=n;i++)
	{
		scanf("%s",ch);
		for (j=1;j<=m;j++)
		{
			a[i][j]=ch[j-1];
			if (a[i][j]=='S') a[i][j]='o',S=id(i,j)+nm;
			if (a[i][j]=='T') a[i][j]='o',T=id(i,j);
			if (a[i][j]=='o')
			{
				add(id(i,j),id(i,j)+nm,1);
				add(id(i,j)+nm,i+2*nm,inf);
				add(i+2*nm,id(i,j),inf);
				add(id(i,j)+nm,j+2*nm+n,inf);
				add(j+2*nm+n,id(i,j),inf);
			}
		}
	}
	dinic();
	if (ans>=inf) printf("-1\n");else printf("%d\n",ans);
}

Measured memory_bytes: 10624
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, k; cin >> n >> k;
	vector<LL> v(n+2);

	for (int i = 1; i < n+1; i++) {
		cin >> v[i];
	}

	vector<vector<LL>> dpr(n+1, vector<LL>(k+1,-INF));
	dpr[0][0] = 0;

	for (int i = 1; i < n+1; i++) {
		for (int j = 1; j < k+1; j++) {

			//1回使って、宝石をとる
			if (j >= 1) {
				dpr[i][j] = max(dpr[i][j], dpr[i - 1][j - 1] + v[i]);
			}

			//2回使って、宝石をとって、捨てる
			if (j >= 2) {
				dpr[i][j] = max(dpr[i][j], dpr[i - 1][j - 2]);
			}
			
		}
	}

	//集計にvは使わないのでreverseして↑をまとめて使いまわす
	vector<vector<LL>> dpl(n + 1, vector<LL>(k + 1,-INF));
	dpl[0][0] = 0;

	reverse(v.begin(), v.end());


	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < k + 1; j++) {

			//1回使って、宝石をとる
			if (j >= 1) {
				dpl[i][j] = max(dpl[i][j], dpl[i - 1][j - 1] + v[i]);
			}

			//2回使って、宝石をとって、捨てる
			if (j >= 2) {
				dpl[i][j] = max(dpl[i][j], dpl[i - 1][j - 2]);
			}

		}
	}

	//結果の集計

	
	//全部取らないをいつでも選択できるので、0で初期化
	LL ans = 0;
	
	//操作回数を左右に振り分け
	for (int r = 0; r < k+1; r++) {
		for (int l = 0; l < k+1; l++) {
			if (r + l > k)continue;

			
			for (int i = 0; i < n+1; i++) {
				for (int j = 0; j < n+1; j++) {
					if (i + j > n)continue;
					
					ans = max(ans, dpr[i][r] + dpl[j][l]);

				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
M, D = [int(i) for i in input().split()]

ans = 0
for m in range(1, M+1):
  for d in range(22, D+1):
    d1 = int(str(d)[0])
    d2 = int(str(d)[1])
    if m == d1 * d2 and d1>=2 and d2>=2:
      ans += 1
print(ans)

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

using namespace std;

int a[100005];

int main() {
	int n, k, q;
	
	scanf("%d%d%d", &n, &k, &q);
	
	for (int i = 0; i < q; i++) {
		int x;
		scanf("%d", &x);
		a[x]++;
		k--;
	}
	
	for (int i = 1; i <= n; i++) {
		if (a[i] + k <= 0) printf("No\n");
		else printf("Yes\n");
	}
}


Measured memory_bytes: 1024
import numpy as np
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))

idxs = np.arange(n)
L, R = idxs + a, idxs - a

count = 0
d = defaultdict(int)
for i in range(n-1):
    d[L[i]] += 1
    count += d[R[i+1]]

print(count)

Measured memory_bytes: 84748
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
 
const int N = 2000;
vector<int>d(N+1);
vector<int>dp(N+1);
vector<int>inq(N+1);
vector<vector<pair<int,int>>>g(N+1);
int n , x , y ;

void spfa(int s)
{
	fill(inq.begin(),inq.begin()+n+1,0);
	fill(d.begin(),d.begin()+n+1,1e15);
	
	queue<int>q;
	inq[s]=1;
	d[s]=0;
	q.push(s);
	while( q.size() )
	{
		int u=q.front();q.pop();
		inq[u]=0;
		for(auto it:g[u])
		{
			int v=it.first;
			int w=it.second;
			if( d[v] > d[u] + w)
			{
				d[v]=d[u]+w;
				if(!inq[v])
				{
					inq[v]=1;
					q.push(v);
				}
			}
		}
	}
}

int32_t main()
{
	IOS	
	cin >> n >> x >> y;
	
	for(int i=1;i<n;i++)
	{
		g[i].push_back({i+1,1});
		g[i+1].push_back({i,1});
	}
	g[x].push_back({y,1});
	g[y].push_back({x,1});
	
	for(int i=1;i<=n;i++)
	{
		spfa(i);
		for(int i=1;i<=n;i++)
		{
			dp[d[i]]++;
		}
	}
	for(int i=1;i<n;i++)
	cout<<dp[i]/2<<" ";
	cout<<endl;
	
}


Measured memory_bytes: 512
package main

// echo '\\/_' | go run scripts/alds/1_3_D_cross-section-diagram.go

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func stringifyArray(arr []float64) {
	for i := 0; i < len(arr); i++ {
		if i == len(arr)-1 {
			fmt.Printf("%.0f\n", arr[i])
		} else {
			fmt.Printf("%.0f ", arr[i])
		}
	}
}

var infty = 100000

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)

	line := nextString()
	nPoints := len(line) + 1

	height := 0
	heights := make([]int, nPoints)
	heights[0] = 0
	for i := 0; i < len(line); i++ {
		if line[i] == '\\' {
			height--
		} else if line[i] == '/' {
			height++
		}
		heights[i+1] = height
	}

	left := make([]int, nPoints)
	leftMax := -infty
	for i := 0; i < nPoints; i++ {
		leftMax = max(leftMax, heights[i])
		left[i] = leftMax
	}

	right := make([]int, nPoints)
	rightMax := -infty
	for i := nPoints - 1; i >= 0; i-- {
		rightMax = max(rightMax, heights[i])
		right[i] = rightMax
	}

	// fmt.Println(heights)
	// fmt.Println(left)
	// fmt.Println(right)

	areas := []float64{}
	currentArea := 0.0
	for i := 0; i < nPoints-1; i++ {
		l := heights[i]
		r := heights[i+1]

		areaEdgeHeight := min(left[i], right[i+1])
		maxHeightOfPoint := max(l, r)
		minHeightOfPoint := min(l, r)
		if minHeightOfPoint < areaEdgeHeight {
			currentArea += float64(areaEdgeHeight - maxHeightOfPoint)
			if l != r {
				currentArea += 0.5
			}
		}
		// fmt.Println(l, r, areaEdgeHeight, minHeightOfPoint, maxHeightOfPoint, currentArea)
		if currentArea > 0 && r == areaEdgeHeight {
			areas = append(areas, currentArea)
			currentArea = 0
		}
	}

	totalArea := 0.0
	for _, a := range areas {
		totalArea += a
	}
	fmt.Println(int(totalArea))
	if len(areas) > 0 {
		fmt.Print(len(areas), " ")
		stringifyArray(areas)
	} else {
		fmt.Println(0)
	}
}



Measured memory_bytes: 1796
i = int(input())
l= [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[i-1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long N;
    cin>>N;
    long A[N],B[N],C[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    sort(A,A+N);
    sort(C,C+N);
    long ans=0;
    for(int i=0;i<N;i++){
        long a=lower_bound(A,A+N,B[i])-A;
        long c=N-(upper_bound(C,C+N,B[i])-C);
        ans+=a*c;
    }
    cout<<ans;
    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  while(n!=0)
  {
    vector<int> times(n,0);
    vector<int> timesto(n,0);
    int i;
    rep(i,n)
    {
      string hms;cin>>hms;
      string h=hms.substr(0,2);
      string m=hms.substr(3,2);
      string s=hms.substr(6,2);
      int th=atoi(h.c_str());
      int tm=atoi(m.c_str());
      int ts=atoi(s.c_str());
      times[i]=th*3600+tm*60+ts;
      cin>>hms;
      h=hms.substr(0,2);
      m=hms.substr(3,2);
      s=hms.substr(6,2);
      th=atoi(h.c_str());
      tm=atoi(m.c_str());
      ts=atoi(s.c_str());
      timesto[i]=th*3600+tm*60+ts;
    }
    vector<int> sum(86401,0);
    rep(i,n)
    {
      sum[times[i]]++;
      sum[timesto[i]]--;
    }
    rep(i,86400)
    {
      sum[i+1]+=sum[i];
    }
    int ans=0;
    rep(i,86401)
    {
      ans=max(ans,sum[i]);
    }
    cout<<ans<<endl;
    cin>>n;
  }
}




Measured memory_bytes: 3460
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

signed main()
{
    int N = 50;
    int data[N];
    int K;
    cin >> K;
    int syou = K / N;
    int amari = K - syou * N;
    /*
    fill(data, data + N, N - 1 + syou - amari);
    data[0] = N - 1 + syou + amari * N;
    */
    fill(data, data + N, N - 1 + syou - amari);
    fill(data, data + amari, 2 * N + syou - amari);
    cout << N << endl;
    rep(i, N)
    {
        cout << data[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ld rad;
cin>>rad;
ld pi=3.14159265359;
ld cir=2*pi*rad;
cout<<fixed<<setprecision(10)<<cir;
}


Measured memory_bytes: 3804
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

int main(){
    char c;
    cin>>c;
    cout<<(char)(c+1);
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

def solve():
    MOD = 10**9 + 7
    maxA = 10**6

    def getPrimeFactors(x):
        anss = []
        while x%2 == 0:
            anss.append(2)
            x //= 2
        for d in range(3, int(x**0.5)+1, 2):
            while x%d == 0:
                anss.append(d)
                x //= d
        if x != 1:
            anss.append(x)
        return anss

    N = int(input())
    As = list(map(int, input().split()))

    cntP = Counter()
    for A in As:
        PFs = getPrimeFactors(A)
        for key, num in Counter(PFs).items():
            cntP[key] = max(cntP[key], num)

    lcmA = 1
    for key, num in cntP.items():
        lcmA *= pow(key, num, MOD)
        lcmA %= MOD

    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs

    invs = getInvs(maxA, MOD)

    ans = 0
    for A in As:
        ans += lcmA * invs[A]
        ans %= MOD

    print(ans)

solve()


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

int main(){
 int N; cin >> N;
 vector<int> a(N);
 int alice = 0, bob = 0;
 int ans;

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

  sort(a.begin(), a.end(), greater<int>());
  for(int i = 0; i <= N - 1; i = i + 2){
    alice += a[i];
    bob += a[i+1];
  }
  
  ans = alice - bob;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int aliceStart = sc.nextInt();
		int aliceEnd = sc.nextInt();
		int bobStart = sc.nextInt();
		int bobEnd = sc.nextInt();
		int time = 0;

		if (aliceStart >= bobStart) {
			if (aliceEnd >= bobEnd) {
				time = bobEnd - aliceStart > 0 ? bobEnd - aliceStart : 0;
			} else {
				time = aliceEnd - aliceStart;
			}
		} else {
			if (bobEnd >= aliceEnd) {
				time = aliceEnd - bobStart > 0 ? aliceEnd - bobStart : 0;
			} else {
				time = bobEnd - bobStart;
			}
		}

		System.out.println(time);

	}

}


Measured memory_bytes: 20820
#include <iostream>
#include <cmath>
using namespace std; 
int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	int dA = abs(x-a);
	int dB = abs(x-b);
	if(dA<dB) cout << "A" << endl;
	else cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <map>
using namespace std;
#define ll long long

int main () {
  ll n, m;
  cin >> n >> m;
  map<ll, ll> box;
  ll v[9] = {
   2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 
  };
  for (ll i = 1; i <= 9; i++) {
    box[i] = v[i - 1];      
  }  
  ll a[m], b[m];
  for (ll i = 0; i < m; i++) {
    cin >> a[i];
  }
  sort(a, a + m);
  for (ll i = 0; i < m; i++) {
    b[i] = box[a[i]];  
  }
  string dp[100000 + 1];
  for (ll i = 0; i <= n; i++) {
    dp[i] = "0";
    string max = "";
    for (ll j = 0; j < m; j++) {
      if (i - b[j] == 0) {
        if (dp[i][0] < ('0' + a[j])) {
          dp[i][0] = '0' + a[j];  
        }        
      }  
      if (i - b[j] > 0 && dp[i - b[j]] != "0") {
        string sub = to_string(a[j]) + dp[i - b[j]]; 
        if (sub.size() > max.size()) {
          max = sub;  
        }
        else if (max.size() == sub.size() && string(sub).compare(max) > 0) {
          max = sub;
        }
      }
    }   
    if (max != "") {
      dp[i] = max;  
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 27264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

  vector<vector<P>> ixy(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    ixy[i].resize(a);

    for (int j = 0; j < a; j++) {
      cin >> ixy[i][j].first >> ixy[i][j].second;

      ixy[i][j].first--;
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    // bit全探索
    bitset<20> bit(i);

    bool ok = true;

    set<int> kinds;

    for (int j = 0; j < n; j++) {
      if (bit[j]) {  // ビットが立っている = 正直物としてkindsに何人目かをset
        kinds.emplace(j);
      }
    }

    // 証言と矛盾しないかをチェック
    for (auto witness : kinds) {
      for (auto p : ixy[witness]) {
        int who = p.first;
        int f = p.second;

        if (!f && kinds.find(who) != kinds.end())
          ok = false;  // 証言でunkindな人がkind setにいたら矛盾
        if (f && kinds.find(who) == kinds.end())
          ok = false;  // 証言でkindな人がkind setにいなかったら無常
      }
    }

    if (ok) {
      // 矛盾がなければあり得る
      ans =
          max(ans, (int)kinds.size());  // あり得る場合は正直物の数を数えてchmax
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n, m = gets.split().map(&:to_i)
ab = Array.new(m)
graph = Array.new(n+1).map{Array.new()}
dist = Array.new(n+1, -1)
queue = []

m.times do |i|
  ab[i] = gets.split().map(&:to_i)
end

ab.each do |a, b|
  graph[a] << b
  graph[b] << a
end

dist[1] = 1
queue.push(1)

while !queue.empty?()
  v = queue.shift

  graph[v].each do |i|
    next if dist[i] != -1
    dist[i] = v
    queue.push(i)
  end
end

if dist.count(-1) > 1
  puts 'No'
else
  puts 'Yes'
  (2..n).each do |i|
    puts dist[i]
  end
end



Measured memory_bytes: 42748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define FASTIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N = 200005, M = 1000000007, BIG = 0x3f3f3f3f;

int ct = 0;
int n;
int r;

bool Read() {
  cin >> n;
  if (cin.eof())
    return 0;
  cin >> r;

  return 1;
}

void Process() {
  if (n >= 10)
    cout << r << "\n";
  else
    cout << r + 100 * (10 - n) << "\n";
}

int main() {
  FASTIO();

  while (Read())
    Process();

  return 0;
}

Measured memory_bytes: 256
a,b,c=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

#aとcの入れ替え
temp = b
b = a
a =temp

#aとcの入れ替え
temp = c
c = a
a =temp

#出力
print(a,b,c)

Measured memory_bytes: 3060
use proconio::input;
use std::string::String;

fn main() {
    input! {
        S: String, // read as String
        T: String, 
    }

    let cs: Vec<char> = S.chars().collect();
    let ct: Vec<char> = T.chars().collect();
    let mut count: u32;
    count = 0;
   
    for i in 0..S.len(){
      if cs[i] != ct[i]{
          count = count +1;
      }
    }
    
    println!("{}", count);

}


Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int N, X, T;
    cin>>N>>X>>T;
    int c;
    if(N%X==0)
     c=N/X;
    else
     c=(N/X)+1;
    cout<<c*T<<endl;
    
}

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

#define sai(j,n) for(sei j=0;j<sei(n);++j)
#define hsai(j,n) for(sei j=sei(n)-1;j>=0;--j)
#define kan(j,m,n) for(sei j=m;j<sei(n);++j)
#define hkan(j,m,n) for(sei j=sei(n)-1;j>=sei(m);--j)
#define zen(v) (v).begin(),(v).end()
#define yu(v) v.erase(unique(zen(v)), v.end());
//#define syutu(v) si(a, (v).size()) {cout << v[a];if(a != v.size()-1)cout << " ";else cout << endl;}
#define mug 10000000111;
#define yo 10000000711;
#define kyo 1e-9;

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

using namespace std;
typedef long long sei;
typedef long double xyo;
typedef vector<sei> vs;
typedef vector<xyo> vx;
typedef vector<vs> vvs;
typedef vector<vx> vvx;
typedef pair<sei, sei> ks;
typedef bool singi;

sei dai(sei a, sei b){return max(a,b);}
sei syo(sei a, sei b){return min(a,b);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sei n;
    cin >> n;
    vs a(n);
    sai(j,n){
        cin >> a[j];
    }
    sort(a.begin(),a.end());
    cout << a[n-1] - a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int n;

  vector<int> num(100001);
  vector<int> num2(100001);
  map<int, int> mp1;
  map<int, int> mp2;
  cin >> n;

  REP(i, n) {
    int x;
    cin >> x;
    if (i % 2 == 0) {
      if (mp1.count(x))
        mp1.at(x)++;
      else
        mp1[x] = 1;
    } else {
      if (mp2.count(x))
        mp2.at(x)++;
      else
        mp2[x] = 1;
    }
  }
  int X1, M1 = 0, X2, M2 = 0;
  int Y1, M3 = 0, Y2, M4 = 0;

  for (auto p1 : mp1) {
    auto k = p1.first;
    auto v = p1.second;
    if (M1 < v) {
      X1 = k;
      M1 = v;
    }
  }

  mp1.erase(X1);

  for (auto p1 : mp1) {
    auto k = p1.first;
    auto v = p1.second;
    if (M3 < v) {
      Y1 = k;
      M3 = v;
    }
  }

  for (auto p2 : mp2) {
    auto k = p2.first;
    auto v = p2.second;
    if (M2 < v) {
      X2 = k;
      M2 = v;
    }
  }
  mp2.erase(X2);

  for (auto p2 : mp2) {
    auto k = p2.first;
    auto v = p2.second;
    if (M4 < v) {
      Y2 = k;
      M4 = v;
    }
  }

  if (X1 != X2)
    cout << n - (M1 + M2) << endl;
  else
    cout << n - max(M1 + M4, M2 + M3) << endl;
}

Measured memory_bytes: 8676
h,w = map(int,input().split())
can = []
hm = h//3
hp = hm+1
wm = w//3
wp = wm+1
now = [hm*w]
if (h-hm) % 2 == 0 or w % 2 == 0:
  now.append((h-hm)*w//2)
  now.append((h-hm)*w//2)
else:
  maxi = max((h-hm),w)
  mini = min((h-hm),w)
  now.append((maxi//2)*mini)
  now.append((maxi//2+1)*mini)
can.append(max(now)-min(now))
now = [hp*w]
if (h-hp) % 2 == 0 or w % 2 == 0:
  now.append((h-hp)*w//2)
  now.append((h-hp)*w//2)
else:
  maxi = max((h-hp),w)
  mini = min((h-hp),w)
  now.append((maxi//2)*mini)
  now.append((maxi//2+1)*mini)
can.append(max(now)-min(now))
now = [wm*h]
if (w-wm) % 2 == 0 or h % 2 == 0:
  now.append((w-wm)*h//2)
  now.append((w-wm)*h//2)
else:
  maxi = max((w-wm),h)
  mini = min((w-wm),h)
  now.append((maxi//2)*mini)
  now.append((maxi//2+1)*mini)
can.append(max(now)-min(now))
now = [wp*h]
if (w-wp) % 2 == 0 or h % 2 == 0:
  now.append((w-wp)*h//2)
  now.append((w-wp)*h//2)
else:
  maxi = max((w-wp),h)
  mini = min((w-wp),h)
  now.append((maxi//2)*mini)
  now.append((maxi//2+1)*mini)
can.append(max(now)-min(now))
print(min(can))

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n=s.size();
	string x=s;
	reverse(x.begin(),x.end());
	if (x!=s){
		cout<<"No"<<endl;
		return 0;
	}
	x=s.substr(0,n/2);
	string y=x;
	reverse(y.begin(),y.end());
	if (x!=y){
		cout<<"No"<<endl;
		return 0;
	}
	x=s.substr(n/2+1);
	y=x;
	reverse(y.begin(),y.end());
	if (x!=y){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	a=a%10;
	if(a==2||a==4||a==5||a==7||a==9){
		cout<<"hon";
	}
	else if(a==0||a==1||a==6||a==8){
		cout<<"pon";
	}
	else{
		cout<<"bon";
	}

} 

Measured memory_bytes: 3636
class ST
	def initialize a
		@l = (1<<(a.size-1).bit_length)-1
		@h = [nil]*@l + a
		(@l-1).downto(0){|i|
			j = 2*i+1
			@h[i] = fn(@h[j],@h[j+1])
		}
	end

	def [] l,r=l
		l,r = l+@l,r+@l
		x = fn(@h[l],@h[r])
		while 0
			l,r = l/2,r/2-1
			break if r<l
			x = fn(x,fn(@h[l],@h[r]))
		end
		return x
	end

	def []= i,x
		i += @l
		@h[i] = x
		while 0<i
			i = (i-1)/2
			j = 2*i+1
			@h[i] = fn(@h[j],@h[j+1])
		end
	end

private
	def fn a,b
		return a ? (b ? a|b : a) : b
	end
end

gets
bs = ST.new [0]+gets.chomp.bytes.map{|c| 1<<(c-?a.ord) }
gets.to_i.times{
	c,d,e = gets.split
	case c
	when ?1
		bs[d.to_i] = 1<<e.ord-?a.ord

	when ?2
		p 26.times.inject([0,bs[d.to_i,e.to_i]]){|(n,b),| next n+(b&1),b>>1 }[0]
	end
}


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


int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int result = 0;
  for (int i = 1; i <= N; ++i) {
    int num = i;
    int total = 0;
    for (int j = 4; 0 <= j; --j) {
      int a = num / pow(10, j);
      total += a;
      num -= a * pow(10, j);
    }
    if (A <= total && total <= B) {
      result += i;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
using namespace std;

#define MAX 100
#define NIL -1

struct Node {
    int parent;
    int left;
    int right;
    int sibling;//邪道？
};

Node T[MAX];
int D[MAX];

//子供の数を出力する
int count_degrees(Node n) {
    int cnt = 0;

    if(n.left!=NIL) {
        cnt++;
    }
    if(n.right!=NIL) {
        cnt++;
    }

    return cnt;
}

//高さを出力する
int count_height(int n) {
    int h1 =0, h2 = 0;
    if(T[n].left!=NIL) {
        h1 = count_height(T[n].left) + 1;
    }
    if(T[n].right!=NIL) {
        h2 = count_height(T[n].right) + 1;
    }
    
    if(h1>h2) {
        return h1;
    }
    else {
        return h2;
    }
}

//深さを出力する
void count_depth(int u, int p) {
    D[u] = p;
    if(T[u].right!=NIL) {
        count_depth(T[u].right, p+1);
    }
    if(T[u].left!=NIL) {
        count_depth(T[u].left,  p+1);
    }
}

int main() {
    int n;
    int id, l, r, p;
    cin >> n;
    for(int i=0; i<n; i++) {
        T[i].parent = T[i].left = T[i].right = T[i].sibling = NIL;
        D[i] = 0;
    }
    for(int i=0; i<n; i++) {
        cin >> id >> l >> r;
        //idの左右の子供を入力する
        T[id].left = l;
        T[id].right = r;
        //逆に左右の子供の親としてidを登録する
        //左右の子供の兄弟としてお互いを登録する
        if(l!=NIL) {
            T[l].parent = id;
            T[l].sibling = r;
        }
        if(r!=NIL) {
            T[r].parent = id;
            T[r].sibling = l;
        }
    }
    //printf("n = %d\n", n);
    //根の番号を特定する
    for(int i=0; i<n; i++) {
        if(T[i].parent==NIL) {
            p = i;
        }
    }
    //printf("ok2!\n");
    count_depth(p, 0);
    //printf("ok3!\n");
    for(int i=0; i<n; i++) {
        cout << "node " << i << ": ";
        cout<< "parent = " << T[i].parent << ", ";
        cout << "sibling = " << T[i].sibling << ", ";
        cout << "degree = " << count_degrees(T[i]) << ", ";
        cout << "depth = " << D[i] << ", ";
        cout << "height = " << count_height(i) << ", ";
        if(T[i].parent==NIL) {
            cout << "root\n";
        }
        else if(T[i].left==NIL && T[i].right==NIL) {
            cout << "leaf\n";
        }
        else {
            cout << "internal node\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3080
#![allow(unused_imports)]
use std::cmp;
use std::collections::*;

pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let k: usize = scan.next();
    let mut mp: HashSet<i32> = HashSet::with_capacity(n);
    for _ in 0..k {
        let d: usize = scan.next();
        for _ in 0..d {
            let a: i32 = scan.next();
            mp.insert(a);
        }
    }
    println!("{}", n - mp.len());
}


Measured memory_bytes: 2140
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

double R;
int n, a[100];

struct ST {
    double w, a, h;
    ST() {}
    ST(double w, double a, double h) : w(w), a(a), h(h) {}
};

ST combine(const ST& p, const ST& q) {
    const double a = q.h / (p.h+q.h);
    double l = min(-a-p.a, (1-a)-q.a);
    double r = max((1-a)+(q.w-q.a), -a+(p.w-p.a));
    return ST(r-l, -l, p.h+q.h);
}

vector<ST> calc(int u) {
    if ((u&(u-1)) == 0) {
        int ix = -1;
        rep (i, n) if (u&(1<<i)) ix = i;
        return vector<ST>(1, ST(0, 0, a[ix]));
    }
    vector<ST> ans;
    rep (b, 1<<n) if ((u&b) == b && b != u && b != 0) {
        vector<ST> x = calc(b);
        vector<ST> y = calc(u-b);
        rep (i, x.size()) rep (j, y.size()) {
            ans.push_back(combine(x[i], y[j]));
        }
    }
    return ans;
}

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        scanf("%lf%d", &R, &n);
        rep (i, n) scanf("%d", a+i);
        vector<ST> ws = calc((1<<n)-1);
        double ans = -1;
        rep (i, ws.size()) if (ws[i].w < R) ans = max(ans, ws[i].w);
        if (ans < 0) printf("%d\n", -1);
        else printf("%.12f\n", ans);
    }
    return 0;
}

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

int main()
{
    int x,y;
    scanf("%d %d",&x,&y);

    int ans = abs(abs(x) - abs(y));

    if(y > x)
    {
        if(x < 0 && y > 0)
        {
            ans += 1;
        }
    }
    else
    {
        if((x < 0 && y < 0) || (x > 0 && y > 0))
        {
            ans += 2;
        }
        else
        {
            ans += 1;
        }
    }

    printf("%d",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdint>
using namespace std;
const int NUM_MAX = 100000;
const int MAX = 1000000000;
int main() {
	int N, A, B, C, h[NUM_MAX], imin, imax, imid, mini = MAX;
	int64_t count, cnt;
	cin >> N >> A >> B;
	C = A - B;
	for (int i = 0;i < N;i ++) {
		cin >> h[i];
	}
	sort(h, h + N);
	for(int i = 0; i < N / 2;i ++){
		int c = h[i];
		h[i] = h[N - i - 1];
		h[N - i - 1] = c;
	}
	// HPを降順にソート終了
	
	// ある爆発回数に関して成立しうるか二分探索
	imax = h[0] / B + (h[0] % B > 0 ? 1 : 0);
	imin = 0;
	while (imax >= imin) {
		imid = imin + (imax - imin) / 2;
		count = 0;
		
		for (int i = 0;i < N;i ++) {
			cnt = (((int64_t)h[i] - imid * B) + (((int64_t)h[i] - imid * B) % C > 0 ? C : 0)) / C;
			if (cnt > 0) count += cnt;
		}
		if (count <= imid) {
			mini = min(mini, imid);
			imax = imid - 1;
//			cout << imid << ":" << count << endl;
		} else {
			imin = imid + 1;
//			cout << "×" << imid << ":" << count << endl;
		}
	}
	cout << mini;
	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict

N = int(input())
A = list(map(int,input().split()))

cnt = 0
L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)

for i in range(N):
    L[i+A[i]] += 1
    R[i-A[i]] += 1

for key in L:
    cnt += L[key] * R[key]


print(cnt)


Measured memory_bytes: 73784
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N;
  int d[111111];
  int i;
  cin >> N;
  for(i=0;i<=N-1;i++)
    cin >> d[i];
  sort(d,d+N);
  int ans;
  if(N%2==0) ans = d[N/2] - d[N/2-1];
  else ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
D = [int(x) for x in input().split()]
D.sort()
d = D[0]
D = [(d * (-1) ** i) % 24 for i, d in enumerate(D)]
D.sort()
for i in range(N - 1):
  d = min(D[i + 1] - D[i], d)
print(d)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string();
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
     
	lli r,d,x;
	cin>>r>>d>>x;
	for(lli i=1;i<=10;i++){
		x=x*r-d;
		cout<<x<<endl;
	}


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
 
int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}
 
//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;
 
void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 
 

 
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   ll n;
   cin>>n;
   ll a[n];
   lp(0,n) cin>>a[i];
   ll ans = 1000;
   ll prev = a[0];
   lp(1, n){
       if(a[i]>prev){
           ans += (ans/prev)*(a[i]-prev);
       }
       prev = a[i];
   }
   cout<<ans;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A = 2,B = 1,C,i,N;
  cin >> N;
  
  if(N == 1){
    C = 1;
  }
  else{
  
  	for(i=1;i<N;i++){
  	  C = A + B;
      A = B;
      B = C;
    }

  }
  cout << C << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n;
    (n==7 || n==5 || n==3)? cout<<"YES\n":cout<<"NO\n";
    return 0;
}


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

int main(){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<a[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
#include <iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<string,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
const ll MODatc = 1000000007;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
bool pairCompare2(P firstElof,P secondElof){
    return (firstElof.second)%1000>(secondElof.second)%1000;
}
bool less_mod1000(int lhs, int rhs) {
  if ((lhs - rhs) % 1000 != 0)
    return lhs % 1000 < rhs % 1000;
  else // 5で割った余りが等しいなら普通に大小比較する
    return lhs < rhs;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
ll dp[107000];
ll jump(ll start,ll goal){
  if(dp[start]>=0)return dp[start];
  if(start==goal){
    return 1;
  }elif(start>goal){
    return 0;
  }
  return dp[start]=(jump(start+1,goal)+jump(start+2,goal))%MODatc;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,d;cin>>n>>d;
    ll x[n][d];
    rep(i,0,n)rep(j,0,d)cin>>x[i][j];
    ll chk=0;
    ll ans=0;
    rep(i,0,n){
      rep(j,0,i){
        chk=0;
        rep(k,0,d){
          chk+=pow(x[i][k]-x[j][k],2);
        }
        double num=sqrt(chk);
        if(ceil(num)==floor(num))ans++;
      }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define FORI(n) for(int i = 0; i < n; i++)
#define FORJ(n) for(int j = 0; j < n; j++)
#define FORK(n) for(int k = 0; k < n; k++) 
#define FOR2I(a, B) for(int i = 0; i < a; i ++) for(int j = 0; j < b; j++)
#define FORIT(S) for(auto it = S.begin(); it != S.end(); it++)

using namespace std;

int main(){
	long long a, b; 
	cin >> a;
	cin >> b;
	if(a * b % 2 == 1) cout << "Odd" << endl; 
	else cout << "Even" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        while (n > 1000)
        {
            n = n % 1000;
        }
        if(n == 0){
            System.out.println(0);
        } else {
            System.out.println(1000 - n);
        }

    }
}

Measured memory_bytes: 35680
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;

const long long MOD = 1000000007;

int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    int d = 0;
    int out = 1;
    for(int i = 0; i < n; i++){
        cerr << d << endl;
        d += l[i];
        if(d <= x){
            out++;
        }
    }

    cout << out << endl;
    
    return 0;
}


Measured memory_bytes: 256