akhauriyash/Code-Regression huggingface dataset:
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

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

    prints(max(0, c-(a-b)));
    return 0;
}



Measured memory_bytes: 256
from collections import Counter
N = int(input())
P = Counter((x for _ in range(N) for x in input()[0] if x in "MARCH"))
Pidx = list(P.keys())
def mycount(i, ptn, c):
    #print((i,ptn,c))
    if c <= 0:
        return ptn
    elif len(P) - i < c:
        return 0
    return mycount(i+1, ptn, c) + mycount(i+1, ptn * P[Pidx[i]], c - 1)
#print(Pidx)
print(mycount(0, 1, 3))


Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	num := int(n)
	var strs []string
	var a, b, c int
	var res string
	var YES string = "YES"
	var NO string = "NO"
	for i := 0; i < num; i++ {
		scanner.Scan()
		strs = strings.Split(scanner.Text(), " ")
		a, _ = strconv.Atoi(strs[0])
		b, _ = strconv.Atoi(strs[1])
		c, _ = strconv.Atoi(strs[2])

		res = NO
		if c*c == (a*a+b*b) || b*b == (a*a+c*c) || a*a == (b*b+c*c) {
			res = YES
		}
		fmt.Printf("%s\n", res)
	}
}



Measured memory_bytes: 1132
var
	K:Longint;
	L,R,M:int64;
function check(T:int64):Longint;
var
	dp:Array[1..15,0..1,0..1,0..9]of Longint;
	S:String;
	i,j,k,l,nj,lim,sum,z:Longint;
begin
	Str(T,S);
	for i:=1 to length(S)+1 do for j:=0 to 1 do for z:=0 to 1 do for k:=0 to 9 do dp[i,j,z,k]:=0;
	dp[1,0,1,0]:=1;
	for i:=1 to length(S) do begin
		for j:=0 to 1 do begin
			if j=0 then lim:=ord(S[i])-48 else lim:=9;
			inc(dp[i+1,1,1,0],dp[i,j,1,0]);
			for l:=1 to lim do begin
				nj:=j;
				if l<lim then nj:=1;
				inc(dp[i+1,nj,0,l],dp[i,j,1,0]);
			end;
			for k:=0 to 9 do begin
				for l:=0 to lim do begin
					if(k<l-1)or(l<k-1)then continue;
					nj:=j;
					if l<lim then nj:=1;
					inc(dp[i+1,nj,0,l],dp[i,j,0,k]);
				end;
			end;
		end;
	end;
	sum:=0;
	for k:=0 to 9 do for i:=0 to 1 do begin
		inc(sum,dp[length(S)+1,i,0,k]);
	end;
	check:=sum;
end;
begin
	read(K);
	L:=0;
	R:=3234566667;
	while R-L>1 do begin
		M:=(L+R)div 2;
		if check(M)>=K then R:=M else L:=M;
	end;
	writeln(R);
end.


Measured memory_bytes: 128
#include <iostream>

using namespace std;

bool BAC[13];
string S;
long long tot;

void test() {

    long long ans = 0;
    long long crr = 0;

    for(int i = 0; i < S.size(); i++) {

        if(i != 0 && BAC[i-1])
            ans += crr, crr = 0;

        crr = (crr*10)+1LL*(S[i]-'0');

    }

    ans += crr;
    tot += ans;

}

void bckt(int P) {

    if(P == S.size()-1) {
        test();
        return;
    }

    BAC[P] = 1;
    bckt(P+1);
    BAC[P] = 0;
    bckt(P+1);

}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> S;
    bckt(0);
    cout << tot;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define ll long long
inline int read(){
	int x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

const int N = 1005;
int a[N];
int n;
int opt[N],top;
ll sum1,sum2;
bool flag;

int main(){
	n = read(); flag = false;
	for(int i = 1;i <= n;++i){
		a[i] = read();
		if(a[i] > 0) flag = true;
		if(i&1) sum1 += a[i] > 0 ? a[i] : 0;
		else sum2 += a[i] > 0 ? a[i] : 0;
	}
	int del = 0;
	if(!flag){
		// puts("1");
		ll Mx = -1e9; int p = 0;
		for(int i = 1;i <= n;++i){
			if(a[i] > Mx) Mx = a[i],p = i;
		}
		for(int i = n;i > p;--i)
			opt[++top] = i;
		for(int i = 1;i < p;++i)
			opt[++top] = 1;
		printf("%lld\n", Mx);
		printf("%d\n",top);
		for(int i = 1;i <= top;++i) printf("%d\n", opt[i]);
			return 0;
	}
	if(sum1 > sum2){
		bool flag2 = false;
		for(int i = 1;i <= n;++i)
			if(i&1)
				if(a[i] < 0){
					opt[top+1] = i-del,top++;
					if(i == 1||i == n){
						del++;
						if(i == 1) flag2 = true;
					}
					else del += 2;
				}
		n -= del;
		if(flag2) opt[++top] = 1,n--;
		while(n > 1){ opt[++top] = 2; n -= 2; }
	}else{
		for(int i = 1;i <= n;++i)
			if(i%2 == 0)
				if(a[i] < 0){
					opt[top+1] = i-del,top++;
					if(i == 1 || i == n) del++;
					else del += 2;
				}
		n -= del;
		opt[++top] = 1; n--;
		while(n > 1){ opt[++top] = 2; n -= 2; }
	}
	printf("%lld\n",max(sum1,sum2));
	printf("%d\n", top);
	for(int i = 1;i <= top;++i)
		printf("%d\n", opt[i]);
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;


int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<P> c(n);
    
    REP(i, n) cin >> a[i] >> b[i];
    REP(i, n) {
        c[i].first = a[i] + b[i];
        c[i].second = i;
    }
    sort(ALL(c));
    reverse(ALL(c));

    ll aoki = 0, takahashi = 0;
    REP(i, n) {
        if(i % 2 == 0) {
            aoki += a[c[i].second];
        } else {
            takahashi += b[c[i].second];
        }
    }

    cout << aoki - takahashi << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<cstring>
using namespace std;
#define ll long long
#define inf 0x7fffffff
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
inline ll readl()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define MOD 1000000007
inline ll power(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1){ans=ans*a%MOD;--b;}
		b>>=1;a=a*a%MOD;
	}
	return ans%MOD;
}
ll n,ans;
int cnt;
int main()
{
	n=readl();
	if(n<10) return cout<<n,0;
	while(n){
		if(n<10)
		{
			 ans+=n;break;
		}
		if(n%10!=9){
			ans+=9;n/=10;n--;
		}else{
			ans+=9;n/=10;
		}
	}
	cout<<ans<<"\n";
}



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

int main() {
  int N, M;
  cin >> N >> M;
  int cnt = 0;
  for (int i = 0; i < M; ++i) {
    int ai;
    cin >> ai;
    cnt += ai;
  }
  if (cnt > N) {
    cout << "-1" << endl;
  } else {
    cout << N - cnt << endl;
  }
}


Measured memory_bytes: 3596
n=int(input())
s=[list(map(int, input().split()))  for i in range(n)]
v=[]
r=[]
x=0
y=0
s.sort(key=lambda x:x[1])

for i in range(n):
    x+=s[i][0]
    y=s[i][1]
    if x>y:
        print('No')
        exit()
print('Yes')

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

long long f(long long x) {
  if(x == 1) return 1;
  return (x * f(x - 1)) % 1000000007;
}

int main() {
  long long n, m;
  cin >> n >> m;
  
  if(n > m) swap(n, m);
  
  if(n + 2 <= m) cout << 0 << endl;
  else if(n == m) cout << (f(n) * f(m) * 2) % 1000000007 << endl;
  else cout << (f(n) * f(m)) % 1000000007 << endl;
}

Measured memory_bytes: 1792
a,b,c,k=map(int,input().split())
ans=0
if a>=k:
    ans=k
    print(ans)
elif a<k<=a+b:
    ans=a
    print(ans)
elif a+b<k<=a+b+c:
    ans=a+(-1)*(k-(a+b))
    print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  string front, back;
  int Q; cin >> Q;
  bool rev = false;
  rep(i,Q) {
    int q; cin >> q;
    if (q==1) rev = !rev;
    else {
      int F; cin >> F;
      string C; cin >> C;
      if ((!rev&&F==1)||rev&&F==2) front += C;
      else back += C;
    }
  }
  reverse(all(front));
  string result = front + S + back;
  if (rev) reverse(all(result));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1348
def main():
    s = input()
    flag = True
    for i in range(len(s)):
        if ((i + 1) % 2 == 0 and s[i] == "R"):
            flag = False
        elif ((i + 1) % 2 != 0 and s[i] == "L"):
            flag = False
    
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL << 31;
constexpr static int dx[] = {1, 0, -1, 0};
constexpr static int dy[] = {0, 1, 0, -1};

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

    string s;
    cin >> s;

    string subs1 = s.substr(0, 2), subs2 = s.substr(2, 2);
    if (subs1 > "00" && subs1 < "13") {
        if (subs2 > "00" && subs2 < "13") cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
        return 0;
    }
    if (subs2 > "00" && subs2 < "13") {
        if (subs1 > "00" && subs1 < "13") cout << "AMBIGUOUS" << endl;
        else cout << "YYMM" << endl;
        return 0;
    }

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

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String W[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
		
		for(int i=0;i<7;i++) {
			if(S.equals(W[i])) {
				System.out.println(7-i);
			}
		}
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll N = 1e9, D = 9;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto& e : a) {
    string s;
    cin >> s;
    ll x = 0, y = 0, d = 0;
    bool b = false;
    for (auto c : s) {
      if (c == '.') {
        b = true;
      } else if (b) {
        y *= 10;
        y += c - '0';
        d++;
      } else {
        x *= 10;
        x += c - '0';
      }
    }
    e = x * N + y * (ll)pow(10, D - d);
    // cerr << x << ' ' << y << ' ' << d << ' ' << e << endl;
  }

  vector<vector<ll>> m(50, vector<ll>(50));
  for (auto e : a) {
    int i = 0, j = 0;
    for (; e % 2 == 0; e /= 2) i++;
    for (; e % 5 == 0; e /= 5) j++;
    m[i][j]++;
  }

  ll r = 0;
  for (int i1 = 0; i1 < 50; i1++) {
    for (int j1 = 0; j1 < 50; j1++) {
      for (int i2 = 0; i2 < 50; i2++) {
        if (i1 + i2 < 2 * D) continue;
        for (int j2 = 0; j2 < 50; j2++) {
          if (j1 + j2 < 2 * D) continue;
          if (i1 == i2 && j1 == j2) {
            r += m[i1][j1] * (m[i1][j1] - 1);
          } else {
            r += m[i1][j1] * m[i2][j2];
          }
        }
      }
    }
  }
  r /= 2;
  cout << r << endl;
}


Measured memory_bytes: 4832
// ARC059E
// 20160924-1321-1630

#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <cmath>
#include <limits>

using namespace std;

using IntType = long long;

const int CHILD_MAX = 401;
const int CANDY_MAX = 401;
const int HASYAGI_MAX = 401;
int childNum;
int candyNum;
int hasyagis[2][CHILD_MAX];
const IntType mod = 1000000007;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)

IntType powAccumSum[CANDY_MAX][HASYAGI_MAX];
void calcPowAccumSum() {
	REP(i, HASYAGI_MAX) {
		powAccumSum[0][i] = 1;
	}
	powAccumSum[0][0] = 0;
	FOR(a, 1, CANDY_MAX) { // calc i^a
		REP(i, HASYAGI_MAX) {
			powAccumSum[a][i] = (powAccumSum[a - 1][i] * i) % mod;
		}
	}
	REP(a, CANDY_MAX) { // calc sum_i i^a
		FOR(i, 1, HASYAGI_MAX) {
			powAccumSum[a][i] += powAccumSum[a][i - 1];
			powAccumSum[a][i] %= mod;
		}
	}
}
IntType polyDp[CHILD_MAX][CANDY_MAX];
void calcPolyDp() {
	polyDp[0][0] = 1;
	FOR(childI, 1, childNum + 1) REP(candyI, candyNum + 1) {
		REP(k, candyI + 1) {
			IntType childISum = (((powAccumSum[candyI - k][hasyagis[1][childI]] - powAccumSum[candyI - k][hasyagis[0][childI] - 1]) % mod) + mod) % mod;
			polyDp[childI][candyI] += polyDp[childI - 1][k] * childISum;
			polyDp[childI][candyI] %= mod;
		}
	}
}
int main() {
	cin >> childNum >> candyNum;
	REP(i, 2) FOR(j, 1, childNum + 1) {
		cin >> hasyagis[i][j];
	}
	calcPowAccumSum();
	calcPolyDp();

	cout << polyDp[childNum][candyNum] << endl;

	return 0;
}

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

int main() {
    int n;cin >> n;
    int l[n];
    rep(i,n)cin >> l[i];
    int max = 0;
    int sum = 0;
    rep(i,n){
        if(l[i]>max)max = l[i];
        sum += l[i];
    }
    sum -= max;
    if(max < sum)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
ll h,w;
void walk(ll &i,ll &j){
  if(j%2==0){
    i++;
    if(i==h){
      i=h-1;
      j++;
    }
  }
  else{
    i--;
    if(i==-1){
      i=0;
      j++;
    }
  }
}
int main(){
  cin >> h >>w;
  vvl f(h,vl(w));
  rep(i,h)rep(j,w){cin >> f[i][j];f[i][j]%=2;}
  ll i=0,j=0;
  ll ans=0;
  vl a,b,c,d;
  while(j<w){
    if(f[i][j]==1){
      while(true){
        a.pb(i+1);b.pb(j+1);
        walk(i,j);
        if(j==w)break;
        c.pb(i+1);d.pb(j+1);
        if(f[i][j]==1)break;
      }
    }
    walk(i,j);
  }
  cout <<d.size() <<endl;
  rep(k,d.size()){
    cout << a[k] <<" " <<b[k] <<" " <<c[k] <<" " <<d[k] <<endl;
  }
}

Measured memory_bytes: 9560
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

vector<ll> cntP(60, 0), l(60, 0);
ll ans;

ll solve(ll n, ll x){
    if(x==1) return (n==0?1:0);
    else if(1<x && x<=l[n-1]+1) return solve(n-1, x-1);
    else if(x==l[n-1]+2) return cntP[n-1]+1;
    else if(l[n-1]+2<x && x<=l[n-1]*2+2) return cntP[n-1]+1+solve(n-1, x-l[n-1]-2);
    else return cntP[n-1]*2+1;
}

int main(){
    ll n, x; cin>>n>>x;
    cntP[0]=1, l[0]=1;
    for(int i=1; i<=n; i++){
        cntP[i]=cntP[i-1]*2+1;
        l[i]=l[i-1]*2+3;
        //cout << cntP[i] << " " << l[i] << endl;
    }

    cout << solve(n, x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>

using namespace std;

complex<double> Z[300];

int main(void)
{
    int N, ans, count;
    double X, Y;
    while(true)
    {
        cin >> N;
        if (!N) break;
        for (int i = 0; i < N; i++)
        {
            cin >> X >> Y;
            Z[i].real(X);
            Z[i].imag(Y);
        }
        ans = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                if (abs(Z[i] - Z[j]) >= 1.9999) continue;
                auto a = (Z[i] - Z[j]) / 2.;
                auto b = (Z[i] + Z[j]) / 2.;
                auto r = sqrt(1. - norm(a));
                a /= abs(a);
                a *= r * 1.i;
                complex<double> c[2] = {b + a, b - a};
                for (int k = 0; k < 2; k++)
                {
                    count = 2;
                    for (int l = 0; l < N; l++)
                    {
                        if (l == i || l == j) continue;
                        if (abs(c[k] - Z[l]) <= 1.) count++;
                    }
                    if (count > ans) ans = count;
                }
            }
        }
        cout << (ans ? ans : 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
# coding: utf-8
N = int(input())
A = []#value
for i in range(N):
    A.append(int(input()))
B = A[:]
B.sort()
one = B[-1]
two = B[-2]
for i in range(N):
    if A[i] == one:
        print(two)
    else:
        print(one)

Measured memory_bytes: 70104
#include<iostream>
using namespace std;
int N,A[2<<17];
long c[2<<17],ans;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		ans+=c[A[i]]++;
	}
	for(int i=0;i<N;i++)
	{
		cout<<ans-c[A[i]]+1<<endl;
	}
}


Measured memory_bytes: 3968
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,a[10],b[10],s,ss;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
//		printf("a=%d\n",a[i]);
	}	
	sort(a,a+10);
	
	for(i=0;i<10;i++){
	}

	for(i=0;i<10;i++){
		scanf("%d",&b[i]);
	}	
	sort(b,b+10);
	for(i=0;i<10;i++){
	}
	
	s=a[7]+a[8]+a[9];
	ss=b[7]+b[8]+b[9];
	printf("%d %d\n",s,ss);
	return 0;
}
	

Measured memory_bytes: 1040
n = int(input())
list = input().split()

for i in range(n):
    list[i] = int(list[i])
    i = i + 1

div = [0]*n

for i in range(n):
    while list[i] % 2 == 0:
        div[i] = div[i] + 1
        list[i] = list[i] / 2
    
    i = i + 1

k = 0
ans = div[0]

for k in range(n):
    if k == n-1:
        break
    
    elif ans > div[k + 1]:
        ans = div[k + 1]
        k = k + 1

print(ans)    

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

using ll = long long;

inline ll min(ll a, ll b) {
	return a < b ? a : b;
}

const int Max = 1e5 + 12;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1; ++i) {
		cout << i << ' ';
	}
	
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<typename T> T minimum(T head, T tail) { return std::min(head, tail); }
template<typename Head, typename... Tail> Head minimum(Head head, Tail... tail) {
  return std::min(head, minimum(tail...));
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  //std::ostringstream oss;
  //oss << "ABC" << N;
  //std::string ans = oss.str();

  ll A, B, C;
  std::cin >> A >> B >> C;

  ll ans = minimum(A + B, B + C, C + A);
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i=0;i<N;i++) {
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    
    int ans = 1;
    for (int i=0;i<N-1;i++) {
        if(d[i] != d[i+1]) {
            ans++;
        }
    }
    cout << ans << endl;
   }

 

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

auto factoring = [](i64 x){
    int sq = sqrt(x) + 1;
    vector<int> ret;
    if(x == 1){
        ret.emplace_back(1);
        return ret;
    }
    for(i64 i = 2; i < sq; ++i)
        while(x % i == 0){
            ret.emplace_back(i);
            x /= i;
        }
    if(x != 1)
        ret.emplace_back(x);
    return ret;
};


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;




signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    map<int,int> v;
    for(auto x : a){
        auto res = factoring(x);
        map<int,int> v2;
        for(auto y : res)
            ++v2[y];
        for(auto p : v2)
            chmax(v[p.first], p.second);
    }
    mint ans = 1;
    auto mpow = [](auto x, i64 y){
        auto z = x;
        decltype(x) val = y & 1 ? x : decltype(x)(1);
        while(z *= z, y >>= 1)
            if(y & 1)
                val *= z;
        return val;
    };

    for(auto p : v){
        ans *= mpow(mint(p.first), p.second);
    }
    mint cnt = 0;
    for(auto x : a){
        cnt += ans * mpow(mint(x), MOD - 2);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4148
#include <stdio.h>

int main(){
	int a,b,c,d,e,f,g,h,i,j;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		scanf("%d %d %d %d",&e,&f,&g,&h);
		i=a+b+c+d;
		j=e+f+g+h;
		if(i==j){
			printf("%d\n",i);
		}else if(i<j){
			printf("%d\n",j);
		}else if(i>j){
			printf("%d\n",i);
		
	}
	return 0;
}

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


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

    int n,k;
    cin>>n>>k;
    
    vector<int> a(n),dp(k+1,0);
    
    rep(i,n){
        cin>>a[i];
        dp[a[i]]=1;
    }
    
    rep(i,k+1)rep(j,n){
        if(i-a[j]<=0)break;
        
        if(dp[i-a[j]]==0)
            dp[i]=1;
    }
        
    if(dp[k]==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}


Measured memory_bytes: 640
import math

a, b, x = map(int,input().split())

if 2 *x <= a ** 2 * b:
    p1 = a * b ** 2
    p2 = 2 * x
else:
    p1 = 2 * (a ** 2 * b - x)
    p2 = a ** 3

sit = math.atan(p1 / p2)
print(math.degrees(sit))


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

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

using namespace std;

ui solve(void)
{
	ui P{}, Q{}, R{};
	cin >> P >> Q >> R;

	ui m = max(max(P, Q), R);
	return (P + Q + R) - m;
}

int main(void)
{
	ui ans = solve();
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
main(m,n,i,j,k,a){for(;a=1,scanf("%d",&m),m;puts(a?"OK":"NG")){int d[300],g[300][300]={0};scanf("%d",&n);for(i=1;i<=n;)scanf("%d",d+i++);for(i=0;i<=n;i++)for(j=1;j<=m;j++)k=i+j+d[i+j],(k=k<0?0:n+1<k?n+1:k),g[i][k]=1;for(k=0;k<n+2;k++)for(i=0;i<n+2;i++)for(j=0;j<n+2;j++)if(g[i][k]&&g[k][j])g[i][j]=1;for(i=0;i<=n;i++)if(g[0][i]&&!g[i][n+1])a=0;}return 0;}

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

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    int x;

    scanf("%d", &x);

    if (x >= 30) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;

}



Measured memory_bytes: 1648
#include<stdio.h>
#include<string.h>
#include<math.h>
int main ()
{
    long long n,m,x;
    scanf("%lld %lld",&n,&m);
    if(n>=m/2)
    {
        printf("%lld\n",m/2);
    }
    else if(n<m/2)
    {
        x=n;
        m=m-2*n;
        x=x+m/4;
        printf("%lld\n",x);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int a[3][3];
bool used[3][3];

int main(){
  using namespace std;
  REP(i, 3){
    REP(j, 3){
      cin>>a[i][j];
    }
  }
  int n;
  cin>>n;
  REP(k, n){
    int b;
    cin>>b;
    REP(i, 3){
      REP(j, 3){
        if(a[i][j] == b){
          used[i][j] = true;
        }
      }
    }
  }
  REP(i, 3){
    if(used[i][0] && used[i][1] && used[i][2]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  REP(j, 3){
    if(used[0][j] && used[1][j] && used[2][j]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(used[0][0] && used[1][1] && used[2][2]){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(used[2][0] && used[1][1] && used[0][2]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;     
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
const int mod = 1e9+7, N = 200005;
using namespace std;
ll  n, m, k;
ll a[N], b[N];
int main(){
	ll i, j=0;
	cin >> n >> m >> k;
	for(i=1;i<=n;i++){
		cin >> a[i];
		a[i] += a[i-1];
	}for(i=1;i<=m;i++){
		cin >> b[i];
		b[i] += b[i-1];
	}

	ll ans = 0;
	for(i=0;i<=n;i++){
		if(a[i] > k)break;
		int l=-1, r=m+1;
		while(l+1 < r){
			int mid = (l+r)/2;
			if(b[mid]+a[i] <= k){
				l = mid;
			}else {
				r = mid;
			}
		}
		ans = max(ans, i + l);
	}cout << ans;
}


Measured memory_bytes: 6716
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;

int main()
{
    ll x;
    cin>>x;
    if(x==0)
        cout<<"1"<<endl;
    else
        cout<<"0"<<endl;
}


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

void rec(int depth, vector<bool> &used, int sum, vector<int> &sums, const vector<int> &perm,
         const int &l, const int &M, const vector<int> &k, const vector<bool> &canZero){
  if(depth == M){
    sums.push_back(sum); return;
  }

  for(int i=0;i<M;i++){
    if(not used[i]){
      if(perm[i]==0 and not canZero[l+depth]) continue;
      used[i] = true;
      rec(depth+1, used, sum + k[l+depth]*perm[i], sums, perm, l, M, k, canZero);
      used[i] = false;
    }
  }
}

vector< pair<int, vector<int>> > calcPossibleSums(int l, int M, vector<int> k, vector<bool> canZero){
  vector< pair<int, vector<int>> > res;
  for(int S=0;S<(1<<10);S++){
    if(__builtin_popcount(S) != M) continue;
    vector<int> perm;
    for(int i=0;i<10;i++){
      if( S & (1<<i) ) perm.push_back(i);
    }
    vector<bool> used(M, false);
    vector<int> sums;
    rec(0, used, 0, sums, perm, l, M, k, canZero);
    /*
    do{
      int sum = 0;
      bool leading_zero = false;
      for(int i=0;i<M;i++){
        sum += k[l+i] * perm[i];
        if(not canZero[l+i] and perm[i]==0) leading_zero = true;
      }
      if(not leading_zero) sums.push_back(sum);
    }while( next_permutation(perm.begin(), perm.end()) );
    */

    sort(sums.begin(), sums.end());
    res.push_back( make_pair(S, sums) );
  }
  return res;
}

int main(){
  int n;
  while(cin >> n){
    if(n == 0) break;

    string s;
    map<char, int> id;
    vector<int> k(10, 0);
    vector<bool> canZero(10, true);
    for(int i=0;i<n;i++){
      cin >> s;
      int x = 1;
      for(int j=s.size()-1;j>=0;j--){
        if(id.count(s[j]) == 0) id[s[j]] = id.size()-1;
        k[id[s[j]]] += (i==n-1) ? -x : x;
        x *= 10;
      }
      if(s.size()>1) canZero[id[s[0]]] = false;
    }

    int M = id.size();
    if(M==1){
      cout << 0 << endl; continue;
    }

    int l_len = M/2, r_len = M - l_len;
    auto l_sums = calcPossibleSums(0, l_len, k, canZero);
    auto r_sums = calcPossibleSums(l_len, r_len, k, canZero);

    int ans = 0;
    for(auto& l : l_sums){
      for(auto& r : r_sums){
        if( l.first & r.first ) continue;
        for(int x : l.second){
          int num = upper_bound(r.second.begin(), r.second.end(), -x)
                     - lower_bound(r.second.begin(), r.second.end(), -x);
          ans += num;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define ff first
#define ss second
int main(){
	ll n; scanf("%lld",&n);
	ll a; scanf("%lld",&a);
	ll mx=a;
	vector<ll> x(n);
	for(int i=0;i<n;++i){
		scanf("%lld",&x[i]);
		mx=max(mx,x[i]);
	}
	mx*=n;
	ll dp[n+1][n+1][mx+1];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=n;++i){
		for(int k=0;k<=n;++k){
			for(int s=0;s<=mx;++s){
				if(i==0 and k==0 and s==0) dp[i][k][s]=1;
				else if(i>=1 and s<x[i-1]){
					dp[i][k][s]=dp[i-1][k][s];
				}
				else if(i>=1 and k>=1 and s>=x[i-1]){
					dp[i][k][s]=dp[i-1][k][s]+dp[i-1][k-1][s-x[i-1]];
				}
				else dp[i][k][s]=0;
			}
		}
	}
	ll ans=0;
	for(int i=a;i<=mx;i+=a){
		if(i/a<=n) ans+=dp[n][i/a][i];
	}
	printf("%lld\n",ans);
	return 0;
}


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

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

	int flag = 0;

	
	rep(i,9){
		if (N % i == 0){
			if(N / i < 10){
				flag = 1;
			}
		}
	}

	if(flag == 1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
  
int main(void){
  int i,n = 0;
  char w[11], t[1001];
  
  scanf("%s", w);
  
  do{
    scanf("%s",t);
    if(!strcmp(t,"END_OF_TEXT")) break;
      for(i=0;t[i]!='\0';i++)
        if(t[i]<91) t[i] += 32;
    if( !strcmp(w,t) ) n++;
  }while(1);
  
  printf("%d\n",n);
  
  return 0;
}


Measured memory_bytes: 2052
import math

def main():
    num, sum_money = map(int, input().split())
    flg = 0
    for i in range(num + 1):
        for j in range(num - i + 1):
            nokori = sum_money - i * 10000 - j * 5000
            k = nokori // 1000
            if i + j + k == num:
                print(i, j, k)
                flg = 1
                break
        if flg:
            break
    else:
        print(-1, -1,-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;
int search(int A[],int key,int n){
  A[n]=key;
  int i=0;
  while(A[i]!=key)i++;
  return i!=n;
}

int main(void){
  int n,q;
  cin>>n;
  int S[n];
  for(int i=0;i<n;++i){
    cin>>S[i];
  }

  cin>>q;
  
  int count=0;
  int key;
  for(int i=0;i<q;i++){
    cin>>key;
    if(search(S,key,n))count++;
  }

  cout<<count<<endl;

  return 0;
}


Measured memory_bytes: 3108
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc078_a.cpp
 * time   : Wed Apr 29 22:39:04 2020
 * quest  : A - Hex
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char a, b;
  cin >> a >> b;
  cout << ((a == b) ? '=' : (a > b) ? '>' : '<') << "\n";
  return 0;
}


Measured memory_bytes: 256
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        N,A,B=map(int,input().split())
        X=list(map(int,input().split()))
        if A>=B:
            return (N-1)*B
        else:
            ans=0
            merit=math.ceil(B/A)
            for i in range(N-1):
                d=X[i+1]-X[i]
                if d>=merit:
                    ans+=B
                else:
                    ans+=A*d
            return ans
    print(main())


    
resolve()

Measured memory_bytes: 62832
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    String t=sc.next();
    String a="";
    for(int i=0;i<n;i++){
      a+=s.substring(i,i+1);
      a+=t.substring(i,i+1);
    }
    System.out.println(a);
  }
}


Measured memory_bytes: 22612
#include <stdio.h>

int main() {
    int n,firstNumber,thisNumber;
    int min,max;
    long sum=0;
    
    scanf("%d %d", &n,&firstNumber);
    min = firstNumber;
    max = firstNumber;
    
    while (--n > 0){
        scanf("%d",&thisNumber);
        if(thisNumber < min)
            min = thisNumber;
        if(thisNumber > max)
            max = thisNumber;
        sum += thisNumber;
    }
    
    sum += firstNumber;
    
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2128
def visit(u):
  global t
  flag[u] = 1
  t += 1
  s[u] = t
  for v in range(n):
    if M[u][v]==0:
      continue
    if flag[v]==0:
      visit(v)
  flag[u] = 2
  t += 1
  e[u] = t


def dfs():
  for u in range(n):
    if flag[u]==0:
      visit(u)
  for u in range(n):
    print '%d %d %d' % (u+1, s[u], e[u])


n = input()
t = 0
flag = [0 for row in range(n)]
s = [0 for row in range(n)]
e = [0 for row in range(n)]
M = [[0 for col in range(n)] for row in range(n)]
for i in range(n):
  str = map(int, raw_input().split())
  u = str[0]
  k = str[1]
  a = str[2:]
  u -= 1
  for v in a:
    M[u][v-1] = 1

dfs()

Measured memory_bytes: 6508
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int n;
int head[maxn], to[maxn*2], nxt[maxn*2], tot;

inline void add_edge(int u, int v) {
    ++tot; to[tot]=v; nxt[tot]=head[u]; head[u]=tot;
    ++tot; to[tot]=u; nxt[tot]=head[v]; head[v]=tot;
}

int cnt[maxn], vis[maxn];
int son[maxn], c[maxn], sz[maxn];
ll ans[maxn];

void dfs0(int u, int f) {
    sz[u]=1;
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f) continue;
        dfs0(v,u); sz[u]+=sz[v];
        if(sz[v]>sz[son[u]]) son[u]=v;
    }
}

void dfs1(int u, int f, int ff) {
    if(!vis[c[u]]) cnt[c[u]]+=ff?sz[u]:-sz[u];
    vis[c[u]]++;
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f) continue;
        dfs1(v,u,ff);
    }
    vis[c[u]]--;
}

void dfs(int u, int f, int ff) {
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f||v==son[u]) continue;
        dfs(v,u,0);
    }
    if(son[u]) dfs(son[u],u,1);
    vis[c[u]]++;
    cnt[c[u]]=sz[u];
    for(int i=head[u]; i; i=nxt[i]) {
        int v=to[i]; if(v==f||v==son[u]) continue;
        dfs1(v,u,1);
    }
    if(f) {
        ll b=sz[u]-cnt[c[f]];
        ans[c[f]]-=b+b*(b-1)/2;
    }
    if(!ff) {
        for(int i=head[u]; i; i=nxt[i]) {
            int v=to[i]; if(v==f) continue;
            dfs1(v,u,0);
        }
        cnt[c[u]]=0;
    }
    vis[c[u]]--;
}

int main() {
    n=read();
    for(int i=1; i<=n; ++i) c[i]=read();
    for(int i=1; i<n; ++i) add_edge(read(),read());
    dfs0(1,0); dfs(1,0,1);
    for(int i=1; i<=n; ++i) {
        ll b=n-cnt[i];
        ans[i]-=b+b*(b-1)/2;
    }
    ll total=n+ll(n)*(n-1)/2;
    for(int i=1; i<=n; ++i) printf("%lld\n", total+ans[i]);
}

Measured memory_bytes: 28748
n=int(input())
a=list(map(int,input().split()))
x=[i for i in range(1,n+1)]
for i in range(n):
    x[i]=a[i]-x[i]
x.sort()
b=x[n//2]
suma=0
for i in range(n):
    suma+=abs(x[i]-b)
print(suma)

Measured memory_bytes: 26020
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll h; cin >> h;
    ll monster_count = 1;
    ll attack_count = 0;
    while (h) {
        attack_count += monster_count;
        h /= 2;
        monster_count *= 2;
    }
    cout << attack_count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=1e5+5;
const double eps=1e-4;
typedef long long ll;
typedef pair<int,int> pii;
int a[N],b[N];
int sum[N];
char s[3];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a,b;
    scanf("%d%d",&a,&b);
    n-=a,m-=b;
    int ans=n*m;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 2e9;
const int N = 2e5 + 3;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
 
const double PI = acos(-1);
 
long long dist(int x1, int y1, int x2, int y2) {
    return 0ll + abs(x1 - x2) + abs(y1 - y2);
}
 
void solve() {
    int lux = INF, luy = 0;
    int rux = 0, ruy = 0;
    int rbx = 0, rby = INF;
    int lbx = INF, lby = INF;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (dist(x, y, 0, 0) < dist(lbx, lby, 0, 0))
            lbx = x, lby = y;
        if (dist(x, y, 0, INF) < dist(lux, luy, 0, INF))
            lux = x, luy = y;
        if (dist(x, y, INF, INF) < dist(rux, ruy, INF, INF))
            rux = x, ruy = y;
        if (dist(x, y, INF, 0) < dist(rbx, rby, INF, 0))
            rbx = x, rby = y;
    }
    vector<pair<int, int>> vec;
    vec.push_back({lux, luy});
    vec.push_back({rux, ruy});
    vec.push_back({rbx, rby});
    vec.push_back({lbx, lby});
    auto ans = 0ll;
    for (auto x : vec) {
        for (auto y : vec) {
            int ax = x.first, ay = x.second;
            int bx = y.first, by = y.second;
            ans = max(ans, dist(ax, ay, bx, by));
        }
    }
    cout << ans;
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
  cin>>s;
  int na=0,nb=0;
  (s[0]=='A')?na++:nb++;
  (s[1]=='A')?na++:nb++;
  (s[2]=='A')?na++:nb++;
  if(na>0&&nb>0)cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

            int[] counts = new int['z' - 'a' + 1];
            for (int i = 0; i < w.length(); i++) {
                counts[w.charAt(i) - 'a']++;
            }

            for (int i = 0; i < counts.length; i++) {
                if (counts[i] % 2 != 0) {
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 26984
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first    
#define se second
void solve()
{
    ll n,i,j,k;
    cin>>n;
    vector<ll> a(n+1);
    ll b[n];
    for(i=0;i<n+1;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    ll ans=0;
    for(i=0;i<n;i++)
    {
        // cout<<b[i]<<"\n";
        if(a[i]<=b[i])
        {
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            // cout<<"tt"<<"\n";
        }
        else
        {
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
            // cout<<ans<<"\n";
        }
        // cout<<b[i]<<"\n";;
        if(a[i+1]<=b[i])
        {
            ans+=a[i+1];
            b[i]-=a[i+1];
            a[i+1]=0;
            // cout<<ans<<"\n";
        }
        else
        {
            ans+=b[i];
            a[i+1]-=b[i];
            b[i]=0;
            // cout<<b[i]<<"\n";
        }
        // cout<<ans<<"\n";
    }
    cout<<ans;
}
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif  
    clock_t tStart = clock();
    ll t,k;
    // cin>>t;
    // while(t--)
        solve();
    // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}       

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

string copy(string s){
	return s;
}

int main(){
	int n;cin>>n;
	string s;cin>>s;
	string t = copy(s);
	string l = "";
	string r = "";

	int i = 0;
	while(1){
		if(t[i] == '(' && t[i + 1] == ')'){
			t.erase(t.begin() +i,t.begin() +i + 2);
			if(t.size() == 0){
				break;
			}
			i = 0;
		}
		else if(i == t.size() - 1){
			break;
		}
		else{
			i++;
		}
	}
	for(int i = 0; i < t.size(); i++) {
		if (t[t.size() - 1 - i] == ')'){
			l.pb('(');
		}
		else if(t[t.size() - i - 1] == '('){
			r.pb(')');
		}
	}

	cout << l;
	cout << s;
	cout << r << endl;
	return 0;
}

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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    int w, h, x, y, s, t;
    cin >> w >> h;
    vector<vector<bool> > persimmon(w, vector<bool>(h, false));
    for(int i = 0; i < n; i++){
      cin >> x >> y;
      persimmon[x - 1][y - 1] = true;
    }
    cin >> s >> t;
    
    int ans = 0;
    for(int i = 0; i < w; i++){
      for(int j = 0; j < h; j++){
        int count = 0;
        for(int k = i; k < w && k < i + s; k++){
          for(int l = j; l < h && l < j + t; l++){
            if(persimmon[k][l]){
              ++count;
            }
          }
        }
        ans = ans > count ? ans : count;
      }
    }
    
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2952