akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

const int MAX_ROW = 510; // to be set appropriately
const int MAX_COL = 510; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};


int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<ll> b) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    return rank;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;cin>>N>>M;
  BitMatrix A(M,N);
  for(ll i=0;i<M;i++){
    ll k;cin>>k;
    for(ll j=0;j<k;j++){
      ll s;cin>>s;s--;
      A[i][s]=1;
    }
  }
  vll p(M);
  for(ll i=0;i<M;i++){
    cin>>p[i];
  }
  ll rank = linear_equation(A,p);
  cout<<(rank<0? 0:1<<(N-rank))<<endl;
  return 0;
}


Measured memory_bytes: 384
from sys import stdin


def main() -> None:
    n, k = [int(next_str()) for _ in range(2)]
    ans = 1
    for i in range(n):
        ans = min(ans * 2, ans + k)
    print(ans)


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>

int height;  /* 盤面の高さ */
int stone[10][5];  /* 石の並び */
int score;

/* 初期化し石の並びを入力する */
void input(int h){
	int x, y;
	height = h;
	for (y = h - 1; y >= 0; y--){
		for (x = 0; x < 5; x++){
			scanf("%d", &stone[y][x]);
		}
	}
	score = 0;
}

/* 石の並びを出力する */
void show(){
	int x, y;
	for (y = height - 1; y >= 0; y--){
		for (x = 0; x < 5; x++){
			if (x != 0) printf(" ");
			if (stone[y][x] != 0){
				printf("%d", stone[y][x]);
			}else{
				printf(" ");
			}
		}
		printf("\n");
	}
	printf("---------\n");  /* 底 */
}

/* 指定された石群を消滅させる (0 でセルを埋める) */
int delete(int y, int from, int to){
	int x, score = 0;
	for (x = from; x < to; x++){
		score += stone[y][x];
		stone[y][x] = 0;
	}
	return score;
}

/* 揃った石を消滅させ、コンボ数を返す */
int try(){
	int combo = 0, y;
	for (y = 0; y < height; y++) combo += tryLine(y);  /* 各行について判定する */
	return combo;
}

int tryLine(int y){
	int x, from, to;

	for (from = 0, to = 1; to <= 5; to++){
		if (to == 5 || stone[y][to] != stone[y][to-1]){
			/* 同じ石が3個以上並んでいるなら石が消滅する */
			if (to - from >= 3 && stone[y][to-1] != 0){
				score += delete(y, from, to);  /* from から to - 1 までの石を消しスコアを加算する */
				return 1;
			}
			/* 連続の左端を更新する */
			from = to;
		}
	}

	return 0;
}

/* 石を落として空きセルを埋める */
void drop(){
	int y, top, bottom;  /* 空きセルの上端 top, 下端 bottom */
	for (y = 0; y < 5; y++){
		for (bottom = 0, top = 0; top < height; top++){
			if (stone[top][y] != 0){
				/* 石を下まで落とす */
				if (top > bottom){
					stone[bottom][y] = stone[top][y];
					stone[top][y] = 0;
				}
				bottom++;
			}
		}
	}
}

int main(void){
	int h;
	while (scanf("%d", &h) == 1 && h >= 1 && h <= 10){
		input(h);
		/* show(); */
		while (try()){  /* 新たに消える石がなくなるまで繰り返す */
			drop();
			/* show(); */
		}
		printf("%d\n", score);  /* スコアを出力する */
	}
    return 0;
}

Measured memory_bytes: 600
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
ans=0
while(True):
    flag=0
    #print(B)
    for i in range(N):
        tmp=B[(i-1)%N]+B[(i+1)%N]
        if B[i]>tmp and B[i]>A[i]:
            beforeans=ans
            if B[i]%tmp>=A[i]:
                ans+=B[i]//tmp
                B[i]%=tmp
            else:
                k=((A[i]-1-(B[i]%tmp))//tmp)+1
                ans+=B[i]//tmp
                B[i]%=tmp
                #print(i,1,B)
                ans-=k
                B[i]+=k*tmp
                #print(i,2,B)
            if ans!=beforeans:
                flag=1
    if flag==0:
        break
flag2=1
for i in range(N):
    if A[i]!=B[i]:
        flag2=0
        break
if flag2:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 119032
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, A, B, C, D;
  cin >> N;
  D=N%10;
  C=((N-D)%100)/10;
  B=((N-C)%1000)/100;
  A=(N-B)/1000;
  if (A+B+C+D==7) {
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  }
  else if (A+B+C-D==7) {
    cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if (A+B-C+D==7) {
    cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else if (A+B-C-D==7) {
    cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  }
  else if (A-B+C+D==7) {
    cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  }
  else if (A-B+C-D==7) {
    cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if (A-B-C+D==7) {
    cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else {
    cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
  }
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  i32 s = r;
  while (n > 0) {
    if (n & 1) t = (i64) t * s % mod;
    s = (i64) s * s % mod;
    n >>= 1;
  }
  return t;
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  i32 a = 1;
  i32 b = 1;
  for (i32 i =1; i <= k; ++i) {
    a = (i64) a * (n + 1 - i) % mod;
    b = (i64) b * i % mod;
  }
  return (i64) a * mod_pow (b, mod - 2) % mod;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 ans = 0;
  for (i32 i = k, sign = 1; i >= 1; --i, sign *= -1) {
    ans = (ans + mod + (i64) sign * comb (k, i) * mod_pow (i, n) % mod) % mod;
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;


int main() {
    int n, m;
    int fav[32] = {0};
    cin >> n >> m;

    int k, ind;
    for (int i = 0; i < n; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> ind;
            fav[ind] += 1;
        }
    }

    int ans = 0;
    for (int l = 1; l <= m; ++l) {
        if(fav[l]==n) ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll n,A,B,C; 
vl vec;
ll dfs(ll cnt,ll a,ll b,ll c){
	if(cnt == n){
		if(min({a,b,c})==0)return MOD;
		else return abs(a - A) + abs(b - B) + abs(c - C) - 30;
	}
	ll ret0 = dfs(cnt + 1,a + vec[cnt],b,c) + 10;
	ll ret1 = dfs(cnt + 1,a,b + vec[cnt],c) + 10;
	ll ret2 = dfs(cnt + 1,a,b,c + vec[cnt]) + 10;
	ll ret3 = dfs(cnt + 1,a,b,c);
	return min({ret0,ret1,ret2,ret3});
}


signed main(){
	//cout << fixed << setprecision(10);
	cin >> n >> A >> B >> C;
	vec.resize(n);
	rep(i,0,n)cin >> vec[i];
	cout << dfs(0,0,0,0) << endl;




	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int n = 0;
		int w = 0;
		int s = 0;
		int e = 0;
		for(int i = 0; i < S.length(); i++) {
			char c = S.charAt(i);
			if(c == 'N') {
				n++;
			}else if(c == 'S') {
				s++;
			}else if(c == 'E') {
				e++;
			}else {
				w++;
			}
		}
		if((n == 0 && s != 0) || (n != 0 && s == 0)) {
			System.out.println("No");
		}else if((e == 0 && w != 0) || (e != 0 && w == 0)) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}

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

using int64 = long long;
const int64 kInfty = 100000000;

int main() {
  int64 n, m, r;
  cin >> n >> m >> r;

  vector<int64> rs(r);
  for (int64 i = 0; i < r; ++i) {
    cin >> rs[i];
    --rs[i];
  }
  vector<vector<int64>> matrix(n, vector<int64>(n, kInfty));
  for (int64 i = 0; i < m; ++i) {
    int64 a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    matrix[a][b] = matrix[b][a] = c;
  }

  for (int64 k = 0; k < n; ++k) {
    for (int64 i = 0; i < n; ++i) {
      int64 ik = matrix[i][k];
      if (ik >= kInfty)
        continue;
      for (int64 j = 0; j < n; ++j) {
        int64 kj = matrix[k][j];
        matrix[i][j] = matrix[j][i] = min(matrix[i][j], ik + kj);
      }
    }
  }

  sort(rs.begin(), rs.end());
  int64 res = kInfty;
  do {
    int64 d = 0;
    for (int64 i = 1; i < r; ++i) {
      d += matrix[rs[i - 1]][rs[i]];
    }
    res = min(res, d);
  } while (next_permutation(rs.begin(), rs.end()));
  cout << res << "\n";

  return 0;
}


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

int main()
{
    ll N;cin >> N;
    ll ans=0;
    vector<vector<ll>> maps(N,vector<ll> (N,0));
    vector<vector<ll>> dis(N,vector<ll> (N,0));
    for (ll i=0;i<N;i++)
    {
        for (ll j=0;j<N;j++)
        {
            cin >> maps[i][j];
            ans+=maps[i][j];
            dis[i][j]=maps[i][j];
        }
    }
    for (ll k=0;k<N;k++)
    {
        for (ll i=0;i<N;i++)
        {
            for (ll j=0;j<N;j++)
            {
                if (dis[i][j]>dis[i][k]+dis[k][j]) dis[i][j]=dis[i][k]+dis[k][j];
            }
        }
    }
    bool can=true;
    for (ll i=0;i<N;i++)
    {
        for (ll j=0;j<N;j++)
        {
            if (dis[i][j]!=maps[i][j]) can=false;
        }
    }
    if (!can) cout << -1 << endl;
    else 
    {
    vector<vector<int>> visit(N,vector<int> (N,0));
    for (ll k=0;k<N;k++)
    {
        for (ll i=0;i<N;i++)
        {
            for (ll j=0;j<N;j++)
            {
                if (dis[i][j]==dis[i][k]+dis[k][j] && k!=i && k!=j && !visit[i][j])
                {
                    ans-=dis[i][j];
                    visit[i][j]=1;
                }
            }
        }
    }
    cout << ans/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vector<P> data(n);
    rep(i,n) {
        int a, b; cin >> a >> b;
        data[i] = P(a,b);
    }
    for (int i = 0; i <= n-3; i++) {
        bool ok = true;
        rep(j,3) if (data[i+j].first != data[i+j].second) ok = false;
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int f(int64_t a, int64_t b){
  if(a==-1){return 0;}else{return a/b+1;}
}

int main(){
  int64_t a,b,x,cnt;
  cin>>a>>b>>x;
  if(a==0){cnt=b/x+1;}
  else{cnt=b/x-(a-1)/x;}
  cout<<cnt<<endl;
}


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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

ll N;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    map<string, ll > mp;
    REP(i, 0, N){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for(auto& p : mp){
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int e,y;
  cin >> e >> y;
  if(e == 1) cout << y+1867 << endl;
  if(e == 2) cout << y+1911 << endl;
  if(e == 3) cout << y+1925 << endl;
  if(e == 4) cout << y+1988 << endl;
  if(e == 0){
    if(y <= 1911) cout << "M" << y-1867 << endl;
    else if(y <= 1925) cout << "T" << y-1911 << endl;
    else if(y <= 1988) cout << "S" << y-1925 << endl;
    else if(y <= 2016) cout << "H" << y-1988 << endl;
  }
  return(0);
}



Measured memory_bytes: 3100
/*BINH :))*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL cout<<endl
#define maxn 1005

void init(){
}
string a,b;
int f[3001][3001];
int main(){
    IO
    init();
    cin>>a>>b;
    int m = a.size(),n=b.size();
    a='0'+a;
    b='0'+b;
    FOR(i,1,m){
        FOR(j,1,n){
            if(a[i]==b[j])f[i][j]=f[i-1][j-1]+1;
            else {
                f[i][j]= max(f[i-1][j],f[i][j-1]);
            }
        }
    }
    int i=m,j=n;
    string res;
    while(i>0&&j>0){
        if(a[i]==b[j]){
            res = a[i]+res;
            i--;j--;

        }
        else{

        if(f[i-1][j]>f[i][j-1]){
            i--;
        }else j--;

        }
    }
    cout<<res;

}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    ll r = 0, g = 0, b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }

    ll ans = r*g*b;

    for(int j = 1; j < n; j++){
        int i = j-1, k = j+1;
        while(i >= 0 && k < n){
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
            i--; k++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    ll res = 0;
    bool mod = false;
    for (int i=0; i<n; i++) {
        if (mod && a.at(i) > 0) {
            res++;
            a.at(i)--;
        }
        res += a.at(i) / 2;
        if (a.at(i)%2 == 0) mod = false;
        else mod = true;
    }
    cout << res << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
vector<string> v;
string s[100000009];
int n,k,Max;
int main()
{
	cin>>n;
	for(k=1;k<=n;k++)
	{
		cin>>s[k];
		if(m[s[k]]==0)
		{
			v.push_back(s[k]);
		}
		m[s[k]]++;
		if(m[s[k]]>Max)
		{
			Max=m[s[k]];
		}
	}
	sort(v.begin(),v.end());
	for(k=0;k<=v.size()-1;k++)
	{
		if(m[v[k]]==Max)
		{
			cout<<v[k]<<endl;
		}
	}
}

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

int main(void){
	int h, w, d;
	cin >> h >> w >> d;
	vector<int> ax(h*w+1+d), ay(h*w+1+d);
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			int tmp;
			cin >> tmp;
			ax[tmp] = i;
			ay[tmp] = j;
		}
	}
	vector<int> bx(h*w+1+d, 0), by(h*w+1+d, 0);
	for(int i = 0; i < d; ++i){
		for(int j = i; j < h*w; j += d){
			bx[j+d] = bx[j] + abs(ax[j] - ax[j+d]);
			by[j+d] = by[j] + abs(ay[j] - ay[j+d]);
		}
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int l, r;
		cin >> l >> r;
		cout << (by[r] - by[l]) + (bx[r] - bx[l]) << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include<cstdio>

using namespace std;

int a[100100];
int N;

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i){
		scanf("%d", a + i);
		a[i]--;
	}
	int cnt = 0;
	for(int i = 0; i < N; ++i){
		if(a[i] > i && a[a[i]] == i) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        
        int max = 0;
        
        for(int i = 1; i < s.length(); i++){
            String temp = s.substring(0,i);
            
            Set<Character> set = new HashSet<Character>();
            
            for(char c : temp.toCharArray()){
                set.add(c);
            }
            
            String str = s.substring(i,s.length());
            
            int cnt = 0;

            for(char c : set){
                for(char ch : str.toCharArray()){
                    if(c == ch){
                        cnt++;
                        break;
                    }
                }
            }
            max = Math.max(max,cnt);
        }
        
        System.out.println(max);
    }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    int st = 0;
    int a,b;
    bool ans = false;
    Rep(i,N) {
        Scd2(a,b);
        if( a == b ) {
            st++;
            if( st == 3 ) ans = true;
        }else{
            st = 0;
        }
    }

    YesNo(ans);

    return 0;
}



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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 ll t=1,n;
 //cin>>t;
 while(t--)
 {cin>>n;
  ll a=100;
  double d=1.01;
  int i=0;
  while(1){
    a*=d;
    i++;
    if(a>=n){
        break;
    }
  }
  cout<<i;
 }
 return 0;
}


Measured memory_bytes: 3636
S = input()
T = S[::-1]
T = list(T)
for i in range(len(T)):
    if T[i] == "b":
        T[i] = "d"
    elif T[i] == "d":
        T[i] = "b"
    elif T[i] == "p":
        T[i] = "q"
    elif T[i] == "q":
        T[i] = "p"
T = "".join(T)
if S == T:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4084
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  cin>>N>>H;
  if(N>H)swap(N,H);
  rep(i,H)cout<<N;
  
  return 0;
}

Measured memory_bytes: 256
import sys
import itertools

input = sys.stdin.readline
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

l = list(itertools.permutations([i for i in range(1, n+1)], n))
x = sorted([l.index(p)+1, l.index(q)+1], reverse=True)
print(x[0] - x[1])

Measured memory_bytes: 8052
n = int(input())
a = list(map(int, input().split()))
d = {}
total = 0

for i in a:
    if i not in d:
        d[i] = 1
    else:
        total += d[i]
        d[i] += 1

for i in range(n):
    ans = total - (d[a[i]] - 1)
    print(ans)

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

int k, ans;

void enu(int n, int i, int x){
    if(i == n){
        if(x <= k){
            bool f3 = false;
            bool f5 = false;
            bool f7 = false;
            while(x > 0){
                if(x % 10 == 3){
                    f3 = true;
                }
                if(x % 10 == 5){
                    f5 = true;
                }
                if(x % 10 == 7){
                    f7 = true;
                }
                x /= 10;
            }
            if(f3 && f5 && f7){
                ans++;
            }
        }
    }
    else{
        enu(n, i + 1, x * 10 + 3);
        enu(n, i + 1, x * 10 + 5);
        enu(n, i + 1, x * 10 + 7);
    }
}

int main()
{
    cin >> k;
    ans = 0;
    for(int i = 1; i < 10; i++){
        enu(i, 0, 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
B = []
for i in range(N):
    for j in range(i,N):
        B.append(sum(A2[j:])+sum(A1[i:j+1]))
print(max(B))

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

using namespace std;

long long int memo[100001];  // デフォルト値は0

long long int fac(int x) {
  if(x == 0 || x == 1) {
    return 1;
  }

  if(memo[x] == 0) {
    memo[x] = (x * fac(x - 1)) % 1000000007;
  }

  return memo[x];
  
}

int main(void) {
  int N, M;
  cin >> N >> M;

  if(N - M < -1 || 1 < N - M) {
    cout << "0" << endl;
    return 0;
  }

  int tmp = 1;
  if(N - M == 0) tmp = 2;
  long long int ans = fac(N) * fac(M) * tmp % 1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 2560
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ls := make([]int, n)
	var l int
	for i := 0; i < n; i++ {
		fmt.Scan(&l)
		ls[i] = l
	}
	sort.Ints(ls)
	var r int
	for _, i := range ls[n-k:] {
		r += i
	}
	fmt.Println(r)
}

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

int main() {
    int a, b;
    cin >> a >> b;
  	int sum;
  	sum = a + b;
  	if(sum < 2*a - 1) sum = 2*a - 1;
  	if(sum < 2*b - 1) sum = 2*b - 1;

  	cout << sum<< endl;

}

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

int main (void) {
    int n, d = 1000000007;
    long int a = 1, b = 1, c = 1;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        a *= 10;
        a %= d;
        b *= 9;
        b %= d;
        c *= 8;
        c %= d;
    }
    printf("%ld\n", (a + 2 * (d - b) + c) % d);
    return 0;
}

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

int main(void) {
  int n, x, y;
  
  cin >> n >> x >> y;
  
  int l[3000];
  
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      int len1 = j-i-1;
      int len2 = abs(x-i-1) + abs(y-j-1);
      l[min(len1, len2)]++;
    }
  }
  
  for(int i = 0; i < n-1; i++) {
    cout << l[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int a, b, c, d, e, f, g;
    cin >> a >> b >> c;
    if (a <= b) {
        d = a;
        e = b;
    } else {
        d = b;
        e = a;
    }

    if (e <= c) {
        f = c;
    } else {
        f = e;
        e = c;
    }

    if (d > e) {
        g = d;
        d = e;
        e = g;
    }
    
    cout << d << " " << e << " " << f << endl;
    
    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int i, N;
  long long sum = 0;
  unused = scanf("%d", &N);

  for(i=1; i<=N; i++){
    if(i%3!=0 && i%5!=0) sum += i;
  }
  printf("%lld", sum);

  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int A, B;

int main() {
    cin >> A >> B;
    cout << max(0, A - 2 * B) << endl;
}



Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();

    let XY:Vec<_> = (0..N).map(|_|
         (buf_it.next().unwrap().parse::<f64>().unwrap(),
         buf_it.next().unwrap().parse::<f64>().unwrap())
    ).collect();

    let mut ans = 1e9;
    for i in 0..N{
        for j in 0..N{
            for k in 0..N{
                if k==i && k==j{continue;}
                let Va = (XY[i].0 - XY[k].0,XY[i].1 - XY[k].1);
                let Vb = (XY[j].0 - XY[k].0,XY[j].1 - XY[k].1);
                let Vc = (XY[i].0 - XY[j].0,XY[i].1 - XY[j].1);
                let la = norm(Va);
                let lb = norm(Vb);
                let lc = norm(Vc);
                let PosC;
                let rc;
                if la*la+lb*lb<=lc*lc{
                    rc = lc/2.;
                    PosC = ((XY[i].0+XY[j].0)/2.,(XY[i].1+XY[j].1)/2.);
                }else if lb*lb+lc*lc<=la*la{
                    rc = la/2.;
                    PosC = ((XY[i].0+XY[k].0)/2.,(XY[i].1+XY[k].1)/2.);
                }else if lc*lc+la*la<=lb*lb{
                    rc = lb/2.;
                    PosC = ((XY[j].0+XY[k].0)/2.,(XY[j].1+XY[k].1)/2.);
                }else{
                    let CosA = (dot(Vb,Vc)/norm(Vb)/norm(Vc)).abs();
                    let CosB = (dot(Va,Vc)/norm(Va)/norm(Vc)).abs();
                    let CosC = (dot(Vb,Va)/norm(Vb)/norm(Va)).abs();
                    PosC = ((la*CosA*XY[j].0 + lb*CosB*XY[i].0 + lc*CosC*XY[k].0)/(la*CosA+lb*CosB+lc*CosC),
                            (la*CosA*XY[j].1 + lb*CosB*XY[i].1 + lc*CosC*XY[k].1)/(la*CosA+lb*CosB+lc*CosC));
                    rc = norm((PosC.0-XY[i].0,PosC.1-XY[i].1))
                }
                'outer: for _ in 0..1{
                    if ans <= rc{break}
                    for l in 0..N{
                        let rl = norm((PosC.0-XY[l].0,PosC.1-XY[l].1));
                        if rl > rc {
                            break 'outer
                        }
                    }
                    ans = rc;
                }
            }
        }
    }

    println!("{}",ans);


}

fn dot(a:(f64,f64),b:(f64,f64)) -> f64{
    a.0*b.0+a.1*b.1
}
fn norm(V:(f64,f64)) -> f64{
    dot(V,V).sqrt()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

/*vector<pair<int,int> >op;
string s,t;
int isprime(ll n){
    if(n==2 || n==3) return 1;
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return 0;
    }
    return 1;
}*/

void solve(){
    ll m,n,k;
    cin>>n>>k;
    cout<<(n*k)/__gcd(n,k);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int q;
    //cin>>q;
    //while(q--){
        solve();
    //}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define hh   puts("");
#define db double
#define ull unsigned long long
#define maxn 1000010
ll cal(ll n){
    if(n==1)return 1;
    else return 1+2*cal(n/2);
}
int main(){
    ll a;
    cin>>a;
    cout<<cal(a);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

long long nexta[18][100001];

long long arr(long long from, long long days){
    long long shisu=0;
    while(days>0){
        if(days%2==1){
            from=nexta[shisu][from];
        }
        days/=2;
        shisu++;
    }
    return from;
}

int main(){
    //input
    long long N;
    cin >> N;
    long long x[N+1];
    long long i,j;
    for(i=1; i<=N; i++){
        cin >> x[i]; 
    }
    long long L;
    cin >> L;
    long long Q;
    cin >> Q;
    long long a[Q+1], b[Q+1];
    for(i=1; i<=Q; i++){
        cin >> a[i] >> b[i];
        if(a[i]>b[i]) swap(a[i],b[i]);
    }

    //calc
    for(i=1; i<=N; i++){
        j=lower_bound(x+1,x+N+1,x[i]+L)-x;
        if(j>N){
            nexta[0][i]=N;
            continue;
        }
        if(x[i]+L<x[j]){
            j--;
        }
        nexta[0][i]=j;
    }
    for(i=1; i<18; i++){
        for(j=1; j<=N; j++){
            nexta[i][j]=nexta[i-1][nexta[i-1][j]];
        }
    }
    long long ans[Q+1];
    long long lef, rig, mid;
    long long arrarr, arrarrarr;
    for(i=1; i<=Q; i++){
        lef=0;
        rig=N;
        while(lef<rig-1){
            mid=(lef+rig)/2;
            arrarr=arr(a[i],mid-1);
            if(arrarr>=b[i]){
                rig=mid;
            }else{
                lef=mid;
            }
        }
        ans[i]=lef;
    }


    //output
    for(i=1; i<=Q; i++){
        cout << ans[i] << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 20748
a,b,x=map(int,input().split())
from math import *
if x*2>a*a*b:
    l,r=0,b
    while r-l>10e-12:
        h=(l+r)/2
        if a*a*(h+b)/2<x:
            l=h
        else:
            r=h
    h=(l+r)/2
    print(degrees(atan((b-h)/a)))
else:
    l,r=0,a
    while r-l>10e-12:
        h=(l+r)/2
        if a*h*b/2<x:
            l=h
        else:
            r=h
    h=(l+r)/2
    print(degrees(atan(b/h)))

Measured memory_bytes: 3064
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


class Ruiseki_lr:
    """左右からの畳み込みをそれぞれ計算する"""
    def __init__(self, array, op, e):
        self.op = op
        self.e = e

        n = len(array)
        self.left = [e] * (n + 1)
        self.right = [e] * (n + 1)
        for i in range(n):
            self.left[i + 1] = self.op(self.left[i], array[i])
        for i in reversed(range(n)):
            self.right[i] = self.op(self.right[i + 1], array[i])

    def left(self, p):
        """区間[0, p)の畳み込み結果を返す"""
        return self.left[p]
    
    def right(self, p):
        """区間[p, n)の畳み込みを返す"""
        return self.right[p]

    def fold(self, p):
        """p番目を除いた区間[0, n)の畳み込み結果を返す"""
        return self.op(self.left[p], self.right[p + 1])


n = int(input())
a = list(map(int, input().split()))
ru = Ruiseki_lr(a, gcd, 0)

ans = 0
for i in range(n):
    ans = max(ru.fold(i), ans)
print(ans)



Measured memory_bytes: 63984
#include <stdio.h>
 
int main ()
{
	int a, b,jumlah=0;
	scanf("%d %d", &a, &b);
	char str[a+b+1];
	scanf("%s", str);
	for (int i=0;i<a+b+1;i++)
	{
		if(i!=a)
		{
			if(str[i]>='0' && str[i]<='9')
			{
				jumlah++;
			}
		}
			else if(str[i]=='-')
			{
				jumlah++;
			}
	}
		if(jumlah==a+b+1)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    int n,i;
    cin >> n >> i;
    cout << (n-1)*(i-1) << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

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

		String t;
		int i;
		String e;
		int count = 0;

		String str = sc.nextLine();
		String[] strX = str.split("");

		t = strX[0];
		e = strX[strX.length - 1];

		for(int j = 0; j < strX.length - 2; j++){
			count++;
		}

		System.out.println(t + count + e);
	}

}


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


int main() {

	double a, b, c, r;
	double pi = 3.141592653589;

	cin >> r; "\n";
	
	a = r * 2;
	b = a * pi;
	c = r * r * pi;

	cout << fixed << setprecision(8) << c << " " << b << "\n";

}

Measured memory_bytes: 1288
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int e,f;
  e=a*b;
  f=c*d;
  if(e<f){
   cout << f << endl; 
  }else{
   cout << e << endl; 
  }
  
return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;




int main() {
	int n;
	cin >> n;
	
	vector<int> data(n);
	
	for(int i=0;i<n;++i){
		cin >> data[i];
	}
	
	int m = 10000000;
	int res = 0;
	
	for(int i=0;i<n;++i){
		if(m > data[i]){
			res++;
		}
		m = min(m,data[i]);
	}
	
	cout << res << endl;
	
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int MAX_H = 1000, MAX_W = 1000;
int h, w, n, loop = 0, ans, dis[MAX_H][MAX_W] = {};
char town[MAX_H][MAX_W], list[10] = "123456789";
bool reached[MAX_H][MAX_W];
queue <P> place;
P xy;

int solve(){
	int dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
	
	while(1){
		xy = place.front();
		place.pop();
		for(int i = 0; i < 4; i++){
			int x = xy.first + dx[i], y = xy.second + dy[i];
			
			if(x < 0 || x >= h || y < 0 || y >= w){
				continue;
			}
			if(town[x][y] == 'X' || reached[x][y] == 1){
				continue;
			}
			
			reached[x][y] = 1;
			dis[x][y] = dis[xy.first][xy.second] + 1;
			place.push(P(x, y));
			
			if(town[x][y] == list[loop]){
				loop++;
				if(loop == n){
					return dis[x][y];
				} else{
					for(int i = 0; i < h; i++){
						for(int j = 0; j < w; j++){
							reached[i][j] = 0;
						}
					}
					reached[x][y] = 1;
				
					while(place.size() != 1){
						place.pop();
					}
					
					break;
				}
			}
		}
	}
}

int main() {
	cin >> h >> w >> n;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> town[i][j];
			
			if(town[i][j] == 'S'){
				reached[i][j] = 1;
				place.push(P(i, j));
			}
		}
	}
	
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 7076
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a), i##ed = (b); i <= i##ed; i++)
#define per(i, a, b) for(int i = (a), i##ed = (b); i >= i##ed; i--)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 110;
int n, ans = 2e9;
int a[N];

template<typename T> void gi(T &x) {
	x = 0; register char c = getchar(), pre = 0;
	for(; c < '0' || c > '9'; pre = c, c = getchar());
	for(; c >= '0' && c <= '9'; c = getchar()) x = x * 10ll + (c ^ 48);
	if(pre == '-') x = -x;
}
int main() {
	gi(n);
	rep(i, 1, n) gi(a[i]);
	rep(j, -100, 100) {
		int sum = 0;
		rep(i, 1, n) sum += (a[i] - j) * (a[i] - j);
		ans = min(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(void){
    int ab_s[26] = {0}, ab_t[26] = {0};
    string str_s, str_t;
    int s[200000], t[200000];
    
    cin >> str_s >> str_t;
    int i;
    for(i = 0; i < str_s.length(); i++){
        s[i] = ab_s[str_s[i] - 'a'];
        ab_s[str_s[i] - 'a'] = i;
        
        t[i] = ab_t[str_t[i] - 'a'];
        ab_t[str_t[i] - 'a'] = i;
    }
    
    for(i = 0; i < str_s.length(); i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 2440
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int[] a = sc.nextIntArray(3);
        Arrays.sort(a);
        pw.println(a[2] - a[0]);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N;
	cin >> N;

	int sum = 0;
	int lmax = -1;
	for(int i=0; i<N; i++) {
		int l;
		cin >> l;

		lmax = max(lmax, l);
		sum += l;
	}
	if(lmax < sum-lmax) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



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

int main(){
    long long N;
    cin >> N;
    vector<long long> S(N);

    for(long long i=0; i<N; i++){
        cin >> S[i];
    }

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

    for(long long i=1; i<N; i++){
        if(S[i] == S[i-1]){
            cout << "NO"<< endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 1792
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    XY = [[int(x) for x in input().split()] for _ in range(N)]

    c = collections.Counter()

    if N == 1:
        print(1)
        return

    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            xi, yi = XY[i]
            xj, yj = XY[j]
            c[(xi - xj, yi - yj)] += 1

    print(N - c.most_common()[0][1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9688
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define same2(a,b) (c[a]==c[b])
#define same3(a,b,c) (same2(a,b)&&same2(b,c))
#define same4(a,b,c,d) (same3(a,b,c)&&same2(c,d))
int c[5];
bool four_card(){
if(same4(0,1,2,3)||same4(1,2,3,4)){
return 1;
}
return 0;
}
bool full_house(){
if((same3(0,1,2)&&same2(3,4)) || (same2(0,1)&&same3(2,3,4))){
return 1;
}else{
return 0;
}
}
bool straight(){
bool res=1;
for(int i=0;i<4;i++){
if((c[i]+1)!=c[i+1])res=0;
}
if((res==0) && (c[0]==1) && (c[1]==10)){
res=1;
for(int i=1;i<4;i++){
if((c[i]+1)!=c[i+1])res=0;
}
}
return res;
}
bool three_card(){
if(same3(0,1,2)||same3(1,2,3)||same3(2,3,4)){
return 1;
}else{
return 0;
}
}
bool two_pair(){
int p=0;
for(int i=0;i<4;i++){
if(same2(i,i+1)){
p++;
}
}
if(p==2){
return 1;
}else{
return 0;
}
}
bool one_pair(){
if(same2(0,1)||same2(1,2)||same2(2,3)||same2(3,4)){
return 1;
}else{
return 0;
}
}
int main(){
while(scanf("%d,%d,%d,%d,%d",&c[0],&c[1],&c[2],&c[3],&c[4])!=EOF){
sort(c,c+5);
if(four_card()){
cout<<"four card"<<endl;
}else if(full_house()){
cout<<"full house"<<endl;
}else if(straight()){
cout<<"straight"<<endl;
}else if(three_card()){
cout<<"three card"<<endl;
}else if(two_pair()){
cout<<"two pair"<<endl;
}else if(one_pair()){
cout<<"one pair"<<endl;
}else{
cout<<"null"<<endl;
}
}
}

Measured memory_bytes: 1224