akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int grids = a * b;
        if (grids - (b * c) == 0) {
            System.out.println(0);
        } else {
            System.out.println(grids - (b * c + (a * d - (c * d))));   
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N;
vector<int> G[10101];
bool vis[10101];
vector<int> ans;

void bfs(int n) {
  vis[n] = true;
  queue<int> q;
  q.push(n);
  ans.push_back(n);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto y : G[x]) {
      if (vis[y]) continue;

      vis[y] = true;
      q.push(y);
      ans.push_back(y);
    }
  }
}

signed main() {
  cin >> N;
  map<int, int> mp;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    mp[a]++;
    mp[b]++;
    G[a].push_back(b);
    G[b].push_back(a);
  }

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

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

  vector<pair<int, int>> vv;
  for (int i = 0; i < N; i++) {
    vv.push_back({mp[i], i});
  }

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

  int cent = vv[N - 1].second;
  bfs(cent);

  map<int, int> mpp;
  for (int i = 0; i < N; i++) {
    mpp[ans[i]] = c[i];
  }

  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    for (auto x : G[i]) {
      if (x < i) continue;
      sum += min(mpp[i], mpp[x]);
    }
  }

  cout << sum << endl;

  for (int i = 0; i < N; i++) {
    if (i != 0) cout << " ";
    cout << mpp[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
int x[15][15];
int main()
{
    int n,d;
    cin>>n>>d;
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
            cin>>x[i][j];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int integer=0;
            for(int k=0;k<d;k++)
                integer+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            if(sqrt(integer)==(int)sqrt(integer))
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
lis = [str(input()) for i in range(3)]
ans = 0
for i in range(n):
  if lis[0][i] == lis[1][i]:
    if lis[1][i] != lis[2][i]:
      ans += 1
  else:
    if lis[1][i] != lis[2][i] and lis[0][i] != lis[2][i]:
      ans += 2
    else:
      ans += 1
print(ans)

Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll as(n);
  rep(i, n) cin >> as[i];

  ll ans = 0;
  rep(i, n) {
    ans += as[i] / 2;
    as[i] %= 2;    
    if (i < n - 1) {
      ll addv = min(as[i], as[i + 1]);
      ans += addv;
      as[i + 1] -= addv;
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

  int N = S.size();
  int ans = 0;
  int pre_ans = 0;

  for (int i = 0; i < N; i++)
  {
    if (S[i]=='A' or S[i]=='C' or S[i] == 'G' or S[i] == 'T')
    {
      pre_ans++;
    }
    else
    {
      if (pre_ans >= ans)
      {
        ans = pre_ans;
        pre_ans = 0; 
      }
    }
  }

  if (pre_ans >= ans)
  {
    ans = pre_ans;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
    n <- (map read) . words <$> getLine
    m <- (map read) <$> replicateM (head n) getLine
    putStrLn . show $ solve (last n) m

solve :: Int -> [Int] -> Int
solve x m = length m + (x - sum m) `div` (minimum m)

Measured memory_bytes: 1020
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A = sorted(A, reverse=True)[:K+1]
B = sorted(B, reverse=True)[:K+1]
C = sorted(C, reverse=True)[:K+1]
 
res = []
 
for i in A:
    for j in B:
        res.append(i + j)
res2 = []
res = sorted(res, reverse=True)[:K+1]
 
for i in C:
    for re in res:
        res2.append(i + re)
        
res2 = sorted(res2, reverse=True)[:K+1]
          
 
for i in range(K):
    print(res2[i])




Measured memory_bytes: 185928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            var s = Console.ReadLine();
            var splits = s.Split(' ');
            string ans = splits[0][0].ToString() + splits[1][0].ToString() + splits[2][0].ToString();
            ans = ans.ToUpper();
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A.at(i);
    --A.at(i);
  }
  
  ll cnt = 0;
  ll cur = 0;
  vector<bool> flgs(N, false);
  vector<ll> cnts(N, 0);
  ll loop;
  for (ll i = 0; i < K; ++i) {
    ++cnt;
    cur = A.at(cur);
    if (flgs.at(cur)) {
      loop = cnt - cnts.at(cur);
      break;
    }
    flgs.at(cur) = true;
    cnts.at(cur) = cnt;
  }
  ll mod = (K - cnt) % loop;
  for (ll i = 0; i < mod; ++i) {
    cur = A.at(cur);
  }
  cout << cur + 1 << endl;
  
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int d,r;
    double f;
    d = a/b;
    r = a%b;
    f = (double)a/b;
    cout << d << " " << r << " ";
    cout << fixed << setprecision(8) << f << endl;
    return 0;
}


Measured memory_bytes: 3272
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>


using namespace std;

bool f[10000002];

int main(){
	
	f[1]=true;f[3]=true;f[5]=true;

	for(int i=2;i<10000001;i*=2)
	{
		f[i]=true;
	}
	//cout<<"#";
	for(int i=3;i<10000001;i*=3)
	{
		f[i]=true;
	}
	for(int i=5;i<10000001;i*=5)
	{
		f[i]=true;
	}
	for(int i=2;i<10000001;i++)
	{
		if(f[i]==true){
		for(int j=i;j<10000001;j*=5)
		f[j]=true;
		for(int j=i;j<10000001;j*=3)
		f[j]=true;
		for(int j=i;j<10000001;j*=2)
		f[j]=true;
			}
	}

	int a,b;

	while(1){
		int ans=0;
		cin>>a;if(a==0)break;
		cin>>b;
		
		for(int i=a;i<=b;i++)
			if(f[i]==true){ans++;}//cout<<i<<endl;}

		cout<<ans<<endl;
	}


	return 0;
}

Measured memory_bytes: 8320
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


Measured memory_bytes: 151512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
    int i, j;
    string s;
    int n, m;
    int ans;

    cin >> n >> m;

    ans = (n * (n - 1) + m * (m - 1)) / 2;

    cout << ans << endl;

    return 0;
}


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

class Edge
{
	public:
	int from,to;
	ll cost;
	Edge(int f,int t,ll c)
	{
		from=f;to=t;cost=c;
	}
};

class UF
{
	public:
	int s;
	vector<int> par;
	vector<int> dep;
	vector<int> size;

	UF(int n)
	{
		s=n;
		par.resize(s);
		dep.resize(s);
		size.resize(s);
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			dep[i]=0;
			size[i]=1;
		}
	}
	int find(int x)
	{
		if(par[x]==x)
			return x;
		else
			return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y)
			return;
		if(dep[x]<dep[y])
		{
			par[x]=y;
			size[y]+=size[x];
		}else{
			par[y]=x;
			size[x]+=size[y];
			if(dep[x]==dep[y])
				dep[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
	int getSize(int x)
	{
		return size[find(x)];
	}
};

vector<int> sink[1000000];
vector<Edge> g;
vector<Edge> g2[200];
UF u=UF(10);
bool usef[200]; //使える頂点

bool comp(Edge &lhs,Edge &rhs)
{
	return lhs.cost<rhs.cost;
}

//現在の頂点数における最小全域木
ll MST(int n)
{
	ll ret=0;
	UF cp=u; //あらかじめコピーを取っておく
	int k;//起点となる点
	for(int i=0;i<200;i++)
	{
		if(usef[i])
		{
			k=i;
			break;
		}
	}
	for(int i=0;i<g.size();i++)
	{
		Edge e=g[i];
		if(!(usef[e.from] && usef[e.to]))
			continue;
		if(!u.same(e.from,e.to))
		{
			u.unite(e.from,e.to);
			ret+=e.cost;
		}
		if(u.getSize(k)==n)
			break;
	}
	//橋が建設できないならなかったことにする
	if(u.getSize(k)<n)
	{
		u=cp;
		ret=0;
	}
	//cerr<<n<<" "<<ret<<endl;
	return ret;
}
bool visited[200]; //下の再帰で訪れた頂点
bool saiki(int now)
{
	visited[now]=true;
	for(int i=0;i<g2[now].size();i++)
	{
		Edge e=g2[now][i];
		if(!visited[e.to] && usef[e.to])
			saiki(e.to);
	}
	bool ret=true;
	for(int i=0;i<200;i++)
	{
		if(usef[i]!=visited[i])
			ret=false;
	}
	return ret;
}
int main()
{
	while(1)
	{
		int n,m;
		ll ans=0;
		cin>>n>>m;
		if(n==0)
			break;
		g.clear();
		for(int i=0;i<1000000;i++)
			sink[i].clear();
		for(int i=0;i<200;i++)
			g2[i].clear();
		fill(usef,usef+200,false);
		for(int i=0;i<n;i++)
		{
			int h;
			cin>>h;
			sink[h-1].push_back(i);
		}
		for(int i=0;i<m;i++)
		{
			int a,b,c;
			cin>>a>>b>>c;
			a--;b--;
			g.push_back(Edge(a,b,c));
			g2[a].push_back(Edge(a,b,c));
			g2[b].push_back(Edge(b,a,c));
		}
		sort(g.begin(),g.end(),comp);
		u=UF(n);
		int now=0;
		int last=999999;
		//初めて全域木が構成できなくなる時間を求める
		for(int i=0;i<n;i++)
			usef[i]=true;
		now=n;
		fill(visited,visited+200,false);
		if(!saiki(0))
		{
			cout<<0<<endl;//最初から構成できない場合を除く
			continue;
		}
		for(int i=0;i<1000000;i++)
		{
			bool f=true;
			if(sink[i].size()==0)
				continue;
			for(int j=0;j<sink[i].size();j++)
				usef[sink[i][j]]=false;
			now-=sink[i].size();
			for(int j=0;j<200;j++)
			{
				if(usef[j])
				{
					fill(visited,visited+200,false);
					f=saiki(j);
					if(!f)
						last=i;
					break;
				}
			}
			if(!f)
				break;
		}
		for(int i=last;i>-1;i--)
		{
			if(sink[i].size()==0)
				continue;
			for(int j=0;j<sink[i].size();j++)
				usef[sink[i][j]]=true;
			now+=sink[i].size();//現在の島の数
			ans+=MST(now);
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 27892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long sum = 0;
		int count = 0;
		while (n-- > 0) {
			sum += scanner.nextLong();
			count++;
		}
		System.out.println(sum / count);
	}
}

Measured memory_bytes: 31000
a=int(input())
b=list(map(int,input().split()))
dp=[0]
dp.append(abs(b[0]-b[1]))
for i in range(2,len(b)):
    h1=abs(b[i]-b[i-1])+dp[i-1]
    h2=abs(b[i-2]-b[i])+dp[i-2]
    dp.append(min(h1,h2))
print(dp[a-1])



Measured memory_bytes: 13980
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int ans, par[100010];
typedef pair<int, int> P;
typedef pair<int, P> edge;
edge e[200010];

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

void unite(edge e) {
  int x = find(e.second.first);
  int y = find(e.second.second);
  if(x != y) {
    par[x] = y;
    ans += e.first;
  }
}

int main() {
  int N; cin >> N;
  for(int i = 0; i < N; ++i) {
    par[i] = i;
  }
  P x[N], y[N];
  for(int i = 0; i < N; ++i) {
    int a, b; cin >> a >> b;
    x[i] = P(a, i);
    y[i] = P(b, i);
  }
  sort(x, x+N);
  sort(y, y+N);
  for(int i = 0; i < N-1; ++i) {
    e[i] = make_pair(x[i+1].first - x[i].first, P(x[i].second, x[i+1].second));
    e[N-1+i] = make_pair(y[i+1].first - y[i].first, P(y[i].second, y[i+1].second));
  }
  sort(e, e+2*N-2);
  ans = 0;

  for(int i = 0; i < 2 * N - 2; ++i) {
    unite(e[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5376
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
const int maxN = 4e6 + 2;
typedef pair<int, int> P;
typedef pair<int, P>PP;
struct edge {
	int to, cost;
};

int kj[maxN], kji[maxN];
int modpow(int a, int x, int mod) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		x >>= 1;
		a = a*a%mod;
	}
	return res;
}
void setkj(int n) {
	kj[0] = 1;
	rep(i, n)kj[i + 1] = kj[i] * (i + 1) % mod;
	rep(i, n + 1)kji[i] = modpow(kj[i], mod - 2, mod);
}
int comb(int r, int c) {
	if (c<0 || r<c)return 0;
	return kj[r] * kji[c] % mod*kji[r - c] % mod;
}
signed main() {
	int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
	setkj(r2 + c2+2);
	int res = comb(r2 + c2 + 2, r2 + 1) + comb(r1 + c1 , r1) - comb(r1 + c2 + 1, r1) - comb(r2 + c1 + 1, c1);
	cout << (res+mod*3)%mod << endl;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

int main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y ;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a, x;
int main(){
	scanf("%lld", &x);
	for (long long i=1; i<=1000000; i++){
		a += i; if (a >= x) { printf("%lld\n", i); return 0; }
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int N,M,Q,L,R,p[100000],q[100000],i,j,k,l,ans;
    scanf("%d %d %d",&N,&M,&Q);
    int kukan[500][500],kukana[500][500];
    for (i = 0;i < N;i++) {
        for (j = i;j < N;j++) {
            kukan[i][j] = 0;
        }
    }
    for (i = 0;i < M;i++) {
        scanf("%d %d",&L,&R);
        kukan[L - 1][R - 1]++;
    }
    for (i = 0;i < N;i++) {
        for (j = i;j < N;j++) {
            kukana[i][j] = 0;
            for (k = i;k <= j;k++) {
                for (l = k;l <= j;l++) {
                    kukana[i][j] += kukan[k][l];
                }
            }
        }
    }
    for (i = 0;i < Q;i++) {
        scanf("%d %d",&p[i],&q[i]);
    }
    for (i = 0;i < Q;i++) {
        printf("%d\n",kukana[p[i] - 1][q[i] - 1]);
    }
    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {   
        Scanner scan = new Scanner(System.in);
        double r = scan.nextDouble();
        //System.out.println(r*r*Math.PI + " " + 2*r*Math.PI);
        System.out.println(String.format("%.6f",r*r*Math.PI) + " " +String.format("%.6f",2*r*Math.PI));
    }
}


Measured memory_bytes: 28260
class PriorityQueue
  attr_reader :elements

  def initialize
    @elements = [nil]
  end

  def <<(element)
    @elements << element
    bubble_up(@elements.size - 1)
  end

  def pop
    exchange(1, @elements.size - 1)
    max = @elements.pop
    bubble_down(1)
    max
  end

  private

  def bubble_up(index)
        parent_index = (index / 2)

    return if index <= 1
    return if @elements[parent_index] >= @elements[index]

    exchange(index, parent_index)
    bubble_up(parent_index)
  end

  def bubble_down(index)
    child_index = (index * 2)

    return if child_index > @elements.size - 1

    not_the_last_element = child_index < @elements.size - 1
    left_element = @elements[child_index]
    right_element = @elements[child_index + 1]
    child_index += 1 if not_the_last_element && right_element > left_element

    return if @elements[index] >= @elements[child_index]

    exchange(index, child_index)
    bubble_down(child_index)
  end

  def exchange(source, target)
    @elements[source], @elements[target] = @elements[target], @elements[source]
  end
end

# //
#n = gets.chomp.to_i
n, m = gets.chomp.split().map(&:to_i)
a = gets.chomp.split().map(&:to_i)


q = PriorityQueue.new()
a.each{|e| q << e}

m.times do
  max_a = q.pop
  q << max_a / 2
end

ans = 0
n.times do
  ans += q.pop
end

p ans


Measured memory_bytes: 13068
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e14+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
//ll x[100001]={0};
ll a[200001]={0};
//ll b[200001]={0};
//ll b[200001]={0};
//bool c[100001]={0};
//vector<pair<ll,ll> > adj[100001];
//vector<ll> adj[100001];
//vpii edges;
//bool visited[100001]={0};
//bool color[100001]={0};
//ll dist[100001]={0};
ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}

double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr)+1;
        }
    }
}*/

/*void dfs(ll x,ll y){
    if(x<0 || y<0 || x>=n || y>=m)return;
    if(visited[x][y])return;
    visited[x][y]=true;
    dfs(x+1,y);dfs(x-1,y);dfs(x,y+1);dfs(x,y-1);
}*/

/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};

/*void dfs(ll s,bool colr){
    if(visited[s])return;
    visited[s]=true;
    color[s]=colr;
    for(auto u:adj[s]){
        dfs(u,!colr);
    }
}*/
//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/

void solve(){
    ll x,y;
    cin>>x>>y;

    ll turtle=0,crane=0;

    for(ll i=0;i<=x;i++){
        turtle=x-i;
        crane=i;
        if(4*turtle+2*crane==y){
            cout<<"Yes";
            return;
        }
    }

    cout<<"No";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //sieve(100001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


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

int main(){

  string s;

  for(int i=0;i<3;i++){
    cin>>s;
    printf("%c", toupper(s[0]));
  }
  cout<<endl;
  
  return 0;
}


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

int main(){
  int N;
  int a,b,c;

  cin >> N;

  a = N / 100;
  b = (N - a*100) / 10;
  c = N - a*100 - b*10;

  if(a==7 || b==7 || c==7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int ans[N];
  for(int i=0;i<N;i++)
  ans[i]=0;
  int K=0;
 if(N>3)
  {
      K = sqrt(4+ 4*(N-3));
      K= (K-2)/2;
  }
  //cout<<"value - "<<K<<endl;
 for(int i=1;i<=K;i++)
 {
     for(int j=i;j<=K;j++)
     {
         for(int k=j;k<=K;k++)
         {
             int val = i*i + j*j + k*k + i*j + i*k + j*k;
             if(val<=N)
             {
                if(i==j && j==k)
                ans[val-1]++;
                else if(i==j || j==k || i==k)
                ans[val-1]+=3;
                else
                ans[val-1]+=6;
             }
         }
     }
 }
// cout<<N<<endl;
 for(int i=0;i<N;i++)
 cout<<ans[i]<<endl;
 
}
   
  

Measured memory_bytes: 3508
#include <iostream>
#include<string>
#include<map> 
using namespace std;
int main()
{
	int n;
	cin >> n;
	map<string, int> myMap;
	for (int i = 0; i < n; i++)
	{
		string x;
		cin >> x;
		myMap[x]++;
	}
	int max = 0;
	for (auto i = myMap.begin(); i != myMap.end(); i++) {
		if (i->second > max)
			max = i->second;
	}
	for (auto i = myMap.begin(); i != myMap.end(); i++) {
		if (i->second == max)
			cout<< i->first<<endl;
	}
}

Measured memory_bytes: 25216
#include<stdio.h>
main(){
  int n,m,l,i,j,k;
  double a[100][100],b[100][100],c[100][100]={};
  scanf("%d%d%d",&n,&m,&l);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%lf",&a[i][j]);
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%lf",&b[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){
      c[i][j]+=a[i][k]*b[k][j];
      }
      if(j) printf(" ");
      printf("%.0f",c[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

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

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


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

    int n;
    cin >> n;
    map<ll, ll> m;

    ll t = 0;
    m[0] = 1;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        t += a;
        if (m.find(t) == m.end()) {
            m[t] = 1;
        } else {
            m[t]++;
        }
    }

    ll ans = 0;
    for (auto i : m) {
        ans += i.second * (i.second - 1) / 2;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
import java.util.*;

class Main {
  public static void main(String[] args){
    Scanner cin = new Scanner(System.in);
    MyArray myArray = new MyArray(110);
    
    while(cin.hasNext()){
      myArray.add(cin.nextInt());
    }
    myArray.mode();
  }
}

class MyArray {
  private int num[];
  private int size = 0;
   
  MyArray(int n){
    this.num = new int[n];
  }
 
  protected void sort(){
    Arrays.sort(num);
  }
 
  protected int top(){
    if (size == 0) {
//      System.out.println("empty");
      return (0);
    }
    return (num[size - 1]);
  }
 
  protected void pop(){
    for (int i = size - 1; i > 1; i--){
      num[i] = num[i - 1];
    }
  }
 
  protected void add(int n){
    num[n]++;
  }
 
  protected int at(int n){
    return (num[n]);
  }

  protected void mode(){
    int max = 0;
    for (int i = 1; i < 101; i++){
      max = Math.max(max, num[i]);
    }
    for (int i = 1; i < 101; i++){
      if (max == num[i]){
        System.out.println(i);
      }
    }
  }
}

Measured memory_bytes: 26220
#include <iostream>
int f(int  a,int b,int c,int d){
    if(a/c+1>=b/d+1){
        if(a%c==0)
        return a/c;
        else return a/c+1;
    }else if(b%d==0){
        return b/d;
    }else return b/d+1;
}
int main(){
    int a,b,c,d,e;
    std::cin>>a>>b>>c>>d>>e;
    std::cout<<a-f(b,c,d,e)<<std::endl;
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    lint dp[105][4][2];
    //解説AC
  int main(){
      string s;
      lint K,n;
      cin>>s>>K;
      n=s.size();
      dp[0][0][0]=1;
    rep(i,n){
        rep(j,4){
            rep(k,2){
                lint x=s[i]-'0';
                rep(l,10){
                    lint ni,nj,nk;
                    ni=i+1;nj=j;nk=k;
                    if(l!=0)nj++;
                    if(nj>K)continue;
                    if(k==0){
                       if(l>x)continue;
                       if(l<x)nk=1;
                    }
                    dp[ni][nj][nk]+=dp[i][j][k];
                }
            }
        }
    }
    cout<<dp[n][K][0]+dp[n][K][1];
  }
  
     


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  S='.'+S;
  int cnt=0;
  for(int i=0; i<N; i++){
    if(S[i]!=S[i+1]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int n = (int)s.size();
  vector<int> count(n);
  count[0]=int(s[0]-'0');
  for(int i=1;i<n;i++){
  	count[i]=count[i-1]+int(s[i]-'0');
  }
  int ans=count[n-1];
  for(int i=0;i<n;i++){
  	ans=max(ans, count[i]+(n-i-1)*9-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import copy 
def solve():
  while(True):
    n, r = map(int, input().split())
    beforelist = [i for i in range(n, 0, -1)]
    afterlist = copy.deepcopy(beforelist)
    #print(beforelist)
    #print(afterlist)
    if n == 0 and r == 0:
        break
    for _ in range(r):
        p, c = map(int, input().split())
        j = 0
        for i in range(p-1,p-1+c):
            #print(beforelist)
            afterlist[j] = copy.deepcopy(beforelist[i])
            j+=1
            #print(afterlist)
            #print(beforelist)
        for i in range(0,p-1):
            afterlist[j] = copy.deepcopy(beforelist[i])
            j+=1
        beforelist = copy.deepcopy(afterlist)
        #print(afterlist)
    print(beforelist[0])
if __name__ == '__main__':
  solve()


Measured memory_bytes: 6336
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *s = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSArray *arr = [s componentsSeparatedByString:@" "];
        NSInteger a = [[arr objectAtIndex:0] integerValue];
        NSInteger b = [[arr objectAtIndex:1] integerValue];
        
        NSString *answer = @"Even";
        if((a*b)%2){
            answer = @"Odd";
        }
        
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[answer dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    
    return 0;
}


Measured memory_bytes: 2404
n=int(input())
s=list(input())
cnt=0
for i in range (10):
  i=str(i)
  for j in range (10):
    j=str(j)
    for k in range (10):
      k=str(k)
      if s.count(i)!=0:
        a=s.index(i)
        x=s[(a+1):]
        if x.count(j)!=0:
          b=x.index(j)
          y=x[(b+1):]
          if y.count(k)!=0:
            cnt+=1

print(cnt)     

Measured memory_bytes: 4456
#include <stdio.h>

int main(){
	int y,m,d;
	int i;
	while(scanf("%d %2d %2d",&y,&m,&d)!=EOF){
		i=y*10000+m*100+d;
		if(i<18680908){
			printf("pre-meiji\n");
		}else{
			if(i<19120730){
				printf("meiji %d ",y-1867);
			}else{
				if(i<19261225){
					printf("taisho %d ",y-1911);
				}else{
					if(i<19890108){
						printf("showa %d ",y-1925);
					}else{
						printf("heisei %d ",y-1988);
					}
				}
			}
			printf("%d %d\n",m,d);
		}
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>

using namespace std;

int main() {
    int x,y;
    
    do {
        cin >> x >> y;
        if(0 == x && 0 == y) {
            break;
        }
        
        if(x < y) {
            cout << x << " " << y << endl;
        }else {
            cout << y << " " << x << endl;
        }
    }while(!(0 == x && 0 == y));
    
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a == 1) a+= 100;
  if(b == 1) b+= 100;
  if(a > b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;



int main(){
    ll n,a,b;
    cin >> n >> a>>b;
    if((b-a)%2==0){
        cout << (b-a)/2 <<endl;
        return 0;
    }
    ll dir = max(b-1,n-a);
    ll left = (b+a-1)/2;
    ll right = (2*n-b+1-a)/2;
    //cout << dir <<endl;
    //cout << left <<endl;
    //cout <<right <<endl;
    cout << min(dir,min(left,right))<<endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define ll long long

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

    int n;
    cin >> n;
    while(n>0) {
    	int d = n%10;
    	if(d==7) {cout << "Yes";return 0;}
    	n/=10;
    }
    cout << "No";

	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int ara[300010];
int bra[300010];
int main() {
	int h,w,n,k,l;
	int maxi=0,mai=0;
	vector<vector<int>> v(300010);
	vector<int> row;
	vector<int> column;
	cin>>h>>w>>n;
	for (int i=0;i<n;i++){
		cin>>k>>l;
		v[k-1].push_back(l-1);
		ara[k-1]+=1;
		maxi=max(maxi,ara[k-1]);
		bra[l-1]+=1;
		mai=max(mai,bra[l-1]);
	}
	
	for (int i=0;i<h;i++){
		if (ara[i]==maxi){
			row.push_back(i);
		}
	}
	
	for (int i=0;i<w;i++){
		if (bra[i]==mai){
			column.push_back(i);
		}
	}
	
	for (int i=0;i<row.size();i++){
		int ct=0;
		sort(v[row[i]].begin(),v[row[i]].end());
		int j=0;
		int k=0;
		while(1){
			
			if (k==v[row[i]].size()) break;
			if (j==column.size()) break;
			if (v[row[i]][k]==column[j]){
				ct++;
				j++;
				k++;
			}
			else if (v[row[i]][k]>column[j]){
				j++;
			}
			else if (v[row[i]][k]<column[j]){
				k++;
			}
		}
		/*for (int )
		for (int k=0;k<v[row[i]].size();k++){
			if (v[row[i]][k]>column[column.size()-1]){
				continue;
			}
			
			for (int j=0;j<column.size();j++){
				
				if (v[row[i]][k]==column[j]){
					ct++;
					break;
				}
				else if (v[row[i]][k]<column[j]){
					break;
				}
				
			}
			
		}*/
		if (ct!=column.size()){
			cout<<maxi+mai;
			return 0;
		}
		//return 0;
	}
	cout<<maxi+mai-1;
	
	return 0;
}

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

int n;
string s;
int ans = 0;
int main() {
	cin >> s;
	n = s.size();
	for(int i = 0; i < n; i++) {
		if(s[i] == '1' && i % 2)
			ans++;
		else if(s[i] == '0' && i % 2 == 0)
			ans++;
	}
	int res = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == '0' && i % 2)
			res++;
		else if(s[i] == '1' && i % 2 == 0)
			res++;
	}
	cout << min(ans, res);	
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if((b-a)==(c-b)) System.out.println("YES");
		else System.out.println("NO");
	}

}


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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
	string line;cin>>line;
	if(line=="SUN")cout<<7<<"\n";
	else if(line=="MON")cout<<6<<"\n";
	else if(line=="TUE")cout<<5<<"\n";
	else if(line=="WED")cout<<4<<"\n";
	else if(line=="THU")cout<<3<<"\n";
	else if(line=="FRI")cout<<2<<"\n";
	else if(line=="SAT")cout<<1<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = int(1e9)+7;
int n,k;
long long C[2003][2003],ans;
int main(){
    int i,j;
    C[0][0]=1;
    for(i=0;i<=2000;i++){
        for(j=0;j<=2000;j++){
            C[i][j]%=mod;
            C[i+1][j]+=C[i][j];
            C[i+1][j+1]+=C[i][j];
        }
    }
    scanf("%d %d",&n,&k);
    for(i=0;i<k;i++){
        ans=C[k-1][i]*C[n-k+1][n-k-i]%mod;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;

ll ab(ll x){
    if(x > 0){
        return x;
    }
    else{
        return -x;
    }
}


int main(){
    ll N;
    P a[100];
    cin >> N;
    map<P, int> m;
    for(int i = 0; i < N; i++){
        cin >> a[i].fs >> a[i].sc;
        m[a[i]] = 1;
    }

    vector<P> p_list;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
//            cout << i << " " << j << endl;
//            cout << a[i].fs << " " << a[j].fs << endl;
//            cout << ab(a[j].fs - a[i].fs) << endl;
//            cout << endl;
            p_list.push_back(P(ab(a[j].fs - a[i].fs), ab(a[j].sc - a[i].sc)));
        }
    }

    int mi = INT32_MAX;
    for(auto p2: p_list){
        int tmp = 0;
        ll p = p2.fs;
        ll q = p2.sc;
        if(p == 0 && q == 0){
            continue;
        }

        for(int i = 0; i < N; i++){
            if(m.find(P(a[i].fs+p, a[i].sc+q)) == m.end()){
                tmp += 1;
            }
        }
        mi = min(tmp, mi);

        tmp = 0;
        for(int i = 0; i < N; i++){
            if(m.find(P(a[i].fs+p, a[i].sc-q)) == m.end()){
                tmp += 1;
            }
        }
        mi = min(tmp, mi);
    }

    if(N == 1){
        cout << 1 << endl;
    }
    else {
        cout << mi << endl;
    }

//
//    sort(a, a+N);
//    map<P, int> m;
//    for(int i = 0; i < N-1; i++){
//        ll x = a[i+1].fs - a[i].fs;
//        ll y = a[i+1].sc - a[i].sc;
//        if(m.find(P(x, y)) == m.end()){
//            m[P(x, y)] = 1;
//        }
//        else{
//            m[P(x, y)] += 1;
//        }
//    }
//
//    int ma = 0;
//    for(auto itr = m.begin(); itr != m.end(); itr++){
//        ma = max(itr->second, ma);
//    }
//
//    cout << N - ma << endl;


    return 0;
}


Measured memory_bytes: 256
import collections
n, k = map(int, input().split())
dat_a = list(map(int,input().split()))
d = collections.Counter(dat_a)
r_num =  len(d)- k
res = 0
r = d.most_common()[::-1]
for i in range(r_num):
    res += r[i][1]
print(res)

Measured memory_bytes: 103240
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}
    
void run(){
    int x;
    cin>>x;
    REP(i,x,x*2){
        bool f=true;
        for(int j=2;j*j<=i;j++){
            if(i%j==0)f=false;
        }
        if(f){
            cout<<i<<endl;
            return;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]){
    ll n;
    int x,m;
    cin >> n >> x >> m;
    set<int> s; //集合

    ll sum=0;
    ll c;
    ll a=x;
    int k=0;
    int zero=1;
    while(true){
        c=s.size();
        s.insert(a);
        if(c==s.size()) break;//aを加えてもサイズが変わってない
        k++;
        sum+=a;
        a%=m;
        a*=a;
        a%=m;
        if(a==0){
            zero=0;
            break;
        }
    }
    int l=0;
    ll b=x;
    ll sum2=0;
    while(true){
        if(b==a) break;
        l++;
        sum2+=b;
        b%=m;
        b*=b;
        b%=m;
    }
    //l++;
    k=k-l;
    if(zero==0){
        cout << sum << endl;
        return 0;
    }
    ll t=(n-l)/k;
    ll u=(n-l)%k;
    //t++;
    sum=sum-sum2;
    sum*=t;
    //a=x;
    for(int i=0;i<u;i++){
        sum+=a;
        a%=m;
        a*=a;
        a%=m;
    }
    sum=sum+sum2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


#define N 	 100005
void solve(){
	int n;
	cin>>n;
	int A[n+1], s =0;
	rep(i,1,n+1){ cin>>A[i]; s+=A[i];}
	int q;
	cin>>q;
	while(q--){
		int i, xx;
		cin>>i>>xx;
		cout<<s-A[i]+xx <<endl;
	}
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int minresult=999;
        int result[7]={0};
        result[1]=abs(a-c)+abs(c-b);
        result[2]=abs(a-b)+abs(b-c);
        result[3]=abs(b-a)+abs(a-c);
        result[4]=abs(b-c)+abs(c-a);
        result[5]=abs(c-a)+abs(a-b);
        result[6]=abs(c-b)+abs(b-a);
        for(int i=1;i<=6;i++)
            if(minresult>result[i])
        {
            minresult=result[i];
        }
        cout<<minresult<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

int main()
{
    ll n,d,tmp=0,ans=1;
    map<ll,ll> mp;
    cin >> n;
    rep(i,n){
        cin >> d;
        mp[d]++;
        if((i==0 && d!=0) || mp[0]>1) ans=0;
        tmp=max(tmp,d);
    }
    rep(i,tmp+1){
        rep(j,mp[i+1]){
            ans*=mp[i];
            ans%=998244353;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        int sockets = 1;
        int needed = 0;

        while (sockets < B) {
            needed++;
            sockets += A - 1;
        }

        System.out.println(needed);
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define orep(i, n) for(int i = 1; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    bool ans = false;
    rep(i, 10) {
        rep(j, 10) {
            if (i * j == n) {
                ans = true;
                break;
            }
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N, M;cin >> N >> M;
	ll ans = 0;
	if      (N >= M/2) ans =M / 2;
	else if (N <= M / 2) {
			ans += N;
			M -= N*2;
			ans += M / 4;
		}
	cout << ans;
}

Measured memory_bytes: 256