akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N, X;
    in2(N, X);

    vi L(N);
    rep(i, N) in(L[i]);

    vi D(N + 1);
    rep(i, N) D[i + 1] = D[i] + L[i];

    int count = 0;
    rep(i, D.size())
    {
        if (D[i] <= X) count++;
    }

    outl(count);

    return 0;
}


Measured memory_bytes: 3628
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = list(c.keys())
q = 1
for i in range(1,len(d)-1):
	if d[i+1] - d[i] == 1 and d[i] - d[i-1] == 1:
		s = c[d[i-1]] + c[d[i]] + c[d[i+1]]
		q = max(q,s)
	if i == 1:
		if d[i] - d[i-1] == 1:
			s = c[d[i-1]] + c[d[i]]
			q = max(q, s)
	if d[i+1] - d[i] == 1:
		s = c[d[i+1]] - c[d[i]]
		q = max(q, s)
if len(d) == 1:
	q = c[d[0]]
if len(d) == 2:
	if d[1] - d[0] == 1:
		q = c[d[1]] + c[d[0]]
	else:
		q = max(1, c[d[1]], c[d[0]])
print (q)

Measured memory_bytes: 14564
N = int(input())
s = list(map(int,input().split()))
s.sort()
alice = 0
bob = 0
for n in range((N+1)//2):
    alice += s[-1]
    del s[-1]
    try:
        bob += s[-1]
        del s[-1]
    except IndexError:
        break
print(alice-bob)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int r, c, n;
struct point
{
	int id;
	int val;
};
vector <point> v[4];
bool check (int x, int y)
{
	if (x == 0 || x == r || y == 0 || y == c) return true;
	return false;
}
void push (int id, int x, int y)
{
	if (x == 0) v[0].pb({id, y});
	else if (y == c) v[1].pb({id, x});
	else if (x == r) v[2].pb({id, y});
	else if (y == 0) v[3].pb({id, x});
}
bool cmp1 (point a, point b)
{
	return a.val < b.val;
}
bool cmp2 (point a, point b)
{
	return a.val > b.val;
}
int main()
{
	ios::sync_with_stdio (false);
	cin.tie(0); cout.tie(0);
	cin >> r >> c >> n;
	int x1, x2, y1, y2;
	for (int i=1; i<=n; i++)
	{
    	cin >> x1 >> y1 >> x2 >> y2;
    	if (check (x1, y1) && check (x2, y2))
    	push (i, x1, y1), push (i, x2, y2);
	}
	sort (v[0].begin(), v[0].end(), cmp1);
	sort (v[1].begin(), v[1].end(), cmp1);
	sort (v[2].begin(), v[2].end(), cmp2);
	sort (v[3].begin(), v[3].end(), cmp2);
	stack <int> s;
	for (int j=0; j<4; j++)
		for (int i=0; i<v[j].size(); i++)
		{
    		if (s.size() == 0) 
			{
				s.push(v[j][i].id);
				continue;
			}
    		if (s.top() == v[j][i].id) s.pop();
    		else s.push (v[j][i].id);
		}

	cout << (s.empty() ? "YES" : "NO" ) << endl;
	return 0;
}

Measured memory_bytes: 2520
def segfunc(x,y):
  return x+y

class SegmentTree(object):
    def __init__(self, A, dot, unit):
        n = 1 << (len(A) - 1).bit_length()
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._tree = tree
        self._dot = dot
        self._unit = unit

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1])

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r): #これで[l,r)から取り出す。
        l += self._n
        r += self._n
        l_val = r_val = self._unit
        while l < r:
            if l & 1:
                l_val = self._dot(l_val, self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = self._dot(self._tree[r], r_val)
            l >>= 1
            r >>= 1
        return self._dot(l_val, r_val)


N,Q = map(int,input().split())
A = list(map(int,input().split()))
Tree = SegmentTree(A, segfunc, 0)
for _ in range(Q):
  query, a,b = map(int,input().split())
  if query == 0:
    Tree.add(a,b)
  else:
    print(Tree.sum(a,b))


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

 

int main() {
    string S;
    cin >> S;
    string T = "keyence";
    int samebegin = 0;
    int sameend = 0;
    rep(i,T.size()) {
        if (S.at(i) != T.at(i)) break;
        else ++samebegin;
    }
    rep(i,T.size()) {
        if (S.at(S.size() - 1 - i) != T.at(T.size() - 1 - i)) break;
        else ++sameend;
    }
    if (samebegin + sameend >= T.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3496
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var h = Array.ConvertAll(line, int.Parse);
        var ng = new bool[n];
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]) - 1;
            if (h[a] == h[b]) { ng[a] = true; ng[b] = true; }
            else if (h[a] > h[b]) ng[b] = true;
            else ng[a] = true;
        }
        Console.WriteLine(ng.Count(x => x == false));
    }
}


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

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

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

    int r = 0, b = 0;
    rep(i, n) {
        if (s.at(i) == 'R')
            r++;
        else
            b++;
    }

    cout << ((r > b) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	int a,b,c,d,e,f;
	double x,y;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
		x = (double)(e*c-b*f)/(e*a-b*d);
		y = (double) (c-a*x)/b;
		if(0.00049>x && x> -0.00049) x=0;
		if(0.00049>y && y> -0.00049) y=0;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1064
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int N;
ll t[MAX_N],a[MAX_N],x[MAX_N];
bool is_determined[MAX_N];

int main(){
  cin >> N;
  rep(i,N) scanf("%lld",t+i);
  rep(i,N) scanf("%lld",a+i);
  x[0] = t[0]; x[N-1] = a[N-1];
  if(N==1){
    if(t[0]==a[0]) cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
  }
  fill(is_determined,is_determined+N,false);
  is_determined[0] = true; is_determined[N-1] = true;
  REP(i,1,N){
    if(t[i]!=t[i-1]){
      if(is_determined[i]){
        if(x[i]!=t[i]){
          cout << "0" << endl;
          return 0;
        }
      }
      is_determined[i] = true;
      x[i] = t[i];
    }else{
      if(is_determined[i]){
        if(!(x[i]<=t[i])){
          cout << "0" << endl;
          return 0;
        }
      }
    }
  }
  RREP(i,N-2,0){
    if(a[i]!=a[i+1]){
      if(is_determined[i]){
        if(x[i]!=a[i]){
          cout << "0" << endl;
          return 0;
        }
      }
      is_determined[i] = true;
      x[i] = a[i];
    }else{
      if(is_determined[i]){
        if(!(x[i]<=a[i])){
          cout << "0" << endl;
          return 0;
        }
      }
    }
  }
  ll ans = 1LL;
  rep(i,N){
    if(is_determined[i]) continue;
    (ans *= min(a[i],t[i])) %= lmod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (int)(v).size()
#define int long long
#define mod 1000000007

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n, m; cin >> n>> m;
        priority_queue<int> pq;
        lp(i, n) { int a; cin >> a; pq.push(a); }
        while ( m-- ) {
                int x = pq.top();
                pq.pop();
                x /= 2;
                pq.push(x);
        }
        int ans = 0;
        while ( pq.size() ) {
                ans += pq.top();
                pq.pop();
        }
        cout << ans;
return 0;
}



Measured memory_bytes: 1400
def judge(s1, s2)
    if s1.size != s2.size
        return false
    end
    s1.size.times do |i|
        if s1[i] != ?? && s1[i] != s2[i]
            return false
        end
    end
    return true
end
 
s,t=$<.map(&:chomp)
ans = -1
s.size.times do |i|
    if judge(s[i, t.size], t)
        tmp = String.new(s)
        tmp[i, t.size] = t
        s.size.times do |j|
            if tmp[j] == ??
                tmp[j] = ?a
            end
        end
        if ans == -1
            ans = tmp
        else
            ans = [ans, tmp].min
        end
    end
end
puts (ans == -1 ? "UNRESTORABLE" : ans)

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

int main(){
    int H,W,i,j;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(j=0;j<H;j++){
            for(i=0;i<W;i++){
                if((i+j) % 2 == 0){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;    
    }
}


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

using namespace std;

int main()
{
  unsigned long n,a,b,result;
  cin>>n>>a>>b;
 
  if((n%(a+b)>=a))
  	result+=((n/(a+b))*a+a);
  else
    result+=((n/(a+b))*a+n%(a+b));
  cout<<result<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
#define MOD 1000000007
using namespace std;
int n;
long long num[100005],sum[100005];
int main()
{
    int ans=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",num+i);
    sort(num+1,num+n+1);
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]+num[i];
    while(--n)
    {
        if(sum[n]*2>=num[n+1])
            ans++;
        else
            break;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

typedef long long ll;

int main() {
    ll c, bcount=0, sum=0;
    while ((c = getchar()) != EOF && c != '\n') {
        if (bcount && c == 'W') sum += bcount;
        else if (c == 'B') bcount++;
    }
    printf("%lld\n",sum);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        long[] sums = new long[n+1];
        for(int i=0; i<=n; i++) {
            sums[i] = 0;
        }
        for(int i=0; i<n; i++) {
            sums[a[i]]++;
        }
        
        long total = 0;
        for(int i=1; i<=n; i++) {
            total += sums[i] * (sums[i]-1) / 2;
        }
        
        for(int i=0; i<n; i++) {
            long ans = total - (sums[a[i]] * (sums[a[i]]-1) / 2) + ((sums[a[i]]-1) * (sums[a[i]]-2) / 2);
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 92732
#include<stdio.h>
int p[100010]={0};
int d[100010]={0};
int Find(int a,int b){
  int r,n;
  for(r=++a;p[r];r=p[r]);
  for(;n=p[a];a=n)p[a]=r;
  for(r=++b;p[r];r=p[r]);
  for(;n=p[b];b=n)p[b]=r;
  return a-b?1:0;
}
void Union(int a,int b){
  int r,n;
  if(Find(a,b)){
    for(++a;p[a];a=p[a]);
    for(++b;p[b];b=p[b]);
    d[a]<d[b]?(p[a]=b):(p[b]=a);
    if(d[a]==d[b])d[a]++;
  }
}
int main(){
  int n,m,i,c=0;
  scanf("%d %d",&n,&m);
  while(m--){
    scanf("%d %d %*d",&i,&c);
    Union(i,c);
  }
  for(i=c=0;i<n;i++){//printf("%d\n",p[i+2]);
    if(p[i+2]==0)c++;
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int A, B; cin >> A >> B;

	if (A > 12) cout << B << endl;
	else if (A >= 6) cout << B / 2 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    ll x, k, d; cin >> x >> k >> d;
    ll cnt = abs(x) / d;
    if(k <= cnt) {
        ll ans = abs(x) - d * k;
        cout << ans << endl;
    }else{
        ll ans = abs(x) - d * cnt;
        k -= cnt;
        if(k % 2 == 1){
            ans -= d;
            cout << abs(ans) << endl;
        }else {
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

int main() {
    uint64_t h; cin >> h;

    long long ans = 1;
    while (h > 0) {
        h = h/ 2;
        ans *= 2;
    }
    cout << (ans - 1)<< endl;
}


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

int main (void)
{
	double x[100],y[100],dis1,dis2,dis3,dis4,max;
	int n,i;
	
	max = 0;
	dis1 = 0;
	dis2 = 0;
	dis3 = 0;
	dis4 = 0;
	scanf("%d",&n);
	
	for(i = 0 ; i < n ; i++)
	{
		scanf("%lf",&x[i]);
	}
	
	for(i = 0 ; i < n ; i++)
	{
		scanf("%lf",&y[i]);
	}
	
	for(i = 0 ; i < n ; i++)
	{
		dis1 += abs(x[i] - y[i]);
		dis2 += pow(abs(x[i] - y[i]),2);
		dis3 += pow(abs(x[i] - y[i]),3);
		dis4 = abs(x[i] - y[i]);
		
		if(max < dis4)
		{
			max = dis4;
		}
	}
	
	dis2 = sqrt(dis2);
	dis3 = pow(dis3,(double)1/3);
	
	printf("%lf\n%lf\n%lf\n%lf\n",dis1,dis2,dis3,max);
	
	return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int co[220000];
bool used[110000];
int use[110000];
vector<P> path[200005];

void check(int a){
	int b,c;
	if(used[a])return;
	used[a]=true;
	for(auto node:path[a]){
		b=node.second;
		if(co[b])use[co[b]]=a;
	}
	c=1;
	for(auto node:path[a]){
		b=node.second;
		if(co[b])continue;
		for(;;c++){
			if(use[c]==a)continue;
			co[b]=c;
			c++;
			break;
		}
	}
	for(auto node:path[a]){
		check(node.first);
	}
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	memset(use,-1,sizeof(use));
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(make_pair(b,i));
		path[b].push_back(make_pair(a,i));
	}
	check(0);
	a=0;
	for(i=0;i<n;i++){
		a=max(a,(int)path[i].size());
	}
	cout<<a<<endl;
	array_show(co,n-1,'\n');
}

Measured memory_bytes: 9728
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint ans=0;
  int minus=0;
  lint amin=1e9+1; 
  REP(i,N){
    lint A;
    cin>>A;
    if(A<0)minus++;
    ans+=max(A,-A);
    amin=min(amin,max(A,-A));
  }
  cout<<ans-(lint)2*(minus%2==0?0:amin)<<endl;
  return 0;
}


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

using namespace std;

int main(void)
{
    int m1,d1,m2,d2;
    cin >>m1 >>d1 >>m2 >>d2;

    if(m1 != m2){
        printf("1\n");
    }else{
        printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if((n|m)==0){
				return;
			}
			int[] t = new int[n+m+1];
			t[0] = 0;
			for(int i=1;i<=n;i++){
				t[i] = stdIn.nextInt();
			}
			for(int i=n+1;i<=n+m;i++){
				t[i] = stdIn.nextInt();
			}
			Arrays.sort(t);
			int max = 0;
			for(int i=0;i<n+m;i++){
				max = Math.max(max, t[i+1]-t[i]);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

vector<ll> positions;
ll n;

ll calc(ll x) {
  ll r = 0;
  for (ll i = 0; i < n; i++) {
    ll p = positions[i];
    r += (x - p) * (x - p);
  }
  return r;
}

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

  positions = vector<ll>(n);
  for (ll i = 0; i < n; i++) {
    ll v;
    scanf("%lld", &v);
    positions[i] = v;
  }

  ll ans = 2 << 29;

  for (ll i = 0; i <= 100; i++) {
    ans = min(ans, calc(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

#define X real()
#define Y imag()
typedef double D;
typedef complex<double>P;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    P p1(x1,y1), p2(x2,y2);
    printf("%.9f\n", sqrt(norm(p2-p1)));

    return 0;
}

Measured memory_bytes: 1256
#include<stdio.h>

int main() {
    int n, x[100];
    int i, j, p, min1 = 0, min2;
    int tmp;

    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }

    for(i = 0; i < n; i++) {
        for(j = i + 1; j < n; j++) {
            if(x[i] > x[j]) {
                tmp = x[i];
                x[i] = x[j];
                x[j] = tmp;
            }
        }
    }

    for(i = x[0]; i <= x[n-1]; i++) {
        min1 = 0;
        for(j = 0; j < n; j++) {
            min1 = min1 + ((x[j] - i) * (x[j] - i));
        }
        if(i == x[0]) {
            min2 = min1;
        } else if(min1 < min2) {
            min2 = min1;
        }
    }
    printf("%d", min2);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] heap = new int[n];
        for(int i = 0; i < n; i++) {
            heap[i] = input.nextInt();
        }
        buildMaxHeap(heap);
        for(int i = 0; i < n; i++) {
            System.out.print(" " + heap[i]);
        }
        System.out.println();
    }

    public static void buildMaxHeap(int[] heap) { // 自底向上建堆
        for(int i = heap.length/2; i >= 1;  i--) {
            maxHeapify(heap, i);
        }
    }

    public static void maxHeapify(int[] heap, int i) {
        int left = 2*i;
        int right = 2*i + 1;
        int largest;
        if(left <= heap.length && heap[left-1] > heap[i-1]) {
            largest = left;
        } else {
            largest = i;
        }
        if(right <= heap.length && heap[right-1] > heap[largest-1]) {
            largest = right;
        }

        if(largest != i) {// i的子节点值更大时
            int temp = heap[i-1];
            heap[i-1] = heap[largest-1];
            heap[largest-1] = temp;
            maxHeapify(heap, largest);
        }
    }
}



Measured memory_bytes: 167624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (b % a == 0)cout << a + b << endl;
    else cout << b - a << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int a[3][3];
	rep(i, 3) rep(j, 3) cin >> a[i][j];
	int q;
	cin >> q;
	while(q--){
		int x;
		cin >> x;
		rep(i, 3) rep(j, 3) if(a[i][j] == x) a[i][j] = -1;
	}
	rep(i, 3){
		int sum = 0;
		int xsum = 0;
		rep(j, 3){
			sum += a[i][j];
			xsum += a[j][i];
		}
		if(sum == -3 || xsum == -3) {
			cout << "Yes" << endl;
			return;
		}
	}
	if(a[0][0] == a[1][1] && a[1][1] == a[2][2] && a[2][2] == -1){
		cout << "Yes" << endl;
		return;
	}
	if(a[0][2] == a[1][1] && a[1][1] == a[2][0] && a[2][0] == -1){
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
k = gets.chomp.to_i
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

puts a[k-1]

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define first F
#define second S

int main(){
    FAST
    int n; cin >> n;
    int need = 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a == need){
            ans++;
            need++;
        }
    }
    if(ans == 0)cout << -1;
    else cout << n - ans;
}


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

int main(){
    long long  N;
    cin>>N;
    long long  min=N+1,mini=1,minj=N;
    double n = sqrt(N);
    for(long long i=1;i<=n;i++){
        if(N%i==0){
            long long j = N/i;
            if(i+j<min){
                min = i+j;
                mini = i;
                minj = j;
            }
        }
    }
    
    cout<<(mini-1)+(minj-1)<<endl;
}


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

#define ll long long

using namespace std;

int main(void) {
	while (1) {
		ll n, r;
		cin >> n >> r;
		if (n == 0 && r == 0)break;
		vector<ll> a(n);
		for (int i = n; i > 0; i--) {
			a[n - i] = i;
		}
		for (int i = 0; i < r; i++) {
			ll pos, num;
			cin >> pos >> num;
			vector<ll> s(num);
			for (int j = 0; j < num; j++) {
				s[j] = a[pos - 1 + j];
			}
			a.erase(a.begin() + pos - 1, a.begin() + pos - 1 + num);
			/*for (auto i = a.begin(); i != a.end();i++) {
				cout << *i;
			}
			cout << endl << "!!!" << endl;*/
			for (int i = 0; i < a.size(); i++) {
				s.push_back(a[i]);
			}
			a.resize(n);
			copy(s.begin(), s.end(), a.begin());
			/*for (auto i = a.begin(); i != a.end(); i++) {
				cout << *i;
			}
			cout << endl << "???" << endl;*/
		}
		cout << a[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 3056
s = input()
n = len(s)
alp = [False] * 26
for i in range(n):
    num = ord(s[i]) - ord('a')
    alp[num] = True
ok = 0
for i in range(26):
    if alp[i]:
        continue
    print(chr(ord('a') + i))
    ok = 1
    break
if ok == 0:
    print("None")


Measured memory_bytes: 3188
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


N = INT()
# print(divisor(N))
ans = INF
for d in divisor(N):
    r = N // d
    ans = min(ans, r+d-2)
print(ans)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int k, a, b;
    cin >> k >> a >> b;
    FOR(i, a, b+1) if(i % k == 0) {
        cout << "OK" << en; 
        return;
    }
    cout << "NG" << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N; cin>>N;
  int non=0;
  for(int i=0; i<N; i++){
    int a; cin>>a;
    if(a!=i+1){
      non++;
    }
  }
  if(non<=2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

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

    int acc = 0;
    for (int i=1;i<n-1;i++){
        if (s[i-1] == 'A' && s[i] == 'B' && s[i+1] == 'C'){
            acc++;
        }
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 3e5 + 5;
const double eps = 1e-9;
using namespace std;
char tmp[MAXN];
int sum[MAXN];

int main()
{
    scanf("%s", tmp);
    int n = strlen(tmp);
    int lo = 0, hi = n;
    while (lo <= hi)
    {
        int mid = (lo + hi) >> 1;
        int cur = 0, flag = 1;
        memset(sum, 0, sizeof sum);
        for (int i = 0; i < n; i++)
        {
            cur += sum[i];
            if (tmp[i] == '1' && cur % 2 == 0)
            {
                if (i + mid > n && i < mid )
                {
                    flag = 0;
                    hi = mid - 1;
                    break;
                }
                sum[i]++, cur++;
                sum[i + mid]--;
            }
            else if (tmp[i] == '1' && cur % 2 == 1) {}
            else if (tmp[i] == '0' && cur % 2 == 0) {}
            else if (tmp[i] == '0' && cur % 2 == 1)
            {
                if (i + mid > n && i < mid)
                {
                    flag = 0;
                    hi = mid - 1;
                    break;
                }
                sum[i]++, cur++;
                sum[i + mid]--;
            }
        }
        if (flag) lo = mid + 1;
    }
    printf("%d\n", lo - 1);
    return 0;
}


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

using namespace std;

using ll = long long;

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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    pair<int, int> max_v(0, 1);

    for (int y1 = 0; 100 * a * y1 <= f; ++y1) {
        int res1 = f - 100 * a * y1;
        for (int y2 = 0; 100 * b * y2 <= res1; ++y2) {
            int res2 = res1 - 100 * b * y2;
            for (int x1 = 0; c * x1 <= res2; ++x1) {
                int res3 = res2 - c * x1;
                for (int x2 = 0; d * x2 <= res3; ++x2) {
                    int x = c * x1 + d * x2;
                    int y = y1 * 100 * a + y2 * 100 * b;

                    if (x <= 0.01 * e * y) {
                        if (max_v.first * (x + y) <= x * max_v.second) {
                            max_v.first = x;
                            max_v.second = x + y;
                        }
                    }
                }
            }
        }
    }

    cout << max_v.second << ' ' << max_v.first << endl;


    return 0;
}


Measured memory_bytes: 256
n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


divisors=make_divisors(n)
#print(divisors)
ans = "No"

if len(divisors)%2 == 0:
    #print("hoge")
    for i in range(len(divisors)//2):
        a,b = divisors[i],divisors[len(divisors)-1-i]
        #print(a,b)
        if (a>=1)&(a<=9)&(b>=1)&(b<=9):
            ans = "Yes"
            break
if len(divisors)%2 == 1:
    for i in range(len(divisors)//2+1):
        if i ==len(divisors)//2:
            a,b = divisors[i],divisors[i]
        else:
            a,b = divisors[i],divisors[len(divisors)-1-i]
        #print(a,b)
        if (a>=1)&(a<=9)&(b>=1)&(b<=9):
            ans = "Yes"
            break
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    /*int x;
    cin >> x;
    if(x>=400&&x<=599)
        cout << 8 << endl;
    if(x>=600&&x<=799)
        cout << 7 << endl;
    if(x>=800&&x<=999)
        cout << 6 << endl;
    if(x>=1000&&x<=1199)
        cout << 5 << endl;
    if(x>=1200&&x<=1399)
        cout << 4 << endl;
    if(x>=1400&&x<=1599)
        cout << 3 << endl;
    if(x>=1600&&x<=1799)
        cout << 2 << endl;
    if(x>=1800&&x<=1999)
        cout << 1 << endl;*/
    int  a,b,c,k;
    cin >> a>> b >> c >> k;
    while(k&&b<=a)
    {
        b = b*2;
        k--;
    }
    while(k&&c<=b)
    {
        c = c*2;
        k--;
    }

    if(b>a&&c>b)
        cout << "Yes\n";
    else
    cout << "No\n";
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];
  vector<P> vec(5);
  for (int i = 0; i < 5; ++i) {
    vec[i].second = a[i];
    if (a[i] % 10 == 0) {
      vec[i].first = 0;
    } else {
      vec[i].first = (10 - (a[i] % 10));
    }
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  for (int i = 0; i < 5; ++i) {
    if (i == 4) {
      ans += vec[i].second;
    } else {
      ans += vec[i].first + vec[i].second;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

const int MAXN = 100100;
const int MOD7 = 1000000007ll;
const int MOD9 = 1000000009ll;
const int INF = 2000000000;
const double ESP = 1e-9;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int val[MAXN];

int main()
{
	int n, i;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i)
		scanf("%d", &(val[i]));
	int ans = 0;
	for(i = 1; i < n; ++i)
		if (val[i] == i)
		{
			ans++;
			i++;
		}
	if (i == n && val[i] == i)
		ans++;

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

	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

main(){
  ll n,a1,a2,a3;
  ld f;
  cin>>n;
  rep(i,1,3501){
    rep(j,1,3501){
      ll f=n*i*j;
      ll z=4*i*j-n*j-n*i;
      if(z!=0&&f%z==0&&0<f/z&&f/z<3600){a1=i;a2=j;a3=f/z;break;}
    }
  }
  cout<<a1<<" "<<a2<<" "<<a3;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1]; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1]; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb(x) push_back(x)
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	READ(n);
	READARR(a, n + 1);
	READARR(b, n);
	
	int sum = 0;
	FOR (i, 1, n)
	{
	    if (a[i] < b[i])
	    {
	        int t = a[i + 1];
	        a[i + 1] = max(0LL, a[i + 1] - b[i] + a[i]);
	        sum += t - a[i + 1] + a[i];
	    }
	    
	    else sum += b[i];
	}
	
	cout << sum;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(N * M - 2)
elif N == 2 or M == 2:
    print(0)
else:
    print((N-2)*(M-2))

Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){

	int counter=0;
	string str;

	cin >> str;

	if(str[0]=='1') counter++;
	if(str[1]=='1') counter++;
	if(str[2]=='1') counter++;

	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 01.07.2020 09:49:56
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int n;
    cin>>n;

    int d[100001];
    REP(i,n)cin>>d[i];

    sort(d,d+n);
    int ans1,ans2;
    ans1=d[n/2-1];
    ans2=d[n/2];
    
    cout<<ans2-ans1<<endl;

    return 0;
}

Measured memory_bytes: 4032
#include <iostream>
using namespace std;
int main(void){
    int r, c, i, j, sum;
    int x[101][101], sumx[101], sumy[101];
    
    cin >> r >> c;
    sum = 0;
    for(i = 0; i < r; i++){
        sumx[i] = 0;
        for(j = 0; j < c; j++){
            cin >> x[i][j];
            sum += x[i][j];
            sumx[i] += x[i][j];
            sumy[j] += x[i][j];
        }
    }
    
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            cout << x[i][j] << " ";
            if(j == c - 1)  cout << sumx[i] << endl;
        }
    }
    for(i = 0; i < c; i++){
        cout << sumy[i] << " ";
        if(i == c - 1)  cout << sum << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << ((a*b>c*d)?(a*b):(c*d));
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nn 1008
#define mod 1000000007
#define N 2
struct mat{
	ll a[N][N];
};
mat operator *(mat a,mat b)
{
	mat c;
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
		{
			c.a[i][j]=0;
			for(int k=0;k<N;k++)
				c.a[i][j]=(c.a[i][j]+a.a[i][k]*b.a[k][j]%mod)%mod;
		}
	return c;
}
mat qpow(mat x,ll y)
{
	mat res;
	for(int i=0;i<N;i++) for(int j=0;j<N;j++) res.a[i][j]=(i==j);
	while(y)
	{
		if(y&1) res=res*x;
		x=x*x,y=y/2;
	}
	return res;
}
ll qpow(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod,y=y/2;
	}
	return res;
}

ll n,m,k;
char buf[nn][nn];
char tmp[nn][nn];
void out(int x)
{
	printf("%d",(x%mod+mod)%mod);
	exit(0);
}
int lc,rc;
int main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=0;i<n;i++) scanf("%s",buf[i]);
	int cnt=0;
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cnt+=(buf[i][j]=='#');
	if(k<2) out(1);
	for(int i=0;i<n;i++) if(buf[i][0]==buf[i][m-1] and buf[i][0]=='#') lc++;
	for(int i=0;i<m;i++) if(buf[0][i]==buf[n-1][i] and buf[0][i]=='#') rc++;
//	cout<<lc<<" "<<rc<<"\n";
	if(lc&&rc) out(1);
	if(!lc&&!rc) out(qpow(cnt,k-1));
	if(lc) 
	{
		for(int i=0;i<n;i++) for(int j=0;j<m;j++) tmp[j][i]=buf[i][j];
		swap(n,m);
		swap(lc,rc);
		swap(tmp,buf);
	}
	ll a=0;
	for(int i=0;i<n-1;i++) for(int j=0;j<m;j++) if(buf[i+1][j]==buf[i][j] and buf[i][j]=='#') a++;
	ll b=rc;
//	cout<<a<<" "<<b<<cnt<<"\n";
	mat mm;
	mm.a[0][0]=cnt,mm.a[0][1]=0,mm.a[1][0]=a,mm.a[1][1]=b;
	mm=qpow(mm,k-2);
	ll vn=qpow(cnt,k-1);
	ll en=a*mm.a[0][0]%mod+b*mm.a[1][0]%mod;
//	cout<<vn<<" "<<en<<"\n";
	en%=mod;
	out(vn-en);
	return 0;
} 

Measured memory_bytes: 2176
class Node
  attr_accessor :par, :left_cld, :right_sib, :depth, :childs, :type, :id
  def initialize()
    @par = -1
    @left_cld = nil
    @right_sib = nil
    @depth = nil
    @childs = []
    @type = "internal node"
    @id = nil
  end
end

#入力
n = gets.to_i
#inputs = Array.new(n){gets.split.map(&:to_i)}
#ノード生成ここから
$nodes = Array.new(n){Node.new}
n.times do |i|
#str.lines do |line|
  input = gets.split.map(&:to_i)
  #input = line.split.map(&:to_i)
  #p input
#inputs.each_with_index do |input, i|
  #もし子がないならnext
  if input[1] == 0
    next
  end

  #parを設定
  input[2..-1].each do |num|
    $nodes[num].par = input[0]
  end

  #left_cldを設定
  $nodes[input[0]].left_cld = input[2]

  #right_sibを設定
  tmp = input[2..-1] + [nil]
  tmp.each_with_index do |num, j|
    if num
      $nodes[num].right_sib = tmp[j+1]
    end
  end
end

def set_depth(node)
  d = 0
  p = node.par
  while p != -1
    d+=1
    p = $nodes[p].par
  end
  return d
end

def set_childs
  $nodes.each do |node|
    c = node.left_cld
    while c
      node.childs << c
      c = $nodes[c].right_sib
    end
  end
end

def set_type
  $nodes.each_with_index do |node, k|
    if node.par == -1
      node.type = "root"
    elsif !node.left_cld
      node.type = "leaf"
    end
  end
end

$nodes.each do |node|
  node.depth = set_depth(node)
end
set_childs()
set_type()
#ノード生成ここまで

#p inputs[0]
$nodes.each_with_index do |n, i|
  #p i
  #p n
  puts 'node %d: parent = %d, depth = %d, %s, %s' % [i, n.par, n.depth, n.type, n.childs.to_s]
end


Measured memory_bytes: 54060