akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<int> va(n);
    vector<int> vb(n);
    vector<int> vc(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> va[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> vb[i];
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> vc[i];
    }
    int sum = 0;
    int prev = 100;
    for (int i = 0; i < n; i++) {
        sum += vb[va[i] - 1];
        if (prev + 1 == va[i]) {
            sum += vc[va[i] - 2];
        }
        prev = va[i];
    }
    cout << sum << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] p = new int[2];
		for (int i = 0; i < 2; i++) {
			int a1, a2, a3;
			p[i] += a1 = in.nextInt();
			p[i] += a2 = in.nextInt();
			p[i] += a3 = in.nextInt();
			for (int j = 4; j <= 10; j++) {
				int aj = in.nextInt();
				if (aj > a1) {
					p[i] += (aj - a1);
					int c = a1;
					a1 = aj;
					aj = c;
				}
				if (aj > a2) {
					p[i] += (aj - a2);
					int c = a2;
					a2 = aj;
					aj = c;
				}
				if (aj > a3) {
					p[i] += (aj - a3);
					int c = a3;
					a3 = aj;
					aj = c;
				}
			}
		}
		System.out.println(new StringBuilder().append(p[0]).append(' ')
				.append(p[1]));
	}
}

Measured memory_bytes: 17180
N = int(input())
P = list(map(int, input().split()))

p_list = P[:]

ans = 0
for a, b, c in zip(p_list[0:-2],p_list[1:-1],  p_list[2:]):
    x = [a, b, c]
    x = sorted(x)
    if x[1] == b:
        ans += 1
print(ans)

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,h,w;
	cin>>n>>h>>w;
	cout<<((n+1)-h)*((n+1)-w)<<endl;
	return 0;
}


Measured memory_bytes: 3568
# -*- coding: utf-8 -*-

def a():
    A = int(raw_input())
    B = int(raw_input())
    C = int(raw_input())
    D = int(raw_input())
    E = int(raw_input())
    K = int(raw_input())

    flag = True

    if B-A > K:
        flag = False
    elif C-A>K:
        flag = False
    elif D-A>K:
        flag = False
    elif E-A > K:
        flag = False
    elif C-B > K:
        flag =False
    elif D-B > K:
        flag = False
    elif E-B > K:
        flag =False
    elif D-C > K:
        flag = False
    elif E-C > K:
        flag = False
    elif E-D > K:
        flag = False


    if flag == True:
        print "Yay!"
    else:
        print ":("


def main():
    a()
	
if __name__ == '__main__':
    main()

Measured memory_bytes: 2696
MARCH = list('MARCH')
# print(MARCH)
N = int(input())
S = [input() for _ in range(N)]
# print(S)

namect = []
for i in range(5):
    st = [s for s in S if s.startswith(MARCH[i])]
    namect.append(len(st))
ans = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += namect[i]*namect[j]*namect[k]
print(ans)


Measured memory_bytes: 88852
#include<bits/stdc++.h>
using namespace std;
double compute(long long a)
{
	long long temp = a, sum = 0;
	while(temp)
	{
		sum += temp % 10;
		temp /= 10;
	}
	double ans = (double) a / sum;
	return ans;
}
int main()
{
	int a;
	cin >> a;
	long long now = 1, toplus = 1;
	for(int i=1; i<=a; i++)
	{
		printf("%lld\n",now);
		double one = compute(now + toplus), two = compute(now + (toplus * 10));
		if(one > two) toplus *= 10;
		now += toplus;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>
#include<math.h>

class UnionFind{
public:
	std::vector<int> unit;

	UnionFind(int num){
		unit.resize(num);

		for(int i=0; i<num; i++)
			unit[i]= i;
	}

	int findRoot(int idx){
		if(unit[idx]== idx)
			return idx;
		else
			return unit[idx]= findRoot(unit[idx]);
	}

	void unite(int small, int large){
		if(findRoot(small) == findRoot(large))
			return;
		else
			unit[small]= findRoot(large);
	}

private:

};

struct job{
	int day;
	int rew;
};

int main(){
	int n, m;
	long long ans =0;
	std::cin>>n>>m;

	std::vector<job> xList(n);
	UnionFind uf = UnionFind(m+2);

	for(int i=0; i<n; i++)
		std::cin>>xList[i].day>>xList[i].rew;

	std::stable_sort(xList.begin(), xList.end(), [](const job &x, const job &y){return x.day< y.day;});
	std::stable_sort(xList.begin(), xList.end(), [](const job &x, const job &y){return x.rew> y.rew;});

	for(int i=0; i<n; i++){
		if(xList[i].day >m)
			continue;

		if(uf.findRoot(xList[i].day) >m)
			continue;

		ans+= xList[i].rew;

		uf.unite(uf.findRoot(xList[i].day),uf.findRoot(uf.findRoot(xList[i].day)+1));
	}
	
	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


long long int value(string str, int b, int e) {
	string str1;
	str1 = str.substr(b, e - b);
	return stoll(str1);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	

	int K, A, B;
	cin >> K >> A >> B;

	rep(i, K) {
		if (A + i > B)break;
		if ((A + i) % K == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}


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

using namespace std;
int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << w*h/2 << " ";
  if(x==w/2 && y==h/2)cout << 1;
  else cout << 0; 
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        int ans=0;
        for(int i=1;i*a<=t;i++){
            ans+=b;
        }
        out.println(ans);
	}
}

// int n = sc.nextInt();
// int[] array = new int[n];
// String s = sc.next();
// s.charAt(i)
// out.println();
// Math.min()


Measured memory_bytes: 21844
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();
		if (a <= 0 && 0 <= b) {
			System.out.println("Zero");
		}else if(a > 0) {
			System.out.println("Positive");
		}else{
			int negative = b - a + 1;
			System.out.println(negative % 2 == 0 ? "Positive" : "Negative");
		}
	}

}


Measured memory_bytes: 10068
import math

n, d = map(int, input().split())
a = []
for l in range(n):
    a.append(list(map(int, input().split())))
res = 0
temp = 0
for x in a:
    for i in range(0, n):
        temp = 0
        for j in range(0, d):
            temp += (x[j] - a[i][j]) ** 2
        temp = math.sqrt(temp)
        if temp.is_integer():
            res += 1

print((res - n) // 2)



Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str = br.readLine();
			if(str.equals(".")){
				break;
			}
			boolean f = true;
			Stack<Integer> stack = new Stack<Integer>();
			char[] s = str.toCharArray();
			for(int i= 0;i<s.length;i++){
				
				if(s[i]=='('){
					stack.push(1);
				}
				else if(s[i]=='['){
					stack.push(2);
				}
				else if(s[i]==')'){
					if(stack.size()==0){
						f=false;
						break;
					}
					
					int a = stack.pop();
					
					if(a!=1){
						f=false;
						break;
					}
				}
				else if(s[i]==']'){
					if(stack.size()==0){
						f=false;
						break;
					}
					int a = stack.pop();
					if(a!=2){
						f=false;
						break;
					}
				}
			}
			if(stack.size()!=0)
				f=false;
			if(f){
				System.out.println("yes");
			}
			else{
				System.out.println("no");
			}
		}

	}

}

Measured memory_bytes: 11000
from sys import stdin
N,M= list(map(int,stdin.readline().strip().split()))
H=[int(x) for x in input().split()]
count=[1]*N
for i in range(M):
    A,B=(list(map(int,input().split())))
    if H[A-1]<H[B-1]:
        count[A-1]=0
    elif H[A-1]>H[B-1]:
        count[B-1]=0
    else:
        count[A-1]=0
        count[B-1]=0
print(sum(count))

#print(len(set(road)))


Measured memory_bytes: 20040
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;
    VPII an;
    R(N);
    VI a(N);
    REP(i,N)R(a[i]);
    int ma=-1,id;
    REP(i,N){
        if(ma<abs(a[i])){
            ma=abs(a[i]);
            id=i;
        }
    }
    for(int i=id;i;i--){
        an.PB(MP(id+1,i));
    }
    REPP(i,id+1,N)an.PB(MP(id+1,i+1));
    if(a[id]<0){
        for(int i=N;i>1;i--)an.PB(MP(i,i-1));
    }
    else{
        REPP(i,1,N)an.PB(MP(i,i+1));
    }
    W(SZ(an));
    REP(i,SZ(an)){
        W(an[i].F,an[i].S);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] as = new long[n];
		long sum = 0;
		for(int i=0; i<n; i++){
			as[i] = sc.nextLong();
			sum = sum ^ as[i];
		}
		for(long i: as){
			System.out.println(sum ^ i);
		}
	}
}


Measured memory_bytes: 61372
import java.io.*;
import java.util.*;


public class Main {
	public static void main (String[] args) {
	Scanner s=new Scanner(System.in);
	String c=s.next();
	boolean flag=false;
	for(int i=0;i<c.length();i++)
	{if(c.charAt(i)=='7')
	{flag=true;
	break;
	}}
	if(flag)
	System.out.println("Yes");
	else
	System.out.println("No");
	}
}

Measured memory_bytes: 35664
#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
#define INF 9223372036854775807
#define pairint pair<int,int>
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if((double)a.first/(double)a.second!=(double)b.first/(double)b.second){
    return (double)a.first/(double)a.second < (double)b.first/(double)b.second;
  }else{
    if(a.first!=b.first){
      return a.first>b.first;
    }
    else return a.second > b.second;
  }
}
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0;
  std::cin >> x;
  std::vector<int> v(x);
  rep(i,x)std::cin >> v[i];
  sort(all(v));
  rep(i,x-1){
    if(v[i]==v[i+1]){
      std::cout << "NO" << '\n';
      return 0;
    }
  }
  std::cout << "YES" << '\n';
  return 0;
}


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

int main()
{
    int n; cin>>n;
    vector<int> a(n);
    for(auto& e: a) cin>>e;

    int64_t res=0;
    for(int m=0, L=0, R=0; L<n; L++) {
        for(; R<n && (m^a[R])==(m|a[R]); R++) {
            res+=R-L+1;
            m^=a[R];
        }
        m^=a[L];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>

using namespace std;

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

int main() {
  int N, M; cin >> N >> M;
  int g;
  for (int i = 2; i * i <= M; i++) {
    if (!(M % i)) {
      for (int i = N; i <= M; i++) {
        if (!(M % i)) {
          g = M / i;
          cout << g << endl;
          return 0;
        }
      }
    }
  }
  cout << 1 << endl;
}



Measured memory_bytes: 256
import math
N,K = map(int,input().split())
p = 0
def f(n):
  return n*2

for i in range(N+1):
  if i !=0:
    n = 0
    while(True):
      if i >= K:
        break
      i = f(i)
      n+=1
    p += (1/N)*(0.5)**n
print(p)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 配列
        int n = sc.nextInt();
        long[] a = new long[n];
        long e = 1000000007L;
        long sum = 0;
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
            sum += a[i];
            if(sum >= e) {
                sum -= e;
            }
        }
        long ans =0;
        long mul = 0;
        for(int i=0; i<n;i++) {
            if(sum < a[i]) {
                mul = sum + e - a[i];
            } else {
                mul = sum - a[i];
            }

            ans = (ans + (a[i] * mul)) % e;
        }

        if(ans%2 == 0) {
        System.out.println(ans/ 2);
        } else {
            System.out.println((ans + e)/ 2);
        }
    }
   
}



Measured memory_bytes: 60796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;


int main(){
    int n;
    cin >> n;
    string c;
    cin >> c;
    int ans = INF;
    int nr = 0;
    int nw = 0;
    for (char x: c) {
        if (x=='R') nr++;
        else nw++;
    }
    ans = min(nr, nw);
    int x1 = 0;
    int x2 = n-1;
    int res = 0;
    while (x1<x2) {
        if (c[x1]=='R') {
            x1++;
            continue;
        }
        if (c[x2]=='W') {
            x2--;
            continue;
        }
        res++;
        x1++;
        x2--;
    }
    chmin(ans, res);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int start,goal,start_h,start_m,goal_h,goal_m,ans;
	int dist[8] = {0,0,6,13,18,23,43,58},toll[8][8];
	toll[1][1] = 0,toll[1][2] = 300,toll[1][3] = 500,toll[1][4] = 600,toll[1][5] = 700,toll[1][6] = 1350,toll[1][7] = 1650;
	toll[2][2] = 0,toll[2][3] = 350,toll[2][4] = 450,toll[2][5] = 600,toll[2][6] = 1150,toll[2][7] = 1500;
	toll[3][3] = 0,toll[3][4] = 250,toll[3][5] = 400,toll[3][6] = 1000,toll[3][7] = 1350;
	toll[4][4] = 0,toll[4][5] = 250,toll[4][6] = 850,toll[4][7] = 1300;
	toll[5][5] = 0,toll[5][6] = 600,toll[5][7] = 1150;
	toll[6][6] = 0,toll[6][7] = 500;

	while(true){
		scanf("%d",&start);
		if(start == 0)break;

		scanf("%d %d",&start_h,&start_m);

		scanf("%d",&goal);
		scanf("%d %d",&goal_h,&goal_m);

		ans = toll[start][goal];

		if(dist[goal]-dist[start] <= 40){
			if((start_h*60+start_m) >= 17*60+30 || (goal_h*60+goal_m) <= 19*60+30){
				ans /= 2;
				if(ans%50 > 0){
					while(ans % 50 != 0)ans++;
				}
			}
		}

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

	}

    return 0;
}

Measured memory_bytes: 2620
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  ll a,b,c,cnt=0,ta,tb,tc;
  cin >> a >> b >> c;
  if(a==b&&b==c){
    if(a%2==1||b%2==1||c%2==1){
      cout << "0\n";
    }else{
      cout <<"-1\n";
    }
  }else{
    while(a%2!=1&&b%2!=1&&c%2!=1){
      ta=a/2;
      tb=b/2;
      tc=c/2;
      a=tb+tc;
      b=ta+tc;
      c=ta+tb;
      cnt++;
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<long long, long long> P;
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
int main() {
	int N; cin >> N;
	vector<pair<long long, long long> >A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
	sort(A.begin(), A.end(), pairCompare);
	cout << A[N - 1].first + A[N - 1].second << endl;
}

Measured memory_bytes: 2300
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
int n;int a[22][22];
int dp[22][1<<22];
signed main(){
    cin>>n;
    rep(i,0,n)rep(j,0,n)cin>>a[i][j];
    dp[0][0]=1;
    rep(i,0,n){
        for(int x=(1<<(1+i))-1;x<(1<<n);){
            //cout<<i<<" "<<x<<endl;
            rep(k,0,n){
                if(!(x&1<<k))continue;
                if(!a[i][k])continue;
                (dp[i+1][x]+=dp[i][x&~(1<<k)])%=mod;
            }
            int t=x|(x-1);
            x=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(x)+1));
        }
    }
    cout<<dp[n][(1<<n)-1]<<endl;return 0;
}

Measured memory_bytes: 321792
#include<stdio.h>

int main(void){
  int N,L,min,num,sum;
  scanf("%d %d",&N,&L);
  sum=0;
  min=L;
  num=1;
  for(int i=2;i<=N;i++){
    if((L+i-1)*(L+i-1)<min*min){
      min=L+i-1;
      num=i;
    }
  }
  for(int i=1;i<=N;i++){
    if(i!=num){
      sum+=L+i-1;
    }
  }
  printf("%d",sum);
  return 0;
}
    

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int a,b,c;cin >> a >> b >> c;
    if(a+b+c>=22) puts("bust");
    else puts("win");
    return 0;
}


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

int main() {
	int64_t a,b,c,k;
	cin>>a>>b>>c>>k;

	if(abs(a-b)>1e18) {
		cout<<"Unfair"<<endl;
		return 0;
	}

	cout<<((k%2?-1:1)*(a-b))<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		boolean f = false;
		int n = scan.nextInt();
		int m = scan.nextInt();
		boolean[] A = new boolean[n];
		boolean[] B = new boolean[n];
		Arrays.fill(A, false);
		Arrays.fill(B, false);
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}
		
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				A[b[i]] = true;
			} else if (b[i] == n) {
				A[a[i]] = true;
			} else if (a[i] == 1) {
				B[b[i]] = true;
			} else if (b[i] == 1) {
				B[a[i]] = true;
			}
		}
		
		for (int i = 0; i < n; i++) {
			if (A[i] == true && B[i] == true) {
				f = true;
				break;
			}
		}
		
		if (f) {
			System.out.println("POSSIBLE");
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 97888
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right,bisect
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
LIS = []
for i in range(N):
    a =- int(input())
    idx = bisect(LIS,a)
    if idx == len(LIS):
        LIS.append(a)
    else:
        LIS[idx]=a
print(len(LIS))

Measured memory_bytes: 7708
#include <iostream>

using namespace std;

const int p = 1000000007;
int n, m, f[100005];
bool bad[100005];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int a;
		cin >> a;
		bad[a] = 1;
	}
	f[0] = 1;
	f[1] = 1;
	for (int i = 2; i <= n; i++)
	{
		if (!bad[i - 2]) f[i] += f[i - 2];
		if (!bad[i - 1]) f[i] += f[i - 1];
		f[i] %= p;
	}
	cout << f[n] << endl;
	return 0;
 } 

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>

int main() {
    int a[3], k;
    for (int i=0; i<3; i++) std::cin >> a[i];
    std::cin >> k;
    std::sort(a, a+3);
    for (int i=0; i<k; i++) a[2] = 2*a[2];
    int n = sizeof(a) / sizeof(a[0]);
    std::cout << std::accumulate(a, a+n, 0) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100];
	int a,i,c=0;
	scanf("%s",s);
	a=strlen(s);
	for(i=0;i<a;i++){
		if(s[i]!=s[a-1-i]) c++;
	}
	printf("%d\n",c/2);
	return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INFll (1LL << 60)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) cin >> a[i]>>b[i];
    vector<ll> x[1<<17];
    rep(i,n){
        if(m-a[i]<0)continue;
        x[m-a[i]].push_back(b[i]);


    }
    ll ans=0;
    priority_queue<ll> y;
    for(int i=m;i>=0;i--){
        for(int j=0;j<x[i].size();j++) y.push(x[i][j]);

        if(!y.empty()){
            ans+=y.top();
            y.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7168
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int n,a,b,asum,bsum;

int main(){
	while(1){
		cin>>n;
		if( n == 0 ) break;
		for(int i=0;i<n;i++){
			cin >> a >> b ;
			if( a > b ){
				asum+=(a+b);
			}else if( a == b ){
				asum+=a;
				bsum+=b;
			}else{
				bsum+=(a+b);
			}
		}
		cout<<asum<<" "<<bsum<<endl;
		asum=0;bsum=0;
	}
	return 0;
}

Measured memory_bytes: 1160
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
  Comb(){
    fac = new ll[1000001];
    finv = new ll[1000001];
    inv = new ll[1000001];
    fac[0] = 1;
    for(int i=1;i<1000001;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000001;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000001;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll h,n;
  cin >> h >> n;
  ll a[n];
  ll b[n];
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];
  ll dp[h+1];
  dp[0] = 0;
  for(ll i=1;i<h+1;i++){
    dp[i] = MOD;
    for(ll j=0;j<n;j++){
      if(i < a[j]) dp[i] = min(dp[i],b[j]);
      else dp[i] = min(dp[i],dp[i-a[j]]+b[j]);
    }
  }
  cout << dp[h] << endl;
  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int p[n];
	int c[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
		c[i] = p[i];

	}
	sort(p,p+n);
	int ag = 0;
	for (int i = 0; i < n; ++i)
	{
		if(c[i] != p[i])  ++ag;
	}

	if(ag > 2) cout << "NO"<<endl;
	else  cout <<"YES"<<endl ;

	
	return 0;
}

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

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

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll xor_of (ll c) {
	ll bits = 0;
	c++;
	for (ll i = 0; (1LL << i) <= c; i++) {
		ll loop = (1LL << (i + 1));
		ll d = c / loop;
		ll ones = loop / 2 * d;
		ll r = c % loop;
		ll loop2 = (1LL << i);
		if (r > loop2) {
			ones += r - loop2;
		}
		ones %= 2;
		if (ones) {
			bits |= (1LL << i);
		}
	}
	return bits;
}

int main() {
	//rep(i, 100) {
	//	ll sum = 0;
	//	rep(j, i + 1) {
	//		sum ^= j;
	//	}
	//	cout << i << "," << sum << "," << xor_of(i) << endl;
	//}

	//周期
	//0...0,1,0,1,0,1
	//1...0,0,1,1,0,0,1,1
	//2...0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1
	//3...0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,

	ll a, b;
	cin >> a >> b;
	ll xa = xor_of(a-1);
	ll xb = xor_of(b);
	cout << (xa ^ xb) << endl;
	return 0;
}


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

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  string N;
  cin >> N;
  if (N.at(int(N.size() - 1)) == 's') {
    cout << N << "es" << endl;
  }
  else {
    cout << N << "s" << endl;
  }
}
  
  
  
  

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

using namespace std;

const int MAXN = 1e5 + 10;

long long n;
int st[2 * MAXN], fi[2 * MAXN];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int l, r;
		cin >> l >> r;
		l += MAXN;
		r += MAXN;
		fi[r]++;
		st[l]++;
	}
	st[MAXN]++;
	fi[MAXN]++;
	for (int i = 1; i < 2 * MAXN; i++)
		fi[i] += fi[i - 1];
	for (int i = (2 * MAXN - 2); ~i; i--)
		st[i] += st[i + 1];
	long long answer = 0;
	for (int i = 0; i < (2 * MAXN - 1); i++) {
		answer += min(2 * min(fi[i] , st[i + 1]) , fi[i] + st[i + 1]);
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <algorithm>
#define N 1002
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, m;
vector<pair<pair<int, int>, ll>> edges;
ll dis[N];
int main() {
	cin>>n>>m;
	for (int i = 1; i <= m; ++i) {
		int a, b, c;
		cin>>a>>b>>c;
		edges.push_back(make_pair(make_pair(a, b), -c));
	}
	for (int i = 1; i <= n; ++i) {
		dis[i] = (i == 1 ? 0 : 1000000000000000000LL);
	}
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			int a = edges[j].first.first;
			int b = edges[j].first.second;
			ll c = edges[j].second;
			if (dis[a] >= 1000000000000000000LL) continue;
			if (dis[b] > dis[a] + c) {
				dis[b] = dis[a] + c;
			}
		}
	}
	bool neg[N];
	memset(neg, false, sizeof(neg));
	for (int i = 1; i <= n; ++i) {
		for (int j=0; j < m; ++j) {
			int a = edges[j].first.first;
			int b = edges[j].first.second;
			ll c = edges[j].second;
			if (dis[a] >= 1000000000000000000LL) continue;
			if (dis[b] > dis[a] + c) {
				neg[b] = true;
			}
			neg[b] |= neg[a];
		}
	}
	if (neg[n]) {
		cout<<"inf"<<endl;
	} else {
		cout<<-dis[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int people[50];
int main(){
	int n,p;
	
	while (scanf("%d%d",&n,&p)!=EOF){
		if (n==0&&p==0) {
			break;
		}
		int flag=p;
		int output;
		int x=0;
		memset(people,0,sizeof(people));

		while (x<=1000000) {
			for(int i=0;i<n;i++){
				if(p!=0){
					p=p-1;
					people[i]++;
					//printf("%d\n",p);
					//printf("%d\n",people[i]);


					if(people[i]==flag){
						output=i;
						goto print;
					}
				}
				
				//printf("%d\n",i);

				else if(p==0&&people[i]>0) {
					p=people[i];
					people[i]=0;					
				}
					x++;
			}
		}
		print:
		printf("%d\n",output);

	}
}



Measured memory_bytes: 2036
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

LL N,M,K,A,B,C,T,S[3000];
//駅の数、急行の駅の数、準急の駅の数、各停の時間、急行の時間、準急の時間、目標時間、急行停車駅[]

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

	cin >> N >> M >> K >> A >> B >> C >> T;
	for(int i=0; i<M; i++){
		cin >> S[i];
		S[i]--;
	}

	int ans = -1;
	multiset<int> koho;
	for(int i=0; i<M; i++){
		LL c = B * S[i];
		if(c > T) break;
		ans++;
		if(i == M-1) break;
		LL tmp = (T - c) / A;
		if(S[i]+tmp >= S[i+1]){
			ans += S[i+1] - S[i] - 1;
			continue;
		}
		ans += tmp;
		//cout << "#" << i << " " << ans << endl;
		int now = S[i] + tmp + 1;
		c += C * (tmp+1);
		for(int j=1; j<INT_MAX; j++){
			//cout << now << " " << c << " ";
			if(c > T) break;
			tmp = (T - c) / A;
			if(now+tmp >= S[i+1]){
				koho.insert(S[i+1] - now);
				//cout << koho[koho.size()-1] << endl;
				while(koho.size() > K-M) koho.erase(koho.begin());
				break;
			}
			if(koho.size() == K-M && tmp+1 <= *koho.begin()) break;
			koho.insert(tmp+1);
			while(koho.size() > K-M) koho.erase(koho.begin());
			//cout << koho[koho.size()-1] << endl;
			now += tmp + 1;
			c += C * (tmp+1);
		}
	}
	while(koho.size() > K-M) koho.erase(koho.begin());
	for(auto itr=koho.begin(); itr!=koho.end(); itr++){
		ans += *itr;
		//cout << *itr << endl;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

int main () {

    int n; cin >>n;
    vector<ll> t(n); REP(i,n) cin >> t[i];

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

    ll ans = t[0];
    for (int i = 1; i < n; i++) {
        ans = lcm(ans, t[i]);
    }

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <fstream>
#pragma GCC optimize("O2")
using namespace std;

#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
#define ashar(x , y , z) cout<<setprecision(x)<<fixed<<y ; if (z==1) cout<<"\n" ;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7 , inf2 = 1e12;
int const mxn = 3e5 + 10 ;


ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}







int main(){
	long long x ; 
	cin>>x ; 
	for (long long i = 0 ; i <= 200 ; i++){
		for (int j = -100; j <= 200;j++){
			if (poww(i , 5 , inf) - poww(j,5,inf)==x){
				cout<<i<<" "<<j ; 
				return 0 ; 
			}
		}
	}
}	

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

int main() {
    int a,b,c,d;
    while(scanf("%d%d",&a,&b)==2)
    {
        scanf("%d%d",&c,&d);
        int res = a*b - b*c - a*d + c*d;
        printf("%d\n",res);
    }
}


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

int main(){
    string N; cin >> N;
    bool ok=false;
    if(N[0]==N[1]&&N[1]==N[2]) ok=true;
    else if(N[1]==N[2]&&N[2]==N[3]) ok=true;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6
int main()
{
	string s,t;
	int ans=0;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	if(s[i]!=t[i])
	ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3924
#include "bits/stdc++.h"
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
    
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        ll a[n];rep(i,n)cin>>a[i];
        ll ans=0;
        sort(a,a+n,greater<ll>());
        ans=a[0];
        int cnt=n-2;
        for(int i=1;i<n;i++){
            if(cnt==0)break;
            cnt--;ans+=a[i];
            if(cnt==0)break;
            cnt--;ans+=a[i];      
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 5212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int h, w;
string s[100];

int main() {
	cin >> h >> w;
	REP(i, h) cin >> s[i];
	REP(i, h) {
		cout << s[i] << endl;
		cout << s[i] << endl;
	}
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val a = long()
    val b = long()
    val c = long()
    println(Math.max(0, c - (a - b)))
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 31264
def gcd(a, b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

def cul(n, x):
    l = len(x)
    b = x
    b.pop(n)
    tmp = b[0]
    for i in range(1, l-1):
        tmp = gcd(tmp, b[i])
    return tmp

import sys
p = 50
N = int(input())
if p>N: p=N
a = list(map(int, input().split()))

ans = 0
for i in range(p):
    s = cul(i, a[:p])
    if s>ans: ans=s

print(ans)

Measured memory_bytes: 14428
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	if (a.back() == b.front() and b.back() == c.front()) std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int L = a+b;
  int R = c+d;
    
    if ( L < R) {
      cout << "Right" << endl;
    }
  else if( L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Left" << endl;
  }
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)               cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
	
int main() 
{
	ll ans; 
	char ch; 
	cin>>ch; 
	ch++;
	cout<<ch;
//	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {

	int n, d, x, a;
	cin >> n >> d >> x;
	int ch = n + x;
	for (int i = 0; i < n; i ++) {
		cin >> a;
		ch += (d-1) / a;
	}
	cout << ch;
	
	return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<utility>
using namespace std;
#define X first
#define Y second
const double eps = 1e-9;
typedef long double ld;
int main(){
ld x[4];
ld y[4];
while(cin >>x[0]>>y[0]>>x[1]>>y[1] >>x[2]>>y[2]>>x[3]>>y[3]){
if(min(x[1],x[3])<max(x[0],x[2]) || min(y[1],y[3])< max(y[0],y[2]))cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
}

Measured memory_bytes: 1220