akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

from fractions import Fraction

N = I()
cnt = {}
pair = {}
bothzero = 0
for i in range(N):
    A,B = MI()
    if A==0 and B==0:
        bothzero += 1
    elif B==0:
        pair[0]=pair.get(0,0)+1
    elif A == 0:
        cnt[0]=cnt.get(0,0)+1
    elif A/B>0:
        frac = Fraction(A,B).as_integer_ratio()
        
        cnt[frac]=cnt.get(frac,0)+1
    else:
        frac = Fraction(-B,A).as_integer_ratio()
        pair[frac]=pair.get(frac,0)+1
    
res = N-bothzero
ans = 1
for v in cnt:
    if pair.get(v,0)==0:
        continue
    res -= (cnt[v]+pair[v])
    ans = ans*((pow(2,cnt[v],MOD)+pow(2,pair[v],MOD)-1)%MOD)
    ans = ans%MOD
ans = (ans*pow(2,res,MOD)-1)%MOD
ans = (ans+bothzero)%MOD
print(ans)



Measured memory_bytes: 45900
var
  n,m,k,i,j,x,y,head,tail,tot,ans:longint;
  map:array[0..801,0..801]of char;
  cost,dx,dy:array[0..650000]of longint;
  p:array[0..801,0..801]of boolean;
  s:ansistring;

function min(x,y:longint):longint;
begin
    if x<y then exit(x) else exit(y);
end;

begin
    readln(n,m,k);
    for i:=1 to n do begin
        readln(s);
        for j:=1 to m do begin
            map[i,j]:=s[j];
            if map[i,j]='S' then begin
                x:=i;
                y:=j;
                if (x=1)or(x=n)or(y=1)or(y=n) then begin
                    writeln(0);
                    halt;
                end;
            end;
            if map[i,j]='.' then p[i,j]:=true;
        end;
    end;
    head:=1; tail:=1;
    dx[1]:=x; dy[1]:=y;
    while head<=tail do begin
        x:=dx[head]; y:=dy[head];
        if cost[head]=k+1 then break;
        if p[x-1,y] and (x>1) then begin
            inc(tail);
            dx[tail]:=x-1; dy[tail]:=y;
            cost[tail]:=cost[head]+1;
            p[x-1,y]:=false;
        end;
        if p[x+1,y] and (x<n) then begin
            inc(tail);
            dx[tail]:=x+1; dy[tail]:=y;
            cost[tail]:=cost[head]+1;
            p[x+1,y]:=false;
        end;
        if p[x,y-1] and (y>1) then begin
            inc(tail);
            dx[tail]:=x; dy[tail]:=y-1;
            cost[tail]:=cost[head]+1;
            p[x,y-1]:=false;
        end;
        if p[x,y+1] and (y<m) then begin
            inc(tail);
            dx[tail]:=x; dy[tail]:=y+1;
            cost[tail]:=cost[head]+1;
            p[x,y+1]:=false;
        end;
        inc(head);
    end;
    ans:=maxlongint;
    for i:=1 to head-1 do begin
        x:=dx[i]; y:=dy[i];
        tot:=min(min(x-1,y-1),min(n-x,m-y));
        if tot mod k=0 then ans:=min(ans,tot div k)
        else ans:=min(ans,(tot div k)+1);
    end;
    writeln(ans+1);
end.

Measured memory_bytes: 8976
H, W = map(int, input().split())
a = [[] for i in range(H)]
for i in range(H):
    line = input()
    for cell in line:
        a[i].append(cell)

for _ in range(100):
    for i, row in enumerate(a):
        if "#" not in row:
            a.pop(i)
            break

    for i, col in enumerate(zip(*a)):
            if "#" not in col:
                for j, row in enumerate(a):
                    a[j].pop(i)
                break

for row in a:
    for sign in row:
        print(sign, end="")
    print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i,k,n,ans;
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&n);
    for (i=0;i<=a;i++)
     for (k=0;k<=b;k++)
      if ((n-i*500-k*100>=0)&&(n-i*500-k*100<=c*50))ans++;
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;


int main(void){
    ll N;
    cin >> N;
    
    vector<ll> a(N);
    for(ll i = 0; i < N; i++) cin >> a.at(i);
    
    vector<ll> cnt(60);
    for(ll i = 0; i < 60; i++){
        for(ll j = 0; j < N; j++){
            if(a.at(j) & 1) cnt.at(i)++;
            a.at(j) = a.at(j) / 2;
        }
    }
    ll ans = 0;
    ll tmp;
    ll tmp2 = 1;
    for(ll i = 0; i < 60; i++){
        tmp = cnt.at(i) * (N- cnt.at(i)) % MOD;
        tmp = tmp * tmp2 % MOD;
        ans = (ans + tmp) % MOD;
        tmp2 = tmp2 * 2 % MOD;
    }
    
    printf("%lld\n", ans);
}



Measured memory_bytes: 2560
N = int(input())
s = []
for i in range(N):
    si = list(input())
    s.append(''.join(sorted(si)))

s.sort()

ans = 0
pre_same = 1
for i in range(1,N):
#    print("a,s[i]:" + s[i]+",pre_same:" + str(pre_same) + ",ans:" + str(ans))
    if(s[i-1] == s[i]):
        pre_same = pre_same +1
    else:
        if(pre_same > 1):
            ans = ans + (pre_same * (pre_same-1) / 2)
        pre_same = 1
#    print("b,s[i]:" + s[i]+",pre_same:" + str(pre_same) + ",ans:" + str(ans))

if(pre_same > 1):
    ans = ans + (pre_same * (pre_same-1) / 2)

print(int(ans))

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

// A
int main(){
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    vector<int> data={A1, A2, A3};
    sort(data.begin(), data.end());
    int B;
    B = (data[1]-data[0]) + (data[2]-data[1]);
    cout << B <<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

def calc(theta, l):
  if theta >= 0 and theta <= np.pi/2:
    return l * np.sin(theta), l * np.cos(theta)
  elif theta > np.pi/2 and theta <= np.pi:
    return l * np.cos(theta - np.pi/2), - l * np.sin(theta - np.pi/2)
  elif theta > np.pi and theta <= np.pi * 1.5:
    return - l * np.sin(theta - np.pi), - l * np.cos(theta - np.pi)
  else:
    return - l * np.cos(theta - np.pi*1.5), l * np.sin(theta - np.pi*1.5)
  

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

theta_m = m * np.pi / 30
theta_h = (h * np.pi / 6) + (m * np.pi / 360)

x1, y1 = calc(theta_h, a)
x2, y2 = calc(theta_m, b)

print(((x1-x2)**2 + (y1-y2)**2)**0.5)

Measured memory_bytes: 27216
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

#define VECTOR_LIMIT (100000+5)

int x[VECTOR_LIMIT] = { 0 };

int main() {

	long long res = 0;
	long long s[2] = { 0,0 };
	int n,i,a=0;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> x[i];
	}

	sort(x, x+n, greater<int>());

	for (i = 0; i<n - 1; i++) {
		if (x[i] == x[i + 1]) {
			s[a] = x[i];
			i++;
			a++;
		}
		if (a > 1) {
			break;
		}
	}

	res = s[0] * s[1];
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007

using namespace std;
typedef long long ll;

ll a, b;
vector<ll> j(200000, 0);

ll Inverse(ll a) {
	int d = MOD - 2;
	ll ans = 1;
	while (d > 0) {
		if (d & 1)
			ans = ans * a % MOD;
		a = a * a % MOD;
		d >>= 1;
	}
	return ans;
}

ll Combi(int n, int k) {
	if (k == 0)
		return 1;
	ll a = j[n], b = Inverse(j[k]), c = Inverse(j[n - k]);
	a *= b;
	a %= MOD;
	a *= c;
	a %= MOD;
	return a;
}

void Ini(int n) {
	ll a = 1;
	for (int i = 1; i <= n; i++) {
		a *= i;
		a %= MOD;
		j[i] = a;
	}
	return;
}

int main(void) {
	int H, W, px, py;
	ll ans = 0, buf;
	cin >> H >> W >> px >> py;
	Ini(H + W - 2);
	for (px++, py++; px <= H && py <= W; px++, py++) {
		buf = Combi(H - px + py - 1, min(H - px, py - 1));
		buf *= Combi(px - 1 + W - py, min(px - 1, W - py));
		buf %= MOD;
		ans += buf;
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > G;
vector<bool> visited;

void dfs(int now){
  visited[now] = true;
  for(auto next : G[now]){
    if(!visited[next]) dfs(next);
  }
}

signed main(){
  int n, m; scanf("%d %d", &n, &m);
  G.resize(n);
  visited.resize(n, false);
  for(int i = 0; i < m; i++){
    int x, y, z; scanf("%d %d %d", &x, &y, &z);
    --x; --y;
    G[x].push_back(y); G[y].push_back(x);
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(!visited[i]){
      dfs(i);
      ans++;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 11820
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100100;

int a[200010];
int dp[200010][3];
signed main(){
  int n;cin>>n;
  int m=n/2;
  rep(i,n)cin>>a[i];
  for(int i=1;i<=m;i++){
    rep(j,3){
      int ans=-INF;
      rep(k,j+1){
        ans=max(ans,dp[i-1][k]+a[2*(i-1)+k]);
      }
      dp[i][j]=ans;
    }
  }
        
  cout<<dp[m][n-(2*m-1)]<<endl;    
  
  return 0;
}

Measured memory_bytes: 7448
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int x, y;
	int h, w;
	int fee;
	int lar;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		fee = 0;
		for (i = 0; i < n; i++){
			scanf("%d %d %d %d", &x, &y, &h, &w);
			
			lar = x + y + h;
			if (lar <= 60 && w <= 2){
				fee += 600;
			}
			else if (lar <= 80 && w <= 5){
				fee += 800;
			}
			else if (lar <= 100 && w <=10){
				fee+= 1000;
			}
			else if (lar <= 120 && w <= 15){
				fee += 1200;
			}
			else if (lar <= 140 && w <= 20){
				fee += 1400;
			}
			else if (lar <= 160 && w <= 25){
				fee += 1600;
			}
		}
		printf("%d\n", fee);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};

    int main()
    {
        vector<int> a(5,0);
        REP(i,5) cin>>a[i];
        sort(a.begin(),a.end());
        int k;
        cin>>k;
        if(a[4]-a[0]>k) cout<<":("<<endl;
        else cout<<"Yay!"<<endl;

    }


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

int H, W;
vector<string> S;

int main() {
	cin >> H >> W;
	S = vector<string>(H);
	for (int i = 0; i < H; i++)
		cin >> S[i];

	vector<vector<int>> v(H, vector<int>(W, -1)), h(H, vector<int>(W, -1));
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			if (S[i][j] == '#') {
				v[i][j] = 0;
				h[i][j] = 0;
			}
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (v[i][j] == -1) {
				int vcnt = 0;
				int jj = j;
				while (true) {
					if (jj < W and S[i][jj] == '.') {
						vcnt++;
						jj++;
					}
					else
						break;
				}
				for (int jjj = j; jjj < jj; jjj++)
					v[i][jjj] = vcnt;
			}
			if (h[i][j] == -1) {
				int hcnt = 0;
				int ii = i;
				while (true) {
					if (ii < H and S[ii][j] == '.') {
						hcnt++;
						ii++;
					}
					else
						break;
				}
				for (int iii = i; iii < ii; iii++)
					h[iii][j] = hcnt;
			}
		}
	}

	int c_max = 0;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			if (S[i][j] == '.')
				c_max = max(c_max, v[i][j] + h[i][j]);


	cout << c_max - 1 << endl;
	return 0;
}


Measured memory_bytes: 35712
N = int(input())
A = list(map(int, input().split()))
a = 0
for i in range(N):
  if A[i] < 0:
    a += 1
    A[i] *= -1
ans = sum(A)
if a % 2 == 1:
  A.sort()
  ans -= 2 * A[0]
print(ans)
  


Measured memory_bytes: 19976
use List::Util qw/first reduce/;
my $input = <STDIN>;
chomp($input);
my ($h, $w) = split(' ', $input);
print '#'x($w+2)."\n";
for (1..$h) {
print '#';
my $line = <STDIN>;
chomp($line);
print $line;
print "#\n";
}
print '#'x($w+2)."\n";


Measured memory_bytes: 640
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(1024), 2020)

    def test_2(self):
        self.assertEqual(think(0), 0)

    def test_3(self):
        self.assertEqual(think(1000000000), 2000000000)


def solve():
    x = read()
    result = think(x)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    result = 1000 * (data // 500)
    data %= 500
    result += 5 * (data // 5)
    return result


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 51052
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010
ll f(ll n){
	ll ans=0;
	while(n)ans+=(n%10),n/=10;
	return ans;
}
int main(){
	IOS;
	ll n;cin>>n;
	ll val=f(n);
	if(n%val==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}



Measured memory_bytes: 256
def rangesum(a, b=0):
    return (abs(a-b)+1) * (a+b) // 2

n, k = map(int, input().split())

mod = 10**9+7
res = 1
for i in range(k, n+1):
    res += rangesum(n-i+1, n) - rangesum(i-1) + 1
    res %= mod

print(res)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=3;i++) {
		if((i*a*b)%2==1){
			puts("Yes"); return 0;
		}
	}
	puts("No");
}

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


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

using namespace std;

int main()
{
    ll n; cin >> n;
    vector<ll> D(n); 
    ll Max = 0;
    rep(i, n){cin >> D[i]; Max = max(Max, D[i]);}

    vector<ll> C(Max + 1); 
    rep(i, n) C[D[i]]++;

    if(C[0] != 1 || D[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    ll tmp = 998244353;
    for(int i = 0; i < Max; i++){
        for(int j = 0; j < C[i + 1]; j++){
            ans *= C[i];
            ans %= tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define int long long

signed main() {
	int n, k;
	string s;
	cin >> n >> s >> k;

	//vector<int> v(n);
	//for (size_t i = 0; i < n; i++)
	//{
	//	cin >> v[i];
	//}
	char c = s[k - 1];
	for (size_t i = 0; i < n; i++)
	{
		if (s[i] != c) s[i] = '*';
	}

	cout << s << endl;
}




Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n, m, k;
  cin >> n ;

  vector<long> original;

  for (int i = 2; i <= n; ++i) { //素数カウント
    bool isSosu = true;
    for (int j = 0; j < original.size(); j++) {
      if (i % original[j] == 0)isSosu = false;
      if (isSosu == false)break;
    }
    if (isSosu) {
      original.push_back(i);
    }
  }

  vector<long> ori_count(original.size());


  for (int j = 0; j < original.size(); j++) {
    for (int i = 2; i <= n; ++i) {
      long tmp = i;
      while (true) {
        if (tmp % original[j] != 0)break;
        tmp /= original[j];
        ori_count[j]++;
      }
    }
  }

  long ans = 1;


  for (int j = 0; j < original.size(); j++) {
    cerr << original[j]<<" : " <<ori_count[j] <<endl;
  }


  for (int j = 0; j < original.size(); j++) {
    ans *= (ori_count[j]+1);
    ans %= MOD;
  }


  cout << ans << endl;



}




















Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
import sys
import heapq
import math

# input = sys.stdin.readline

sys.setrecursionlimit(1000000000)

MIN = -10 ** 9
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    # A, B = [int(a) for a in input().split()]
    H = [int(a) for a in input().split()]
    # A = [
    #     [int(a) for a in input().split()]
    #     for _ in range(N)
    # ]

    last = 10 ** 10
    res = 0
    count = 0
    for hi in reversed(H):
        if hi >= last:
            count += 1
        else:
            res = max(res, count)
            count = 0
        last = hi
    if count != 0:
        res = max(res, count)

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14636
#include <stdio.h>

int main(void)
{
	int H, N, i;
	int A;
	
	
	scanf("%d %d", &H, &N);
	
	for(i=0; i<N; i++){
		scanf("%d", &A);
		H-=A;
	}
	
	if(H<=0){ printf("Yes\n"); }
	else{printf("No\n");}
	
	return 0;
}

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

int main(void){
  int n,x,y,len;
  int ans[5000]={0};
  
  cin >> n >> x >> y;
  len = y-x;
  for (int l=1; l<=n-1; l++){
    for (int r=l+1; r<=n; r++){
      if (l>=x && r<=y){
        if (r-l>l-x+1+y-r) ans[l-x+1+y-r]++;
        else ans[r-l]++;
      } else if (l<x && r>y){
        ans[r-l-len+1]++;
      } else if (y<r && l-x<y-l){
        ans[l-x+1+r-y]++;
      } else if (l<x && y-r<r-x){
        ans[y-r+1+x-l]++;
      } else {
        ans[r-l]++;
      }
    }
  }
  
  for (int k=1; k<n; k++){
    cout << ans[k] << endl;
  }
  return 0;
}


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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int S1=A*B;
  int S2=C*D;
  if(S1<=S2){
    cout<<S2<<endl;
  }
  else{
    cout<<S1<<endl;
  }
}
    


Measured memory_bytes: 256
dic = [{'L':1, 'R':0, 'U':1, 'D':1},{'L':0, 'R':1, 'U':1, 'D':1}]
s = input()
ans = 1
for i ,key in enumerate(s):
  ans = ans*(dic[(i+1)%2][key])
print('YNeos'[not(ans)::2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

ll ans[100][100001];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,W;	cin>>n>>W;
	ll i,j,w[n],v[n];
	for(i=0;i<n;i++){
		for(j=0;j<=100000;j++){
			ans[i][j]=2000000000;
		}
	}
	for(i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	ans[0][0]=0;	ans[0][v[0]]=w[0];
	for(i=1;i<n;i++){
		for(j=0;j<=100000;j++){
			ans[i][j]=ans[i-1][j];
		}
		for(j=0;j<=100000-v[i];j++){
			ans[i][j+v[i]]=min(ans[i][j+v[i]], ans[i-1][j]+w[i]);
		}
	}
	ll maxi=0;
	for(i=0;i<=100000;i++){
		if(ans[n-1][i]<=W)	maxi=max(maxi, i);
	}
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 78336
/**
 *    author:  tourist
 *    created: 22.11.2019 20:40:28       
**/
#include <bits/stdc++.h>

using namespace std;

class dsu {
 public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].emplace_back(y, i);
    g[y].emplace_back(x, i);
  }
  vector<int> from(m), to(m);
  for (int i = 0; i < m; i++) {
    cin >> from[i] >> to[i];
    --from[i]; --to[i];
  }
  vector<vector<int>> at(n - 1);
  vector<int> any_que;
  vector<int> any_pe;
  for (int i = 0; i < m; i++) {
    vector<int> pr(n, -1);
    vector<int> pe(n, -1);
    vector<int> que(1, from[i]);
    pr[from[i]] = -2;
    for (int b = 0; b < (int) que.size(); b++) {
      for (auto& p : g[que[b]]) {
        int u = p.first;
        if (pr[u] == -1) {
          que.push_back(u);
          pr[u] = que[b];
          pe[u] = p.second;
        }
      }
    }
    any_que = que;
    any_pe = pe;
    int v = to[i];
    while (v != from[i]) {
      int me = i + m * (v < pr[v]);
      at[pe[v]].push_back(me);
      v = pr[v];
    }
  }
  int ans = 0;
  dsu d(2 * m);
  vector<int> mark(m, -1);
  for (int it = n - 1; it > 0; it--) {
    int e = any_pe[any_que[it]];
    bool fail = false;
    for (int i : at[e]) {
      int x = d.get(i) % m;
      fail |= (mark[x] == it);
      mark[x] = it;
    }
    ans += min((int) at[e].size(), 2);
    if (fail || at[e].size() < 2) {
      continue;
    }
    d.unite(at[e][0], (at[e][1] + m) % (2 * m));
    d.unite((at[e][0] + m) % (2 * m), at[e][1]);
  }
  cout << ans << '\n';
  for (int i = 0; i < m; i++) {
    if (i / m != d.get(i) / m) {
      swap(from[i], to[i]);
    }
    cout << from[i] + 1 << " " << to[i] + 1 << '\n';
  }
  return 0;
}


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

using namespace std;

using int64 = long long;

struct Block {
  int64 weight;
  int64 strength;
  int64 value;
};

constexpr int S_MAX = 20000;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int n;
  cin >> n;
  vector<Block> blocks;
  for (int i = 0; i < n; i++) {
    int64 w, s, v;
    cin >> w >> s >> v;
    blocks.push_back(Block({w, s, v}));
  }
  sort(blocks.begin(), blocks.end(), [](const auto& b1, const auto& b2) {
    return (b1.weight + b1.strength) < (b2.weight + b2.strength);
  });

  vector<vector<int64>> dp = Make2DVector<int64>(n + 1, S_MAX + 1, -1);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= S_MAX; j++) {
      if (dp[i][j] < 0) continue;
      if (i == n - 1) {
        dp[n][0] = max(dp[n][0], dp[n - 1][j]);
        if (j <= blocks[i].strength) {
          dp[n][0] = max(dp[n][0], dp[n - 1][j] + blocks[n - 1].value);
        }
      } else {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        // cout << "i: " << i << " strength: " << blocks[i].strength << endl;
        if (j <= blocks[i].strength && j + blocks[i].weight <= S_MAX) {
          dp[i + 1][j + blocks[i].weight] =
              max(dp[i + 1][j + blocks[i].weight], dp[i][j] + blocks[i].value);
        }
      }
    }
  }
  cout << dp[n][0] << endl;
}


Measured memory_bytes: 160640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void){
    ll h, n;
    cin >> h >> n;
    
    ll a_sum = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        a_sum += a;
    }
    
    if (a_sum >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  s1[0] = toupper(s1[0]);
  s2[0] = toupper(s2[0]);
  s3[0] = toupper(s3[0]);
  cout << s1[0] << s2[0] << s3[0] << endl;
  return 0;
}


Measured memory_bytes: 256
def g(x):
    ret = 1 if x % 4 in {1, 2} else 0
    for i in range(1, 50):
        if x % (2 << i) >= (1 << i) and not x % 2:
            ret += (1 << i)
    return ret


A, B = map(int, input().split())
print(g(A - 1) ^ g(B))


Measured memory_bytes: 2940
N,K = map(int, raw_input().split())
S = raw_input()
i = 0
S2 = ""
for c in S:
	i += 1
	if(i == K):
		if c =='A':
			S2 += 'a'
		elif c == 'B':
			S2 += 'b'
		elif c == 'C':
			S2 += 'c'
	else:
		S2 += c
print(S2)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> l(M);
  vector<int> r(M);
  
  for (int i = 0; i < M; i++) {
  	cin >> l.at(i) >> r.at(i);
  }
  
  int lmax = 0;
  int rmin = N;
  
  for (int i = 0; i < M; i++) {
  	lmax = max(l.at(i), lmax);
  	rmin = min(r.at(i), rmin);
  }
  
  
  if (rmin >= lmax) {
  	cout << rmin - lmax + 1 <<endl;
  }
  
  else {
  	cout << 0 << endl;
  }
  
}

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

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define LL long long

int main(){
    int A=read(),B=read();
    printf("%d",max(A-2*B,0));
}


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

int main(){
	const int N=1e5+10;
	int n,m;
	int pre=0;int cnt=0;
	cin >>n>>m;
	struct Node{
		int l,r;
		bool operator<(const Node& rhs)const{
			return r<rhs.r;
		}
	}p[N];

	for(int i=0;i<m;i++){
		cin>>p[i].l>>p[i].r;
	}
	
	sort(p,p+m);
	for(int i=0;i<m;i++){
		if(p[i].l>=pre){
			pre=p[i].r;
			cnt++;
		}
	}
	cout <<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 100005
#define ll long long int
using namespace std;

int main(void) 
{
	ll m; //????????????????????° 
	ll n; //?????¨????????°
	ll sisan;
	ll year;
	vector <ll> th; //????????????????????????
	vector <double> tanhuku;
	vector <ll> tesu;

	int i, j, k;
	vector<ll> ans;
	
	ll temp1, temp3;
	double temp2;
	ll max = 0;
	ll a, b;
	ll zan = 0;

	cin >> m;

	for (i = 0; i < m; i++) {
		max = 0;
		n = 0;
		sisan = 0; 
		year = 0;

		cin >> sisan >> year >> n;



		for (j = 0; j < n; j++) {
			cin >> temp1 >> temp2 >> temp3;
			th.push_back(temp1);
			tanhuku.push_back(temp2);
			tesu.push_back(temp3);


		}


		for (j = 0; j < n; j++) {
			if (th[j] == 0) {
				a = b = 0;

				for (k = 0; k < year; k++) {
					a = sisan - tesu[j] * k;

					b = b + (int)(a * tanhuku[j]);

				}
	
				zan = a - tesu[j];



				if (max < zan + b) {
					max = zan + b;
				}
			}
			else if (th[j] == 1) {
				b = 0;
				a = sisan;

				for (k = 0; k < year; k++) {
					b = (int)(a * tanhuku[j]);
					a = a + b - tesu[j];
				}

				if (max < a) {
					max = a;
				}

			}


		}

		ans.push_back(max);

		th.clear();
		tanhuku.clear();
		tesu.clear();

	}


	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}


	return (0);
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <ll, pair <ll, ll>>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e3 + 10;

ll n, m, k, t;

ll x, y;

ll ANS[maxn][maxn];

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> n >> m >> x >> y;
    for (q = 0; q < n; q++) {
        for (w = 0; w < x; w++) {
            ANS[q][w] = 0;
        }
        for (w = x; w < m; w++) {
            ANS[q][w] = 1;
        }
    }
    for (q = 0; q < y; q++) {
        for (w = 0; w < m; w++) {
            ANS[q][w] ^= 1;
        }
    }
    for (q = 0; q < n; q++) {
        for (w = 0; w < m; w++) {
            cout << ANS[q][w];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 11472
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2==0:
                print("#", end="")
            else:
                print(".", end="")
        print()
            
    print()


Measured memory_bytes: 7000
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      if (string.Compare(input[0], input[1])<0)
      {
        Console.WriteLine("<");
      }
      else if (string.Compare(input[0], input[1])>0)
      {
        Console.WriteLine(">");
      }
      else
      {
        Console.WriteLine("=");
      }
    }
}


Measured memory_bytes: 26176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n;
	cin >> n;
	string s, r;
	cin >> s >> r;
	for (int i = 0; i < n; ++i)
		{
			cout << s[i] << r[i];
		}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <array>
#include <map>
#include <set>

using namespace std;

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

    int count = 0;
    for (int i = 0; i <= min(c, 400); i++)
    {
        for (int j = 0; j <= min(b, 200); j++)
        {
            for (int k = 0; k <= min(a, 40); k++)
            {
                if (50 * i + 100 * j + 500 * k == x)
                {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
/// In The Name Of God
/// I wish, that I could leave it all behind me / Go to my own world where no one can find me
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define pii pair <int , int>
#define ld long double
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()

const int maxn = 718;
bool a[maxn][maxn];
int seen[maxn];
vector<PII> w;
PII sz;
int tmp[maxn];
int dp[maxn];
int n;

void dfs(int root,bool h = 0){
    seen[root] = h+1;
    if(h) sz.F ++;
    else sz.S++;
    for2(i,0,n) if(!a[root][i] && !seen[i]) dfs(i,!h);
                else if(!a[root][i] && seen[i] == seen[root] && root != i){
                    cout << -1 << endl;
                    exit(0);
                }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m; cin >> n >> m;
    for2(i,0,m){
        int v,u; cin >> v >> u; v-- ,u--;
        a[v][u] = a[u][v] = 1;
    }
    for2(i,0,n) if(!seen[i]){
        sz = {0,0};
        dfs(i);
        w.pb(sz);
    }
    dp[0] = 1;
    for(auto x : w){
        for(int i = 700; i >= 0; i--){
            if(i >= x.F) tmp[i] |= dp[i-x.F];
            if(i >= x.S) tmp[i] |= dp[i-x.S];
        }
        for2(i,0,700) dp[i] = tmp[i],tmp[i]=0;
    }
    int ans = n*n;
    for2(i,0,n+1) if(dp[i]) ans = min(ans,(i*(i-1)/2) + (n-i)*(n-i-1)/2 );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> ve;
int main()
{
	ll i,n,j,t;
	cin>>n;
	cin.ignore();
	string s;
	getline(cin, s);
	
	if(s.length()<=n)
	cout<<s<<endl;
	else
	{
		s.resize(n);
		s+="...";
		cout<<s<<endl;
	}
	
	
}

Measured memory_bytes: 3628
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;

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


    int N = scanner.nextInt();

    int[] V = new int[N];
    int[] C = new int[N];
    for (int i = 0; i < N; i++) {
      V[i] = scanner.nextInt();


    }

    for (int i = 0; i < N; i++) {
      C[i] = scanner.nextInt();

    }

    for (int i = 0; i < N; i++) {
      ans += Math.max(0, V[i] - C[i]);
    }

    System.out.println(ans);

  }
}


Measured memory_bytes: 22996
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const double eps = 1e-8;

int main() {
	ll a,b,c;
	cin >> a >> b >> c;
	if(c - a - b <= 0) cout <<"No\n";
	else{
		if((c-a-b)*(c-a-b)-4*a*b>0) cout <<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<bool,pair<int,int> > >v;
int n,m,p,q,r;

void Vp(bool a,int b,int c){v.push_back(make_pair(a,make_pair(b,c)));}

int main(){
	while(cin>>n&&n){
	cin>>m>>p>>q>>r;v.clear();
	Vp(1,1,r);Vp(0,r+1,n);
	while(m--){
		int x,y;cin>>x>>y;
		for(int i=0;i<v.size();i++){
			int a=v[i].second.first,b=v[i].second.second;bool c=v[i].first;
			if(a<=x&&x<b){
				Vp(c,x+1,b);
				b=x;
			}
			if(a<=y&&y<b){
				Vp(c,y+1,b);
				b=y;
			}
			if(0<a&&b<=x)a+=n-x,b+=n-x;
			else if(x<a&&b<=y)a+=n-x-y,b+=n-x-y;
			else if(y<a&&b<=n)a-=y,b-=y;
			v[i].second.first=a,v[i].second.second=b;
		}
	}
	int ans=0;
	for(int i=0;i<v.size();i++){
		if(v[i].first){
			ans+=max(0,1+min(v[i].second.second,q)-max(v[i].second.first,p));
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long int

int main(){
  ll n;
  scanf("%lld",&n);

  ll ans=n*(n+1)/2;
  ans -= 3*(n/3)*(n/3+1)/2;
  ans -= 5*(n/5)*(n/5+1)/2;
  ans += 15*(n/15)*(n/15+1)/2;

  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 1724
solver::Int->Int->Int
solver n m = let first_proc = min n (div m 2)    in
             let rest_c     = m-(first_proc * 2) in
             if rest_c <= 1 then first_proc else first_proc + (div rest_c 4)

main::IO()
main =do
  dc<-getLine
  let n:m:[]= map read (words dc)::[Int]
  print (solver n m)


Measured memory_bytes: 508
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,cnt=0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  cin >> n >> k;
  for(int b=k+1; b<=n; b++){
    Max = 0;
    int p = n/b;
    int r = n%b;   // n = pb + r とする。
    chmax(Max,r-k+1);
    ans += p*(b-k) + Max;
    if(k==0) // r-k+1の1を減らす. 0が被る.
      ans--;
  }
  pri(ans);
  return 0;
}

Measured memory_bytes: 3564
def main():
    N = input()
    K = int(input())
    t = len(N)
    if K == 1:
        return (t - 1) * 9 + int(N[0])
    elif K == 2:
        if t < 2:
            return 0
        r = (t - 1) * (t - 2) * 81 // 2
        r += (int(N[0]) - 1) * (t - 1) * 9
        for i, v in enumerate(N):
            if i < 1:
                continue
            if v != '0':
                r += int(v) + 9 * (t - 1 - i)
                return r
        return r
    else:
        if t < 3:
            return 0
        r = (t - 1) * (t - 2) * (t - 3) * 729// 6
        r += (int(N[0]) - 1) * (t - 1) * (t - 2) * 81 // 2
        second = False
        for i, v in enumerate(N):
            if i < 1:
                continue
            if v != '0' and not second:
                r += (int(v)-1) * (t - 1 - i) * 9
                r += (t - 1 - i) * (t - 2 - i) * 81 // 2
                second = True
            elif v != '0':
                r += int(v) + 9 * (t - 1 - i)
                return r
        return r
print(main())


Measured memory_bytes: 38384
#include<stdio.h>

int main()
{
	int a,b,c,d;
	int n;
	int count;
	
	while(scanf("%d",&n)!=EOF)
	{
	 count=0;
	for(a=0;a<10;a++)
	{
		for(b=0;b<10;b++)
		{
			for(c=0;c<10;c++)
			{
				for(d=0;d<10;d++)
				{
					if(a+b+c+d==n)count++;
				}
			}
		}
	}
		printf("%d\n",count);
	}

	
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
const int maxn = 1e5 + 10;
using namespace std;
long long a[maxn];
int n;
bool cmp(long long a, long long b) {
    return a > b;
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        scanf("%lld", a + i);
    sort(a, a + n, cmp);
    long long b, c;
    b = c = 0;
    int ok1, ok2;
    ok1 = ok2 = 0;
    for (int i = 0; i < n - 1; i++) {
        if ( !ok1 && a[i] == a[i + 1]) {
            b = a[i];
            i++;
            ok1 = 1;
        }
        else if (!ok2 && a[i] == a[i + 1]) {
            c = a[i];
            i++;
            ok2 = 1;
        }
        if (ok1 && ok2) {
            cout << b * c << endl;
            break;
        }
    }
    if (ok1 == 0 || ok2 == 0)
        cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

void bubble(int N,int a[N]){
    int i,j,tmp;
    
    for(i=0;i<N-1;i++){
        for(j=0;j<N-1-i;j++){
            if(a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
            }
        }
    }
}

int main(void){
    int i,x,y,N,n[1000];
    double ans;
    
    scanf("%d",&N);
    ans=0;
    
    for(i=0;i<N;i++){
        scanf("%d",&n[i]);
    }
    bubble(N,n);
    
    for(i=0;i<N-1;i++){
        y=n[i+1]-n[i];
        if(i==N-2){
            x=n[N-3]+n[N-4];
        }
        else if(i==N-3){
            x=n[N-1]+n[N-4];
        }
        else{
            x=n[N-1]+n[N-2];
        }
        ans = (ans > (double)x/(double)y) ? ans : (double)x/(double)y;
    }
    
    printf("%lf\n",ans);
    
    return 0;
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "No" << endl;
    else if (a != b && b != c && c != a) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;
const int N = 1e4 + 10;

int res[N];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i *i < n; ++i)
    {
        int sum = i * i;
        for(int j = 1; j *j + sum < n; ++j)
        {
            sum += j * j;
            for(int k = 1; k *k + sum < n; ++k)
            {
                sum += k * k;
                sum += i * j + i * k + j * k;

                if(sum <= n)res[sum]++;

                sum -= k * k;
                sum -= i *j + i * k + j * k;
            }
            sum -= j * j;
        }
    }

    for(int i = 1; i <= n; ++i)cout << res[i] << endl;
    return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n;
vector<pi>v[MAXN];
ll dist[MAXN];
void dfs(ll x, ll p){
	for(auto i:v[x])if(i.f!=p){
		dist[i.f]=dist[x]+i.s;
		dfs(i.f,x);
	}
}
int main()
{
	FAST
	cin>>n;
	FOR(i,1,n){
		ll a,b,c;cin>>a>>b>>c;
		v[a].pb(pi(b,c));
		v[b].pb(pi(a,c));
	}
	dfs(1,1);
	vector<ll>ans(n+1,0);
	FOR(i,1,n+1)ans[i]=dist[i]%2;
	FOR(i,1,n+1)cout<<ans[i]<<'\n';
}


Measured memory_bytes: 15872
#include <iostream>
using namespace std;
 
int b[10];
  
bool dfs(int i,int j,int k){
  if(k==10)
    return true;
  if(i<b[k]){
    if(dfs(b[k],j,k+1))return true; 
  }
  if(j<b[k]){
    if(dfs(i,b[k],k+1))return true;
  }
  return false;
}
 
int main(){
  int a;
  cin >> a;
  while(a>0){
    for(int i=0;i<10;i++){
      cin >> b[i];
    }
    int p=dfs(0,0,0);
    if(p!=0)
      cout << "YES" << endl;
    else
      cout << "NO" <<endl;
    a--;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  if(N/100==7){
    cout << "Yes" << endl;
    return 0;
  }
  N%=100;
  if(N/10==7){
    cout << "Yes" << endl;
    return 0;
  }
  N%=10;
  if(N==7){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}
  

Measured memory_bytes: 3632
/*input
100 0
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
void solve()
{
	lld x,n;
	cin >> x >> n;
	lld cnt[400];
	rep(i,0,400){
		cnt[i]=0;
	}
	x+=100;
	rep(i,0,n){
		lld t;
		cin >> t;
		t+=100;
		cnt[t]++;
	}
	rep(i,0,n+5){
		if(cnt[x-i]==0){
			cout << x-100-i << endl;
			return ;
		}
		if(cnt[x+i]==0){
			cout << x+i-100 << endl;
			return;
		}
	} 
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

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

int main(){
int n;
cin>>n;
ll a[n];
map <ll ,ll>  m;
rep(i,n){
cin>>a[i];
m[a[i]]++;
}
ll count=0;
for(auto i: m){
if(i.first<=i.second){
  count+=i.second-i.first;
}else
{
  count+=i.second;
}


}
cout<<count<<endl;


  return 0;
}


Measured memory_bytes: 7040
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]

ki = v[::2]
gu = v[1::2]

ki = Counter(ki)
gu = Counter(gu)

ki = ki.most_common()
gu = gu.most_common()

ans = 0

#最頻値が同じ
if ki[0][0] == gu[0][0]:
    #リストの値が１つのみ
    if len(ki) == 1 and len(gu) == 1:
        ans = int(n / 2)
    else:
        if ki[1][1] > gu[1][1]:
            ans = n - ki[1][1] - gu[0][1]
        else:
            ans = n - ki[0][1] - gu[1][1]
else:
    ans = n - ki[0][1] - gu[0][1]

print(ans)


Measured memory_bytes: 18776
# スペース区切りの整数の入力
a, b = map(int, input().split())
# 判定
# 2で割った余りが0の時、Evenと出力
if (a * b)% 2 == 0:
  print('Even')
# 余りが0でないとき、Oddと出力
else:
  print('Odd')

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[4][3][10] = {};
    
    for(int i = 0; i < n; i++){
        int b, f, r, v, past;
        cin >> b >> f >> r >> v;
        past = a[b-1][f-1][r-1];
        a[b-1][f-1][r-1] = past + v;
    }
    
    for(int bb = 0; bb < 4; bb++){
        for(int ff = 0; ff < 3; ff++){
            for(int rr = 0; rr < 10; rr++){
                cout << " " << a[bb][ff][rr];
            }
            cout << endl;
        }
        if(bb != 3){
            cout << "####################" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    typedef pair<ll , ll> pair_t;
    
    bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
    }
    
    ll gcd(ll a, ll b) {
        if(b == 0)
            return a;
        else
            return gcd(b, a % b);
    }
    ll lcm(ll a, ll b) {
        return a / gcd(a, b) * b;
    }

    int main(){
        ll n;
        cin >> n;
        ll t1 , t2;
        t2 = 0;
        for(ll i = 1 ; t2 < n ; i++ ){
            t2 = i * (i + 1) / 2;
            t1 = i;
        }
        //cout << t1 << endl;
        while(n > 0 && t1 > 0){
            if(n >= t1){
                cout << t1 << endl;
                n -= t1;
            }
            t1 -= 1;
        }
        
        return 0;
        
    }

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

int main()
{
  long int H, W; // 1<= H, W <= 10^9
  cin >> H >> W;
  long int cnt = 0;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }
  if(W&1 && H&1) cout << H*W/2+1 << endl;
  else cout << H*W/2 << endl;
  //if(H&1) cout << H*W/2 << endl;
  //else cout << H/2*W << endl;
  /*for(long int i=0; i<H; i++){
    long int j = 0;
    if(i&1) j = 1;
    for(j; j<W; j+=2){
      cnt++;
    }
  }
  cout << cnt << endl;
  */
  return 0;
}

Measured memory_bytes: 256