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


public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {

	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int[] a = new int[n+1];
		int s = 0;

		for (int i=1; i<=n; ++i) {
			a[i] = in.nextInt();
			s += a[i];
		}

		int m = in.nextInt(), idx, x;
		int ans;

		for (int i=0; i<m; ++i) {
			idx = in.nextInt();
			x = in.nextInt();
			ans = s + x - a[idx];
			out.println(ans);
		}
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;


	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21460
#include <stdio.h>
#include <math.h>

int main(void){
    int n, m;
    int d[5][2];
    int i, j, flag;
    int max;
    char str[5];
    scanf("%d %d", &n, &m);
    
    for(i = 0; i < m; i++){
        scanf("%d %d", &d[i][0], &d[i][1]);
    }
    
    max = pow(10, n);
    i = max/10;
    i = (i == 1) ? 0 : i;
    for(; i < max; i++){
        sprintf(str, "%d", i);
        //printf("%s\n", str);
        for(j = 0; j < m; j++){
            if(str[d[j][0]-1] != d[j][1] + '0') break;
        }
        if(j == m) break;
    }
    
    if(i == max) i = -1;
    //if(i == 0 && n != 1) i = -1;
    printf("%d", i);
    
    return 0;
}
    

Measured memory_bytes: 128
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		int[] a = new int[26];
		for(i=0;i<s.length;i++) {
			a[s[i]-'a']++;
		}
		boolean f=true;
		for (i = 0; i < a.length; i++) {
			if(a[i]>1) {
				f=false;
				break;
			}
		}
		out.println(f?"yes":"no");
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,w,i,j,a,b;scanf("%lld%lld",&n,&w);
  long long dp[n+1][w+1] = {};
  for(i=0;i<n;i++){
    scanf("%lld%lld",&a,&b);
    for(j=a;j<=w;j++) dp[i+1][j] = max(dp[i][j],dp[i][j-a]+b);
    for(j=0;j<a;j++) dp[i+1][j] = dp[i][j];
  }
  printf("%lld\n",dp[n][w]);
}

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

using namespace std;

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

int main(){
    int x, a;
    cin >> x >> a;
    if (x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    
}


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

string a, b;
int c;


int main() {
	cin >> a >> b;
	string tmp = a + b;
	c = stoi(tmp);

	int sq = sqrt(c);
	if (sq*sq == c || (sq - 1) * (sq - 1) == c || (sq + 1)* (sq + 1) == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
<?php
$input = fgets(STDIN);
// $input = '1000 10';
$temps = explode(' ',$input);
$h = intval($temps[0]);
$a = intval($temps[1]);

$count = 0;
while($h > 0){
    $count++;
    $h -= $a;
}

echo $count;

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
string s[110],t[110];
int main (void){
    int n,m;
    cin>>n;
    for (int i = 0; i < n; ++i)
        cin>>s[i];
    cin>>m;
    for (int i = 0; i < m; ++i)
        cin>>t[i];
    int ans= 0;
    for (int i = 0; i < n; ++i)
    {
        int score =  0;
        for (int j = 0; j < n; ++j)
            if (s[j]==s[i]) score++;
        for (int j = 0; j<m ; j++)
            if (t[j]==s[i]) score--;
        ans = max(ans,score);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

def main():

    # sys.stdin = open('input148c.txt')

    a, b = map(int, input().split())

    ai = a
    bi = b

    while ai != bi:
        if ai < bi:
            ai += a
        else:
            bi += b

    print(ai)

if __name__ == '__main__':
    main()


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

using namespace std;

const int max_n = 111, inf = 1000111222;

int n, sum, a[max_n], ans = inf;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int x = 0;
    for (int i = 0; i + 1 < n; ++i) {
        x += a[i];
        sum -= a[i];
        ans = min(ans, abs(x - sum));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
   	int n;
   	scanf("%d", &n);
   	char input[n];
   	int flag = 1;
   	scanf("%s", input);
   	if(n % 2 != 0)
   	{
	   puts("No");
	} else
	{
		for (int i = 0; i < n/2;i++)
		{
			if(input[i] != (input[(n/2)+i]))
			{
				flag = 0;
			}
		}
		if(flag == 1)
		{
			puts("Yes");
		} else
		{
			puts("No");
		}
	}
   	
	
	return 0;
} 

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

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i >= 1 && i < 10) ans++;
    if (i >= 100 && i < 1000) ans++;
    if (i >= 10000 && i < 100000) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

struct Edge {
    int u, v, d, w, next;
}edge[100005];
int n, m;
int head[10005], cnt;
int q[10000006];
//int pre[10005];
int vis[20010];
int dis[10005];
int cost[10005];

void init() {
    cnt=0;
    memset(cost, 0x3f3f3f3f, sizeof(cost));
    memset(dis, 0x3f3f3f3f, sizeof(dis));
    memset(vis, 0, sizeof(vis));
//    memset(pre, -1, sizeof(pre));
    memset(head, -1, sizeof(head));
}

void Add() {
    int u, v, d, w;
    for(int i=0;i<m;i++) {
        scanf("%d%d%d%d", &u, &v, &d, &w);
        edge[cnt].u=u;
        edge[cnt].v=v;
        edge[cnt].d=d;
        edge[cnt].w=w;
        edge[cnt].next=head[u];
        head[u]=cnt++;

        edge[cnt].u=v;
        edge[cnt].v=u;
        edge[cnt].d=d;
        edge[cnt].w=w;
        edge[cnt].next=head[v];
        head[v]=cnt++;
    }
}

void spfa() {
    int fro=0, rear=1;
    vis[1]=1;
    q[fro]=1;
    dis[1]=0;
    cost[1]=0;
    while(fro!=rear) {
        int u=q[fro++];
        for(int i=head[u];~i;i=edge[i].next) {
            int v=edge[i].v, d=edge[i].d, w=edge[i].w;
            if(dis[v]>dis[u]+d) {
//                pre[v]=u;
                dis[v]=dis[u]+d;
                cost[v]=w;
                if(!vis[v]) {
                    vis[v]=1;
                    q[rear++]=v;
                }
            } else if(dis[v]==dis[u]+d&&cost[v]>w) {
                cost[v]=w;
//                pre[v]=u;
                if(!vis[v]) {
                    vis[v]=1;
                    q[rear++]=v;
                }
            }
        }
        vis[u]=0;
    }

    int ans=0;
    for(int i=1;i<=n;i++) {
        ans+=cost[i];
    }
    printf("%d\n", ans);
}

int main () {
    while(~scanf("%d%d", &n, &m)&&(n+m)) {
        init();
        Add();
        spfa();
    }
    return 0;
}



Measured memory_bytes: 4160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  ll s = 0;
  rep(i, n) {
    cin >> a[i];
    s += a[i];
  }
  ll ans = LLONG_MAX;
  ll t = 0;
  rep(i, n - 1) {
    s -= a[i];
    t += a[i];
    ans = min(ans, abs(s - t));
  }
  cout << ans << endl;

}

Measured memory_bytes: 1024
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

vi V(3);

signed main(){

    in(V);
    sort(all(V));
    out(V[0]+V[1]);

    return 0;
}


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

int main(){
  int n, ac = 0, wa = 0, tle = 0, re = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    string str;
    cin >> str;
    if(str == "AC"){
      ac++;
    }
    else if(str == "WA"){
      wa++;
    }
    else if(str == "TLE"){
      tle++;
    }
    else if(str == "RE"){
      re++;
    }
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char s3 = s.charAt(2);
        char s4 = s.charAt(3);
        char s5 = s.charAt(4);
        char s6 = s.charAt(5);
        if((s3==s4)&&(s5==s6)){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<queue>
#include<algorithm>
#define inf 1000000001
#define f first
#define s second
using namespace std;

int map[1000][1000];
int n,m,s,t,c;

int Prim()
{
  priority_queue<pair<int,int> > PQ;
  int d[1000],color[1000];
  for(int i=0;i<n;i++){
    d[i]=inf;
    color[i]=0;
  }
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=0;
  while(!PQ.empty()){
    pair<int,int> p=PQ.top();PQ.pop();
    int u=p.s;
    color[u]=2;

    if(d[u]<p.f*(-1))continue;

    for(int i=0;i<n;i++){
      if(color[i]==2 || map[u][i]==inf)continue;
      if(d[i]>map[u][i]){
	d[i]=map[u][i];
	PQ.push(make_pair(d[i]*(-1),i));
	color[i]=1;
      }
    }
  }
  sort(d,d+n);
  return d[n/2];
}  

int main()
{
  while(1){
    cin>>n>>m;
    if(n+m==0)break;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)map[i][j]=inf;
    for(int i=0;i<m;i++){
      cin>>s>>t>>c;
      map[s-1][t-1]=c;
      map[t-1][s-1]=c;
    }
    cout<<Prim()<<endl;
  }
  return 0;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// nCr mod を計算する O(n)
const int MAX_N = 2000010;
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll x,y;
    cin>>x>>y;

    if(2*y-x<0 || 2*x-y<0){
        cout<<0<<endl;
        return 0;
    }

    if((2*y-x)%3!=0 || (2*x-y)%3!=0){
        cout<<0<<endl;
        return 0;
    }

    ll a=(2*y-x)/3;
    ll b=(2*x-y)/3;

    COMinit();
    cout<<COM(a+b,a)<<endl;
}


Measured memory_bytes: 50496
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var array = new long[100001];
        var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = input[0];
        var k = input[1];
        
        for(var i = 0;i < n;i++){
            var x = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var a = x[0];
            var b = x[1];
            array[a] += b;
        }
        for(var i = 0;i < array.Length;i++){
            if(k <= array[i]){
                Console.WriteLine(i);
                return;
            }else{
                k -= array[i];
            }
        }
    }
}


Measured memory_bytes: 15968
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

int a,b,c,d,e,f;

int main()
{
    cin >> a >> b >> c >> d >> e >> f;
    int n = 0;
    double ans = 0.0;
    int satou=0;
    int mizu=a;
    rep(x1, (int)(f/a)+1){
        rep(x2, (int)(f/b)+1){
            n = x1*a + x2*b;
            if(n*100 > f || n == 0) continue;

            int mmax = min(n*e, f-(n*100));
            int m = 0;
            rep(y1, (int)(mmax/c)+1){
                rep(y2, (int)(mmax/d)+1){
                    if(y1*c + y2*d > mmax) continue;
                    m = max(m, y1*c + y2*d);
                }
            }
            if(ans <= (double)100*m/(n+m)){
                ans = (double)100*m/(n+m);
                satou = m;
                mizu = 100 * n;
            }
        }
    }
    cout << mizu+satou << ' ' << satou << endl;
}


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

using namespace std;

int main()
{
	int A,B,C,D,E,F;
	cin>> A>> B>> C>> D>> E>> F;

	
	int sugar,water;
	float par=0;
	for(int a=0;a<=F;a+=100*A)
	for(int b=0;a+b<=F;b+=100*B)
	for(int c=0;a+b+c<=F;c+=C)
	for(int d=0;a+b+c+d<=F;d+=D)
	{
		float x=a+b,y=c+d;
		if(x+y!=0&&(float)E/100>=y/x&&par<=(y)/(x+y))
		{
			par=y/(x+y);
			water=x+y;
			sugar=y;
		}
	}
	cout<< water<< " "<< sugar<< endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a == b {
		fmt.Println("Draw")
		return
	}
	if a == 1 {
		fmt.Println("Alice")
		return
	}
	if b == 1 {
		fmt.Println("Bob")
		return
	}
	if a > b {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

int main(){
    
    int n1,n2,t1,t2,a,b,c,d,n_sum = 0,t_sum = 0;
    cin >> n1 >> n2;
    cin >> t1 >> t2;
    
    cin >> a >> b >> c >> d;
    n_sum = (n1*a+n2*b+(n1/10)*c+(n2/20)*d);
    t_sum = (t1*a+t2*b+(t1/10)*c+(t2/20)*d);
    
    if(n_sum > t_sum){
        cout << "hiroshi" <<endl;
    }
    else if(n_sum < t_sum){
        cout << "kenjiro" <<endl;
    }
    else{
        cout << "even" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=500010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v,vans;
vp p[100010];
string s;
ll solve(void){
    if(a>12)return b;
    if(a>5)return b/2;
    return 0;
}
int main(){
    cin>>a>>b>>c;
    rep(i,10){
     c=a*c-b;
     v.push_back(c);
    }
 
    rep(i,10){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
long long int a[1010],x,y;
int main()
    {
        cin>>x>>y;
        int now=0;
        for(int i=1;i<=999;i++)
            {
                now+=i;
                if((now-x)==(now+i+1-y))
                    {
                        cout<<now-x<<endl;
                        return 0;
                    }
            }
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++) 
#define FOR(i,ini,n) for(int i=(ini);i<(n);i++)

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n){
		vector<int> sum1(n);
		vector<int> v2(n);
		vector<int> sum2(n);
		int sum = 0;
		REP(i,n){
			int a;
			cin >> a;
			sum += a;
			sum1[i] = sum;
		}
		sum = 0;
		REP(i,n){
			cin >> v2[i];
			sum += v2[i];
		}
		
		REP(i,n){
			sum2[i] = sum;
			sum -= v2[i];
		}
		
		int ans = 0;
		REP(i,n){
			ans = max(ans,sum1[i] + sum2[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int Max_N=1e7+5;

bool is_prime[Max_N];

int main(){
	int N;
	cin >> N;
	vector<int> p;
	for(int d=2; d<=N; d++) is_prime[d]=true;
	for(int d=2; d<=N; d++){
		if(is_prime[d]){
			p.emplace_back(d);
			for(int r=2; d*r<=N; r++) is_prime[d*r]=false;
		}
	}
	vector<LL> f(N+1);
	for(int X=1; X<=N; X++) f[X]=1;
	for(int X=2; X<=N; X++){
		int Xc=X;
		if(is_prime[Xc]){
			f[X]=2;
			continue;
		}
		rep(i,p.size()){
			int num=0;
			if(Xc%p[i]==0){
				while(Xc%p[i]==0){
					Xc/=p[i];
					num++;
				}
				f[X]*=num+1;
				f[X]*=f[Xc];
				break;
			}
		}
	}
	LL ans=1;
	for(int X=2; X<=N; X++){
		LL res=X;
		res*=f[X];
		ans+=res;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 93956
import bisect

n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

result = 0
for i in range(n):
    x = bisect.bisect_left(a, b[i])
    y = n - bisect.bisect_right(c, b[i])
    result += x*y


print(result)

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    namespace _DSU{
    int cnt=0;
    int mem[2][212345];
    int* get(){
        return mem[cnt++];
    }
}
class UnionFind{    
public:
    int *par,*rank;
    int find(int x){
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
    }
    UnionFind(int n,int *par,int *rank) :par(par),rank(rank){
	for(int i = 0; i < n; i++)par[i] = i,rank[i] = 0;
    }
    UnionFind(int n):UnionFind(n,_DSU::get(),_DSU::get()){}
    bool unite(int x, int y){
	x = find(x);y = find(y);
	if (x == y)return false;
	if (rank[x] < rank[y]) par[x] = y;
	else{
	    par[y] = x;
	    if (rank[x] == rank[y])rank[x]++;
	}
	return true;
    }
    bool same(int x, int y){
	return find(x) == find(y);
    }
};

int main(){
    int N,M;
    cin>>N>>M;
    UnionFind uf(2*N);
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b+N);
        uf.unite(a+N,b);
    }
    vector<int> cnt(2*N);
    REP(i,2*N)cnt[uf.find(i)]++;
    LL a,b,c;
    a=b=c=0;
    REP(i,2*N){
        if(i<N&&cnt[i]==1)a++;
        else if(cnt[i]>0&&uf.same(i,(i+N)%(2*N)))b++;
        else if(cnt[i]>1)c++;
    }
    c/=2;
    //cout<<a<<b<<c<<endl;
      //  cout<<2*a*(N-a)+a*a<<endl<<c*(c+1)<<endl<<b*c<<endl<<b*(b+1)/2<<endl;    
     cout<<2*a*(N-a)+a*a+2*c*c+2*b*c+b*b<<endl;
    //(bb+2bc+2cc)
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;

ll a,b;
int ans=0;

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c>'9'||c<'0')&&c!='-')c=getchar();
   	if(c=='-')t=-1,c=getchar();
   	while(c>='0'&&c<='9')s=s*10+c-'0',c=getchar();
   	return s*t;
}

int main(void){
	scanf("%lld %lld",&a,&b);
	ll p=__gcd(a,b);
	for(ll i=2;i*i<=p;i++){
		if(p%i==0){
			ans++;
			while(p%i==0)p/=i;
		}
	}
	if(p!=1)ans++;
	printf("%d\n",ans+1);
}


Measured memory_bytes: 256
w, h, x, y = gets.chomp.split(" ").map(&:to_i)

s = w.to_f * h.to_f / 2.0

if (w % 2 == 0) && (h % 2 == 0) && (x == w / 2) && (y == h / 2)
    puts "#{s} 1"
else
    puts "#{s} 0"
end

Measured memory_bytes: 1788
#include<stdio.h>
void check_day(int day);
main()
{
	int month[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
	int i = 0, sum = 0;
	int mon = 0, day = 0;
	
	while(1)
	{
		scanf("%d %d", &mon, &day);
		if(mon == 0)
		{
			break;
		}
		for(i = 0; i < mon; i++)
		{
			sum += month[i];
		}
		day += sum;
		check_day(day);
		sum = 0;
	}
	
	return 0;
}
void check_day(int day)
{
	//printf("%d\n", day);
	switch(day % 7)
	{
	case 0:
		printf("Wednesday\n");
		break;
	case 1:
		printf("Thursday\n");
		break;
	case 2:
		printf("Friday\n");
		break;
	case 3:
		printf("Saturday\n");
		break;
	case 4:
		printf("Sunday\n");
		break;
	case 5:
		printf("Monday\n");
		break;
	case 6:
		printf("Tuesday\n");
		break;
	}
}

Measured memory_bytes: 584
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/
//---------------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//---------------------------------------------------
LL max(LL a, LL b){
  if (a > b) {
    return a;
  }else return b;
}

int main(void)
{
  char n[4];
  scanf("%s", &n);
  if (strcmp(n,"ABC") == 0) {
    printf("ARC\n" );
  }else printf("ABC\n");
}


Measured memory_bytes: 1608
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 3e5 + 100 , N = 2e6 + 10 , SQ = 320 , base = 97 , mod = 1e9 + 7 , INF = 1e18 , lg = 19;

int H , S , E , ans , p[maxn] , pos[maxn] , sum[maxn];
vector <int> leaf;
bool mark[maxn];

inline void get(int v) {
    int s = v , e = v;
    for (int i = 0; i < H - 1; ++i) {
        s = (s * 2);
        e = (e * 2) + 1;
    }
    S = s; E = e;
    for (int i = s; i <= e; ++i) {
        leaf.PB(i);
        mark[i] = 1;
        pos[i] = i - s;
    }
}



inline void undo_root(int v) {
    while(v >= 1) {
        sum[v] = 0;
        v /= 2;
    }
}
inline void undo(int v) {
    int s = v , e = v;
    while(!mark[s] && !mark[e]) {
        s = (2 * s);
        e = (2 * e + 1);
    }
    for (int i = s; i <= e; ++i) {
        int idx = pos[i];
        undo_root(leaf[p[idx]]);
    }
}


inline void go_root1(int v , int val) {
    while(v >= 1) {
        val = (val * v) % mod;
        sum[v] += val;
        v /= 2;
    }
}
inline void go_root2(int v , int val) {
    while(v > 1) {
        val = (val * v) % mod;
        int par = v / 2;
        int other_child = (par * 2 == v ? v + 1 : v - 1);
        ans = (ans + (((par * sum[other_child]) % mod) * val) % mod) % mod;
        v /= 2;
    }
}


void go_l(int v , int val) {
    val = (val * v) % mod;
    if(mark[v]) {
        int idx = pos[v];
        go_root1(leaf[p[idx]] , val);
        return;
    }
    go_l(2 * v , val);
    go_l(2 * v + 1 , val);
}
void go_r(int v , int val) {
    val = (val * v) % mod;
    if(mark[v]) {
        int idx = pos[v];
        // cout << leaf[idx] << ' ' << leaf[p[idx]] << endl;
        go_root2(leaf[p[idx]] , val);
        return;
    }
    go_r(2 * v , val);
    go_r(2 * v + 1 , val);
}



void fix_lca(int v) {
    go_l(2 * v , v);
    go_r(2 * v + 1 , 1);
    undo(2 * v);
}

int32_t main() {
	FAST
    cin >> H;
    for (int i = 0; i < (1 << (H - 1)); ++i) {
        cin >> p[i]; p[i]--;
    }
    get(1);

    for (int i = 1; i < leaf[0]; ++i) {
        fix_lca(i);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 8756
#include <stdio.h>

int main(void)
{
    int a;
    scanf("%d",&a);
    int h , m , s;
    h = a / 3600;
    m = a % 3600 / 60;
    s = a % 3600 % 60 % 60;
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {

	static Scanner sc =new Scanner(System.in);
	public static void main(String[] args) {
		
		int N=sc.nextInt();
		int a[]=new int[N];
		for(int i=0;i<N;i++)a[i]=sc.nextInt();
		
		int dp[]=new int[N+1];
		
	if(N==2)System.out.println(Math.abs(a[0]-a[1]));
	else if(N==3)System.out.println(Math.min(Math.abs(a[0]-a[1])+Math.abs(a[1]-a[2]),Math.abs(a[0]-a[2])));
	
	
	else {
		dp[0]=0;
		dp[1]=0;
		dp[2]=Math.abs(a[0]-a[1]);
		dp[3]=Math.min(Math.abs(a[0]-a[1])+Math.abs(a[1]-a[2]),Math.abs(a[0]-a[2]));
	
		
		for(int i=4;i<N+1;i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i-2]-a[i-1]),dp[i-2]+Math.abs(a[i-3]-a[i-1]));
		}
		System.out.println(dp[N]);
	}}

}


Measured memory_bytes: 50728
#include <stdio.h>

#define N 2000002
int B[N];
main(){
  int i,j,n,A[N],C[10002],k=0;
  scanf("%d",&n);
  for(i = 1; i < n+1; i++){
    scanf("%d",&A[i]);
    if(A[i] > k){
      k = A[i];
    }
  }
  for(i = 0; i < k+1; i++){
    C[i] = 0;
  }
  for(j = 1; j < n+1;j++){
    C[A[j]]++;
  }
  for(i = 1; i < k+1; i++){
    C[i] = C[i] + C[i-1];
  }
  for(j = n; j > 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i = 1; i < n; i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
  return 0;
}

Measured memory_bytes: 16264
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,A,B; cin>>N>>A>>B;
    if((A-B)%2==0){
        cout<< abs(A-B)/2 <<"\n";
    }
    else{
        cout<< min((A-1+B-1+1)/2,(N-A+N-B+1)/2)<<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop() {
    top--;
    return S[top+1];
}

int main(int argc, char const *argv[]) {
    int a, b;
    char op[1];

    top = 0;

    while (cin >> op) {
        if (op[0] == '+') {
            a = pop();
            b = pop();
            push(a+b);
        } else if (op[0] == '-') {
            b = pop();
            a = pop();
            push(a-b);
        } else if (op[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(op));
        }
    }

    cout << pop() << endl; 
    return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>
#include<string.h>
#define MAX 1003
main(){
  int n,i;
  char X[MAX],Y[MAX];
 scanf("%d",&n);

  for(i = 0;i < n;i++){
  scanf("%s",X+1);
  scanf("%s",Y+1);
   LCSlength(X,Y);
}

return 0;
}







LCSlength(char* X,char* Y){
  int m,n,i,j;
  int c[MAX][MAX];
  m = strlen(X+1);
  n = strlen(Y+1);
  for(i = 1;i <=m;i++)
    c[i][0] = 0;
  for(j=0;j<=n;j++)
    c[0][j] = 0;
  for(i = 1;i <= m;i++){
    for(j = 1;j <=n; j++){
      if(X[i] == Y[j]){
	c[i][j] = c[i-1][j-1]+1;
      }else if(c[i-1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }else c[i][j] = c[i][j-1];
    }
  }
  printf("%d\n",c[i-1][j-1]);
}

Measured memory_bytes: 4540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

int main(){
  int n; cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n) cin >> a[i];
  b=a;
  vector<ll> primes(1000005,0);
  rep(i,n){
    for(int j=2; j<=1000/*sqrt(a[i])+1*/; j++){
      int tmp=0;
      while(b[i]%j==0){
        tmp++;
        b[i]/=j;
      }
      if(primes[j]<tmp) primes[j]=tmp;
    }
    if(b[i]!=1) primes[b[i]]=1;
  }

  vector<P> ps;

  rep(i,1000005){
    if(primes[i]) ps.push_back(P(i,primes[i])); 
  }

  ll ans=0;
  rep(i,n){
    ll t=1;
    rep(j,ps.size()){
      int tmp=0;
      int now=a[i];
      while(now%ps[j].first==0){
        tmp++;
        now/=ps[j].first;
      }
      rep(k,ps[j].second){
        if(tmp>0){
          tmp--;
          continue;
        }
        t*=ps[j].first;
        t%=MOD;
      }
    }
    ans+=t;
    ans%=MOD;
  }
  cout << ans << endl;
return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 50 + 5;
 
int main(){
	string s,t;
	cin >> s >> t;
	int a,b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(u == s)
		cout << a-1 << " " << b << endl;
	else if(u == t)
		cout << a << " " << b-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string a,b,c;
  cin>>a>>b>>c;
  char ans='A'+a[0]-'a';
  cout<<ans;
  ans='B'+b[0]-'b';
  cout<<ans;
  ans='C'+c[0]-'c';
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

ll GCD (ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

ll LCM (ll a, ll b) {
    ll g = GCD (a, b);
    return a * b / g;
}

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

    ll A, B, C;
    cin >> A >> B;
    C = GCD(A, B);
    ll D = C;

    ll ans = 1;
    for (ll i = 2; i * i <= D; i++) {
        if (C % i == 0) {
            ans++;
            while (C % i == 0) {
                C /= i;
            }
        }
    }

    if (C != 1) ans++;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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 V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
string S;

void _main() {
    cin >> N;
    cin >> S;
    int ans = 0;
    char c = '?';
    REP(i, SZ(S)) {
        if (S[i] != c) {
            ans++;
            c = S[i];
        }
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define esc(ret) cout << ret << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,t,s) for(int i = (int)(t); i >= (int)(s); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 == b & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const int mod = 1e9 + 7;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> size;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n) {
		init(n);
	}

	void init(int n) {
		par.resize(n);
		size.assign(n,1);
		rank.resize(n);
		diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i; 
	}

	int find(int x) {
		if (par[x] == x) {
			return x;
		} else { 
			int r = find(par[x]);
			size[x] = size[r];
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}
	
	int scale(int x) {
		return size[find(x)];
	}

	Abel weight(int x) {
		find(x);
		return diff_weight[x];
	} 

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	} 

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

	bool unite(int x, int y, Abel w = 0) {
		w += weight(x);
		w -= weight(y);
		x = find(x);
		y = find(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) {
			swap(x,y);
			w = -w;
		}
		if (rank[x] == rank[y]) ++rank[x];
		size[x] += size[y];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}
};
 
int N;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	string s;
	int a = 0,b = N;
	string sa,sb;
	cout << a << endl << flush;
	cin >> sa;
	if(sa == "Vacant") exit(0);
	sb = sa;
	while(1){
		int mid = (a + b) / 2;
		cout << mid << endl << flush;
		cin >> s;
		if(s == "Vacant") exit(0);
		int l = mid - a;
		int r = b - mid;
		if((l % 2 == 0 && sa != s) || (l % 2 == 1 && sa == s)){
			b = mid,sb = s;
		}else{
			a = mid,sa = s;
		}
	}
}



Measured memory_bytes: 852
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a==1){
        if(b==2){
            printf("3\n");
        }else if(b==3){
            printf("2\n");
        }
    }else if(a==2){
        if(b==1){
            printf("3\n");
        }else if(b==3){
            printf("1\n");
        }
    }else if(a==3){
        if(b==1){
            printf("2\n");
        }else if(b==2){
            printf("1\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007,N=410;
int a[N],b[N];
int qp(int x,int k)
{
	int res=1;
	while(k)
	{
		if(k&1)res=1ll*res*x%mod;
		x=1ll*x*x%mod;
		k>>=1;
	}
	return res;
}
int n,c;
int fac[N],inv[N];
void init()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=c;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[c]=qp(fac[c],mod-2);
	for(int i=c-1;i;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
long long ans;
int f[N][N],g[N][N],sum[N][N];
int main()
{
	scanf("%d%d",&n,&c);
	init();
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=a[i];k<=b[i];k++)
				(sum[i][j]+=qp(k,j))%=mod;
	f[0][0]=g[n+1][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++)
				(f[i][j]+=1ll*f[i-1][j-k]*sum[i][k]%mod)%=mod;
	printf("%d",f[n][c]);
	return 0;
}


Measured memory_bytes: 1536
h, w, d = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
n = h*w
L = [0]*(n+1)
def dis(p, q):
  return abs(p[0]-q[0]) + abs(p[1]-q[1])
for i in range(h):
  for j in range(w):
    t = A[i][j]
    L[t] = (i, j)
K = [0]*(n+1)
for i in range(1, n-d+1):
  K[i+d] = dis(L[i+d], L[i])
  K[i+d] += K[i]
q = int(input())
for _ in range(q):
  l, r = map(int, input().split())
  print(K[r] - K[l])

Measured memory_bytes: 17904
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC166E
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            string[] sa;
            line = Console.ReadLine();
            int n = int.Parse(line);

            int[] ha = new int[n];
            line = Console.ReadLine();
            sa = line.Split(' ');
            int[] mark = new int[n];
            for (int i = 0; i < n; ++i)
            {
                ha[i] = int.Parse(sa[i]);
            }

            long result = 0;
            for (int i = 0; i < n; ++i)
            {
                var pos = i + ha[i];
                if (pos < n)
                {
                    mark[pos] += 1;
                }

                pos = i - ha[i];
                if (pos > 0)
                {
                    result += mark[pos];
                    /*
                    foreach(var m in l)
                    {
                        if (i - m == ha[i] + ha[m])
                        {
                            result += 1;
                        }
                    }
                    */
                }

                /*
                for (int j = i + ha[i]; j < n && j <= i + ha[i] + highest; ++j)
                {
                    if (j - i == ha[i] + ha[j])
                    {
                        result += 1;
                    }
                }
                */

            }

            Console.WriteLine(result);
#if DEBUG
            Console.WriteLine();
#endif
        }
    }
}


Measured memory_bytes: 44140
#include <stdio.h>

int FizzBuzz(int N)
{
	if (N % 3 == 0 || N % 5 == 0)
		return 0;

	return N;
}

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

	long long int Result = 0;
	for (int n = 1; n <= N; n++)
		Result += FizzBuzz(n);
	
	printf("%lld", Result);

	return 0;
}







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


int main()
{
  int n;
  cin >> n;
  int a, b, c;
  int ab;
  int m = 0;
  for(c = 1 ;c < n; ++c){
    for(a = 1; a * a <= c; ++a){
      b = c / a;
      if(a * b == c){
        m+=2;
        if(a == b) m--;
      }
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  random_device rd;
  mt19937 mt(rd());
  uniform_int_distribution<ll> a(1,26);
  vector<ll> day(26);
  rep(i,365) {
    if (i/26 % 2 == 0) {
      cout << 26 - i%26 << '\n';
    }
    else {
      cout << 1+i%26 << '\n';
    }
  }  
}

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

int main()
{
    int tate=1,yoko=1;
    while(1){
        cin>>tate>>yoko;
        if(tate==0 && yoko==0)break;
        for(int i=0;i<tate;i++) {
            for(int j=0;j<yoko;j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

reverse = True if abs(A[0] - A[1]) > abs(A[-2] - A[-1]) else False
prev = -1
sum = 0
for a in sorted(A, reverse=reverse):
    if prev == -1:
        prev = a
        continue
    sum += abs(prev - a)
    prev = a
print(sum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0,m=0;
std::map<string, int> map;
std::cin >> x;
string s;
rep(i,x){
  std::cin >>s;
  map[s]++;
}
std::cin >> x;
rep(i,x){
  std::cin >>s;
  map[s]--;
}
for(auto ma : map){
  if(ma.second>y) y=ma.second;
}
std::cout <<y<< '\n';
}


Measured memory_bytes: 256