akhauriyash/Code-Regression huggingface dataset:
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

ll solve(ll n, ll x){
    if(n == (ll)-1) return (ll)0;
    return n / x + (ll)1;
}

int main(){
    ll a,b; scanf("%lld %lld", &a, &b);
    ll x; scanf("%lld", &x);
    printf("%lld\n", solve(b,x) - solve(a-(ll)1,x));
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=input()
l=[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]
for i in range(len(l)):
    s=int(n[0])
    if l[i][0]==0:
        s+=int(n[1])
        t1="+"
    else:
        s-=int(n[1])
        t1="-"
    if l[i][1]==0:
        s+=int(n[2])
        t2="+"
    else:
        s-=int(n[2])
        t2="-"
    if l[i][2]==0:
        s+=int(n[3])
        t3="+"
    else:
        s-=int(n[3])
        t3="-"

    if s==7:
        print(n[0]+t1+n[1]+t2+n[2]+t3+n[3]+"=7")
        exit()
print("No")

Measured memory_bytes: 38384
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 13 22:34:56 2020

@author: ctiuser
"""

import numpy as np

s = np.array(list(input()), dtype='U1')
t = np.array(list(input()), dtype='U1')

ls, lt = len(s), len(t)

eq = s[:, None] == t[None,:]
dp = [np.zeros(lt+1, int)]

for i in range(ls):
    prev = dp[-1].copy()
    np.maximum(prev[1:], prev[:-1] + eq[i], out = prev[1:])
#    print(prev)
    np.maximum.accumulate(prev, out = prev)
#    print(prev)
    dp.append(prev)

i, j = ls, lt
ans = ''
while i > 0 and j > 0:
    if eq[i-1][j-1]:
        ans += s[i-1]
        i -= 1
        j -= 1
        
    if dp[i][j] == dp[i][j-1]:
        j -= 1
        continue
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
        continue
        
ans = ans[::-1]
print(ans)


Measured memory_bytes: 91976
#include <stdio.h>

int	main(void)
{
	int	n;
	int	cnt = 0;

	scanf("%d", &n);
	for (int a = 1; a < n; a++)
	{
		for (int b = 1; a * b < n; b++)
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1728
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {
	
	vll A(3);
	cin >> A[0] >> A[1] >> A[2];
	sort(all(A));
	cout << A[2] - A[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main() {
  int n;
  std::vector<int> p;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int num;
    std::cin >> num;
    p.push_back(num);
  }
  const auto origin_p = p;
  auto sorted_p = p;
  std::sort(sorted_p.begin(), sorted_p.end());

  int i = 0;
  int count = 0;
  for (auto sp : sorted_p) {
    count += sp != *(origin_p.cbegin() + i);
    i++;
  }
  if (count <= 2)
    std::cout << "YES";
  else
    std::cout << "NO";
  return 0;
}

Measured memory_bytes: 256
def main():
# input
    n = int(input())
    a = [i for i in map(int, input().split())]
    b = [i for i in map(int, input().split())]
    c = [i for i in map(int, input().split())]

# loop
    ans = 0
    temp = -1
    for i in a:
        ans += b[i-1]
        if temp+1 == i:
            ans += c[temp-1]
        temp = i
    print(ans)


if __name__ == '__main__':
    main()


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

int main(void)
{
    using namespace std;
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p.at(i);
    }

    sort(p.begin(), p.end());
    int res = 0;
    for (int i = 0; i < k; ++i) {
        res += p.at(i);
    }

    cout << res << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>

int n;
long long a, b, c, ans, a_, b_, ans_;
short ok = 1;
long long min(long long a, long long b) {
  if(a > b) return b;
  else return a;
}

int main() {
  scanf("%d%lld%lld", &n, &a, &b);
  for(int i = 0; i < n-2; i++) {
    long long d;
    scanf("%lld", &d);
    c ^= d;
  }
  a_ = a;
  b_ = b;
  for(int i = 41; i >= 0; i--) {
    if(c>>i&1) {
      if((1LL<<i) > a+b) ok = 0;
      b -= 1LL<<i;
      ans |= 1LL<<i;
      if(b < 0) {
        a += b;
        b = 0;
      }
    }
    else {
      if(a+b >= (1LL<<(i+1))) {
        a -= 1LL<<i;
        b -= 1LL<<i;
        ans |= 1LL<<i;
        ans_ |= 1LL<<i;
        if(b < 0) {
          a += b;
          b = 0;
        }
      }
    }
  }
  for(int i = 41; i >= 0; i--) {
    if((ans>>i&1) && (~ans_>>i&1)) {
      if((ans_|(1LL<<i)) <= a_) {
        ans_ |= 1LL<<i;
        ans &= ~(1LL<<i);
      }
    }
  }
  if(a || b || ans == a_+b_) ok = 0;
  if(ok) printf("%lld\n", ans-b_);
  else printf("-1\n");
}

Measured memory_bytes: 2084
#include <iostream>

using namespace std;

using ll = long long;
const int MAX_A = 100000;

int main() {
    int N;
    ll K;
    ll cnt[MAX_A + 1];
    for (int i = 0; i < MAX_A + 1; ++i) {
        cnt[i] = 0;
    }
    cin >> N >> K;

    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }

//    int total = 0;
//    for (int ans = 1; ans <= MAX_A; ++ans) {
//        total += cnt[ans];
//        if (K <= total) {
//            cout << ans << endl;
//            break;
//        }
//    }
    for (int ans = 1; ans <= MAX_A; ++ans) {
        if (K <= cnt[ans]) {
            cout << ans << endl;
            break;
        }
        K -= cnt[ans];
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std; using ll=long long; const ll LNF=1e18; const int INF = 1e9+1; const ll M = 1e9+7;
typedef pair<int,int> P;

int main() {
  ll n,m,x; cin>>n>>m>>x;
  ll c[n], a[n][m];
  for(int i=0;i<n;i++) {
    cin>>c[i];
    for(int j=0;j<m;j++) cin>>a[i][j];
  }

  ll an=LNF;
  for(int i=0;i<(1<<n);i++) {
    ll y[m]={}, sm=0;
    for(int j=0;j<n;j++) {
      if (i & (1<<j)) {
        sm+=c[j];
        for(int k=0;k<m;k++) {
          y[k]+=a[j][k];
        }
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++) {
      if (y[j]<x) ok=false;
    }
    if (ok) an=min(an,sm);
  }
  if (an == LNF) cout<<-1<<endl;
  else cout<<an<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int n, m, d;
ld ans;
int main()
{
	scanf("%d%d%d", &n, &m, &d);
	int mn = 1+d;
	if (mn <= n) ans += n-mn+1;
	int mx = n-d;
	if (d && mx >= 1) 
	{
		ans += mx;
	}
	ans /= ((ld)n)*((ld)n);
	ans *= (ld)(m-1);
	printf("%.20Lf\n", ans);
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a==b && a!=c){
            System.out.println("Yes");
        }
        else if(a==c && a!=b){
            System.out.println("Yes");
        }
        else if(c==b && a!=c){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23892
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int a =0;
  scanf("%d\n",&a );
  for(int i =0;i<3;i++){
    if(a % 10 == 7){
      printf("Yes");
      exit(0);
    }
    a /= 10;
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 1728
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n,m,x;

int main() {
scanf("%d %d", &n, &m);
x = (n - m) * 100 + m * 1900;
while (m > 0) {
	m--;
	x *= 2;
}
printf("%d\n", x);
return 0;
}


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

int main(){

  int n,k; cin>>n>>k;

  vector<int>l(n);

  for(int i=0; i<n; i++){

    cin>>l.at(i);
    
  }

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

  reverse(l.begin(),l.end());

  int sum=0;

  for(int i=0; i<k; i++){

    sum += l.at(i);
    
  }

  cout<<sum<<endl;

  return 0;
                        

                        
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int dp[2005][2005];

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

    int a,b,c; cin >> a >> b >> c;

    cout << max(0, c-(a-b)) << endl;

    
    
    

    return 0;
}

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

int main(){
  int N,M,P,Xwin,Xt,cnt;

  while(1){
    cin >> N >> M >> P;
    Xwin=0;
    Xt=0;
    cnt=0;
    if (N==0&&M==0&&P==0) break;
    for (int i=0;i<N;i++){
      cin >> Xt;
      if (M==i+1)Xwin=Xt;
      cnt+=Xt;
    }
    if (Xwin==0)cout << Xwin << endl;
    else cout << (cnt*100*(100-P)/100/Xwin) << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
import itertools
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(M)]#辺の集合
graph =[[] for i in range(N+1)]#隣接リスト
for edge in edges:
    graph[edge[0]].append(edge[1])
    graph[edge[1]].append(edge[0])

node = [i for i in range(1, N+1)]
per_list = list(itertools.permutations(node))#順列生成
count = 0
for l in per_list:#全ての順列について条件を満たすかどうか探索
    if l[0] != 1:#開始ノードが1じゃなかったらダメ
        continue
    flg = 0
    for i in range(len(l)-1):
        if not (l[i+1] in graph[l[i]]):#グラフの間に辺がなかったら
            flg = 1
            break
    if not flg:#フラグがたってなかったら
        count += 1

print(count)

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int m;
  cin >> m;
  ll res = 0;
  ll sum = 0;
  rep(i,m){
    ll c,d;cin >> d >> c;
    sum += c*d;
    res += c;
  }
  res--;
  res += sum/9;
  if(sum%9 == 0)res--;
  cout << res << endl;
  
  
  


  return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);



			int n = sc.nextInt();
			
			pr.println(n + (n * n) + (n * n * n));

		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 32992
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	while (1) {
		int a[5001] = { 0 };
		int n;
		cin >> n;
		if (n == 0)break;
		a[0] = 0;
		int maxv = -100000;
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		for (int i = 1; i <= n; i++) {
			a[i] = max(a[i], a[i] + a[i - 1]);
			maxv = max(maxv, a[i]);
		}
		cout << maxv << endl;
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 50;
const int INF = 1<<29;

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

int a[MAX_N], b[MAX_N], c[MAX_N];
int dp[MAX_N][MAX_N][MAX_N];

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    for (int i = 0; i < n; i++){
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
    }

    int i, j, k;
    REP(i, MAX_N) REP(j, MAX_N) REP(k, MAX_N){
        dp[i][j][k] = INF;
    }

    dp[0][0][0] = 0;

    REP(i, n) REP(j, MAX_N) REP(k, MAX_N){
        if (j < a[i] || k < b[i]){
            dp[i + 1][j][k] = dp[i][j][k];
        }else{
            dp[i + 1][j][k] = min(dp[i][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
        }
    }

    int ans = INF;
    REP(i, MAX_N) REP(j, MAX_N){
        if (i != 0 && j != 0 && i * y == j * x) ans = min(ans, dp[n][i][j]);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N,K; cin >> N >> K;
    int A[N]; rep(i,N){cin >> A[i]; if(A[i]==K){cout << "POSSIBLE" << endl; return 0;}}
    if(N==1){cout << "IMPOSSIBLE" << endl; return 0;}
    sort(A,A+N,greater<int>());
    int a=A[0];
    rep(i,N-1){
        a=gcd(a,A[i+1]);
    }
    bool can = false;
    rep(i,N){
        if(abs(A[i]-K)%a==0){
            can = true; break;
        }
    }
    if(can && A[0] >= K){
        cout << "POSSIBLE" << endl;
    }
    else cout << "IMPOSSIBLE" << endl;

}

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

int main() {
  int n;
  cin>>n;
  
  vector<char> data(n);
  
  for (int i=0;i<n;i++){
    cin>>data.at(i);
  }
  
  string answer="Three";
  
  for (int i=0;i<n;i++){
    if (data.at(i)=='Y'){
      answer="Four";
      break;
    }
  }
  
  cout<<answer<<endl;
  
  
  
}

  













Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a;
  cin >> b;
  int ans = 0;
  if(a >= 13)cout << b << endl;
  else if(a >= 6)cout << b/2 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)

print(max(len(colors), 1), len(colors) + over_cnt)


Measured memory_bytes: 3060
local n, m = io.read("*n", "*n","*l")
local str = io.read()
local posval = {}
for strnum in string.gmatch(str, "%d+") do
  table.insert(posval, tonumber(strnum))
end

local parent = {}
for i = 1, n do parent[i] = 0 end
function findroot(x)
  local cand = x
  while(parent[cand] ~= 0) do
    cand = parent[cand]
  end
  return cand
end

for i = 1, m do
  local a, b = io.read("*n", "*n")
  local aroot, broot = findroot(a), findroot(b)
  if(aroot ~= a) then parent[a] = aroot end
  if(broot ~= b) then parent[b] = broot end
  if(aroot ~= broot) then
    parent[broot] = aroot
  end
end
local ret = 0
for i = 1, n do
  local gsrc, gdst = findroot(i), findroot(posval[i])
  if(gsrc ~= 0 and gsrc == gdst) then ret = ret + 1 end
end
print(ret)


Measured memory_bytes: 5428
#import sys

# N枚の餅N
N = int(input())

# 入力される餅 X
X = list(int(input()) for i in range(N))
X = set(X)

#print(X)

print(len(X))

"""
#sysを使ってXを表現したかったがErrorが出る　ValueError: invalid literal for int() with base 10: '\n'
for i in sys.stdin:
    X.append(int(i))

print(X)
"""

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=3e3+5;

int n,Mo,C[N][N],s[N][N],pw[N],pw2[N*N];

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

int main() {
	scanf("%d%d",&n,&Mo);
	fo(i,0,n) {
		C[i][0]=1;
		fo(j,1,i) C[i][j]=(C[i-1][j]+C[i-1][j-1])%Mo;
	}
	s[0][0]=1;
	fo(i,1,n+1) {
		fo(j,1,i) {
			s[i][j]=s[i-1][j-1];
			(s[i][j]+=(ll)s[i-1][j]*j%Mo)%=Mo;
		}
	}
	int p=1;
	fo(i,0,n) {
		pw[i]=pwr(2,p)%Mo;
		p=(p<<1)%(Mo-1);
	}
	pw2[0]=1;fo(i,1,n*n) pw2[i]=(pw2[i-1]<<1)%Mo;
	int ans=0;
	fo(j,0,n) {
		int ret=0;
		fo(i,0,j) (ret+=(ll)s[j+1][i+1]*pw2[(n-j)*i]%Mo*pw[n-j]%Mo)%=Mo;
		(ans+=(ll)(j&1?-1:1)*ret*C[n][j]%Mo)%=Mo;
	}
	printf("%d\n",(ans+Mo)%Mo);
	return 0;
}

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


 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  int n,h;
  int mx=0;
  int count=0;
  std::scanf("%d %d",&n,&h);
  //cin >> n >> h;
  for(int i=1;i<n;i++){
    int hh=0;
    std::scanf("%d",&hh);
    //cin >> hh;
  	if(hh<=h){
    	count++;
    }else{
    	//mx=max(count,mx);
    	if(count>mx){mx=count;}
    	count=0;
    }
    h=hh;
  }
  //mx=max(count,mx);
  if(count>mx){mx=count;}
  std::printf("%d",mx);
  //cout << mx;
  
  

}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] w = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			w[i] = sc.nextInt();
		}
		int l = 0;
		int r = 0;
		
		for(int i = 0; i < N; i++) {
			if(x[i] == 0) continue;
			if(x[i] < 0) {
				l += -x[i] * w[i];
			}
			else {
				r += x[i] * w[i];
			}
		}
		int aN = 0;
		ArrayList<Integer> xn = new ArrayList<Integer>();
		ArrayList<Integer> wn = new ArrayList<Integer>();
		if(l == r) {
			aN = 0;
		}
		else if(l < r) {
			while(r - l > 50000) {
				aN++;
				xn.add(-1);
				wn.add(50000);
				l += 50000;
			}
			aN++;
			xn.add(-1);
			wn.add(r - l);
		}
		else {
			while(l - r > 50000) {
				aN++;
				xn.add(1);
				wn.add(50000);
				r += 50000;
			}
			aN++;
			xn.add(1);
			wn.add(l - r);
		}
		System.out.println(aN);
		for(int i = 0; i < aN; i++) {
			System.out.println(xn.get(i) + " " + wn.get(i));
		}
		
	}
}
	
	
		

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

typedef long long ll;

int main(){
    int N; cin >> N;
    vector<ll> x(N); for(int i=0;i<N;i++) cin >> x[i];
    ll L; cin >> L;

    ll tmp=0;
    int y[N];
    int j=0;
    for(int i=0;i<N;i++){
        int ind=upper_bound(x.begin(),x.end(),x[i]+L)-x.begin();
        if(ind>=N) ind=N;
        y[i]=ind-1;
    }

    int dp[30][N];
    for(int i=0;i<N;i++){
        dp[0][i]=y[i];
    }
    for(int i=0;i<29;i++){
        for(int j=0;j<N;j++){
            dp[i+1][j]=dp[i][dp[i][j]];
        }
    }
  
    int Q; cin >> Q;
    while(Q--){
        int a,b; cin >> a >> b;
        a--; b--;
        if(b<a) swap(a,b);
        ll ans=0;
        for(int i=29;i>=0;i--){
            if(dp[i][a]<b){
                a=dp[i][a];
                ans+=(1<<i);
            }
        }
        if(a==b) cout << ans << endl;
        else cout << ans+1 << endl;
    }
}

Measured memory_bytes: 13696
#include <stdio.h>
#include <string.h>
int main(){
	int x,y,z;
	char a[10],b[10],c[10];
	scanf("%s %s %s",&a,&b,&c);
	x=strlen(a);
	y=strlen(b);
	if (a[x-1]==b[0])
	{
		if (b[y-1]==c[0])
		{
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> wc;
	vector<int> ec;
	int buf_sum = 0;
	for (auto itr = s.begin(); itr != s.end(); ++itr) {
		int buf = buf_sum;
		if (*itr == 'W') buf++;
		wc.push_back(buf);
		buf_sum = buf;
	}
	buf_sum = 0;
	for (auto itr = s.rbegin(); itr != s.rend(); ++itr) {
		int buf = buf_sum;
		if (*itr == 'E') buf++;
		ec.push_back(buf);
		buf_sum = buf;
	}
	int min = 364364;
	for (int i = 0; i < n; ++i) {
		int sum = 0;
		if (i != 0) {
			sum += wc[i - 1];
		}
		if (i != n - 1) {
			sum += ec[n - i - 2];
		}
		if (min > sum) min = sum;
	}
	cout << min;
}

Measured memory_bytes: 4728
#include "bits/stdc++.h"

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

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

int n;
vector<ll> v(100 + 10, 0);

void prime(){

  for(int i = 2; i <= n; i++){
    int temp = i;
    for(int j = 2; j <= i; j++){
      if(temp == 1) break;
      while(temp % j == 0){
        v[j]++;
        temp /= j;
      }
    }
  }

}

int num(int m){

  int cnt = 0;

  for(int i = 2; i <= 100; i++){
    if(v[i] >= m - 1)
      cnt++;
  }

  return cnt;

}

int main(){
 
  cin >> n;

  prime();

  int ans = 0;

  ans = num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) / 2;
  pr(ans);

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;

    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9 + 5

int main(){
	int n;
	cin >> n;
	vector<int> dp(3, 0);
	for(int i = 0; i < n; i++){
		vector<int> new_dp = dp;
		int a, b, c;
		cin >> a >> b >> c;
		if(i == 0){
			dp[0] = a;
			dp[1] = b;
			dp[2] = c;
		}
		else {
			new_dp[0] = max(dp[1] + a, dp[2] + a);
			new_dp[1] = max(dp[0] + b, dp[2] + b);
			new_dp[2] = max(dp[0] + c, dp[1] + c);
			dp = new_dp;
		}
	}
	cout << max(max(dp[0], dp[1]), dp[2]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

typedef array<int, 2> P;

int N, Z, W, A[2001];
P dp[2001][2];

int g(P p) { return abs(p[0] - p[1]); }

P f(int k, P score, int who) {
    if (k == N)return score;
    P &res = dp[k][who];
    if (res[0] != (int)1e9)return res;
    res[0] = (int)1e9;
    res[1] = (int)1e9;
    FOR(i, k, N) {
        P ns = score;
        ns[who] = A[i];
        P val = f(i + 1, ns, 1 - who);
        if (res[0] == (int)1e9)res = val;
        if (who == 0 && g(res) < g(val))res = val;
        if (who == 1 && g(res) > g(val))res = val;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> Z >> W;
    rep(i, N)cin >> A[i];
    P a; a[0] = Z; a[1] = W;
    rep(i, N)rep(j, 2)dp[i][j][0] = (int)1e9;
    auto res = f(0, a, 0);
    cout << g(res) << endl;
}


Measured memory_bytes: 512
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

best_d = float('inf')
best_i = -1

for i,x in enumerate(H):
    t = T - x * 0.006
    d = abs(A - t)
    if d < best_d:
        best_d = d
        best_i = i
print(best_i + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 200005;
int f[1 << 18], g[1 << 18], pla[MAXN], nxt[18][MAXN], n, V, tn;
vector<int> seg[18];

int main() {
	scanf("%d%d", &n, &V);
	for (int i = 1; i <= n; i++) scanf("%d", pla + i);
	for (int i = V; i; i >>= 1) ++tn;
	for (int i = 0; i < tn; i++) {
		for (int j = 1; j < n; j++)
			if (pla[j] + (V >> i >> 1) < pla[j + 1]) seg[i].push_back(j);
		seg[i].push_back(n);
	}
	int m = 1;
	for (int i = 1; i < n; i++)
		if (pla[i] + V < pla[i + 1]) ++m;
	if (m > tn + 2) {
		for (int i = 1; i <= n; i++) puts("Impossible");
		return 0;
	}
	
	fill(f, f + (1 << tn), 0);
	for (int i = 0; i < tn; i++) {
		int lst = 1;
		for (int j : seg[i]) {
			for (int k = lst; k <= j; k++) nxt[i][k] = j;
			lst = j + 1;
		}
	}
	for (int i = 0; i + 1 < 1 << tn; i++) {
		for (int j = 0; j < tn; j++) if (~i >> j & 1)
			chkmax(f[i | 1 << j], nxt[j][f[i] + 1]);
	}
	
	for (int i = 0; i < tn; i++) {
		int lst = 1;
		for (int j : seg[i]) {
			for (int k = lst; k <= j; k++) nxt[i][k] = lst;
			lst = j + 1;
		}
	}
	fill(g, g + (1 << tn), n + 1);
	for (int i = 0; i + 1 < 1 << tn; i++) {
		for (int j = 0; j < tn; j++) if (~i >> j & 1)
			chkmin(g[i | 1 << j], nxt[j][g[i] - 1]);
	}
	
	int lst = 1;
	for (int i = 1; i <= n; i++) {
		if (i < n && pla[i] + V >= pla[i + 1]) continue;
		bool flag = false;
		for (int j = 0; j < 1 << tn; j++)
			if (f[j] >= lst - 1 && g[j ^ ((1 << tn) - 1)] <= i + 1) { flag = true; break; }
		for (int j = lst; j <= i; j++) puts(flag ? "Possible" : "Impossible");
		lst = i + 1;
	}
	return 0;
}

Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const int mod=1000000007,MAX=200005,INF=1<<30;

int main() {
	int n;
  	cin>>n;
  
  	vector<int> l(n);
  
  	rep(i,n)cin>>l[i];
  	sort(l.begin(), l.end());
  
  	int ans=0;
  
  for(int i=0;i<n;i++){
  	for(int j=0;j<i;j++){
    	for(int k=0;k<j;k++){
          	if(l[k]!=l[j]&&l[j]!=l[i]&&l[k]+l[j]>l[i]){
				ans++;
              }
                
        }
    }
  }
      cout<<ans<<endl;
      	
  
}

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

using ll = long long;
using pii = pair<int, int>;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;

void setIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//shift r is search & replace
//shift d is delete a line
int main(){
    setIO();
    int n; cin >> n;
    int a[n];
    int xr = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        xr ^= a[i];
    }
    for(int i = 0; i < n; ++i){
        cout << (xr ^ a[i]) << " ";
    }
    cout << "\n";
}



Measured memory_bytes: 4436
#include <stdio.h>

#define N 8

int dfs(int n, int adj[N][N], int vis[N], int pos){
    int allVis = 1, endNode = 1;
    int pathNum;
    
    for (int i=0; i<n; i++){
        if (i == pos) continue;
        if (vis[i] == 0) allVis = 0;
        if (vis[i] == 0 && adj[i][pos]) endNode = 0;
    }
    if (endNode){
        return allVis;
    }
    // まだ行けるところがある
    pathNum = 0;
    for (int i=0; i<n; i++){
        if (adj[i][pos] == 1 && vis[i] == 0){
            vis[i] = 1;
            pathNum += dfs(n, adj, vis, i);
            vis[i] = 0;
        }
    }
    return pathNum;
}

int main(void){
    int adj[N][N] = {0};
    int n, m;
    int vis[N] = {0};
    
    scanf("%d %d", &n, &m);
    for (int i=0; i<m; i++){
        int s,d;
        scanf("%d %d", &s, &d);
        adj[s-1][d-1] = adj[d-1][s-1] = 1;
    }
    vis[0] = 1;
    printf("%d\n", dfs(n, adj, vis, 0));
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
class UnionFind{
    private:
        vector<ll> par;
        vector<ll> siz;
    public:
        UnionFind(ll sz){
            par.resize(sz);
            siz.assign(sz,1LL);
            rep(i,sz) par[i] = i;
        }

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

        void unite(ll x,ll y){
            x = find(x);
            y = find(y);
            if (x == y) return;
            if (siz[x] < siz[y]) swap(x,y);
            siz[x] += siz[y];
            par[y] = x;
        }

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

        ll size(ll x){
            return siz[find(x)];
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind f(n),b(n);
    vector<vector<int>> bl(n);
    vector<int> fr(n,0);
    int c,d;
    rep(i,m){
        cin >> c >> d;
        c--;
        d--;
        f.unite(c,d);
        fr[c]++;
        fr[d]++;
    }
    rep(i,k){
        cin >> c >> d;
        c--;
        d--;
        b.unite(c,d);
        bl[c].push_back(d);
        bl[d].push_back(c);
    }
    rep(i,n){
        c = 0;
        for(int j:bl[i]){
            if (f.same(i,j)) c++;
        }
        if (i != n-1) cout << f.size(i) - fr[i] - c - 1 << " ";
        else PRINT(f.size(i) - fr[i] - c - 1);
    }
}


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

unsigned nChoosek( unsigned n, unsigned k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int main()
{
    int N, M;
    cin >> N >> M;
    cout << nChoosek(N+M, 2) - N * M << endl;
}

Measured memory_bytes: 256
num = []
ans = 0

n = gets.to_i
n.times do
  num << gets.to_i
end

num.sort!
smaller = num[0..(n/2.to_f).ceil-1]
larger = num[(n/2.to_f).ceil..n].reverse

if ((n % 4 == 3) && (num[n/2] - num[n/2-1] < num[n/2+1] - num[n/2])) || ((n % 4 == 1) && (num[n/2] - num[n/2-1] > num[n/2+1] - num[n/2]))

  num.clear
  num[0] = larger.shift

  while smaller.size != 0 || larger.size != 0

    if smaller.size == 1 && larger.size == 1

      larger<<smaller[0]
      smaller.clear

    end

    b = smaller.shift
    d = smaller.shift

    if smaller.size == 1 && larger.size == 1

      larger<<smaller[0]
      smaller.clear

    end

    a = larger.shift
    c = larger.shift


    b != nil && num << b
    d != nil && num.unshift(d)
    a != nil && num << a
    c != nil && num.unshift(c)

  end

else

  num.clear
  num[0] = smaller.shift

  while smaller.size != 0 || larger.size != 0

    if smaller.size == 1 && larger.size == 1

      larger<<smaller[0]
      smaller.clear

    end

    a = larger.shift
    c = larger.shift

    if smaller.size == 1 && larger.size == 1

      larger<<smaller[0]
      smaller.clear

    end

    b = smaller.shift
    d = smaller.shift

    a != nil && num << a
    c != nil && num.unshift(c)
    b != nil && num << b
    d != nil && num.unshift(d)

  end

end

for i in 0..n-2
  ans += (num[i+1]-num[i]).abs
end

p ans


Measured memory_bytes: 7116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main
{
  private static ArrayList<Integer> primeNumberList = new ArrayList<>();

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    ArrayList<Integer> inputList = new ArrayList<>(50);

    while (input.ready())
    {
      int inputNum = Integer.valueOf(input.readLine());
      if (inputNum == 0)
      {
        break;
      }
      inputList.add(inputNum);
    }

    int max = 0;
    for (Integer each : inputList)
    {
      if (max < each)
        max = each;
    }

    setPrimeNumberList(max);

    for (int num : inputList)
    {
      System.out.println(sumOfPrimeNumbers(num));
    }
  }

  private static int sumOfPrimeNumbers(int count)
  {
    int ans = 0;
    for (int i = 0; i < count; i++)
    {
      ans += primeNumberList.get(i);
    }
    return ans;
  }

  private static void setPrimeNumberList(int listSize)
  {
    int num = 3;

    primeNumberList.add(2);
    while (primeNumberList.size() < listSize)
    {
      if (isPrimeNumber(num))
      {
        primeNumberList.add(num);
      }
      num++;
    }
  }

  private static boolean isPrimeNumber(int number)
  {
    if (number % 2 == 0)
    {
      return false;
    }

    final int limit = (int) Math.sqrt(number);
    for (int i = 3; i <= limit; i++)
    {
      if (number % i == 0)
        return false;
    }
    return true;
  }
}

Measured memory_bytes: 25800
N,M=map(int,input().split())
H=list(map(int,input().split()))
bads=set()
ans=N
for m in range(M):
  A,B=map(int,input().split())
  A-=1
  B-=1
  if A not in bads and H[A]<=H[B]:
    bads.add(A)
    ans-=1
  if B not in bads and H[A]>=H[B]:
    bads.add(B)
    ans-=1
print(ans)

Measured memory_bytes: 85240
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>

#define ll long long
#define MOD 1000000007
#define INF 1e9+5
// #define INF 999

using namespace std;

void solve () {
	ll n,W;
	cin >> n >> W;
	ll weights[n],values[n];
	ll valSum = 0;
	for (ll i = 0;i < n;++i) {
		cin >> weights[i] >> values[i];
		valSum += values[i];
	}
	ll dp[n+1][valSum+1];
	for (ll i = 0;i <= n;++i) {
		for (ll j = 0;j <= valSum;++j) {
			dp[i][j] = INF;
		}
	}
	for (ll i = 0;i <= n;++i) {
		dp[i][0] = 0;
	}
	for (ll i = 1;i <= n;++i) {
		for (ll j = 1;j <= valSum;++j) {
			//cout << i << " " << j;
			if (j < values[i-1]) {
				dp[i][j] = min(dp[i][j],dp[i-1][j]);
			} else {
				dp[i][j] = min(dp[i-1][j-values[i-1]]+weights[i-1],dp[i-1][j]);
			}
		}
		//cout << '\n';
	}
	// for (ll i = 0;i <= n;++i) {
	// 	for (ll j = 0;j <= valSum;++j) {
	// 		cout << dp[i][j] << " "; 
	// 	}
	// 	cout << '\n';
	// }
	ll ans = 0;
	for (ll i = 0;i <= valSum;++i) {
		if (dp[n][i] <= W) {
			ans = i;
		}
	}
	cout << ans << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}



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

using namespace std;

vector<int> ans;
vector<int> to[200005];

void dfs(int v, int p = -1) {
    for (auto u:to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    ans.resize(n);
    for (int i = 0; i < q; ++i) {
        int p, x;
        cin >> p >> x;
        ans[p - 1] += x;
    }

    dfs(0, -1);
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 23552
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=a*b-c*b-d*a+c*d;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int c[50][26];
int main(void){
 int n; cin >> n; string s[n];
 for(int i=0;i<n;i++){
  cin >> s[i]; 
  for(int j=0;j<s[i].size();j++) c[i][s[i][j]-'a']++;
 }
 string ans = "";
 for(int i=0;i<26;i++){
  int mini = INT_MAX;
  for(int j=0;j<n;j++) mini = min(mini, c[j][i]);
  for(int j=0;j<mini;j++) ans += ('a'+i);
 }
 cout << ans << endl;
 return 0;
}

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

int main() {
  int A;
  string M;
  cin>>A>>M;
  int N = M.size();
  for(int i=0; i<N; i++){
    M.at(i) = (M.at(i)-'A'+A)%26 +'A';
  }
  cout<<M<<endl;
}

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

int main(){
  int N;
  cin >> N;
  
  bool ans = false;
  
  for (int i=0; i<9; i++){
    for(int j=0; j<9; j++){
      if(N == (i+1) * (j+1) ){
        ans = true;
        break;
      }
      if(ans) break;
    }
    if(ans) break;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3668
//============================================================================
// Name        : TopCoderCompetition.cpp
// Author      : taguchi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <bitset>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <numeric>
#include <list>
#include <sstream>
using namespace std;
//#define P pair<int,int>
//#define max 999999
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ull i = 0;i<n;i++)
#define pb(n) push_back(n)
#define clear(n) memset(n,0,sizeof(n))

typedef vector<int> vi;
typedef vector<string> vs;
struct edge{int cost,to;};

vector<string> split(string &in,char delimiter){
	vector<string> re; uint cur = 0,next;
	while((next = in.find_first_of(delimiter,cur)) != string::npos){
		re.pb(string(in,cur,next-cur));
		cur = next + 1;
	}
	re.pb(string(in,cur,in.size()-cur));
	return re;
}
vector<int> split_int(string &in, char delimiter){
	vector<string> str = split(in,delimiter);
	vector<int> re;
	rep(i,str.size()){
		re.pb(strtol(str[i].c_str(),NULL,10));
	}
	return re;
}

class Range{
public:
	int a,b;
	Range(int an,int bn) : a(an),b(bn){}

	bool operator()(int n){
		return a<=n&&n<=b;
	}
	bool isCross(Range x){
		return x(a) || x(b);
	}
	bool contains(Range x){
		return this->a <= x.a && x.b <= this->b;
	}
};

bool isprime[1000010];
uint primes[500010];
int main(){
	uint cnt = 0;
	for(int i = 2;i<1000010;i++){
		if(!isprime[i]){
			primes[cnt++] = i;
			for(int j = 2;i*j<1000010;j++){
				isprime[i*j] = true;
			}
		}
	}
	while(1){
		int n;
		cin >> n;
		if(!n)break;
		int result = 0;
		for(int k = 0;k<cnt;k++){
			if(binary_search(primes,primes+k+1,n-primes[k]))result++;
		}
		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 2148
n, l = map(int, input().split())
nt = 0
nt1 = 0
for i in range(n):
    nt += l + i
if l >= 0:
    nt1 = nt - l
elif l + n -1 <=0:
    nt1 = nt -(l + n -1)
else:
    nt1 = nt
print(nt1)

Measured memory_bytes: 3060
// made by egor <https://pypi.org/project/egor/>
// @author MaxHeap

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <map>

using namespace std;
long long get(long long n) {
  if(n == 1) return 1;
  return 1 + get(n >> 1LL) * 2LL;
}

int main(){
  long long n; cin >> n;
  cout << get(n) << endl;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        long min = long.MaxValue;
        long n = long.Parse(Console.ReadLine());
        for (long i = 1; i * i <= n; i++)
        {
            if(n % i == 0)
            {
                min = Math.Min(min, n / i + i - 2);
            }
        }
        Console.WriteLine(min);
    }
}

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

typedef long long LL;
const int M=2e5+5;
const int MO=1e9+7;
inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}

int main()
{
	int n,k;
	cin>>n>>k;
	int ans=0;
	for(int i=k;i<=n+1;i++)
	{
		// (0+i-1)*i/2 ~ (n-i+1+n)*i/2;
		LL mi=1LL*(i-1)*i/2,ma=1LL*(2*n-i+1)*i/2;
		addv(ans,(ma-mi+1)%MO);
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var m = firstLine[1];
			var aList = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();

			var totalVote = aList.Sum();
			var threshold = (double)totalVote / (double)(4 * m);

			var str = aList.Count(value => value >= threshold) >= m ? "Yes" : "No";

			Console.WriteLine(str);
		}
	}
}


Measured memory_bytes: 13268
# B - Can you solve this?(ABC121)
N,M,C=map(int, input().split())
B=list(map(int, input().split()))
A=[]
S=C
x=0
for i in range(N):
    A.append(list(map(int, input().split())))
for i in range(N):
    S=C
    for v in range(M):
        S+=A[i][v]*B[v]
        if (v==M-1) and(S>0):
            x+=1
print(x)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());
        int A = int.Parse(Console.ReadLine());
        int B = int.Parse(Console.ReadLine());
        Console.WriteLine((X - A) % B);
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int j = sc.nextInt() - 1;
        int m = sc.nextInt() - 1;
        int x = sc.nextInt();
        int y = sc.nextInt();
        System.out.println(h - Math.max(j / x + 1, m / y + 1));
    }
}


Measured memory_bytes: 26276
#include <iostream>

using namespace std;

unsigned gcd(unsigned a, unsigned b) {
    if(a < b) gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N;
    cin >> N;
    int A[N];
    int lgcd[N], rgcd[N];
    for (int i = 0; i < N; ++i) cin >> A[i];
    int clgcd = A[0], crgcd = A[N - 1];
    for (int i = 0; i < N; ++i) {
        clgcd = gcd(A[i], clgcd);
        lgcd[i] = clgcd;
        crgcd = gcd(A[N - 1 - i], crgcd);
        rgcd[N - 1 - i] = crgcd;
    }
    int maxg = 0;
    for (int i = 0; i < N; ++i) {
        int m;
        if (i == 0) m = rgcd[1];
        else if (i == N - 1) m = lgcd[N - 2];
        else m = gcd(lgcd[i - 1], rgcd[i + 1]);
        if (m > maxg) maxg = m;
    }
    cout << maxg << endl;
    return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;cin >> n;
    string s1,s2;cin >> s1 >> s2;
    string domino[] = {s1,s2};
    ll ans = 1;
    int index = 0;
    char state;
    while(index <n)
    {
        if(index==0)
        {
            if(domino[0][index]==domino[1][index])
            {
                ans *= 3;
                index++;
                state = 'x';
                continue;
            }else
            {
                ans *= 6;
                index += 2;
                state = 'y';
                continue;
            }
        }
        if (state == 'x')
        {
            if (domino[0][index] == domino[1][index])
            {
                ans *= 2;
                ans %= MOD;
                index++;
                state = 'x';
                continue;
            }
            else
            {
                ans *= 2;
                ans %= MOD;
                index += 2;
                state = 'y';
                continue;
            }
        }
        else
        {
            if (domino[0][index] == domino[1][index])
            {
                ans *= 1;
                ans %= MOD;
                index++;
                state = 'x';
                continue;
            }
            else
            {
                ans *= 3;
                ans %= MOD;
                index += 2;
                state = 'y';
                continue;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 764