akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
ll longinf=1ll<<60;



ll n,m,s,t;
ll dista[100002],distb[100002];
vector<P> machia[100002],machib[100002];
priority_queue<P,vector<P>,greater<P>> quea,queb;
ll mini[100002];

int main(){
  cin>>n>>m>>s>>t;
  rep1(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    machia[u].push_back(make_pair(a,v));
    machia[v].push_back(make_pair(a,u));
    machib[u].push_back(make_pair(b,v));
    machib[v].push_back(make_pair(b,u));
  }
  rep1(i,n){
    dista[i]=longinf;
    distb[i]=longinf;
  }
  dista[s]=0;
  rep0(i,machia[s].size()){
    quea.push(machia[s][i]);
    dista[machia[s][i].second]=machia[s][i].first;
  }
  while(quea.size()){
    P p=quea.top();
    quea.pop();
    if(p.first>dista[p.second]) continue;
    for(int i=0;i<machia[p.second].size();i++){
      if(machia[p.second][i].first+dista[p.second]<dista[machia[p.second][i].second]){
        dista[machia[p.second][i].second]=machia[p.second][i].first+dista[p.second];
        quea.push(machia[p.second][i]);
      }
    }
  }
   distb[t]=0;
  rep0(i,machib[t].size()){
    queb.push(machib[t][i]);
    distb[machib[t][i].second]=machib[t][i].first;
  }
  while(queb.size()){
    P p=queb.top();
    queb.pop();
    if(p.first>distb[p.second]) continue;
    for(int i=0;i<machib[p.second].size();i++){
      if(machib[p.second][i].first+distb[p.second]<distb[machib[p.second][i].second]){
        distb[machib[p.second][i].second]=machib[p.second][i].first+distb[p.second];
        queb.push(machib[p.second][i]);
      }
    }
  }
  ll shozikin=1e15;
  mini[n]=dista[n]+distb[n];
  for(int i=n-1;i>=1;i--){
    mini[i]=min(mini[i+1],dista[i]+distb[i]);
  }
  rep1(i,n){
    cout<<shozikin-mini[i]<<endl;
  }
    return 0;
}

Measured memory_bytes: 26860
import numpy as np

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.full(n, np.inf)

dp[0] = 0
dp[1] = np.abs(h[1] - h[0])

# def chmin(a, b):
#     if a < b:
#         return a
#     else:
#         return b

for i in range(2, n):

    # 1回目の投稿：for文。ほぼTLE。遅すぎ。
    # for j in range(1, k):
    #     dp[i] = chmin(dp[i], dp[i - j] + np.abs(h[i] - h[i - j]))
    # 2回目の投稿：ベクトル化。最後4つTLE。少し早いけどまだだめ。
    # tmp1 = dp[max(i - k, 0):i + 1 - 1]
    # tmp2 = np.abs(h[i] - h[max(i - k, 0):i + 1 - 1])
    # dp[i] = np.min(tmp1 + tmp2)
    # 3回目の投稿：
    start = max(i - k, 0)
    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))

print(int(dp[-1]))


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

int main()
{
    long long a,b;
    cin >> a >> b;
    if (a > b) swap(a,b);
    long long gcd = 0;
    for (int i=1; i<=a; ++i){
        if (a % i == 0 && b % i ==0) {
            gcd = i;
        }
    }
    cout << a*b / gcd << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define Ifor(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dfor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, x;
	cin >> n;
	map<int, int> freq;
	Ifor(i, 0, n) { cin >> x; freq[x]++; }
	int ans = 0;
	Trav(p, freq) {
		if (p.first > p.second) ans += p.second;
		else ans += (p.second - p.first);
	}
	cout << ans << '\n';
}



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

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

  int s[] = { 14, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
  int a, b;
  cin >> a >> b;

  if (s[a-1] > s[b-1]) cout << "Alice\n";
  else if (s[a-1] < s[b-1]) cout << "Bob\n";
  else cout << "Draw\n";

  return (0);
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3652
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  string s;
  cin >> s;
  if(s=="ABC") cout <<"ARC"<<endl;
  else cout <<"ABC"<<endl;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long A;
	string S;
	cin >> A >> S;
	const char *s = S.c_str();
	char *p = (char*) s;
	p[1] = '\0';
	int b1 = atoi(p);
	p++; p++;
	int b2 = atoi(p);

	long long ans = A*b1;
	ans += (A*b2)/100;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;

ll f(ll n){
        if(n%2==0)      return n/2;
        return 3*n+1;
}

int main(){
        ll s,nums[10000]={},i=1;
        cin >> s;
        while(1){
                if(nums[s]!=0){
                        cout << i;
                        return 0;
                }  
                else nums[s]=i;
                s = f(s);
                i++;
        }
        return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define _for(i,j,N) for(int i = (j); i < (N);i++)
 
int main()
{
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int cnt = 0;
    _for(i,0,A+1){
        _for(j,0,B+1){
            int m = X-i*500-j*100;
            if(m >= 0&&m%50 == 0&&m/50 <= C)
                cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,n,a[1000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>0;i--) printf("%d ",a[i]);
  printf("%d\n",a[0]);

  return 0;
}

Measured memory_bytes: 1748
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n;
    string s;

    cin >> a >> b;

    switch(a){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            a=1;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            a=2;
            break;
        case 2:
            a=3;
            break;
    }
    switch(b){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            b=1;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            b=2;
            break;
        case 2:
            b=3;
            break;
    }

    if(a==b) cout << "Yes"; 
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
double x,a,b;
int main()
{	scanf("%lf%lf%lf",&x,&a,&b);
	if(fabs(x-a)<fabs(x-b))printf("A");
	else printf("B");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
city=[list(map(int,input().split())) for _ in range(n)]
length=[]
for i in range(n-1):
    for j in range(i+1,n):
        len=((city[i][0]-city[j][0])**2+(city[i][1]-city[j][1])**2)
        length.append(len**(0.5))
ans=sum(length)*2/n
print("{:.7f}".format(ans))

Measured memory_bytes: 9264
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        String[] sArray = new String[S.length()];
        for(int i = 0; i < S.length(); i++){
            String s2 = String.valueOf(S.charAt(i));
            sArray[i] = s2;
        }
        
        if(sArray[2].equals(sArray[3])){
            if(sArray[4].equals(sArray[5])){
                System.out.print("Yes");
            }else{
                System.out.print("No");
            }
        }else{
            System.out.print("No");
        }
        
    }
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	string S;
	cin >> S;
	
	for(int i = 0; i <= 7; i++){
		if(S.substr(0, i) + S.substr(S.size() - 7 + i) == "keyence"){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 256
counts = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

N = int(input())

for p in range(N):
    b,f,r,v = map(int,input().split())
    counts[b-1][f-1][r-1] += v

for i, building in enumerate(counts):
    for floar in building:
        for room in floar:
            print(" " + str(room), end = "")
        print()
    if i < 3:
        print("#"*20)


Measured memory_bytes: 5624
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 area=a*b;
        int length=2*(a+b);
        System.out.println(area+" "+length);
    }
}


Measured memory_bytes: 26048
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;




signed main()
{
 
    fast;
    int n , m ,k ; 
    cin >> n >> m >> k;
    readarr(a,n); readarr(b,m);
    vi sa(n) , sb(m) ;
    sa[0]=a[0]; sb[0]=b[0];
    rep(i,1,n-1) sa[i]=sa[i-1]+a[i];
    rep(i,1,m-1) sb[i]=sb[i-1]+b[i];
    int ans=0;
    rep(i,0,n-1){
    	if(sa[i]<=k){
    	int x = k - sa[i];
    	int j =0;
    	auto it = lower_bound(range(sb),x);
    	if(it==sb.end()){
    		j = m;
    	}
    	else {
    		j = it-sb.begin();
    		if(*it==x) j++;
    	}
    	ans = max(ans,i+j+1);
      }
    }
     rep(i,0,m-1){
    	if(sb[i]<=k){
    	int x = k - sb[i];
    	int j =0;
    	auto it = lower_bound(range(sa),x);
    	if(it==sa.end()){
    		j = n;
    	}
    	else {
    		j = it-sa.begin();
    		if(*it==x) j++;
    	}
    	ans = max(ans,i+j+1);
      }
    }
    cout<<ans<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 9544
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
int p[200];
int root(int x){
	if(p[x] < 0) return x;
	return p[x] = root(p[x]);
}
int h, w, dist[200][200];
int n, sz[200], to[200];
char in[12][13];

int main(){
	while(cin >> w >> h, h){
		int sy, sx, gy, gx;
		rep(i, h * w) p[i] = -1;
		rep(i, 200) rep(j, 200) dist[i][j] = i == j ? 0 : inf;
		
		rep(i, h){
			cin >> in[i];
			rep(j, w){
				if(in[i][j] == 'S') sy = i, sx = j;
				if(in[i][j] == 'G') gy = i, gx = j;
				if(in[i][j] == 'X') rep(d, 2){
					int ny = i + dy[d], nx = j + dx[d];
					if(ny >= 0 && nx >= 0 && in[ny][nx] == 'X'){
						int a = root(i * w + j), b = root(ny * w + nx);
						if(a != b){
							p[a] += p[b];
							p[b] = a;
						}
					}
				}
			}
		}
		rep(i, h) rep(j, w) if(in[i][j] != '#'){
			rep(d, 4){
				int ny = i + dy[d], nx = j + dx[d];
				if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
				if(in[ny][nx] == '#') continue;
				dist[i * w + j][ny * w + nx] = 1;
			}
		}
		rep(k, 200) rep(i, 200) rep(j, 200)
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
		
		priority_queue<pair<pi, pair<int, vi> > > q;  //cost*, cost, pos, ice
		set<pair<int, vi> > s;
		
		n = 0;
		memset(to, -1, sizeof(to));
		rep(i, h) rep(j, w) if(in[i][j] == 'X'){
			int r = root(i * w + j);
			if(to[r] < 0){
				sz[n] = -p[r];
				to[r] = n++;
			}
		}
		q.push(mp(mp(-dist[sy * w + sx][gy * w + gx], 0), mp(sy * w + sx, vi(n))));
		
		while(!q.empty()){
			vi v = q.top().second.second;
			int cost = q.top().first.second;
			int y = q.top().second.first;
			int x = y % w; y /= w;
			q.pop();
			
			if(s.count(mp(y * w + x, v))) continue;
			s.insert(mp(y * w + x, v));
			
			if(in[y][x] == 'G'){
				cout << -cost << endl;
				break;
			}
			
			rep(d, 4){
				int ny = y + dy[d], nx = x + dx[d];
				if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
				if(in[ny][nx] == '#') continue;
				vi nv = v;
				
				if(in[ny][nx] == 'X'){
					int r = to[root(ny * w + nx)];
					nv[r]++;
					if(sz[r] < nv[r] * 2) continue;
				}
				
				if(!s.count(mp(ny * w + nx, nv)))
				q.push(mp(mp(cost - dist[ny * w + nx][gy * w + gx], cost - 1), 
					mp(ny * w + nx, nv)));
			}
		}
	}
	return 0;
}

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

ll kosuu[10000010];

int main(){
    ll n;cin>>n;
    rep(i,0,10000010)kosuu[i]++;
    for(ll i=2;i<=10000000;i++){
        for(ll j=1;j*i<=10000000;j++){
            kosuu[i*j]++;
        }
    }
    ll an=0;
    rep(i,1,n+1){
        an+=i*kosuu[i];
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 81740
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		long[] H = new long[N];
		
		for(int i=0; i<N; i++) {
			H[i] = keyboard.nextLong();
		}
		
		for(int n=0; n<N; n++) {
			if(n==0) {
				H[n]--;
			}
			else if(H[n]-H[n-1]>=1) {
				H[n]--;
			}
		}
		
		String ans = "Yes";
		for (int i=0; i<N-1; i++) {
			if (H[i] > H[i+1]) {
				ans = "No";
			}
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}


Measured memory_bytes: 60448
/*
 * Author       : YangDavid
 * Created Time : 2019年07月21日 星期日 20时36分44秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 422222;
ll n, k, a[maxn], last[maxn], vis[maxn];
pii to[maxn]; // {idx, w}
ll cyc, tot;

signed main() {
    scanf("%lld%lld", &n, &k);
    rep(i, n) scanf("%lld", &a[i]), a[i + n] = a[i];
    for(int i = 1; i <= 2 * n; ++i) {
        int nxt = i + 1; while(nxt > n) nxt -= n;
        if(last[a[i]]) to[last[a[i]]] = {nxt, i-last[a[i]]+1};
        last[a[i]] = i;
    }

    int c = 1;
    while(!vis[c]) vis[c] = true, cyc += to[c].second, c = to[c].first;

    tot = 1LL * n * k % cyc;
    c = 1;
    while(tot >= to[c].second) {
        tot -= to[c].second;
        c = to[c].first;
    }

    vector<int> inq(maxn, 0);
    vector<int> ans;
    while(tot) {
        bool ins = true;
        while(inq[a[c]]) {
            inq[ans.back()]--;
            ans.pop_back();
            ins = false;
        }
        if(ins) ans.push_back(a[c]), inq[a[c]]++;
        c++;
        if(c > n) c -= n;
        tot--;
    }

    int sz = ans.size();
    for(int i = 0; i < sz; ++i)
        printf("%lld%c", ans[i], " \n"[i == sz - 1]);
    return 0;
}


Measured memory_bytes: 20848
dishes = []
for _ in range(5):
    dishes.append(int(input()))

min_dish_num = 0
for i in range(1, 5):
    if (dishes[min_dish_num] % 10) == 0:
        min_dish_num = i
    else:
        temp = dishes[i]%10
        if (temp) < (dishes[min_dish_num]%10) and temp != 0:
            min_dish_num = i

cnt = 0
for i in range(5):
    if i == min_dish_num:
        continue
    
    dish = dishes[i]

    cnt += (dish // 10) * 10
    
    if (dish % 10) != 0:
        cnt += 10

cnt += dishes[min_dish_num]

print(cnt)


Measured memory_bytes: 3064
#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, m;
    cin >> n >> m;
    priority_queue<int> a;
    rep(i, n) {
        int ai;
        cin >> ai;
        a.push(ai);
    }

    rep(i, m) {
        int j = a.top();
        a.pop();
        a.push(j/2);
    }
    ll sum = 0;
    while(!a.empty()) {
        sum += a.top();
        a.pop();
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main
{
  public static void main(String[] args) throws FileNotFoundException
  {
      Scanner scanner = new Scanner(System.in);//new File("input.txt"));
      int n = scanner.nextInt();
      long ans = 0;
      int[][] fr = new int[11][11];
      for(int i = 1 ; i <= n ; i++){
        int x = i;
        while(x >= 10) x /= 10;
        ++fr[i % 10][x];
      }
      for(int i = 1 ; i <= n ; i++){
        int x = i;
        while(x >= 10) x /= 10;
        ans += fr[x][i % 10];
      }
      System.out.println(ans);
  }
}


Measured memory_bytes: 21460
//#define MYDEBUG
#define _CRT_SECURE_NO_WARNINGS
#define TASK "c1"
#pragma comment(linker, "/STACK:67108864")
#include <cstdio>
#include <iostream>
#include <iomanip> 
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <cassert>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>

const int MOD = 1000000007;
const int INF = 1000000001;
const int MAXN = 400;
const long double EPS = 1e-9;
const int HASH_POW = 29;
const long double PI = acos(-1.0);

using namespace std;

double workTime()
{
	return double(clock()) / CLOCKS_PER_SEC;
}

void my_return(int code)
{
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int main()
{
	cin.sync_with_stdio(0);
	cin.tie(0);
	mt19937 mt_rand(time(0));
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "rt", stdin);
	freopen(TASK".out", "wt", stdout);*/
	/*freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);*/
#endif

	int n, k;
	bool good[10];
	memset(good, true, sizeof good);
	scanf("%d %d", &n, &k);
	for (int i = 0; i < k; ++i)
	{
		int foo;
		scanf("%d", &foo);
		good[foo] = false;
	}

	while (true)
	{
		int s = n;
		bool ans = true;
		while (s)
		{
			if (!good[s % 10])
				ans = false;
			s /= 10;
		}
		if (ans)
		{
			printf("%d\n", n);
			my_return(0);
		}
		++n;
	}

	my_return(0);
}

Measured memory_bytes: 256
#include <iostream>
#define N 2005
#define INF 1e18
using namespace std;
typedef long long ll;
ll n, m, a[N], b[N], c[N], d[N];
bool f() {
	int i, j;
	for(i=0; i<=n; i++) d[i]=-INF;
	d[1]=0;
	for(i=0; i<=n; i++) for(j=0; j<m; j++) {
		if(d[b[j]] < d[a[j]] + c[j]) {
			d[b[j]] = d[a[j]] + c[j];
			if(i==n && b[j]==n) return 0;
		}
	}
	return 1;
}

int main() {
	cin>>n>>m;
	for(int i=0; i<m; i++) cin>>a[i]>>b[i]>>c[i];
	f() ? cout<<d[n] : cout<<"inf";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	int N;
	cin >> N;

	map<int, int> has_info;

	for (int i = 0; i < N; i++)
	{
		int d;
		cin >> d;

		has_info[d]++;
	}

	int M;
	cin >> M;

	for (int i = 0; i < M; i++)
	{
		int t;
		cin >> t;

		if (has_info[t] < 1)
		{
			cout << "NO";
			return 0;
		}
		else
		{
			has_info[t]--;
		}
	}

	cout << "YES";

	return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> given(n-1);
    vector<long long> ans(n,0);
    for(int i=0;i<n-1;i++){
        cin >> given[i];
    }
    for(int i=0;i<n-1;i++){
        ans[given[i]-1] +=1;
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6428
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: chars);
    let t = match s.into_iter().collect::<String>().as_ref() {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => unreachable!(),
    };
    puts!("{}\n", t);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << "\n";
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
vector<int> B[N];
vector<int> R[N];
bool black[N];
int par[N];
int lay[N];

void dfs1(int u, int pp){ 
  par[u] = pp;
  for(auto x : B[u]){
    if(x == pp) continue;
    lay[x] = lay[u] + 1;
    dfs1(x,u);
  }
}

int dis[N];

void dfs2(int u, int pp){
  if(dis[u] >= lay[u]){
    dis[u] = (int)1e9;
  }
  for(auto x : R[u]){
    if(x == pp) continue;
    dis[x] = dis[u] + 1;
    dfs2(x,u);
  }
}

int main(){
  fastIO;
  int n, x, y;
  cin >> n >> x >> y;
  int u, v;
  for(int i = 1 ; i < n; i ++ ){
    cin >> u >> v;
    R[u].push_back(v);
    R[v].push_back(u);
  }
  for(int i = 1; i < n; i ++ ){
    cin >> u >> v;
    B[u].push_back(v);
    B[v].push_back(u);
  }
  dfs1(y,0);
  dfs2(x,0);
  bool check;
  for(int i = 1; i <= n; i ++ ){
    for(auto j : R[i]){
      check = true;
      if(par[j] == i || par[par[j]] == i || par[i] == j || par[par[i]] == j || par[i] == par[j]) check = false;
      if(check){
        black[i] = true;
        black[j] = true;
      }
    }
  }
  for(int i = 1; i <= n; i ++ ){
    if(black[i] && dis[i] < (int)1e9){
      cout << "-1\n";
      return 0;
    }
  }
  int res = 2;
  for(int i = 1; i <= n; i ++ ){
    if(dis[i] >= (int)1e9) continue;
    res = max(res, lay[i] * 2);
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 33276
#include <iostream> 
#include <sstream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <functional> 
#include <utility> 
#include <bitset> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
using namespace std;

int par[100005];
pair<int,int> x[100005],y[100005];
pair<int, pair<int,int> > edge[200005];

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

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

void unite(int x,int y){
	x=find(x);
	y=find(y);
	par[x]=y;
}

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		x[i]=make_pair(a,i);
		y[i]=make_pair(b,i);
	}
	sort(x+1,x+n+1);
	sort(y+1,y+n+1);
	for(int i=1;i<=n-1;i++){
		edge[2*i-1]=make_pair(x[i+1].first-x[i].first,make_pair(x[i].second,x[i+1].second));
		edge[2*i]=make_pair(y[i+1].first-y[i].first,make_pair(y[i].second,y[i+1].second));
	}
	sort(edge+1,edge+2*n-1);
	for(int i=1;i<=n;i++) par[i]=i;
	int sum=1,ans=0,ind=1;
	while(sum<n){
		int p1,p2;
		p1=edge[ind].second.first;
		p2=edge[ind].second.second;
		if(same(p1,p2)==false){
			unite(p1,p2);
			ans+=edge[ind].first;
			sum++;
		}
		ind++;
	}
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 5248
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#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 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 inf (1ll<<60)
#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>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

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 n,w;
    cin>>n>>w;
    vi a(n),b(n);
    int v=0;
    rep(i,n){
        cin>>a[i]>>b[i];
        v+=b[i];
    }
    vvi dp(n+1,vi(v+1));
    rep(i,n+1)rep(j,v+1)dp[i][j]=inf;
    rep(i,n+1)dp[i][0]=0;
    REP(i,1,n){
        REP(j,1,v){
            if(j>=b[i-1]&&dp[i-1][j-b[i-1]]+a[i-1]<=w){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-b[i-1]]+a[i-1]);
            }
            else {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    // rep(i,n+1){rep(j,v+1)cout<<dp[i][j]<<" ";cout<<endl;}
    int ans=0;
    rep(i,v+1){
        if(dp[n][i]!=inf)ans=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 80256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll t;
	cin >> n >> t;
	ll b = -1e9, ans = 0;
	rep(i,n){
		ll a;
		cin >> a;
		if(b <= a){
			ans += t;
			b = a + t;
		}
		else{
			ans += a + t - b;
			b = a + t;
		}
	}
	cout << ans << endl;
	return 0;
}

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

signed main(){
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if((A == 7 && B == 5 && C == 5) || (A == 5 && B == 7 && C == 5) || (A == 5 && B == 5 && C == 7)){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

#define int long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define x first
#define y second

int a[100001],b[100001],c[100001];

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

	int n;
	cin>>n;
	int sum=0;
	map<int,int> mp;
	for (int i=0; i<n; i++){
		cin>>a[i];
		sum+=a[i];
		mp[a[i]]++;
	}
	int q;
	cin>>q;
	for (int i=0; i<q; i++){
		cin>>b[i]>>c[i];
		int x=c[i]-b[i];
		sum+=x*mp[b[i]];
		cout<<sum<<endl;
		mp[c[i]]+=mp[b[i]];
		mp[b[i]]=0;
	}
	return 0;
}

Measured memory_bytes: 11788
#include<bits/stdc++.h>
using namespace std;
#define Accepted return 0;
int main()
{
    long long N,h,n,w,fz,fm;
    cin>>N;
    for(h=1;h<=3500;h++)
        for(n=1;n<=3500;n++)
        {
            fz=4*h*n-N*n-N*h;
            fm=N*h*n;
            if (fz>0 && fm%fz==0)
            {
                w=fm/fz;
                cout<<h<<" "<<n<<" "<<w<<endl;
                Accepted
            }
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,M,dist[100005];
vector<P>G[100005];
bool used[100005],used2[100005];
void bfs(){
	queue<int>que;
	REP(i,N)dist[i]=inf;
	dist[0]=0;que.push(0);
	while(!que.empty()){
		int i=que.front();que.pop();
		for(auto j:G[i]){
			if(dist[j.first]==inf){
				dist[j.first]=dist[i]+1;
				que.push(j.first);
			}
		}
	}
}
int cnt[100005];
void dfs(int x){
	used[x]=true;
	for(auto i:G[x])if(!used[i.first]&&dist[i.first]==dist[x]+1)dfs(i.first);
	vector<int>v;
	for(auto i:G[x]){
		if(dist[i.first]==dist[x]&&!used2[i.second]){
			cout<<x+1<<" "<<i.first+1<<endl;
			used2[i.second]=true;
			cnt[x]++;
		}else if(dist[i.first]==dist[x]-1){
			v.pb(i.first);
		}
	}
	if((cnt[x]+len(v))&1){
		rep(i,len(v)-1){
			cout<<x+1<<" "<<v[i]+1<<endl;
		}
		cout<<v.back()+1<<" "<<x+1<<endl;
		cnt[v.back()]++;
	}else {
		for(int i:v){
			cout<<x+1<<" "<<i+1<<endl;
		}
	}
}
signed main(){
	cin>>N>>M;
	if(M%2){
		cout<<-1<<endl;return 0;
	}
	rep(i,M){
		int a,b;cin>>a>>b;a--;b--;
		G[a].pb({b,i});G[b].pb({a,i});
	}
	bfs();
	dfs(0);
}


Measured memory_bytes: 15616
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = new char[s.length()];
        for(int i = 0; i < s.length(); i++){
            c[i] = s.charAt(i);
        }
        String s2 = String.format("%c%s%c", c[0], s.length()-2, c[s.length()-1]);
        System.out.print(s2);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

int main(){

    string s;
    cin >> s;

    ll ans = 0;

    for(int bit = 0; bit < (1<<(s.size() - 1)); bit++){
        ll tmp = s[0] - '0';

        for(int i = 0; i < s.size() - 1; i++){
            if(bit & 1<<i){
                ans = ans + tmp;
                tmp = s[i + 1] - '0';
            }else{
                tmp = tmp * 10 + s[i + 1] - '0';
            }
        }
        ans = ans + tmp;
    }

    cout << ans << endl;
    

    return 0;

}

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
#n = int(readline())
n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))
memo = [0]
for i in range(1,1001):
    memo.append(memo[-1]+i)
for i in range(1,1001):
    memo[i] /= i 

for i in range(len(lst1)):
    lst1[i] = memo[lst1[i]]

p = sum(lst1[:k])
ans = 0
for i in range(n-k+1):
    ans = max(ans,p)
    if i + k >= len(lst1):
        break 
    p -= lst1[i]
    p += lst1[i+k]

print(ans)





Measured memory_bytes: 66800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll s1 = atol(S.substr(0,2).c_str());
    ll s2 = atol(S.substr(2,2).c_str());
    if(s1 >= 1 && s1 <= 12 && s2 >= 1 && s2 <= 12){
        print("AMBIGUOUS");
    }else if(s1 >= 1 && s1 <= 12){
        print("MMYY");
    }else if(s2 >= 1 && s2 <= 12){
        print("YYMM");
    }else{
        print("NA");
    }



    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define repP(i, a, b) for(int i = a; i < b; i++)
#define repM(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  int sum = 0, num = 0, count = 0, ans = 0, min = 0, max = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[999999], a2[999999], a3[999999];
  //char s1[200000], s2[200000], s3[200000];
  //string s1, s2, s3;
  
  cin >> a >> b;
  a1[0] = a1[1] = a1[2] = 0;
  a1[a - 1]++;
  a1[b - 1]++;
  if(a1[0] == 0){
    cout << 1 << endl;
  }else if(a1[1] == 0){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }
}
  


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif


int main()
{
    unsigned K;
    cin >> K;

    // 1, 2, 3, ... 9 : 9
    // 10, 11, 12, 21, 22, 23, ..., 89, 98, 99 : 27 - 1
    // 100, 101, 110, 111, 112, ..., 988, 989, 998, 999 : (26 * 3) - 3

    vector<ull_t> N1({1, 2, 3, 4, 5, 6, 7, 8, 9});
    vector<ull_t> N2;
    while (N1.size() < K)
    {
        for (auto n : N1)
        {
            ull_t x = n * 10;
            ull_t y = n % 10;
            if (y > 0)
                N2.push_back(x + y - 1);
            N2.push_back(x + y);
            if (y < 9)
                N2.push_back(x + y + 1);
        }
        K -= N1.size();
        N1 = std::move(N2);
        N2.clear();
    }

    cout << N1[K - 1] << endl;
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W; cin>>H>>W;
  vii A(H,vi(W));
  rep(i,0,H){
    rep(j,0,W) cin>>A[i][j];
  }
  rep(i,0,H){
    rep(j,0,W){
      int X; cin>>X;
      A[i][j]-=X;
      A[i][j]=abs(A[i][j]);
    }
  }
  bool dp[81][81][25601]={0};
  dp[0][1][12800]=1;
  rep(i,0,H){
    rep(j,0,W){
      REP(k,0,25600){
        if(dp[i][j+1][k]||dp[i+1][j][k]){
          if(k+A[i][j]<=25600) dp[i+1][j+1][k+A[i][j]]=1;
          if(k-A[i][j]>=0) dp[i+1][j+1][k-A[i][j]]=1;
        }
      }
    }
  }
  int ans=INF;
  REP(i,0,25600){
    if(dp[H][W][i]) ans=min(ans,abs(12800-i));
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 164352
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		sc.close();
		String ans[] = { "Yes", "No" };
		int an = 0;
		int n = t.length();
		int change[] = new int[27];
		int change2[] = new int[27];
		for (int i = 0; i < 27; ++i) {
			change[i] = -1;
			change2[i] = -1;
		}
		for (int i = 0; i < n; ++i) {
			int tmpt = t.charAt(i) - 'a';
			int tmps = s.charAt(i) - 'a';
			if (change[tmps] < 0) {
				change[tmps] = tmpt;
			} else {
				if (change[tmps] != tmpt) {
					an = 1;
					break;
				}
			}
			if (change2[tmpt] < 0) {
				change2[tmpt] = tmps;
			} else {
				if (change2[tmpt] != tmps) {
					an = 1;
					break;
				}
			}
		}
		System.out.println(ans[an]);
	}
}


Measured memory_bytes: 27660
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[110000];
int t[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int f=0;
	for(int i=0;i<a;i++){
		f=max(f,p[i]);
		t[p[i]]++;
		if(i==0&&p[i]){
			printf("0\n");return 0;
		}
		if(i&&p[i]==0){
			printf("0\n");return 0;
		}
	}
	init_C(210000);
	long long ret=1;
	for(int i=1;i<=f;i++){
		ret=ret*pw(t[i-1],t[i])%mod;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 12416
use std::cmp::*;
use std::collections::BTreeSet;
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}
fn main() {
    let n: usize = read();
    let rgb = read_string();
    //表現形式の変更
    let mut rs = vec![];
    let mut gs = vec![];
    let mut bs = BTreeSet::new();
    for (index, value) in rgb.into_iter().enumerate() {
        match value {
            'R' => rs.push(index),
            'G' => gs.push(index),
            'B' => {
                bs.insert(index);
            }
            _ => unreachable!(),
        }
    }

    let mut count = 0;
    // println!("{:?}", bs);
    for r in rs.iter() {
        for g in gs.iter() {
            let i = min(r, g);
            let j = max(r, g);
            //println!("{} {}", i, j);
            let d = j - i;
            let mut count2d = bs.len();

            if *i > d && bs.contains(&(i - d)) {
                //println!("a");
                count2d -= 1;
            }
            if bs.contains(&(j + d)) {
                //println!("b");
                count2d -= 1;
            }
            if d & 0x1 == 0 && bs.contains(&(i + (d / 2))) {
                //println!("c");
                count2d -= 1;
            }
            count += count2d;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2208
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

bonus = 0

for i in range(N-1):
    if A[i+1]==A[i]+1:
        bonus+=C[A[i]-1]



from functools import reduce

print(reduce(lambda x,y: x+y,B) + bonus)


Measured memory_bytes: 3572
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str, res;
	int n;

	cin >> str;

	n = str.length();
	res = "";

	for (int i = 0; i < n; ++i)
	{
		if (str[i] == '0')
			res.append("0");

		if (str[i] == '1')
			res.append("1");

		if (str[i] == 'B')
		{
			if (!res.empty())
				res.pop_back();
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256