akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL i,n,x=0,y=0,z=0;
    cin >> n;
    for(i=3;i<=n;i+=3)x+=i;
    for(i=5;i<=n;i+=5)y+=i;
    for(i=15;i<=n;i+=15)z+=i;
    x-=z,y-=z;
    cout << (n*(n+1))/2-x-y-z;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define forn(i, a, b)       for(int i=a; i<=b; ++i)
#define repn(i, a, b)       for(int i=a; i <b; ++i)
typedef long long llong;
const int N = 4010;
const int M = 2e5 +10;
const int maxN = 2000;
const int MOD = 1e9+7;
llong gt[2*N], in[2*N];
int n, mxa, mxb, a[M], b[M];
int ans, dp[N][N];
void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}
int pw(int x, int q) {
    if (!q) return 1;
    llong tmp = pw(x, q>>1);
    tmp = tmp * tmp % MOD;
    if (q & 1) tmp = (tmp * x) % MOD;
    return tmp;
}
int C(int k, int n) {
    return gt[n] * in[k] % MOD * in[n-k] % MOD;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    gt[0] = in[0] = 1;
    repn(i, 1, 2*N) {
        gt[i] = gt[i-1] * i % MOD;
        in[i] = in[i-1] * pw(i, MOD-2) % MOD;
    }
    int mxa = 0, mxb = 0;
    forn(i, 1, n) {
        cin >> a[i] >> b[i];
        dp[-a[i]+maxN][-b[i]+maxN] += 1;
        mxa = max(mxa, a[i]+maxN);
        mxb = max(mxb, b[i]+maxN);
    }
    forn(i, 0, mxa) forn(j, 0, mxb) {
        add(dp[i+1][j], dp[i][j]);
        add(dp[i][j+1], dp[i][j]);
    }
    forn(i, 1, n) add(ans, dp[a[i]+maxN][b[i]+maxN]);
    forn(i, 1, n) ans = (ans - C(2*a[i], 2*a[i] + 2*b[i])) % MOD;
    ans = (llong) ans * in[2] % MOD;
    cout << (ans + MOD) % MOD;
}

Measured memory_bytes: 64768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    long long H;
    cin >> H;
    
    long long ans = 0;
    rep(i,50){
        if(pow(2,i) <= H && H < pow(2, i + 1)){
            ans = pow(2,i + 1) - 1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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;
}

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; i++){
        ll b;
        cin >> b;
        a[i] = b - (i+1);
    }
    sort(a.begin(),a.end());
    ll x = a[N/2];
    ll res = 0;
    for(int i = 0; i < N; i++){
        res += abs(x - a[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4764
n,m,x = map(int, input().split())
fee_list = list(map(int, input().split()))
count = 0
while fee_list[count] <= x:
  count += 1
fee_0 = count
fee_n = m-count
  
ans_0 = fee_0
ans_n = fee_n

print(min(ans_0,ans_n))

Measured memory_bytes: 3060
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, P = map(int, input().split())
A = [int(i) % 2 for i in input().split()]
A0 = A.count(0)
A1 = A.count(1)
s0 = sum([comb(A0, i) for i in range(0, A0 + 1)])
s10 = sum([comb(A1, i) for i in range(0, A1 + 1, 2)])
s11 = sum([comb(A1, i) for i in range(1, A1 + 1, 2)])

if P == 0:
    print(s0 * s10)
else:
    print(s0 * s11)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next(),t=sc.next();
    if(t.substring(0, s.length()).equals(s)) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
  }
}


Measured memory_bytes: 35672
#include<iostream>
using namespace std;
int main(){
    double h[50];
    
    int i;
    double x;
    for(i = 0;i < 50;i++){
        h[i] = 0;
    }
    for(i = 0; x != 0 && i < 50;i++){
        cin >> x;
        h[i] = x;
    }
    int max = 0;
    int min = 0;
    for(i = 1;i < 50;i++){
        if(h[i] != 0){
            if(h[i] > h[max]){
                max = i;
            }
            if(h[i] < h[min]){
                min = i;
            }       
        }

    }
    cout << h[max] - h[min];
}


Measured memory_bytes: 3244
N, A, B, C, D = map(int,input().split())
S = input()

pres = 'x'          # S[i-1]
cntx, cnty = 0, 0   # x:'.'の連続数, y:'#'の連続数
mxx, mxy = 1, 1     # mxx:'.'の連続数max, mxy:'#'の連続数max

for i in range(A-1, max(C, D)): # base=0
    if S[i] == pres:
        if S[i] == '.':
            cntx += 1
            if i >= B and i < D+1:  # .のチェックは B-D+1だけ
                mxx = max(cntx, mxx)
        elif S[i] == '#':
            cnty += 1
            if C > B or (i < C and i >= B-1):   # C < B の場合は、C-Bでは#の数は不問
                mxy = max(cnty, mxy)
    else:
        pres = S[i]
        if S[i] == '.':
            cntx = 1
        elif S[i] == '#':
            cnty = 1

if C < D:
    if mxy < 2:
        print("Yes")
    else:
        print("No")
else:
    if mxy < 2 and mxx >= 3:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3572
from bisect import bisect_right

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
#a,bの累積和
A_sum = [0]
B_sum = [0]
for i in range(N):
    A_sum.append(A_sum[i]+A[i])
for i in range(M):
    B_sum.append(B_sum[i]+B[i])

ans = 0
#Aについて0-N冊読む場合の全探索
for i in range(N+1):
    cntA = i #Aをi冊読む
    rest = K - A_sum[i] #残り時間rest分
    if rest < 0:
        break
    cntB = bisect_right(B_sum,rest)-1 #Bで読むことができる冊数を二分探索で求める
    ans = max(ans,cntA + cntB)
print(ans)

Measured memory_bytes: 47624
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
 
using namespace std;


//Mr. J ???????????????
void decJ(string& s)
{
	string res;
	for(int i=0;i<s.size();i++) res+=s[(s.size()-1+i)%s.size()];
	s=res;
}

//Miss C ???????????????
void decC(string& s)
{
	string res;
	for(int i=0;i<s.size();i++) res+=s[(1+i)%s.size()];
	s=res;
}

//Mr.E ???????????\????????????
void decE(string& s)
{
	if(s.size()%2){
		string left=s.substr(0,s.size()/2);
		char mid=s[s.size()/2];
		string right=s.substr(s.size()/2+1);
		s=right+mid+left;
	}else{
		string left=s.substr(0,s.size()/2);
		string right=s.substr(s.size()/2);
		s=right+left;
	}
}

//Mr.A ?????¢
void decA(string& s)
{
	reverse(s.begin(),s.end());
}

//Dr. P	??°???++
void decP(string &s)
{
	for(int i=0;i<s.size();i++){
		if(s[i]=='0') s[i]='9';
		else if('0'<=s[i] && s[i]<='9' ) s[i]--;
	}
}

//Mr.M ??°???--
void decM(string &s)
{
	for(int i=0;i<s.size();i++){
		if(s[i]=='9') s[i]='0';
		else if('0'<=s[i] && s[i]<='9' ) s[i]++;
	}
}


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

	for(int i=0;i<n;i++){
		string order,given;
		cin>>order>>given;

		//JCEAPM
		for(int j=order.size()-1;j>=0;j--){
			if(order[j]=='J') decJ(given);
			else if(order[j]=='C') decC(given);
			else if(order[j]=='E') decE(given);
			else if(order[j]=='A') decA(given);
			else if(order[j]=='P') decP(given);
			else decM(given);
		}
		cout<<given<<endl;
	}

	return 0;
}

Measured memory_bytes: 1208
n = int(input())

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

ans = 0
ex_A = 0

for i in range(1,n+1):
    A = a[i-1]
    ans += b[A-1]
    if i == 1:
        pass
    elif ex_A == n:
        pass
    elif ex_A + 1 == A: 
        ans += c[ex_A-1]
    
    ex_A = A

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }else if(a==1){
        cout<<"Alice"<<endl;
    }else if(b==1){
        cout<<"Bob"<<endl;
    }else if(a>b){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Bob"<<endl;
    }
}

Measured memory_bytes: 256
package main
import "fmt"

func imin(a ...int) (int){
	min := a[0]
    for _, v := range a {
        if v < min {
            min = v
        }
    }
    return min
}

func imax(a ...int) (int){
	max := a[0]
    for _, v := range a {
        if v > max {
            max = v
        }
    }
    return max
}

func main() {
	var n int
	fmt.Scan(&n)
	ans := "No"
	for i := 0 ; i < n;i ++{
		for j :=0 ; j<n; j++{
			if i*4 + j*7 == n{
				ans = "Yes"
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
N = int(input())
h = list(map(int,input().split()))
des = len(h)-1
cost = []
for i in range(len(h)):
  cost.append(9999)
ste1 = []
ste2 = []
for i in range(len(h)):
  if i == 0:
    ste1.append(0)
    ste2.append(0)
  elif i == 1:
    ste1.append(abs(h[i-1]-h[i]))
    ste2.append(9999)
  else:
    ste1.append(abs(h[i-1]-h[i]))
    ste2.append(abs(h[i-2]-h[i]))
#print('step1:',ste1,'step2:',ste2)
for i in range(len(h)):
  if i == 0:
    cost[i] = 0
  elif i == 1:
    cost[i] = ste1[i]
  else:
    cost[i] = min(ste1[i]+cost[i-1],ste2[i]+cost[i-2])
#print(cost)
print(cost[des])

Measured memory_bytes: 19692
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    char n;
    cin >> n;
    cout << (char)(n + 1) << EOL;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	int N;
	ll D;
	cin >> N >> D;
	int ans=0;
	for(int i=0; i<N; ++i){
		ll X, Y;
		cin >> X >> Y;
		if(X*X+Y*Y<=D*D) ++ans;
	}
	cout << ans << endl;
	return 0;
}


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

#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define F first
#define S second
#define ll long long

const int MAXN = 100005;
struct Node{
    ll G, S, B;
}A[MAXN];

ll preans[MAXN], sufans[MAXN];

inline bool cmp1(Node& x1, Node& x2)
{
    return ((x1.G - x1.S) < (x2.G - x2.S));
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    
    int X, Y, Z, N, temp;
    cin >> X >> Y >> Z;
    N = X+Y+Z;
    for(int i = 1; i<=N; i++)
    {
        cin >> temp;
        A[i].G = temp;
        cin >> temp;
        A[i].S = temp;
        cin >> temp;
        A[i].B = temp;
    }
    sort(A+1, A+1+N, cmp1);
    ll total = 0LL;
    for(int i = 1; i<=N; i++)
        total += A[i].B;

    ll sum = 0LL, diff;
    multiset<ll> s;
    s.clear();
    multiset<ll>::iterator it;
    for(int i = 1; i<=Y; i++)
    {
        diff = A[i].S - A[i].B;
        sum += diff;
        s.insert(diff);
    }
    preans[Y] = sum;
    for(int i = Y+1; i<=N; i++)
    {
        diff = A[i].S - A[i].B;
        s.insert(diff);
        sum += diff;
        it = s.begin();
        sum -= *it;
        s.erase(it);
        preans[i] = sum;
    }
    s.clear();
    sum = 0LL;
    for(int i = N; i>=(N-X+1); i--)
    {
        diff = A[i].G - A[i].B;
        sum += diff;
        s.insert(diff);
    }
    sufans[N-X+1] = sum;
    for(int i = N-X; i>=1; i--)
    {
        diff = A[i].G - A[i].B;
        s.insert(diff);
        sum += diff;
        it = s.begin();
        sum -= *it;
        s.erase(it);
        sufans[i] = sum;
    }
    ll finans = 0LL;
    for(int i = Y; i<=(N-X); i++)
        finans = max(finans, total + preans[i] + sufans[i+1]);
    cout << finans << "\n";

    return 0;
}

Measured memory_bytes: 7808
# 解説を参考に作成


def solve():
    N, M, Q = map(int, input().split())
    abcd = [[int(i) for i in input().split()] for _ in range(Q)]

    # AAs first is minmum M.
    def dfs(AA=[1], now_max=0):
        A = AA.copy()
        if len(A) == N + 1:
            new_max = 0
            for a, b, c, d in abcd:
                if A[b] - A[a] == c:
                    new_max += d
            now_max = max(now_max, new_max)
        else:
            for i in range(A[-1], M + 1):
                now_max = max(now_max, dfs(A + [i], now_max))
        return now_max

    print(dfs())


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9152
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
	Scanner in = new Scanner(System.in);
	int a = in.nextInt();
	int b = in.nextInt();

	if(a==b)System.out.println("a == b");
	if(a>b)System.out.println("a > b");
	else if(a<b)System.out.println("a < b");
    }
}



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

int n, a[202020];
int as[202020];

int main()
{
    cin >> n;
    rep(i, n)
    {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a + n);

    ll sum = 0;
    rep(i, n) sum += a[i] - a[0];

    ll res = sum;
    for(int i = 1; i < n; i++)
    {
        ll diff = a[i] - a[i - 1];
        sum -= diff * (n - i);
        sum += diff * i;
        res = min(res, sum);
        
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
// Beginner Contest 162
// B - FizzBuzz Sum
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, i;
    long long sum = 0;
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }

    cout << sum << endl;
    return 0;
}

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

int main() {
	long long ax[50], ay[50], cx[50], cy[50];
	int n, m;
	std::cin >> n >> m;
	for (int i = 0; i < n; i++) {
		std::cin >> ax[i] >> ay[i];
	}
	for (int i = 0; i < m; i++) {
		std::cin >> cx[i] >> cy[i];
	}
	int ans[50];
	for (int i = 0; i < n; i++) {

		int ansl;

		for (int j = 0; j < m; j++) {

			if (j == 0 || ansl > std::abs(ax[i] - cx[j]) + std::abs(ay[i] - cy[j])) {

				ansl = std::abs(ax[i] - cx[j]) + std::abs(ay[i] - cy[j]);
				
				ans[i] = j + 1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		std::cout << ans[i] << std::endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int b1, b2, b3;
    cin >> b1 >> b2 >> b3;
    if ((b1 && b2 && !b3) || (!b1 && !b2 && b3)) {
        cout << "Open" << endl;
    } else {
        cout << "Close" << endl;
    }
    return 0;
}

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

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

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

    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += p[i];
    }
        cout << ans << endl;
    
    return 0;
}


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

int main() {
  long N;
  cin >> N;
  long t, a, tn, an;
  cin >> t >> a;
  tn = t; an = a;
  for (int i = 1; i < N; i++) {
    cin >> t >> a;
    long n = max(tn/t + (0 < tn%t), an/a + (0 < an%a));
    tn = t * n;
    an = a * n;
  }
  cout << tn + an << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    int x=0;
    scanf("%d %d",&a,&b);
    x=(a+b)/2;
    
    if((a+b)%2==0){
      printf("%d",x);
    }
    else if((a+b)%2 != 0){
        printf("%d\n",x+1);
    }
    return 0;
    
}

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

int main() {
	int n, a, b, c;
	cin >> n;
	while (cin >> a >> b >> c) {
		if (a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b) {
			cout <<"YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1152
/*
 * Pawan Harendra Mishra
 */

#include <bits/stdc++.h>
using namespace std;

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

#define N 100005
ll n, k, q, a[N], b[N];

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);

    cin >> n >> k >> q;
    memset(b, ll(0), sizeof(b));
    
    for (ll i=0; i<q; i++) {
        cin >> a[i];
        b[a[i] - 1]++;
    }

    // cout << endl;
    // for (ll i=0; i<n; i++) {cout << b[i] << endl;}
    // cout << endl;

    ll mx = 0;
    for (ll i=0; i<n; i++) if (b[i] > mx) mx = b[i];
    for (ll i=0; i<n; i++) {
        if (k - q + b[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

int main() {
    float r;
    cin >> r;
    float ans;
    ans = r * 3.1415926 * 2.0;
    printf("%.3f", ans);
    return 0;
}

Measured memory_bytes: 3788
D=int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
t=[]
last_day = [0]*26
for _ in range(D):
  t.append(int(input()))


sum = 0
for i in range(1,len(t)+1):
  sum += s[i-1][t[i-1]-1]
  last_day[t[i-1]-1]=i
  for j in range(len(c)):
    sum -= c[j]*(i-last_day[j])
  print(sum)

Measured memory_bytes: 9400
#include<stdio.h>

int main(){
	char a[3];
  	int i,count;
  	
  
  scanf("%s",a);
  
  for(i=0;i < 3;i++){
    
    if(a[i] == '1'){
      count++;
    }
    
  }
    
  
  	
 printf("%d",count);
  
 
	return 0;
  
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6;;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ac fstream cin("input.txt");ofstream cout("output.txt");
#define ULL unsigned long long
int main()
{  
    int a;
    while(cin>>a){
        int now=1;
        while(1){
            if( (now+1)*now/2>=a){
                bk;
            }
            now++;
        }
        cout<<now<<endl;
    }
    return 0;
}

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

void dfs(int x, int y, vector<int> &ans, int color, vector<vector<pair<int, int>>> &bridge) {
  ans.at(x) = color;
  for(int i = 0; i < bridge.at(x).size(); i++) {
    if(bridge.at(x).at(i).first == y) {
      continue;
    }
    if(bridge.at(x).at(i).second == 0) {
      dfs(bridge.at(x).at(i).first, x, ans, color, bridge);
    }
    else {
      dfs(bridge.at(x).at(i).first, x, ans, 1 - color, bridge);
    }
  }
}

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> bridge(N, vector<pair<int, int>>());
  for(int i = 0; i < N; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    bridge.at(u - 1).push_back(make_pair(v - 1, w % 2));
    bridge.at(v - 1).push_back(make_pair(u - 1, w % 2));
  }
  vector<int> ans(N, -1);
  dfs(0, -1, ans, 0, bridge);
  for(int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 13064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int get_rand(int a, int b) {  // [a, b]
    return uniform_int_distribution<int>(a, b)(rng);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, n = 26;
    cin >> d;
    vector<int> c(n);
    vector<vector<int>> s(d, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    for (int i = 0; i < d; i++) {
        cin >> t[i];
        t[i]--;
    }
    vector<int> last(n, -1);
    int res = 0;
    for (int i = 0; i < d; i++) {
        last[t[i]] = i;
        res += s[i][t[i]];
        for (int j = 0; j < n; j++) {
            res -= (i - last[j]) * c[j];
        }
        cout << res << '\n';
    }
    // res = max(res + 1000000, 0);
    // cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3684
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;

    public static void main(String[] args) {
        int N = in.nextInt();

        int L = 1, R = 10;
        int result = 0;
        for (; R <= N; L *= 100, R *= 100) {
            result += R - L;
        }

        result += N - Math.min(L - 1, N);

        out.println(result);
    }
}


Measured memory_bytes: 21716
X=int(input())
testX=int(X**(1/2))+2
primeset=set()
for i in range(2,testX):
    num=0
    for p in primeset:
        if i%p != 0:
            pass
        else:
            num=1
            break
    if num==0:
        primeset.add(i)
num=0
if X in primeset:
    print(X)
    num=1
while num == 0:
    num=1
    for p in primeset:
        if X%p != 0:
            pass
        else:
            X+=1
            num=0
            break
    if num == 1:
        print(X)

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

int main() {

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

  sort(d, d + N);
  int sum = 1;
  int pre = d[0];
  for (int i = 1; i < N;i++)
  {
    if(pre < d[i])
    {
      sum++;
      pre = d[i];
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();

    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut H:Vec<usize> = Vec::new();
    for _ in 0..N {
        H.push(read());
    }

    let mut flag: bool = true;
    for i in (1..N).rev() {
        if H[i-1] > H[i] {
            if (H[i-1] - 1) <= H[i] {
                H[i-1] -= 1;
            }
            else {
                flag = false;
            }
        }
        else {
            continue;
        }
    }

    if flag {
        println!("Yes");
    } 
    else {
        println!("No");
    }
}



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

int main(){
  int s; cin >> s;
  int t = s % 10;
  if (t == 2 || t == 4 || t == 5 || t == 7 || t == 9) cout << "hon" << endl;
  else if (t == 0 || t == 1 || t == 6 || t == 8) cout << "pon" << endl;
  else if (t == 3) cout << "bon" <<endl;
  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
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<b;i++)
#define bFor(i,a,b) for(i=a;i>=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 output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

double dist(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;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%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;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,j,N,M,a,b,ans=0;
  cin>>N;
  M=(N+1)/2;
  double x=N,y=M,p;
  p=y/x;
  cout<<p<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    int upb=0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        upb=max(upb,a[i]);
    }
    sort(a.begin(),a.end());
    vector<int> chk(upb+5,0);
    for(int i = 0; i < n; i++) {
        if(a[i]==a[i+1]&&i<n-1) chk[a[i]]++;
        int cg=2*a[i];
        while(cg<=upb){
            chk[cg]++;
            cg+=a[i];
        }
    }
    int cnt=0;
    for(int i = 0; i < n; i++) {
//        cout << a[i] << " " << chk[a[i]] << "\n";
        if(chk[a[i]]==0) cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    if( s[m-1] == 'A' ){
        s[m-1] = 'a';
    }
    if(s[m-1] == 'B'){
        s[m-1] = 'b';
    }
    if(s[m-1] == 'C'){
        s[m-1] = 'c';
    }
    cout << s << "\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    if(1000>=N){
        cout<<1000-N<<endl;
    }else if(2000>=N){
        cout<<2000-N<<endl;
    }else if(3000>=N){
        cout<<3000-N<<endl;
    }else if(4000>=N){
        cout<<4000-N<<endl;
    }else if(5000>=N){
        cout<<5000-N<<endl;
    }else if(6000>=N){
        cout<<6000-N<<endl;
    }else if(7000>=N){
        cout<<7000-N<<endl;
    }else if(8000>=N){
        cout<<8000-N<<endl;
    }else if(9000>=N){
        cout<<9000-N<<endl;
    }else
    cout<<10000-N<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x -a) >= abs(x-b)) cout << "B" << endl;
    else cout << "A" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	string s;
	cin >> s;
	Vec a(n);
	bool flg = true;
	rep(i, n){
		a[i] = s[i] - '1';
		flg &= (a[i] != 1);
	}

	if(flg){
		rep(i, n) a[i] /= 2;
	}else{
		rep(i, n) if(a[i] == 2) a[i] = 0;
	}

	ll ans = 0;
	rep(i, n){
		bitset<22> bit1(n - 1), bit2(i);
		ll sum = 1;
		rep(j, 22) if(bit1[j] == 0 && bit2[j] == 1) sum = 0;
		sum %= 2;
		ans += a[i] * sum;
	}
	ans %= 2;
	if(flg) ans *= 2;
	co(ans);

	return 0;
}


Measured memory_bytes: 9220
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    string s;
    cin>>n;
    cin>>s;
    int x=0;
    int max_x=x;
    for(int i=0;i<n;i++){
        if(s[i]=='I')   x++;
        else if(s[i]=='D')  x--;
        max_x = max(max_x,x);
    }
    cout<<max_x<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
mise = []

ans = -10**9

for i in range(1,2 ** 10):
	kari = []
	ii = i
	for j in range(10):
		kari.append(ii%2)
		ii = ii//2	
	mise.append(kari)

mise.pop(0)

for i in range(len(mise)):
	rieki = 0
	for j in range(n):
		counter = 0
		for k in range(10):
			counter += f[j][k]*mise[i][k]
		rieki += p[j][counter]
	ans = max(rieki,ans)
		
print(ans)


Measured memory_bytes: 3316
#pragma GCC optimize ("-O3")
#ifdef LOCAL
  #include "helper_funcs.hpp"
#else
  #include <bits/stdc++.h>
#endif
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define frn(i,a,b) for(ll i=a;i<b;i++)
#define rfrn(i,a,b) for(ll i=a;i>b;--i)
#define forn(i,a,b) for(ll i=a;i<=b;i++)
#define rforn(i,a,b) for(ll i=a;i>=b;--i)
#define frt(it,v) for(auto &it:v)
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define SQ(a) (a)*(a)
#define SUM(n) ((n)*(n+1))/2
// #define SqSUM(n) ((n)*(n+1)*(2*n+1))/2
// #define GMSUM(a,r,n) (a*pow(r,n)-a)/(r-1)
#define ciel(x, y) (((x) / (y)) + ((x) % (y) != 0))
#define input(v,a,b) for(ll i = a ; i<b ; i++) cin>>v[i]
#define output(v,a,b) cout<<"["<<#v<<"]: "; for(ll i = a ; i<b ; i++) cout<<v[i]<<" "; cout<<ln
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
const long long int md = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef vector<ll> v1;
typedef vector<vector<ll > > vv2;
#define M 32
#ifndef M_PI
  #define M_PI 3.14159265358979323846
#endif
typedef bitset<M> btst;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;
typedef priority_queue<int, vector<int>> max_heap;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//     indexed_set;
const ll MAX = LONG_MAX;
const ll lrg = 1000000007;

void solve()
{
  ll a;
  ld b;
  cin>>a>>b;
  cout<<ll(a*b);
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); 
  int t=1,cp;
  // cin>>t;
  cp=t;
  while(t--){
   // cout<<"Case #"<<cp-t<<": ";
   solve();
   cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


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

    while(1){
        int cnt = 0;
        for (int i=1; i <= x; i++){
            if (x%i == 0){
                cnt++;
            }
        }
        if(cnt == 2){
            break;
        }
        x++;
    }


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


    

    return 0;
} 



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

int main(){
	long long N,ans=0;
	scanf("%lld",&N);
	
	if(N<=9){
		printf("%lld",N);
		return 0;
	}
	
	long long n=N;
	int l;
	
	for(l=0;n>0;l++)n=n/10;
	
	n=N;
	int S[l];
	for(int i=l;i>0;i--){
		S[i-1]=n%10;
		n=n/10;
	}
	
	for(int i=0;i<pow(2,l-1);i++){
		long long tmp=0;
		int bit=i;
		for(int j=0;j<l;j++){
			int flag=bit%2;
			bit=bit/2;
			tmp+=S[j];
			if(flag==0 && j<l-1)tmp*=10;
			else{
				ans+=tmp;
				tmp=0;
			}
		}
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
var
  n,k,i,j:longint;
  a:array[0..1000] of longint;
begin
  readln(n);
  a[1]:=1;
  j:=1;
  k:=1;
  while k<=100 do
  begin
    j:=j+1;
    k:=k*2;
    a[j]:=k;
  end;
  for i:=j downto 1 do 
  begin
    if a[i]<=n then begin write(a[i]);exit;end;
  end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;
//
int n;
ll px[2000],py[2000],qx[2000],qy[2000];
int dp[8000][8000];
vector<ll> compress(ll *x1,ll *x2){
	vector<ll> xs;
	for(int i=0;i<n;i++){
		for(int j=0;j<=1;j++){
			xs.push_back(x1[i]+j);
			xs.push_back(x2[i]+j);
		}
	}
	xs.push_back(1e18+7);
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	for(int i=0;i<n;i++){
		x1[i]=lower_bound(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=lower_bound(xs.begin(),xs.end(),x2[i])-xs.begin();
	};
	return xs;
}
//
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>px[i]>>py[i]>>qx[i]>>qy[i];
	}
	vector<ll> X=compress(px,qx);
	vector<ll> Y=compress(py,qy);
	for(int i=0;i<n;i++){
		dp[px[i]][py[i]]++;
		dp[qx[i]][qy[i]]++;
		dp[px[i]][qy[i]]--;
		dp[qx[i]][py[i]]--;
	}
	for(int i=0;i<X.size()-1;i++){
		for(int j=1;j<Y.size()-1;j++){
			dp[i][j]+=dp[i][j-1];
		}
	}
	for(int i=0;i<Y.size()-1;i++){
		for(int j=1;j<X.size()-1;j++){
			dp[j][i]+=dp[j-1][i];
		}
	}
	ll ans=0;
	for(int i=0;i<X.size()-1;i++){
		for(int j=0;j<Y.size()-1;j++){
			if(dp[i][j]>0){
				ans+=(X[i+1]-X[i])*(Y[j+1]-Y[j]);
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 253288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N;
    cin >> N;
    
    map<string, int> A;
    rep(i,N){
        string s;
        cin >> s;
        A[s]++;
    }
    int n = 0;
    for (auto p : A) {
        n = max(n,p.se);
    }
    ve<string> ans;
    for (auto p : A) {
        if(p.se == n){
            ans.pb(p.fi);
        }
    }

    sort(all(ans));
    rep(i,int(ans.size())){
        cout << ans[i] << endl;
    }
    
    
    

    return 0;
}


Measured memory_bytes: 26868
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	int x =0, y =0, t =0;
	for(int i =0; i < N; i++) {
		int t_nw, x_nw, y_nw;
		cin >> t_nw >> x_nw >> y_nw;
		t +=abs(x-x_nw)+abs(y-y_nw);
		if(t > t_nw || (t_nw-t)%2) {
			cout << "No\n";
			return 0;
		}
		x =x_nw, y =y_nw, t =t_nw;
	}
	cout << "Yes\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int k; cin >> k; k--;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k] << endl;
}

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

int main() {
  int N, K, A;
  cin >> N >> K;
  vector<int> cnt(N + 1);
  while (cin >> A) cnt.at(A)++;
  sort(cnt.rbegin(), cnt.rend());
  cout << N - accumulate(cnt.begin(), cnt.begin() + K, 0) << "\n";
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  vector< vector<char> > a(n,vector<char>(n));
  vector< vector<char> > b(m,vector<char>(m));

  rep(i,n) {
    rep(j,n) {
      cin >> a.at(i).at(j);
    }
  }

  rep(i,m) {
    rep(j,m) {
      cin >> b.at(i).at(j);
    }
  }

  char b_leftup = b.at(0).at(0);

  rep(i,n - m + 1) {
    rep(j,n - m + 1) {

      if(a.at(i).at(j) == b_leftup) {
        bool flag = true;
        
        for(int row = i; row < i + m; row++) {
          for(int column = j; column < j + m; column++) {

            if(a.at(row).at(column) != b.at(row - i).at(column - j)) {
              flag = false;
            }
            
          }
          if(!flag) break;
          if(row == i + m - 1) {
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(void) {
  int h, w, d;
  cin >> h >> w >> d;
  vector<int> x(h * w), y(h * w), sum(h * w, 0);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int p;
      cin >> p;
      x[p - 1] = i;
      y[p - 1] = j;
    }
  }
  for (int i = 0; i < d; i++) {
    for (int j = i + d; j < h * w; j += d) {
      sum[j] = sum[j - d] + abs(x[j] - x[j - d]) + abs(y[j] - y[j - d]);
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << sum[r - 1] - sum[l - 1] << endl;
  }
  return 0;
}

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

int main() {
  int H, W, D;
  cin >> H >> W >> D;
  vector<vector<int>> vec(H,vector<int>(W));
  map<int,pair<int,int>> mp;
  pair<int,int> P;
  pair<int,int> Q;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
      P = make_pair(i+1,j+1);
      mp[vec.at(i).at(j)] = P;
    }
  }
  
  vector<vector<int>> G(D);
  for(int i=0; i<D; i++){
    G.at(i%D).push_back(0);
  }
  for(int i=0; i<=H*W-D; i++){
    P = mp[i];
    Q = mp[i+D];
    G.at(i%D).push_back(abs(P.first - Q.first) + abs(P.second - Q.second));
  }
  
  for(int i=0; i<D; i++){
    for(int j=0; j<G.at(i).size()-1; j++){
      G.at(i).at(j+1) += G.at(i).at(j);
    }
  }
  
  int q;
  cin >> q;
  for(int i=0; i<q; i++){
    int a, b;
    cin >> a >> b;
    cout << G.at(b%D).at(b/D) - G.at(a%D).at(a/D) << endl; 
  }
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second

#define ll long long

int n, a[101000], b[101000], ark[101000], brk[101000];
pii pa[101000], pb[101000];

ll ans;

int main(){
    cin>>n;
    for (int i=1;i<=n;++i){
        cin>>a[i]>>b[i];
        pa[i]={a[i],i};
        pb[i]={b[i],i};
    }
    sort(pa+1,pa+n+1);
    sort(pb+1,pb+n+1);
    for (int i=1;i<=n;++i){
        ark[pa[i].se]=i;
        brk[pb[i].se]=i;
    }

    set<int>S;
    int p1=1, p2=1;
    for (int i=1;i<=n;++i)
        if (pa[p1].fi<pb[p2].fi){
            S.insert(pa[p1].se);
            ans+=pa[p1++].fi;
        }else{
            S.insert(pb[p2].se);
            ans+=pb[p2++].fi;
        }
    
    if (p1>n||p2>n||S.size()<n){
        cout<<ans<<endl; return 0;
    }
    ll bas=ans;
    ans=min(bas+pa[p1].fi-pa[p1-1].fi,bas+pb[p2].fi-pb[p2-1].fi);
    for (int i=0;i<2;++i)
        for (int j=1;j<=2;++j)
            if (p1+i<=n&&p2-j>=1)
                if (pa[p1+i].se!=pb[p2-j].se){
                    ans=min(ans,bas+pa[p1+i].fi-pb[p2-j].fi);
                }
    for (int i=0;i<2;++i)
        for (int j=1;j<=2;++j)
            if (p2+i<=n&&p1-j>=1)
                if (pb[p2+i].se!=pa[p1-j].se){
                    ans=min(ans,bas+pb[p2+i].fi-pa[p1-j].fi);
                }
    cout<<ans<<endl;
}

Measured memory_bytes: 8064