akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

typedef long long ll;

ll number2(ll N,ll K){
	if(N == K)
		return 0;
	while(1){
		if(N > K)
    		N = N - (N / K) * K;
    	else
    		return (labs(N - K) <= N ? labs(N - K) : N);
	}
	
}

int main(){
	ll N,K;
	while(~scanf("%lld %lld",&N,&K))
	    printf("%lld\n",number2(N,K));
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <istream>
#include <sstream>
using namespace std;

int main()
{
	int N, K;
	string S;
	cin >> N >> K >> S;
	S[K-1] = tolower(S[K-1]);
	cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>
     
    using namespace __gnu_pbds;
    using namespace std;
     
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
    #define all(a) a.begin(),a.end()
    #define F first
    #define S second
    #define pb push_back
    #define ll long long
    #define vi vector<int>
    #define pi pair<int,int>
    #define mp make_pair
     
    #ifdef LOCAL
    #include "debug.h"
    #else
    #define debug(...) 42
    #endif
     
    const int mod=1e9+7;
     
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
    template<typename A> istream& operator>>(istream&,vector<A>&);
    void add(int&,int);
    int mul(int,int);
    int powz(int,int);
    template<typename A> ostream& operator<<(ostream&,vector<A>&);
     
    const int N=500001;
     
    int dp[2][101][100001];
    string k;
    int d,n,ans;
     
    int rec(int pos,int sum,int flag){
    	if(dp[flag][sum][pos]!=-1)return dp[flag][sum][pos];
    	dp[flag][sum][pos]=0;
    	if(pos==n){
    		if(sum%d==0)return dp[flag][sum][pos]=1;
    		return dp[flag][sum][pos]=0;
    	}
    	int ans=0;
    	int LMT=k[pos]-'0';
    	if(flag)LMT=9;
    	for(int i=0;i<=LMT;i++){
    		if(flag){
    			add(dp[flag][sum][pos],rec(pos+1,(sum+i)%d,flag));
    		}
    		else{
    			if(i<LMT){
    				add(dp[flag][sum][pos],rec(pos+1,(sum+i)%d,1));
    			}
    			else{
    				add(dp[flag][sum][pos],rec(pos+1,(sum+i)%d,flag));
    			}
    			
    		}
    			
    	}
    	return dp[flag][sum][pos];
    }
    	
     
     
    void solve(){
    	cin>>k>>d;
    	n=k.length();
      for(int j=0;j<d;j++){
    	for(int i=0;i<=n;i++){
    		
    			dp[1][j][i]=dp[0][j][i]=-1;
    		}
    	}
    	cout<<(rec(0,0,0)-1+mod)%mod;
    	
    }
    	
    signed main(){
    	ios_base::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	int tc=1;
    	//~ cin>>tc;
    	for(int _=0;_<tc;_++){
    		//~ cout<<"Case #"<<_+1<<": ";
    		solve();
    		if(_!=tc-1)
    		cout<<"\n";
    	}
    }
     
    int mul(int a,int b)
    {
    	return ((a)*1ll*(b))%mod;
    }
     
    void add(int &a,int b)
    {
    	a+=b;
    	if(a>=mod)a-=mod;
    	
    }
     
    int powz(int a,int b)
    {
    	int res=1;
    	while(b)
    	{
    		if(b&1)res=mul(res,a);
    		b/=2;
    		a=mul(a,a);
    	}
    	return res;
    }
     
    template <typename A, typename B>
    istream& operator>>(istream& input,pair<A,B>& x) {
    	input>>x.F>>x.S;
    	return input;
    }
     
    template <typename A>
    istream& operator>>(istream& input,vector<A>& x) {
    	for(auto& i:x)
    		input>>i;
    	return input;
    }
     
    template<typename A>
    ostream& operator<<(ostream& output,vector<A>& x) {
    	for(auto& i:x)
    	    output<<i<<' ';
    	return output;	
    }

Measured memory_bytes: 77312
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y):x(x),y(y){}
	Pt operator+(const Pt&a)const{return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt&a)const{return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt&a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator*(const double&k)const{return Pt(x*k,y*k);}
	Pt operator/(const double&k)const{return Pt(x/k,y/k);}
	double abs2()const{return x*x+y*y;}
	double arg()const{return atan2(y,x);}
	double dot(const Pt&a)const{return x*a.x+y*a.y;}
};

Pt proj(Pt a,Pt b){return a*a.dot(b)/a.abs2();}
Pt prep(Pt a,Pt b,Pt c){return a+proj(b-a,c-a);}
Pt refl(Pt a,Pt b,Pt c){return prep(a,b,c)*2-c;}

int main() {
	int n;
	for(;n=in(),n!=-1;){
		Pt pos(1,0),vec(0,1);
		int i;
		for(i=1;i<n;i++){
			pos=pos+vec;
			vec=Pt(cos(pos.arg()+6*asin( 0.5 )/2),sin(pos.arg()+6*asin( 0.5 )/2));
		}
		cout<<pos.x<<endl<<pos.y<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;

namespace Test
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			// 半角スペース区切り
			string[] input = Console.ReadLine().Split(' ');
			string output = "";
			foreach (string s in input)
			{
				output = output + s[0];
			}
			//出力
			Console.Write(output);
		}
	}
}

Measured memory_bytes: 2648
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            WriteLine(n % 2 == 0 ? n / 2 - 1 : n / 2);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int MOD = 998244353;

vector<vector<int>> dp(0b1000000000, vector<int>(500 + 1, 0));

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

    int n, x;
    cin >> n >> x;

    dp[0][0] = 1;
    // dp[i][j]: 0からaまでみたとき、値iとなる長さjの数列が何通りあるか

    // i 0からnまでしらべる
    for (int i = 0; i <= x; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < 0b1000000000; k++) {
                (dp[i ^ k][j + 1] += dp[k][j] % MOD) %= MOD;
            }
        }
    }

    const int ans = dp[x][n];
    cout << ans << endl;
}



Measured memory_bytes: 5244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  EPSILON 1e-12
//int a[]={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};
bool C (double A, double B) 
{
   double diff = A - B;
   //cout<<diff;
   return (diff < EPSILON) && (-diff < EPSILON);
}
int main()
{
 ll a,b,c;
 cin>>a>>b>>c;
 
 long double p= sqrtl(a*b);
 //cout<<p<<"\n";
 double net= c-((a+b)+2*p);
if(net>EPSILON and -net<EPSILON)cout<<"Yes";
else cout<<"No";
}

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

int main() {
  int N;
  cin >> N;
  ll sum = 0;
  rep(i, N + 1) {
    if (i == 0) continue;
    if (i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }
  cout << sum << endl;
}


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

int main() {
    int n;
    cin >> n;
    ll power = 0;
    rep(i,n) {
        ll m;
        cin >> m;
        while(m % 2 == 0) {
            power++;
            m /= 2;
        }
    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
const double PI = acos(-1);

int main(){
    while(1){
        double a,b,c,d;
        cin >> a >> b >> c >> d;
        if(b == -1) break;
        a *= PI/180;
        b *= PI/180;
        c *= PI/180;
        d *= PI/180;

        double r = 6378.1;
        double xa,ya,za, xb,yb,zb;
        xa = cos(b) *r*cos(a); xb = cos(d) *r*cos(c);
        ya = sin(b) *r*cos(a); yb = sin(d) *r*cos(c);
        za = r *sin(a); zb = r *sin(c);
        double s = sqrt((xa-xb)*(xa-xb) +(ya-yb)*(ya-yb) +(za-zb)*(za-zb));
        double t = sqrt(xa*xa +ya*ya +za*za);
        double u = sqrt(xb*xb +yb*yb +zb*zb);
        double theta = acos((t*t +u*u -s*s)/(2*t*u));
        cout << fixed << setprecision(10);
        cout << (int)round(r*abs(theta)) << endl;
    }
    return 0;
}


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

int dp[1 << 10][15000];
int main() {
	int n, s;
	while (~scanf("%d%d", &n, &s)) {
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		int ans = 0;
		rep(i, 1 << 10) {
			rep(j, s + 1) {
				if (!dp[i][j])continue;
				int cnt = 0;
				rep(k, 10) {
					if ((i >> k) & 1)cnt++;
				}
				if (cnt == n) {
					if (j == s)ans += dp[i][j];
					continue;
				}
				rep(k, 10) {
					if (!((i >> k) & 1)) {
						dp[i | (1 << k)][j + k*(cnt + 1)] += dp[i][j];
					}
				}
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 63184
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;
 
 
int main() {
  ll A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  ll ap = A, bp = B;
  ll jud = 0;
  
  for (ll i = 0; i < T; i++) {
    ll sa = max(ap,bp)-min(ap,bp);
    if (V-W < sa) {
      if (ap < bp) {
        ap += V;
        bp += W;
      }
      else {
        ap -= V;
        bp -= W;
      }
    }
    else {
      jud++;
      break;
    }
  }
    if (jud==0) {
      cout << "NO" << endl;
    }
    else {
      cout << "YES" << endl;
    }

}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main()
{
    int n;
    long long r = 0, g = 0, b = 0, count = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++) {
        switch(s[i]) {
            case 'R': r++; break;
            case 'G': g++; break;
            case 'B': b++; break;
        }
        for(int j = 1; i - j >= 0 && i + j < n; j++) {
            if(s[i-j] != s[i] && s[i-j] != s[i+j] && s[i] != s[i+j]) {
                count++;
            }
        }
    }
    cout << r*g*b - count << endl;
    return 0;
}

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

int nearest(int n, int ai, int bi) {
	int s[] = {ai, n-ai+1, bi, n-bi+1}, k = 0, x = ai;
	for(int i=0 ; i<3 ; i++) { if(x > s[i+1]){ k = i+1; x = s[i+1]; } }
	return k;
}

int main(void) {
	int n, k, ai, bi;
	cin >> n >> k;
	for(int i=0 ; i<k ; i++) {
		cin >> ai >> bi;
		int s[] = { (ai-1) % 3, (n-ai) % 3, (bi-1) % 3, (n-bi) % 3 };
		cout << s[nearest(n, ai, bi)] + 1 << endl;
	}
}

Measured memory_bytes: 1160
width, high, num = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(num)]

def rec(xl, yl, xh, yh, arr):
    if xl>xh or yl>yh:
        return 0
    if len(arr) == 0:
        return (xh-xl)*(yh-yl)
    if arr[0][2] == 1:
        xl = max(arr[0][0], xl)
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 2:
        xh = min(arr[0][0], xh)
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 3:
        yl = max(arr[0][1], yl)
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 4:
        yh = min(arr[0][1], yh)
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)

print(rec(0, 0, width, high, arr))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int n=0;
  string a,b;
  cin>>a>>b;
  loop(i,0,3)
    n+=(a[i]==b[i]?1:0);
    ans(n);
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

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

#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long i, j;
	char S[100010];
	char a[100010];
	int idx = 0;
	int len;
	char pre = '-';
	
	ss(S);
	len = strlen(S);
	for(i=0;i<len;i++) {
		if(pre != S[i]) {
			a[idx++] = S[i];
			pre = S[i];
		}
	}
	a[idx] = '\0';
	
	pl(strlen(a)-1);
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef pair<P,int> Pi;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N;
  cin >> N;
  while(N-- > 0){
    int x,y;
    Pi p = Pi(P(0,0),0);
    x = y = 0;
    while(true){
      int nx,ny;
      cin >> nx >> ny;
      if(nx == 0 && ny == 0)break;
      x += nx,y += ny;
    
      if(x*x+y*y >= p.S){
	if(x*x+y*y == p.S){
	  if(p.F.F < x)p.F.F = x,p.F.S = y;

	    }else{
	  p.S = x*x+y*y;
	  p.F.F = x,p.F.S = y;
	}
      }
    }
    cout << p.F.F << " " << p.F.S << endl;
  }
return 0;
}

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

int main(){
	string s;
	cin >> s;
	int N = s.length();
	int count = 0;
	for(int i=0;i<N;i++){
		if(s[i]=='1') count++;
	}
	if(2*count>N){
		cout<<2*(N-count)<<endl;
		return 0;
	}else{
		cout << 2*count << endl;
	}
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
using namespace std;
 
const int N = 1e5+3;
vector<int>v[N];
bool vis[N];
list<int>L;
 
void dfs(int u, bool des)
{
    for(int i=0; i<v[u].size(); ++i)
    {
        int e = v[u][i];
        if(!vis[e])
        {
            if(des) L.push_front(e);
            else L.push_back(e);
            vis[e] = true;
            dfs(e, des);
            return;
        }
    }
}
int main()
{
    int n, m, a, b;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    L.push_back(1);
    L.push_back(v[1][0]);
    vis[1] = vis[v[1][0]] = true;
    dfs(1,true);
    dfs(v[1][0], false);
    printf("%d\n",L.size());
    for(auto it=L.begin(); it!=L.end(); ++it)
        printf("%d ",*it);
    printf("\n");
    return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x,i;
    cin>>n;
    map<int,int>mp;
    for(i=1; i<n; i++)
    {
        cin>>x;
        mp[x]++;
    }
    for(i=1; i<=n; i++)
    {
        cout<<mp[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 13004
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep = ' ', end = '\n'):
    print(*var, file=sys.stderr, end = end, sep = sep)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

a = input()
print(chr(ord(a[0]) + 1))

Measured memory_bytes: 3572
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int h, n;
    cin >> h >> n;
    int arr[n];
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
    }
    int sum = accumulate(arr, arr + n, 0);
    if(sum >= h)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

int main() {
    int n; cin >> n;
    string s;
    map<string, ll> mp;
    rep(i,n) {
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto x : mp) {
        ll c = x.second;
        ans += c*(c-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11300
a,b,c,d = gets.split(' ').map(&:to_i)
e = c.lcm(d)
#puts b-c/b-d/b+e/b -a+1+c/(a-1)+d/(a-1)-e/(a-1)
puts b - b/c - b/d + b/e -a +1 + (a-1)/c + (a-1)/d - (a-1)/e


Measured memory_bytes: 1916
import java.util.Scanner;

class Queue{
  Process[] a = new Process[100001];
  int top;

  Queue(){
    top = 0;
  }

  void enqueue(Process p){
    a[++top] = p;
  }

  Process dequeue(){
    Process p = new Process(a[1]);
    for(int i = 1; i < top; i++){
      a[i] = a[i+1];
    }
    top--;
    return p;
  }

  boolean isFull(){
    if(top == 100000)
      return true;
    else
      return false;
  }

  boolean isEmpty(){
    if(top == 0)
      return true;
    else
      return false;
  }

}

class Process{
  String name;
  int time;
  Process(String name, int time){
    this.name = name;
    this.time = time;
  }
  Process(Process p){
    this.name = p.name;
    this.time = p.time;
  }
}

public class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int q = stdIn.nextInt();
    Queue queue = new Queue();

    for(int i = 0; i < n; i++){
      String name = stdIn.next();
      int time = stdIn.nextInt();
      queue.enqueue(new Process(name, time));
    }

    int time_sum = 0;
    while(!queue.isEmpty()){
      Process p = queue.dequeue();
      p.time -= q;
      if(p.time <= 0){
        time_sum += (q + p.time);
        System.out.println(p.name + " " + (time_sum));
      }
      else{
        queue.enqueue(p);
        time_sum += q;
      }
    }

  }
}

Measured memory_bytes: 75904
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,T;
    cin >> N >> T;
    ll A[N];
    ll m = 1ll << 50;
    ll diff = 0;
    ll count = 0;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        if(m > A[i]){
            m = A[i];
        }else{
            ll tmpDiff = A[i] - m;
            if(tmpDiff > diff){
                diff = tmpDiff;
                count = 1;
            }else if(tmpDiff == diff){
                count++;
            }
        }
    }
    cout << count << endl;

}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int n = 0, i = 0, flg = 0;
    scanf("%d", &n);

    for(i = 9; i >= 1; i--){
        if( (n % i  == 0) && (n / i <= 9)){
            flg = 1;
        }
    }

    if(flg == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s, t; cin >> s >> t;
    ll cnt = 0;
    rep(i, s.size()) if(s[i] != t[i]) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 3800
#include<stdio.h>
  
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}


Measured memory_bytes: 2036
def split(x):
    assert(isinstance(x, int))
    sx = str(x)
    l = len(sx)
    candidates = []
    for idx in range(1, l):
        first = sx[idx:]
        candidates.append(int(sx[:idx]) * int(sx[idx:]))
    if len(candidates) == 0:
        return None
    else:
        return max(candidates)


def problem1():
    Q = input()
    answers = []
    for _ in range(int(Q)):
        N = int(input())
        x = N
        cnt = 0
        while True:
            next_x = split(x)
            if next_x is None:
                break
            elif x == next_x:
                cnt = -1
                break
            else:
                cnt += 1
            x = next_x
        answers.append(str(cnt))
    print('\n'.join(answers))


if __name__ == '__main__':
    problem1()



Measured memory_bytes: 5608
import math
def dprint(*args):
  pass
# print(*args)

N, K = [int(x) for x in input().split()]
As = [int(x) for x in input().split()]
S = sum(As)
Ds = []
for i in range(1, 1+int(math.sqrt(S))):
  if S % i == 0:
    Ds.append(i)
    Ds.append(S//i)
Ds = sorted(set(Ds))

for d in Ds[::-1]:
  if d == 1:
    print(1)
    exit()
  dprint(d)
  rs = []  # Max 500 elements
  for a in As:
    rs.append(a % d)
  rs = sorted(rs)
  dprint(rs)
  total = sum(rs)
  n = total//d
  num = 0
  for i in range(N - n, N):
    rs[i] -= d
    num -= rs[i]
  dprint(rs)
  dprint(num)
  if num <= K:
    print(d)
    exit()
    
  
# 1 2 3 4/-3 -2 -1 
           
    
    

Measured memory_bytes: 3192
#include <iostream> 

using namespace std;

int main()
{
    
    int N, M;
    cin >> N >> M;
    int cells[N][M];
    int ans[N+1][M+1];
   
    
    for(int i = 0; i < N + 1; ++i)
    {
        for(int j = 0; j < M + 1; ++j)
        { ans[i][j] = 0; }
    }
    
    for(int i = 0; i < N; ++i)
    {
        for(int j = 0; j < M; ++j)
        {
            cin >> cells[i][j];
            ans[i][j] = cells[i][j];
            ans[i][M] += cells[i][j];
            ans[N][j] += cells[i][j];
            ans[N][M] += cells[i][j];
        }
    }
    
    for(int i = 0; i < N + 1; ++i)
    { 
       for(int j = 0; j < M + 1; ++j)
       { 
           cout << ans[i][j];// << " " ; 
           if( j  != M )
           cout << " " ;
       }
       cout << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for(int i = 0;i < n;i++){
            a.add(sc.nextInt());
        }
        int ans = 0;
        for(int i = 0;i < n;i++){
           ans += solve(a,i,d);
        }
        ans += x;
        System.out.println(ans);
    }
    public static int solve(List<Integer> a,int index,int d){
        int ans = 0;
        for(int i = 0;;i++){
            int x = i * a.get(index)+1;
            if(x > d){
                break;
            }
            ans++;
        }
        return ans;
    }
}


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


int main() {

    int k;
    cin >> k;
    cout << k/2 * ((k+1)/2) << endl;
    return 0;
}

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

struct node{
	int data;
	node *next;
};

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	int num;
	cin >> num;
	int numpo = num % 10;
	if(numpo==2 || numpo==4 || numpo==5 || numpo==7 || numpo==9){
		cout << "hon";
		return 0;
	}
	else if(numpo==0 || numpo==1 || numpo==6 || numpo==8){
		cout << "pon";
		return 0;
	}
	else if(numpo==3){
		cout << "bon";
		return 0;
	}

	return 0;

}

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

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<19;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

int n,loc[_]={0},f[_]={0};

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

	n=ty();
	for(int i=1;i<=n;i++)loc[ty()]=i;
	int ans=0;
	for(int i=1;i<=n;i++)f[i]=((loc[i]>loc[i-1])?f[i-1]:0)+1,ans=max(ans,f[i]);
	cout<<n-ans<<lf;
	
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
int a[100005], b[100005], sum[100005];

int x = 100002;
int ft[200005];
void update(int i, int v){
    for(;i<=200004;i+=(i&-i)) ft[i] += v;
}
int query(int i){
    int res = 0;
    for(;i>0;i-=(i&-i)) res+=ft[i];
    return res;
}

int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);

    ll m = n*1ll*(n+1)/2;
    m = m/2 + 1;

    int lo = 1, hi = 1e9, ans = 0;
    while(lo <= hi){
        int mid = (lo+hi)/2;

        memset(ft, 0, sizeof(ft));
        for(int i=1;i<=n;i++){
            if(a[i] <= mid) b[i] = 1;
            else b[i] = -1;
            sum[i] = sum[i-1] + b[i];
        }

        ll cnt = 0;
        update(x, 1);
        for(int i=1;i<=n;i++){
            cnt += query(x+sum[i]-1);
            update(x+sum[i], 1);
        }

        if(cnt >= m) ans = mid, hi = mid-1;
        else lo = mid+1;
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 2176
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int sum=0;
    int m=n;
    while(m){
        sum+=m%10;
        m/=10;
    }
    if(n%sum)no;
    else yes;
}


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

int main() {
	int n;
	cin>>n;
	if((n%111)==0)
	  {
	  	 cout<<n<<'\n';
	  }
	else
	  {
	  	 cout<<(n/111+1)*111<<'\n';
	  }
	  
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int w,y,z;
          if ( a > b ){
            w = a;
            a = b;
            b = w;
          }
          if ( b > c ){
            y = b;
            b = c;
            c = y;
          }
          if ( a > b ){
            z = a;
            a = b;
            b = z;
          }
        System.out.println(a + " " + b + " " + c);
        }
      }


Measured memory_bytes: 26156
#include<stdio.h>

int main(void)
{
        int n,a[n],min,max;
        int i;

        scanf("%d",&n);

        for(i=0;i<n;i++)
                scanf("%d",&a[i]);

        min = a[0];
        max = a[0];

        for(i=1;i<n;i++){
                if(min>a[i])
                        min = a[i];
                if(max<a[i])
                        max = a[i];
        }
        max = max - min;

        printf("%d\n",max);

        return 0;
}


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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int n, a[N];
ll ans;

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int j = 0; j < n; j++)
        for(int i = j + 1; i < n; i++)
            ans += a[i] * a[j];
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int N, M;
int foodsCount[32];
int ans = 0;

int main()
{
	scanf("%d %d", &N, &M);

	for (int i = 0; i < N; i++)
	{
		int k;
		scanf("%d", &k);
		for (int j = 0; j < k; j++)
		{
			int num;
			scanf("%d", &num);
			foodsCount[num]++;
		}
	}

	for (int i = 0; i < 32; i++)
	{
		if (foodsCount[i] == N) ans++;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 1e5+10;
int main()
{
    _SAD()
	long long a,b,c;
	cin>>a>>b>>c;
	if(!(a%2)||!(b%2)||!(c%2)) {
		cout<<0;
		return 0;
	}
	cout<<min(min(a*b,a*c),b*c)<<nl;
    return 0;
}



Measured memory_bytes: 256
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000
//cin.ignore (7777, '\n');

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

map<string,ll>used;
vector<string>stroka;
ll n;
int main(){
FAST_READ;
//cin.tie(0);
cin>>n;
for(ll i=1;i<=n;i++)
{
  string strokaa;
  cin>>strokaa;
  stroka.pb(strokaa);
}
used[stroka[0]]=1;
for(ll i=1;i<stroka.size();i++)
{
  string str=stroka[i];
  if(used[str]==1)
  {
    cout<<"No"<<endl;
    return 0;
  }
  used[str]=1;
  string st=stroka[i-1];
  if(str[0]!=st[st.size()-1])
  {
    cout<<"No"<<endl;
    return 0;
  }
}

cout<<"Yes"<<endl;





return 0;
} 


Measured memory_bytes: 256
import sys
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    try:
        _ = p.index(x)
    except ValueError:
        print(x)
    else:
        for i in range(1, 101):
            if x - i not in p:
                print(x - i)
                sys.exit()
            if x + i not in p:
                print(x + i)
                sys.exit()

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  ll a, b, x;
  cin>>a>>b>>x;
  a = a - 1;
  if(a>=0) a = a/x + 1;
  else a = 0;

   b = b/x + 1;
   cout<<b - a<<endl;

  return 0;
}



Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>x(n+1,0), y(n+1,0), t(n+1,0);
	repp(i, 1, n+1)cin >> t[i] >> x[i] >> y[i];
	bool flag = true;
	repp(i, 0, n) {
		if (t[i + 1] < abs(x[i + 1]) +abs( y[i + 1] )) flag = false;
		if (t[i + 1] % 2!=(x[i + 1] + y[i + 1])% 2)flag = false;
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
	int N,M,p,t,n,m,s;
	while(cin >> N >> M, N||M)
	{
		vector<short> tim,num,swt;

		cin >> N;
		while(N--)
		{
			cin >> t >> n >> m >> s;
			tim.push_back(t);
			num.push_back(m);
			swt.push_back(s);
		}

		cin >> N;
		while(N--)
		{
			int lg[1024] = {0};

			cin >> t >> s >> m;		
			for(int i=0; i<num.size(); i++)
			{
				if(m==num[i])
				{
					int d = swt[i]*2-1;
					for(int j=tim[i]-540; j<1024; j++)
					{
						lg[j]+=d;
					}
				}
			}


			int a=0;
			for(int i=t-540; i<s-540; i++)
			{
				if(lg[i]>0) a++;
			}
			cout << a << endl;
		}
		
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <queue>
#include <vector>
using namespace std;
int n, m, r, s, t, f, d[100000], x[100000]; vector<pair<int, int> > g[100000];
int main() {
	scanf("%d%d%d", &n, &m, &r);
	for(int i = 0; i < m; i++) {
		scanf("%d%d%d", &s, &t, &f);
		g[s].push_back(make_pair(t, f)); x[s]++;
	}
	for(int i = 0; i < n; i++) d[i] = 999999999; d[r] = 0;
	priority_queue<pair<int, int> > que; que.push(make_pair(0, r));
	while(!que.empty()) {
		int v = que.top().second; que.pop();
		for(int i = 0; i < x[v]; i++) {
			int u = g[v][i].first;
			int e = g[v][i].second;
			if(d[u] > d[v] + e) {
				d[u] = d[v] + e;
				que.push(make_pair(-d[u], u));
			}
		}
	}
	for(int i = 0; i < n; i++) {
		if(d[i] != 999999999) {
			printf("%d\n", d[i]);
		}
		else {
			printf("INF\n");
		}
	}
	return 0;
}

Measured memory_bytes: 12964
import java.util.*;

public class Main {

	private void doIt() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String str = sc.next();
			int pre = sc.nextInt();
			int after = sc.nextInt();
			long money = pre * 200 + after * 300;
			int sum = pre + after;
			System.out.println(str + " " + sum + " " + money);
		}
		
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--)

signed main() 
{	
	fast;
	int a, n;
	cin >> a >> n;
	int b[n]={};
	rep(i,0,n)
		cin >> b[i];
	int max=0;
	for(int i=0; i<n; i++){
		max+=b[i];
	}
	if(max>=a)
		cout << "Yes";
	else
		cout << "No";		
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	static Scanner scanner = new Scanner(System.in);

	public static void main(String[]$) {
		int n = scanner.nextInt();
		int[][] a = new int[n][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = scanner.nextInt();
			a[i][1] = scanner.nextInt();
		}
		Arrays.sort(a, Comparator.comparing(ar -> -(ar[0] + ar[1])));
		
		long takahashi = 0;
		long aoki = 0;
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				takahashi += a[i][0];
			} else {
				aoki += a[i][1];
			}
		}
		System.out.println(takahashi - aoki);
	}
}

Measured memory_bytes: 94612
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#pragma GCC optimize ("O3")

inline static long gl(void){
    long x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(unsigned char* str, unsigned short i){
    if(i>99){
        str[2] = i%10+48; i/=10;
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 3;
    }else if(i>9){
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

unsigned char a[2*500*500];
unsigned char buffer[8*1024*1024];

int main(void){
    const unsigned long h=gl(), w=gl();
    fread(a, 1, 2*w*h, stdin);
    /*
    ssize_t s = read(0, a, 2*w*h);
    printf("%ld %d %d\n", s, fileno(stdin), fileno(stdout));
    for(unsigned long i=0; i<h; i++){
        for(unsigned long j=0; j<w; j++){
            printf("%d ", a[(i*w+j)*2]);
        }
        putchar('\n');
    }
    */
    unsigned long p=0, pos=0;
    unsigned char *aa = a-2; 
    {
        bool haveCoin = false;
        unsigned short old_y, old_x;
        for(unsigned long i=1; i<=h; i++){
            if(i%2==1){
                for(unsigned long j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = aa[2*j]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(long j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = aa[2*j]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }
            aa+=2*w;
        }
    }
    pl(pos); putchar_unlocked('\n'); fflush(stdout);
    //fwrite(buffer, 1, p, stdout);
    write(1, buffer, p);
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
int N,A;
int x[50];
long dp[51][51][3010];
/*
考察ノート

全探索では O(2^n) = 2**50 > 10^9 のためTLE
もっと計算が早い方法を使う -> DP を使う
DPを使う為に部分問題に分解する-> 漸化式を立てる。

dp[i][j][k] = i枚目までのカードでj枚選んで合計がkである組合せ
カードを選ばない dp[i + 1][j][k] += dp[i][j][k]
カードを選ぶ  dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

*/
void solve_dp(){
  dp[0][0][0] = 1;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      for(int k = 0; k <= 2500; k++){
        dp[i+1][j][k] += dp[i][j][k]; //カードを選ばない
        dp[i+1][j+1][k + x[i]] += dp[i][j][k]; //カードを選ぶ
      }
    }
  }

  long long ans = 0;
	for(int i = 1; i <= N; i++) ans += dp[N][i][i*A];
  cout << ans << endl;
  return ;
}


int main(){
  cin >> N >> A;
  for(int i = 0; i < N; i++){
    cin >> x[i] ;
  }
  solve_dp();
  return 0;
}


Measured memory_bytes: 60160
def solve():
    from sys import stdin
    f_i = stdin
    
    Sd = f_i.readline().rstrip()
    T = f_i.readline().rstrip()
    
    for i in range(len(Sd) - len(T), -1, -1):
        for x, t in zip(Sd[i:], T):
            if x != '?' and x != t:
                break
        else:
            ans = Sd[:i] + T + Sd[i+len(T):]
            return ans.replace('?', 'a')
    
    return 'UNRESTORABLE'

print(solve())

Measured memory_bytes: 3064
n=int(input())
d=[10*[0]for _ in range(10)]
ans=0
for i in range(1,n+1):
  s=str(i)
  if s[0]=="0" or s[-1]=="0":
    continue
  d[int(s[0])][int(s[-1])]+=1
for i in range(1,10):
  for j in range(i,10):
    if i == j:
        ans+=d[i][j]*d[j][i]
    else:
        ans+=d[i][j]*d[j][i]*2
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=1000000007;
string a,b;
int main()
{
	int n;
	cin>>n;
	cin>>a;
	cin>>b;
	long long ans=1;
	int le=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			if(le==2)	ans*=3;
			if(le==1)	ans*=2;
			if(le==0)	ans*=6;
			le=2;
			i++;
		}
		else
		{
			if(le==1)	ans*=2;
			if(le==0)	ans*=3;
			le=1;
		}
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256