akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>

using namespace std;

typedef unsigned long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

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

    int n;
    cin >> n;

    vi hight(n);
    vll cost(n);

    cin >> hight[0];
    cost[0] = 0;

    for(int i = 1 ; i < n ; ++i)
    {
        cin >> hight[i];

        if(i > 1)
        {
            ll one = abs(hight[i]-hight[i-1]), two = abs(hight[i]-hight[i-2]);

            cost[i] = min(one+cost[i-1],two+cost[i-2]);

            //cout << i << " " << cost[i] << endl;
        }
        else
        {
            cost[i] = abs(hight[0]-hight[1]);
        }
    }

    cout << cost[n-1];

    return 0;
}


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

int n,ans,p[200];

int main(){
	cin>>n;
	for (int i=1;i<=n;++i)
	cin>>p[i];
	for (int i=2;i<n;++i){
		if (p[i]>p[i-1]&&p[i]<p[i+1]) ans++;
		if (p[i]<p[i-1]&&p[i]>p[i+1]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = readints()
a.insert(0, 0)
a.append(0)
# print(a)
cost = 0
for i in range(len(a)-1):
    cost += abs(a[i]-a[i+1])
#print('c', cost)
for i in range(1, len(a)-1):
    #print(i-1, i, i+1)
    print(cost - (abs(a[i-1]-a[i])+abs(a[i]-a[i+1])) + abs(a[i-1]-a[i+1]))


Measured memory_bytes: 89116
import sys
from collections import defaultdict
from copy import copy
sys.setrecursionlimit(1000000)
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]

def dfs(x,a,b,c):
    if x == N:
        return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a,b,c) > 0 else 1000000000
    ret0 = dfs(x+1,a,b,c)
    ret1 = dfs(x+1,a+L[x],b,c) + 10
    ret2 = dfs(x+1,a,b+L[x],c) + 10
    ret3 = dfs(x+1,a,b,c+L[x]) + 10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3444
#include <cstdio>
#include <cstring>
#include <algorithm>

#define MOD (1000000007)

using namespace std;

int N, W;
int Wdown, Wup;
int w[256];
int dp[202][10001];

int main()
{
	scanf("%d %d", &N, &W);
	
	for (int i = 0; i < N; i++){
		scanf("%d", &w[i]);
	}
	sort(w, w + N);
	reverse(w, w + N);
	
	dp[0][0] = 1;
	for (int i = 0; i < N; i++){
		memcpy(dp[i + 1], dp[i], sizeof(dp[i]));
		for (int j = W - w[i]; j >= 0; j--){
			dp[i + 1][j + w[i]] += dp[i][j];
			dp[i + 1][j + w[i]] %= MOD;
		}
	}
	reverse(w, w + N);
	int all, res;
	all = res = 0;
	for (int i = 1; i <= N; i++){
		int k = i - 1;
		for (int j = max(0, W - all - w[k] + 1); j <= W - all - (k ? w[k - 1] : 0); j++){
				res = (res + dp[N - k][j]) % MOD;
		}
		all += w[k];
	}
	
	printf("%d\n", res);
	
	return (0);
}

Measured memory_bytes: 8876
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool is_E(string S){
	int size = (int)S.size();
	if(S.size() % 2 != 0){
		return false;
	}
	string front = (string)S.substr(0, size/2);
	string back = (string)S.substr(size/2);

	if(front == back){
		return true;
	}else{
		return false;
	}
}

int main(){
	string S;

	cin >> S;

	for(int i = (int)S.size(); i > 1; i--){
		S.pop_back();
		if(is_E(S)){
			cout << (int)S.size() << endl;
			break;
		}else{
			if(i == 2){
				cout << -1 << endl;
				break;
			}
			continue;
		}
	}

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(" ")))
alice = []
bob = []
a.sort(reverse=True)
for k in range(int(n / 2) + 1):
    try:
        alice.append(a[2 * k])
        bob.append(a[2 * k + 1])
    except:
        pass
al = sum(alice)
bo = sum(bob)
res = abs(al - bo)
print(res)


Measured memory_bytes: 3060
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
string s;
bool b[200010];
signed main() {
	cin >> n >> s;
	if (s[0] == 'W' || s.back() == 'W') {
		cout << 0 << endl;
		return 0;
	}
	REP(i, 2 * n - 1) {
		if (s[i - 1] == s[i] && !b[i - 1])b[i] = true;
		if (s[i - 1] != s[i] && b[i - 1])b[i] = true;
	}
	if (!b[2 * n - 1]) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 1, cnt = 0;
	rep(i, 2 * n) {
		if (b[i]) {
			ans *= cnt;
			ans %= mod;
			cnt--;
		}
		else cnt++;
	}
	if (cnt) {
		cout << 0 << endl;
		return 0;
	}
	REP(i, n) {
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 772
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a-lin bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int H,W;cin >> H >> W;
    vector<vector<char>> ban(H,vector<char>(W));
    for(int i = 0;i<H;i++) for(int j = 0;j<W;j++) cin >> ban.at(i).at(j);
    vector<vector<int>> dist(H+1,vector<int>(W+1));
    for(int i = 0;i<=H;i++) for(int j = 0;j<=W;j++) dist.at(i).at(j) = inf;
    if(ban.at(0).at(0) == '#') dist.at(0).at(0) = 1;
    else dist.at(0).at(0) = 0;

    for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            if(i != H-1){
                bool whiteToBlack = false;
                if(ban.at(i).at(j) == '.' && ban.at(i+1).at(j) == '#') whiteToBlack = true;
                dist.at(i+1).at(j) = min(dist.at(i+1).at(j),dist.at(i).at(j)+((whiteToBlack ? 1 : 0)));
            }
            if(j != W-1){
                bool whiteToBlack = false;
                if(ban.at(i).at(j) == '.' && ban.at(i).at(j+1) == '#') whiteToBlack = true;
                dist.at(i).at(j+1) = min(dist.at(i).at(j+1),dist.at(i).at(j)+((whiteToBlack ? 1 : 0)));
            }
        }
    }
    cout << dist.at(H-1).at(W-1) << endl;
}

Measured memory_bytes: 3712
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 998244353;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	ll inv2 = 1, m = MOD-2, x = 2;
	while(m){
		if(m&1) inv2 = inv2 * x % MOD;
		x = x * x % MOD;
		m >>= 1;
	}
	
	ll dp[c+1][d+1] = {};
	dp[a][b] = 1;
	REP(j, b+1, d+1) dp[a][j] = dp[a][j-1] * a % MOD;
	REP(i, a+1, c+1) dp[i][b] = dp[i-1][b] * b % MOD;

	REP(i, a+1, c+1){
		REP(j, b+1, d+1){
			dp[i][j] = (dp[i-1][j]*j%MOD + dp[i][j-1]*i%MOD) % MOD;
			dp[i][j] -= dp[i-1][j-1]*(i-1)%MOD * (j-1)%MOD;
			if(dp[i][j]<0) dp[i][j] += MOD;
		}
	}

	//REP(i, 0, c+1){REP(j, 0, d+1)printf("%ld ", dp[i][j]);puts("");}puts("");

	printf("%ld\n", dp[c][d]);
	return 0;
}







Measured memory_bytes: 74112
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;



bool ab(int H, int Cx, int Cy,int x[],int y[],int h[],int n)
{
    for(int i = 0; i < n; i++)
    {
        if(abs(max((H - abs(x[i]-Cx)-abs(y[i]-Cy)), 0) - h[i]) > 1e-6)
            return 0;
    }
        return 1;
        
    
}
int main()
{
    int H = 0, Cx, Cy;
    int n;
    int x[100], y[100], h[100];
    int i;
    cin>>n;
    for(i = 0; i < n; i++)
    {
        cin>>x[i]>>y[i]>>h[i];
    }
    
    
    int t;
    for(i = 0;i < n; i++) if(h[i]) break;
    t = i;
    for(Cx = 0; Cx <= 100; Cx++)
        for(Cy = 0; Cy <= 100; Cy++)
        {
            
            H = abs(Cx - x[t]) + abs(Cy - y[t]) + h[t];
            if(ab(H,Cx,Cy,x,y,h,n))
            {
                cout<<Cx<<" "<<Cy<<" "<<H<<endl;
                return 0;
            }
        }
    
    return 0;
    
}

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

typedef long long ll;

int main() {
  int r, D;
  ll x;
  std::cin >> r >> D >> x;

  for(int i = 0; i < 10; ++i) {
    x = (ll) r * x - D;
    std::cout << x << std::endl;
  }
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $A, $B);

if ($A == $B){
    echo "Draw";
    die();
}
if ($A == 1){
    echo "Alice";
    die();
}
if ($B == 1){
    echo "Bob";
    die();
}
if ($A > $B){
    echo "Alice";
    die();
} else {
    echo "Bob";
    die();
}

Measured memory_bytes: 3700
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second

typedef long long ll;
using namespace std;

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

    int ans = 0;
    int n;cin >> n;
    vector<pair<int,int> > prob(n);
    int p = 0,q = 0;
    for(int i = 0;i < n;i++){
        cin >> prob[i].F >> prob[i].S;
        prob[i].S++;
        if(prob[p].F < prob[i].F){
            p = i;
        }
        if(prob[q].S > prob[i].S){
            q = i;
        }
    }
    
    // {p,q,...},{...}
    for(int i = 0;i < n;i++){
        ans = max(ans,max(0,prob[q].S - prob[p].F) + max(0,prob[i].S - prob[i].F));
    }
    
    //{p,...},{q,...}
    int Lmax = prob[p].F;
    int Rmin = prob[q].S;
    for(int i = 0;i < n;i++){
        prob[i] = make_pair(max(0,prob[i].S - Lmax),-max(0,Rmin - prob[i].F));
    }
    sort(prob.begin(),prob.end());
    for(int i = 0;i < n;i++)prob[i].S *= -1;
    multiset<int> s,t;
    for(int i = 0;i < n;i++)s.insert(prob[i].F);
    //for(auto i : s)cout << i << '\n';
    ans = max(ans,*s.begin());
    for(int i = 0;i < n;i++){
        s.erase(s.find(prob[i].F));
        t.insert(prob[i].S);
        if(i < n)ans = max(ans,*s.begin() + *t.begin());
        else ans = max(ans,*t.begin());
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);


ll arr[100000];
int main()
{
	Ill(n); ll s = 0;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &arr[i]);
	}
	for (int i = 0; i < n-1; ++i)
	{
		s += arr[i] / 2;
		if(arr[i]&1)
		{
			if (arr[i + 1] > 0) { arr[i + 1]--; s++; }
		}
	}
	s += arr[n - 1] / 2;


	std::cout << s;


}











Measured memory_bytes: 1152
import bisect

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
inf = pow(10, 12)
s.insert(0, -inf)
s.append(inf)
t.insert(0, -inf)
t.append(inf)
for i in x:
    u, v = bisect.bisect_left(s, i), bisect.bisect_left(t, i)
    s1, s2 = s[u - 1], s[u]
    t1, t2 = t[v - 1], t[v]
    d1 = max(i - s1, i - t1)
    d2 = max(s2 - i, t2 - i)
    d3 = max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i)
    d4 = max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i)
    print(min(d1, d2, d3, d4))

Measured memory_bytes: 16144
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, c;
    cin >> n >> c;
    vvi d(c, vi(c));
    rep(i, c) {
        rep(j, c) {
            cin >> d[i][j];
        }
    }
    vvi ch(3, vi(c));
    rep(i, n) {
        rep(j, n) {
            int dd;
            cin >> dd;
            dd--;
            ch[(i+j)%3][dd]++;
        }
    }

    vector<vector<P> > iwa(3, vector<P>(c));
    rep(i, 3) {
        rep(j, c) {
            int num = 0;
            rep(k, c) {
                num += d[k][j] * ch[i][k];
            }
            iwa[i][j] = P(num, j);
        }
    }

    int ans = INF*10;
    rep(i, c) {
        rep(j, c) {
            rep(k, c) {
                if(iwa[0][i].second != iwa[1][j].second && iwa[1][j].second != iwa[2][k].second && iwa[2][k].second != iwa[0][i].second) {
                    ans = min(ans, iwa[0][i].first + iwa[1][j].first + iwa[2][k].first);
                }
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
    int n, m, a;
    cin >> n >> m;
    long long sum = 0;
    for(int i = 0; i < m; ++i) {
        cin >> a;
        sum += a;
    }
    if(n-sum >= 0) {
        cout << n-sum << '\n';
    } else {
        cout << -1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
// typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,M,b,c;cin>>N>>M;
  int ans=0;
  vector<int>v(N);
  map<int,int,greater<>> mp;
  REP(i,0,N){
    cin>>b;
    mp[b]++;
  }
  REP(i,0,M){
    cin>>b>>c;
    mp[c]+=b;
  }
  //sort(ALL(mp),greater<>());
  map<int,int> :: iterator it; 
  for (it=mp.begin() ; it!=mp.end() ; it++) {
    if(N<=0) break;
    ans+=min((*it).second,N)*(*it).first;
    N-=(*it).second;
  }
  print(ans)
}


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

#include <math.h>
#include <stdlib.h>


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

const int INF = 1001001001;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    
    int ans = INF;
    for(int i = 0; i < 101; i++){
        int ansTemp = 0;
        for(int j = 0; j < n; j++){
            ansTemp += (i - x[j]) * (i - x[j]);
        }
        ans = min(ans, ansTemp);
    }
    cout << ans << endl;


    return 0;
}


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

int main() {
  int point_a, point_b, current_point;
  scanf("%d %d %d", &current_point, &point_a, &point_b);
  if(abs(current_point - point_a) < abs(current_point - point_b)) {
    printf("A\n");
  } else {
    printf("B\n");
  }
  return 0;
}


Measured memory_bytes: 128
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
A,B,C = inputlist()
if A == B == C and A%2==0 and B % 2 == 0 and C % 2 == 0:
    print(-1)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    if arr[0][0] != 2:
            return 0
    if arr[0][0] == 2:
        return arr[0][1]
fa = factorization(A)
fb = factorization(B)
fc = factorization(C)
if fa == 0 or fb == 0 or fc == 0:
    print(0)
    exit()
f = min(fa,fb,fc)
if fa ==fb==fc:
    f+=1
print(f)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n , a[N] , b[N] , c[N] , dp[N][4] , k;
int main(){
    scanf("%d", &n );
    for(int i = 0 ; i < n ; i++){
        scanf("%d%d%d", &a[i] , &b[i] , &c[i]);
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1 ; i < n ; i++){
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
            dp[i][1] = max(dp[i - 1][0] , dp[i - 1][2]) + b[i];
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout<<max(dp[n - 1][0] , max(dp[n - 1][1] , dp[n - 1][2]));
    return 0;
}

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

int main() {
  int n, q, era[1000], west[1000];
  string name[1000];
  
  while( cin >> n >> q && (n|q) ) {
    for(int i=0; i<n; i++) {
      cin >> name[i] >> era[i] >> west[i];
    }
    
    for(int i=0; i<q; i++) {
      int year;
      int f = 0;
      cin >> year;
      for(int j=0; j<n; j++) {
	if( west[j] - era[j] < year
	    && year <= west[j] ) {
	  cout << name[j] << " " << year - west[j] + era[j] << endl;
	  f = 1;
	  break;
	}
      }
      if(!f) cout << "Unknown" << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1304
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    ll x,y;cin>>x>>y;
    ll k=1000000007;
    if(x<=2*y && y<=2*x && (x+y)%3 == 0){
        ll m=(x*2-y)/3;
        ll m_=modkai(m,0,k);
        cout << modkai((x+y)/3,(x+y)/3-(x*2-y)/3,k)*modpow(m_,k-2,k)%k << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,n,t,l,r;
    cin>>n;
    m=n;
    set<pair<ll,pair<ll,ll>>>s;
    ll cnt=0;
    for(i=1; i<n; i++)
    {
        l=i;//cout<<double(n)/double(l)<<'\n';
        for(j=1; j<double(n)/double(l); j++)
        {
            cnt++;
        }
    }
    cout<<cnt<<'\n';
}









Measured memory_bytes: 3648
#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 long long LL;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

LL beki(LL a,LL b)
{
	if(b==0)return 1;
	LL x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

LL inv(LL a)
{
	return beki(a,MOD-2);
}

LL kaijou(LL a)
{
	LL ans=1;
	for(LL i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

LL combi(LL a,LL b)
{
	LL ret=1;
	for(LL i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}

int bp[200010],bq[200010];
int com[200010];
signed main(){
  int n,a,b,c;cin>>n>>a>>b>>c;
  int p=prod(a,inv(100-c)),q=prod(b,inv(100-c)),r=prod(100,inv(100-c));
  int ans=0;
  rep(i,n+5){
    if(i==0)bp[0]=1,bq[0]=1;
    else{
      bp[i]=prod(p,bp[i-1]);
      bq[i]=prod(q,bq[i-1]);
    }
    //cout<<bp[i]<<endl;
  }
  rep(i,n+5){
    if(i==0)com[0]=1;
    else {
      com[i]=prod(com[i-1],prod(n+i-1,inv(i)));
    }
    //cout<<com[i]<<endl;
  }
  rep(i,n){
    ans=add(ans,prod(n+i,prod(com[i],prod(bp[n],bq[i]))));
    ans=add(ans,prod(n+i,prod(com[i],prod(bq[n],bp[i]))));
    //cout<<ans<<endl;
    
  }
  ans=prod(ans,r);
  cout<<ans<<endl;
  return 0;
}

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


def main():
    from collections import defaultdict
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(int)
    ans = 0

    for i in range(n):
        diff = i - a[i]
        ans += d[diff]

        summed = i + a[i]
        d[summed] += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61108
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();

		boolean map[][] = new boolean[H][W];

		for(int h=0;h<H;h++){
			String st = sc.next();
			for(int w=0;w<W;w++){
				if(st.charAt(w) == '#')
				map[h][w] = true;
				else
				map[h][w] = false;
 			}
		}
		boolean flag = true;

		outside:for(int h=0;h<H;h++){
			for(int w=0;w<W;w++){

				if(map[h][w]){
					if(h>0 && map[h-1][w]) continue;
					if(h<H-1 && map[h+1][w]) continue;
					if(w>0 && map[h][w-1]) continue;
					if(w<W-1 && map[h][w+1]) continue;


					flag = false;
					break outside;
				}
				
 			}
		}

		if(flag) System.out.println("Yes");
		else System.out.println("No");

	}
}

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

using namespace std;

int main(){
	int a[3][3],c[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
			c[i][j]=0;
		}
	}
	int n;
	cin>>n;
	int b[n];
	for(int x=0;x<n;x++){
		cin>>b[x];
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(c[i][j]==b[x]){
					c[i][j]=1;
					break;
				}
			}
		}
	}
	for(int x=0;x<n;x++){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(a[i][j]==b[x]){
					c[i][j]=1;
					break;
				}
			}
		}
	}
	bool ans=false;
	for(int i=0;i<n;i++){
		if(c[0][i]==1&&c[1][i]==1&&c[2][i]==1){
			ans=true;
			break;
		}
	}
	for(int i=0;i<n;i++){
		if(c[i][0]==1&&c[i][1]==1&&c[i][2]==1){
			ans=true;
			break;
		}
	}
	if(c[0][0]==1&&c[1][1]==1&&c[2][2]==1||c[0][2]==1&&c[1][1]==1&&c[2][0]==1){
		ans=true;
	}
	cout<<(ans ? "Yes" : "No");
}


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

int main()
{
	long int** ppiA;
	long int** ppiB;
	long int** ppiC;
	int iHeightA;
	int iWeigthA;
	int iHeightB;
	int iWeigthB;
	int iHeightC;
	int iWeigthC;
	int iCountHeight;
	int iCountWeigth;
	int iCountIP;
	scanf("%d %d %d\n", &iHeightA, &iWeigthA, &iWeigthB);
	iHeightB = iWeigthA;
	iHeightC = iHeightA;
	iWeigthC = iWeigthB;
	ppiA = (int**)malloc(sizeof(long int*) * iHeightA);
	ppiB = (int**)malloc(sizeof(long int*) * iHeightB);
	ppiC = (int**)malloc(sizeof(long int*) * iHeightC);
	for (iCountHeight = 0; iCountHeight < iHeightA; iCountHeight++)
	{
		ppiA[iCountHeight] = (int*)malloc(sizeof(long int) * iWeigthA);
	}
	for (iCountHeight = 0; iCountHeight < iHeightB; iCountHeight++)
	{
		ppiB[iCountHeight] = (int*)malloc(sizeof(long int) * iWeigthB);
	}
	for (iCountHeight = 0; iCountHeight < iHeightC; iCountHeight++)
	{
		ppiC[iCountHeight] = (int*)malloc(sizeof(long int) * iWeigthC);
		for (iCountWeigth = 0; iCountWeigth < iWeigthC; iCountWeigth++)
		{
			ppiC[iCountHeight][iCountWeigth] = 0;
		}
	}

	for (iCountHeight = 0; iCountHeight < iHeightA; iCountHeight++)
	{
		for (iCountWeigth = 0; iCountWeigth < iWeigthA; iCountWeigth++)
		{
			scanf("%ld", &ppiA[iCountHeight][iCountWeigth]);
		}
	}
	for (iCountHeight = 0; iCountHeight < iHeightB; iCountHeight++)
	{
		for (iCountWeigth = 0; iCountWeigth < iWeigthB; iCountWeigth++)
		{
			scanf("%ld", &ppiB[iCountHeight][iCountWeigth]);
		}
	}

	for (iCountHeight = 0; iCountHeight < iHeightA; iCountHeight++)
	{
		for (iCountWeigth = 0; iCountWeigth < iWeigthB; iCountWeigth++)
		{
			for (iCountIP = 0; iCountIP < iWeigthA; iCountIP++)
			{
				ppiC[iCountHeight][iCountWeigth] += ppiA[iCountHeight][iCountIP] * ppiB[iCountIP][iCountWeigth];
			}
		}
	}
	for (iCountHeight = 0; iCountHeight < iHeightC; iCountHeight++)
	{
		for (iCountWeigth = 0; iCountWeigth < iWeigthC; iCountWeigth++)
		{
			printf("%ld", ppiC[iCountHeight][iCountWeigth]);
			if (iCountWeigth == iWeigthC - 1)
			{
				printf("\n");
			}
			else
			{
				printf(" ");
			}
		}
	}

	for (iCountHeight = 0; iCountHeight < iHeightA; iCountHeight++)
	{
		free(ppiA[iCountHeight]);
	}
	for (iCountHeight = 0; iCountHeight < iHeightB; iCountHeight++)
	{
		free(ppiB[iCountHeight]);
	}
	for (iCountHeight = 0; iCountHeight < iHeightC; iCountHeight++)
	{
		free(ppiC[iCountHeight]);
	}
	free(ppiA);
	free(ppiB);
	free(ppiC);
}


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

public class Main {
  private static long solve(long x) {
    long div = x / 11;
    long mod = x % 11;
    if (mod == 0) {
      return 2 * div;
    } else if (mod <= 6) {
      return 2 * div + 1;
    } else {
      return 2 * div + 2;
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long x = reader.nextLong();
    out.println(solve(x));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21204
from math import sqrt

count = 0
n, d = map(int, input().split())
x = [[int(xx) for xx in input().split()] for _ in range(n)]

for y in range(n - 1):
    for z in range(y + 1, n):
        if sqrt(sum((i - j) ** 2 for i, j in zip(x[y], x[z]))).is_integer():
            count += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb       push_back
#define mp       make_pair
#define mod      1000000007
#define first    ff
#define second   ss
#define pi       acos(-1.0)
typedef long long ll;
using namespace std;
vector<int>node[10001];

int main()
{      


     ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2)
      cout<<"No"<<endl;
    else
    {
       string a="",b="";
       
       for(int i=0;i<n;i++)
       {
          if(i<n/2)
            a+=s[i];
          else
            b+=s[i];
        
       }        
             if(a==b)
            cout<<"Yes"<<endl;
          else
            cout<<"No"<<endl; 
    }


      return 0;
    
 }       


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
 
auto clk=clock();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll INF = 1e18L+5;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;
 
const int N_MAX = 2005;
ll dp[N_MAX][N_MAX];
 
ll combi(ll n, ll r){
    if(r==0||r==n)
        return 1;
    if(dp[n][r]!=-1)
        return dp[n][r];
    ll a = combi(n-1,r-1);
    ll b = combi(n-1,r);
    dp[n][r] = (a+b)%MOD;
    return dp[n][r];
}
 
ll modexp(ll base,ll power){
    if(base==0)
        return 0ll;
    if(power==0)
        return 1ll;
    ll res=1;
    while(power){
        if(power&1)
            res = (res*base)%MOD;
        base = (base*base)%MOD;
        power /= 2;
    }
    return res;    
}
 
void solve(){
	ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans = a*c;
  ans = max(ans,a*c);
  ans = max(ans,a*d);
  ans = max(ans,b*d);
  ans = max(ans,b*c);
  cout<<ans;
}
    
 
int main () 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
    memset(dp,-1,sizeof(dp));
    ll t = 1;
    // cin>>t;
    while(t--)
        solve();
 
    // cout<<endl<<endl<<"Time elapsed: "<<((double)(clock()-clk)/CLOCKS_PER_SEC)*1000<<"ms"<<endl;
    return 0;
}

Measured memory_bytes: 35004
#include<iostream>
using namespace std;
int main()
{

 int h, w ;
    
 while(1){
  cin >> h >> w ;
        if(h==0 && w==0) break;
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          cout << "#" ;
      }
        cout << "\n" ;
  }
        cout << "\n" ;
 }
 return 0;  

}



Measured memory_bytes: 3032
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
	// your code goes here
	int n,i,t=0;
	cin>>n;
	for(i=1;i<10;i++)
      if(i*(n/i)==n && (n/i)<10)
      {
        cout<<"Yes";
        break;
      }
		else 
        {
          if(i!=9)
            continue;
          else
            t=2;
        }
	if(t==2)
      cout<<"No";
  	
   
	return 0;
}


Measured memory_bytes: 256
n,p=map(int,input().split());i=2;d={}
while i*i<=p:
 if p%i:i+=1
 else:d[i]=d.get(i,0)+1;p//=i
d[p]=d.get(p,0)+1;a=1
for k,v in d.items():a*=k**(v//n)
print(a)

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

struct Point {
  double a,b;
};

void oz(int num,Point A, Point B){
  if(num==0){
    return;
  }
  Point si,ti,ui;
  double te = M_PI * 60.0 / 180.0;

  si.a = (2.0 * A.a + 1.0 *B.a) / 3.0;
  si.b = (2.0 * A.b + 1.0 *B.b) / 3.0;
  ti.a = (1.0 * A.a + 2.0 *B.a) / 3.0;
  ti.b = (1.0 * A.b + 2.0 *B.b) / 3.0;

  ui.a = (ti.a - si.a) * cos(te) - (ti.b - si.b) * sin(te)+si.a;
  ui.b = (ti.a - si.a) * sin(te) + (ti.b - si.b) * cos(te)+si.b;

  oz(num-1,A,si);
  printf("%.8f %.8f\n",si.a,si.b);
  oz(num-1,si,ui);
  printf("%.8f %.8f\n",ui.a,ui.b);
  oz(num-1,ui,ti);
  printf("%.8f %.8f\n",ti.a,ti.b);
  oz(num-1,ti,B);
}

int main(){
  Point a,b;
  int num;

  scanf("%d",&num);

  a.a = 0;
  a.b = 0;
  b.a =100;
  b.b = 0;

  printf("%.8f %.8f\n",a.a,a.b);
  oz(num,a,b);
  printf("%.8f %.8f\n",b.a,b.b);

  return 0;
}

  
  



Measured memory_bytes: 2660
#include <stdio.h>

int main(void){
    
    int i,x,y,z;
    
    scanf("%d", &z);
    
    for (i=1;i<=z;i++){
        scanf("%d", &x);
        scanf("%d", &y);
        
        if(x%y==0)
            printf("%d\n",y);
        else
            printf("%d\n",x%y);
    }
    
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {
    li a[4];
    rep(i, 4)cin >> a[i];
    sort(a, a + 4);
    if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}

typedef std::pair<ll, ll> P;
 
using namespace std;

int main()
{
    ll n;
    cin >> n;
    ll mn = INF*10000;

    for(ll i=1; i*i<=n; i++){
        if (n % i == 0){
            mn = min(mn, (i-1)+(n/i-1));
        }
    }

    cout << mn;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k,s;
    cin>>n>>k>>s;
    if(s==1){
        rep(i,k) cout<<1<<" ";
        rep(i,n-k) cout<<2<<" ";
        cout<<endl;
    }
    else if(n>=k+1){
        int a=s/2,b=s-a;
        rep(i,k+1){
            if(i%2==0) cout<<a<<" ";
            else cout<<b<<" ";
        }
        if(s==1e9){
            rep(i,n-(k+1)){
                cout<<s-1<<" ";
            }
            cout<<endl;
        }
        else{
            rep(i,n-(k+1)){
                cout<<s+1<<" ";
            }
            cout<<endl;
        }
    }
    else{
        rep(i,k) cout<<s<<" ";
        if(s==1e9){
            rep(i,n-k){
                cout<<s-1<<" ";
            }
            cout<<endl;
        }
        else{
            rep(i,n-k){
                cout<<s+1<<" ";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;
ll inf=1LL<<50;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int p,q,r;
	cin>>p>>q>>r;
	int a=q+p,b=q+r,c=p+r;
	int ans=min(a,min(b,c));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<int> G[10];
int N,M;
int ans = 0;

void dfs(int a, int check)
{
	//cout << " visiting:" << a << " check:" << check << endl;
	if (check == (1 << N) - 1)
	{
		ans++;
		return;
	}

	rep(i,G[a].size())
	{
		if (!(check & (1 << G[a][i])))
		{
			int next_check = check + (1 << G[a][i]);
			//cout << "from:" << a;
			dfs(G[a][i],next_check);
		}
	}
}

int main()
{
	cin >> N >> M;
	rep(i,M)
	{
		int a,b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	/*
	rep(i,M)
	{
		rep(j,G[i].size())
		{
			cout << G[i][j];
		}
		cout << endl;
	}
	*/

	dfs(0,1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    map<char, int> a;
    for(int i = 0; i < s.size(); i++){
        a[s[i]]++;
        if(a[s[i]] > 1){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " " <<
#define X first
#define Y second
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

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

const int MAX = 1<<19;
int p[MAX];
int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  REP(i, m) {
    int a, b;
    scanf("%d%d", &a, &b); a--; b--;
    if (a > b) swap(a, b);
    if (!a) p[b] |= 1;
    if (b==n-1) p[a] |= 2;
  }

  int r=0;
  REP(i, n) if (p[i] == 3) r = 1;
  printf("%s\n", r ? "POSSIBLE" : "IMPOSSIBLE");

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

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

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

    int c;
    c = stoi(a+b);

    rep(i, 10010){
        if(i*i==c){
            cout<< "Yes" << endl;
            return 0;
        }

    }

    cout<< "No" <<endl;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int K, A, B;
    cin  >> K >> A >> B;
    
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }

    }

    cout << "NG" << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class BinarySearch
{
public:
  int solve( int n, int s[], int q, int t[] );
  bool search( int x, int i, int j, int a[] );
};

bool BinarySearch::search( int x, int i, int j, int a[] )
{
  if ( i > j )
    return false;

  int k = (i + j) / 2;

  if ( a[k] == x )
    return true;
  else if ( a[k] > x )
    return search( x, i, k-1, a );
  else
    return search( x, k+1, j, a );
}

int BinarySearch::solve( int n, int s[], int q, int t[] )
{
  int cnt = 0;

  for ( int i = 0; i < q; i++ )
    {
      if ( search( t[i], 0, n-1, s ) )
        cnt++;
    }
  return cnt;
}

int main( void )
{
  int n, s[100000], q, t[50000];

  cin >> n;

  for ( int i = 0; i < n; i++ )
    cin >> s[i];
  
  cin >> q;

  for ( int i = 0; i < q; i++ )
    cin >> t[i];
  
  BinarySearch bs;

  cout << bs.solve(n, s, q, t) << endl;
  
  return 0;
}

Measured memory_bytes: 1744
Scanf.scanf "%d %d" @@ fun n x ->
Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0))
|> Array.fold_left (fun (c, d) y -> (if d+y <= x then c+1 else c), d+y) (1, 0)
|> fst |> Printf.printf "%d\n"

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

int main(){
  int n;cin>>n;
  vector<long long> arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  sort(arr.begin(),arr.end());
  int index = lower_bound(arr.begin(),arr.end(),0)-arr.begin();
  vector<pair<int,int>> steps;
  int l,r;
  long long result = 0;

  if(index==0){
    for(int j=1;j<n-1;++j){
      steps.push_back(make_pair(arr[0],arr[j]));
      arr[0] = arr[0]-arr[j];
    }
    steps.push_back(make_pair(arr[n-1],arr[0]));
    result = arr[n-1]-arr[0];
    
  }else if(index == arr.size()){
    l = arr[n-1];
    for(int j=n-2;j>=0;--j){
      steps.push_back(make_pair(l,arr[j]));
      l = l-arr[j];
    }
    result = l;
    }else{ 
    for(int j=index;j<n-1;++j){
      steps.push_back(make_pair(arr[0],arr[j]));
      arr[0] = arr[0]-arr[j];
    }
    
    for(int j=0;j<index;++j){
       steps.push_back(make_pair(arr[n-1],arr[j]));
       arr[n-1] = arr[n-1]-arr[j];     
    }
    result = arr[n-1];
  } 
  
  cout<<result<<endl;
  for(auto i:steps){
    cout<<i.first<<" "<<i.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 3572