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

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

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	ll n;
	cin >> n;
	vector<ll> X(n);
	rep(i,n) cin >> X[i];

	vector<ll> xsort(n);
	xsort = X;
	SORT(xsort);
	ll pos1 = xsort[(n-1)/2];
	ll pos2 = xsort[(n) / 2];
//	che(pos1,"pos1");
//	che(pos2,"pos2");


	rep(i,n){
		if(X[i] <= pos1){
			cout << pos2 << endl;
		}else {
			cout << pos1 <<endl;
		}
	}
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    string s;
    cin >> n;
    cin >> s;

    int m = s.length();

    for(int i=0;i<m;++i) {
        s[i] = 'A' + (int(s[i]-'A') + n) % 26;
    }

    cout << s << endl;
}


Measured memory_bytes: 256
import collections
import sys

*data, = map(int, sys.stdin.read().split()[::-1])

def inp():
    return data.pop()

h, w, m = inp(), inp(), inp()


targets = set()
xs = []
ys = []
for _ in range(m):
    y, x = inp(), inp()
    # y -= 1
    # x -= 1
    ys.append(y)
    xs.append(x)
    targets.add((y, x))

x_stat = collections.Counter(xs)
y_stat = collections.Counter(ys)

xs = sorted(set(xs), key=lambda obj: x_stat[obj], reverse=True)
ys = sorted(set(ys), key=lambda obj: y_stat[obj], reverse=True)

mx_x = x_stat[xs[0]]
mx_y = y_stat[ys[0]]
while xs and x_stat[xs[-1]] < x_stat[xs[0]]:
    xs.pop()
while ys and y_stat[ys[-1]] < y_stat[ys[0]]:
    ys.pop()
# print(xs, x_stat)
# print(ys, y_stat)

found = False
for x in xs:
    for y in ys:
        if (y, x) not in targets:
            found = True
            break
    if found:
        break
ans = mx_y + mx_x
if not found:
    ans -= 1
print(ans)






Measured memory_bytes: 209948
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int ans = 0;
		for (int i = 0; i < N; i++) {
			ans += in.nextInt() - 1;
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 26184
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b)
        printf("a > b\n");
  else if(a<b)
        printf("a < b\n");
    else
        printf("a == b\n");
    return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

int main() {
	ll H, W, A, B;
	cin >> H >> W >> A >> B;

	ll ans[1001][1001] = {};

	repn(i,H-B)repn(j,W-A){
		ans[i][j] = 1;
	}
	repn(i, B)repn(j, A) {
		ans[H - B + i][W - A + j] = 1;
	}

	repn(i, H) {
		repn(j, W) {
			cout << ans[i][j];
		}
		cout << endl;
	}
	

	system("PAUSE");

}





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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

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

	vector< pair<int, int> > a(n);

	REP(i, n){
		cin >> a[i].first;
		a[i].second = i+1;
	}

	sort(a.begin(), a.end());

	REP(i, n){
		cout << a[i].second << ' ';
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1664
from collections import Counter

def main():
    N = int(input())
    S = input()

    res = dot = S.count(".")
    sha = 0
    # print(res, dot)

    for i in range(N):
        if S[i] == "#":
            sha += 1
        else:
            dot -= 1
        tmp = sha + dot
        res = min(tmp, res)
    print(res)
main()

Measured memory_bytes: 3756
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static int x;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    x = Integer.parseInt(in[0]);

    br.close();

    out.println(10 - x/200);

    out.flush();
  }
}

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

using namespace std;

int main(void){
  int l[10];
  int v[2];
  int i, j;
  int sum;
  double p;

  while(cin >> l[0]){
	cin.ignore();
	cin >> l[1];
	cin.ignore();
	cin >> l[2];
	cin.ignore();
	cin >> l[3];
	cin.ignore();
	cin >> l[4];
	cin.ignore();
	cin >> l[5];
	cin.ignore();
	cin >> l[6];
	cin.ignore();
	cin >> l[7];
	cin.ignore();
	cin >> l[8];
	cin.ignore();
	cin >> l[9];
	cin.ignore();
	cin >> v[0];
	cin.ignore();
	cin >> v[1];
	sum = 0;
	for(i=0;i<10;i++){
	  sum += l[i];
	}

	p = sum * ((double)v[0] / (v[0] + v[1]));

	i=0;
	while(p > 0){
	  p -= l[i++];
	}
	cout << i << endl;

  }
  return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	
	while (1) {
		int n;
		bool flag = true;
		int firs = 0, secon = 0;
		int count[26] = {};
		char c;
		int time;
		char p;
		vector< pair <int, char > > dp(26);

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> c;
			count[c - 'A']++;
			FOR(t, 0, 25) {
				dp[t].first = count[t];
				dp[t].second = 'A' + t;
			}
			sort(dp.begin(), dp.end());
			firs = dp[25].first;
			secon = dp[24].first;
			if (n - i + secon < firs) {
				if (flag) {
					p = dp[25].second;
					time = i;
					flag = false;
				}
				
			}
		}
		if (flag) {
			cout << "TIE" << endl;
		}
		else {
			cout << p << " " << time << endl;
		}
	}
}


Measured memory_bytes: 3116
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int ans=1000000;
    string s,t;cin>>s>>t;
    int dif=s.size()-t.size()+1;
    for(int i=0;i<dif;i++){
        int tmp=0;
        for(int j=i;j<t.size()+i;j++){
            if(s[j]!=t[j-i])tmp++;
        }
        ans=min(tmp,ans);
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main(int argc, char* argv[])
{
    int H, W; cin >> H >> W;

    vector<string> C(H);
    for (int i = 0; i < H; i++) {
        cin >> C[i];
    }

    for (int i = 0; i < H; i++) {
        cout << C[i] << endl << C[i] << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

int main() {
  ll n, x;
  cin >> n >> x;
  cout << 3 * (n - __gcd(n, x)) << endl;
  return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
while H!=0 or W!=0:
    
    for i in range(W):
        print("#",end='')
    print() 
    
    for c in range(H-2):
        print("#",end='')
        for b in range(W-2):
            print(".",end='')
        print("#")
    
    for i in range(W):
        print("#",end='')
    print()  
    print()    
    H,W=map(int,input().split())
else:
    pass


Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

struct node {
    int parent;
    double p;
    vector<pii> c;
};
double P;
int N;
double ex;
vector<node> T;
vector<vector<pii>> U;
void make_tree(int i=0) {
    REP(j,SZ(U[i])) {
        pii e=U[i][j];
        if(e.first==T[i].parent) continue;
        T[i].c.push_back(e);
        T[e.first].p=T[i].p*P;
        T[e.first].parent=i;
        make_tree(e.first);
    }
}
double dfs(int i=0) {
    if(SZ(T[i].c)==0) return 0;
    double ret=0;
    FORE(x,T[i].c) {
        ret+=x.second*T[x.first].p+dfs(x.first);
    }
    return ret;
}
double dfs2(int i=0) {
    if(SZ(T[i].c)==0) return T[i].p * ex;
    double ret=0;
    FORE(x,T[i].c) {
        ret+=x.second * T[x.first].p + dfs2(x.first);
    }
    return ret + T[i].p * ex;
}
signed main() {
    cin>>P>>N;
    T=vector<node>(N);
    U=vector<vector<pii>>(N);
    REP(i,N-1) {
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        U[a].push_back({b,c});
        U[b].push_back({a,c});
    }
    T[0].parent=-1;
    T[0].p=1;
    make_tree();  // T????§????
    ex=dfs();
    cout<<dfs2()<<endl;
    return 0;
}

Measured memory_bytes: 23148
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N;
	cin >> N;
	vector<vll> A(3,vll(N+1));
	rep(i, 0, 3) {
		A[i][0] = 0;
		repeq(j, 1, N) {
			cin >> A[i][j];
		}
		sort(A[i].begin(), A[i].end());
	}
	
	ll ans = 0;
	repeq(i, 1, N) {
		ans += (lower_bound(A[0].begin(), A[0].end(), A[1][i]) - A[0].begin()-1) * (N - (upper_bound(A[2].begin(), A[2].end(), A[1][i]) - A[2].begin()-1));
	}
	cout << ans << endl;
	return 0;

}


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

// Range Minimum/Maximum Query: Semigroup
struct Element{
    ll value;
    bool isIdentity;
};
Element Identity = {0, true};
Element Operation(const Element &A, const Element &B){
    if(A.isIdentity) return B;
    if(B.isIdentity) return A;
    return {min(A.value, B.value)};
    // return {max(A.value, B.value)};
}

struct SegmentTree{
    int size; // number of leaves: power of two
    vector<Element> cbt; // complete binary tree

    // Initialize with Identity Element
    SegmentTree(int N){
        size = 1;
        while (size < N) size *= 2;
        cbt.resize(size * 2 - 1, Identity);
    }

    // Initial Input
    void initial_set(int i, const Element &A) {
        i += size - 1;
        cbt[i] = A;
    }

    void initial_build() {
        for (int i = size - 2; i >= 0; --i) {
            cbt[i] = Operation(cbt[i*2+1], cbt[i*2+2]);
        }
    }

    Element get(int i){
        i += size - 1;
        return cbt[i];
    }

    // Update i-th Leaf (0-indexed) to A
    void update(int i, const Element &A){
        i += size - 1;
        cbt[i] = A;
        while (i > 0){
            i = (i - 1) / 2;
            cbt[i] = Operation(cbt[i*2+1], cbt[i*2+2]);
        }
    }

    // Product of Interval [a, b) (0-indexed)
    Element query(int a, int b) {
        return query_rec(a, b, 0, 0, size);
    }

    Element query_rec(int a, int b, int k, int l, int r){
        // k is root of subtree [l, r)
        if(r <= a || b <= l) return Identity; // outside [a, b)
        if(a <= l && r <= b) return cbt[k]; // interior of [a, b)
        Element vl = query_rec(a, b, k*2+1, l, (l+r)/2);
        Element vr = query_rec(a, b, k*2+2, (l+r)/2, r);
        return Operation(vl, vr);
    }
};

struct query{int L; int R; int C;};
bool cmp(query A, query B){
    return A.L < B.L;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<query>qu(M);
    for (int i = 0; i < M; ++i) {
        int L, R, C;
        cin >> L >> R >> C;
        qu[i] = {L, R, C};
    }
    sort(qu.begin(), qu.end(), cmp);

    SegmentTree tree(N+2);
    tree.initial_set(1, {0});
    tree.initial_build();
    for (int i = 0; i < M; ++i) {
        auto minimum = tree.query(qu[i].L, qu[i].R);
        if(minimum.isIdentity) {
            continue;
        }
        ll temp = minimum.value + qu[i].C;
        if(tree.get(qu[i].R).isIdentity || tree.get(qu[i].R).value > temp){
            tree.update(qu[i].R, {temp});
        }
    }

    auto ans = tree.get(N);
    if(ans.isIdentity){
        cout << -1 << "\n";
    } else{
        cout << ans.value << "\n";
    }

    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

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

#define M 2000010


int main(){
	IOS;
	
	
	string s;
	cin>>s;
	bool ok = 1;
	if(s[2]!=s[3])ok=0;
	if(s[4]!=s[5])ok=0;
	if(!ok)cout<<"No";
	else cout<<"Yes";
	
	
	
	
	
	return 0;
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

#define rank asdf

ll rank(vl a) {
	ll m = sz(a), n = 61;

	auto at = [&](ll i, ll j) { return !!(a[i] & (1LL << j)); };
	
	ll r = 0;
	FOR(j,0,n) {
		FOR(i,r+1,m) if (at(i,j)) {
			swap(a[i],a[r]); break;
		}
		if (!at(r,j)) continue;
		FOR(i,r+1,m) if (at(i,j)) a[i] ^= a[r];
		r++;
	}
	return r;
}

bool solve() {
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];
	string s; cin >> s;

	vl b;
	FORD(i,0,n) {
		b.pb(a[i]);
		ll k = rank(b);
		if (k < sz(b)) {
			b.pop_back();
		} else {
			if (s[i] == '1') return 1;
		}
	}
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll tc; cin >> tc;
	while (tc--) cout << solve() << endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
vector <int> bi[N];
int dep[N];
int comp(int a, int b)
{
    return dep[a] > dep[b];
}
void dfs(int t)
{
    for (int i = 0; i < bi[t].size(); ++ i)
        dfs(bi[t][i]);
    sort(bi[t].begin(), bi[t].end(), comp);
    for (int i = 0; i < bi[t].size(); ++ i)
        dep[t] = max(dep[t], dep[bi[t][i]] + i + 1);
}
int main()
{
    scanf("%d", &n);
    for (int i = 2; i <= n; ++ i)
    {
        int x;
        scanf("%d", &x);
        bi[x].push_back(i);
    }
    dfs(1);
    printf("%d\n", dep[1]);
}


Measured memory_bytes: 13184
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

pub trait BinarySearch {
    fn lower_bound(&self, x: &f64) -> usize;
}

impl BinarySearch for [f64] {
    fn lower_bound(&self, x: &f64) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            if self[mid] < *x {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        low
    }
}

fn main() {
    input! {
        n: usize,
        mut v: [f64; n],
    }
    v.sort_by(|a, b| {
        if a < b {
            std::cmp::Ordering::Less
        } else {
            std::cmp::Ordering::Greater
        }
    });
    while v.len() != 1 {
        let val = (v[0] + v[1]) / 2.0;
        v.remove(0);
        v.remove(0);
        let index = v.lower_bound(&val);
        v.insert(index, val);
    }
    println!("{}", v[0]);
}


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

int main()
{
    char s[100001];
    int N,Q,i,l,r,sum,v[100001]={0};
    scanf("%d %d",&N,&Q);
    scanf(" %s",s);
    sum=0;
    for(i=0;i<N;i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
        {
            sum++;
            v[i+1]+=sum;
        }
         if(i!=1&&v[i]==0)
        {
             v[i]=v[i-1];
        }
    }
    for(i=0;i<Q;i++)
    {
        scanf("%d %d",&l,&r);
        printf("%d\n",v[r-1]-v[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  vector<int>b(n,0);
  
  int ans=0;
  for(int i=n-1;i>=0;i--){
    int sum = 0;
    for(int j=i;j<n;j+=(i+1)){
      sum+=b[j];
    }
    if(sum%2!=a[i]){
      b[i]=1;
      ans++;
    }
  }
  cout << ans << endl;
  rep(i,n){
    if(i!=0)cout <<" ";
    if(b[i])cout << i+1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int DP[45][500][500];

int main() {
  int N, Ma, Mb;
  cin>>N>>Ma>>Mb;
  int A[N], B[N], C[N];
  for(int i=0;i<N;++i) cin>>A[i]>>B[i]>>C[i];
  for(int i=0;i<45;++i) {
    for(int j=0;j<500;++j) {
      for(int k=0;k<500;++k) {
        DP[i][j][k] = inf;
      }
    }
  }
  DP[0][0][0] = 0;
  DP[0][A[0]][B[0]] = C[0];
  for(int i=0;i<N-1;++i) {
    for(int j=0;j<500;++j) {
      for(int k=0;k<500;++k) {
        if(DP[i][j][k]==inf) continue;
        DP[i+1][j][k] = min(DP[i+1][j][k], DP[i][j][k]);
        DP[i+1][j+A[i+1]][k+B[i+1]] = min(DP[i+1][j+A[i+1]][k+B[i+1]], DP[i][j][k]+C[i+1]);
      }
    }
  }
  int ans = inf;
  for(int i=1;i*Ma<500 && i*Mb<500;++i) {
    ans = min(ans, DP[N-1][i*Ma][i*Mb]);
  }
  if(ans==inf) cout<<-1<<endl;
  else cout<<ans<<endl;
}



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

int main(){
    int N;
    cin >> N;
    
    int a,b,c,d;
    a = N / 100;
    b = N % 100;
    c = b / 10;
    d = b % 10;
    
    if ( a == 7 or c == 7 or d == 7){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int dp[105][10005]{};

int main() {
    int n,W,v[105],w[105];
    cin >> n >> W;
    REP(i,n)cin >> v[i] >> w[i];
    REP(i,n){
        REP(j,W+1){
            if(j>=w[i]){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
                dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            }
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}



Measured memory_bytes: 6996
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("No"),0;
//#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,a[505][505],h,w;
signed main(){
	n=read();m=read();h=read();w=read();
	int d=2000;
	F(i,1,n){
		F(j,1,m){
			a[i][j]=d;
		}
	} 
	F(i,1,n/h){
		F(j,1,m/w){
			a[i*h][j*w]=-(h*w-1)*d-1;
		}
	}
	int sum=0;
	F(i,1,n){
		F(j,1,m) sum+=a[i][j];
	}
	if (sum<=0) ret;
	puts("Yes");
	F(i,1,n){
		F(j,1,m) wri(a[i][j]);
		put;
	}
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long int;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> memo1(n);
    vector<int> memo2(n);
    memo1[0] = a[0];
    int maxa = a[0];
    for(int i = 1; i < n; i++)
    {
        memo1[i] = max(maxa, a[i]);
        maxa = memo1[i];
    }
    memo2[n - 1] = a[n - 1];
    maxa = a[n - 1];
    for(int i = 1; i < n; i++)
    {
        memo2[n - 1 - i] = max(maxa, a[n - 1 - i]);
        maxa = memo2[n - 1 - i];
    }
    cout << memo2[1] << endl;
    for(int i = 1; i < n - 1; i++)
    {
        cout << max(memo1[i - 1], memo2[i + 1]) << endl;
    }
    cout << memo1[n - 2] << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	string s, p; cin >> s >> p;
	string ss = s + s;
	REP(i, s.size()) {
		if (ss.substr(i, p.size()) == p) {
			puts("Yes");
			return;
		}
	}
	puts("No");
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3232
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    A=list(map(int,readline().split()))
    B=[0]*N
    C=[0]*N
    for i in range(N):
        B[i]=A[i]-(i+1)
        C[i]=A[i]+(i+1)

    d=dict()
    for i in range(N):
        if B[i] not in d:
            d[B[i]]=1
        else:
            d[B[i]]+=1
    
    res=0
    for i in range(N):
        n=-1*C[i]
        if n not in d:
            pass
        elif n in d and d[n]>=1:
            res+=d[n]
            d[B[i]]-=1

    print(res)
if __name__=="__main__":
    main()

Measured memory_bytes: 50248
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll dp[1001][4097];
ll a[1001];
ll c[1001];
int main() {
	ll n, m; cin >> n >> m;
	repe(i, 1, m) {
		ll b;
		cin >> a[i] >> b;
		ll C = 0;
		rep(i, 0, b) {
			ll x; cin >> x;
			C |= 1 << (x - 1);
		}
		c[i] = C;
	}

	ll N = 1; while (n--)N *= 2;
	repe(i, 0, m) repe(j, 0, N) dp[i][j] = INF;
	dp[0][0] = 0;

	rep(i, 0, m)rep(j, 0, N) {
		if (dp[i][j] != INF) {
			//use
			dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
			//un use
			dp[i + 1][j | c[i]] = min(dp[i][j] + a[i], dp[i + 1][j | c[i]]);
		}
	}

	ll ans = INF;
	repe(i, 0, m) {
		ans = min(ans, dp[i][N - 1]);
	}

	if (ans == INF) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
  string s;
  string t;
  cin >> s;
  cin >> t;
  int l=s.size();
  int r=0;
  for(int i=0;i<l;i++){
  	if(s[i]!=t[i]){
      r++;
    }
  }
  cout << r;
  
}

Measured memory_bytes: 3580
import sys
bbn=1000000007
	
#+++++
		
def main():
	n, a, b= map(int, input().split())
	
	k=b-a
	if k % 2 ==0:
		return k // 2
		
	to=a+((b-a-1)//2)
	tn=(n-b+1)+(n-(a+(n-b+1)))//2
	return min(to,tn)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

template<typename T>
vector<T> zeta_transform(int n, vector<T> a, function<T(T, T)> f, bool low2high = true) {
  if (low2high) {
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < 1 << n; ++j)
        if (j >> i & 1)
          a[j] = f(a[j], a[j ^ 1 << i]);
  } else {
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < 1 << n; ++j)
        if (~j >> i & 1)
          a[j] = f(a[j], a[j | 1 << i]);
  }
  return a;
}

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

  vector<int> A(1 << N);
  for (int i = 0; i < 1 << N; ++i) cin >> A[i];

  vector<vector<int>> best(1 << N);
  for (int i = 0; i < 1 << N; ++i) best[i] = {A[i], -1};

  auto merge = [](vector<int> a, vector<int> b) {
    a.insert(a.end(), b.begin(), b.end());
    sort(a.begin(), a.end(), greater<int>());
    a.resize(2);
    return a;
  };
  vector<vector<int>> zeta_best = zeta_transform<vector<int>>(N, best, merge);

  auto chmax = [](vector<int> a, vector<int> b) {
    return a[0] + a[1] > b[0] + b[1] ? a : b;
  };
  partial_sum(zeta_best.begin() + 1, zeta_best.end(), zeta_best.begin() + 1, chmax);
  
  for (int i = 1; i < 1 << N; ++i) cout << zeta_best[i][0] + zeta_best[i][1] << endl;

  return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 1e5;
  cin >> n;
  vector<vector<int>> tree(n);
  int c[max_n + 1] = {};
  vector<pair<int, int>> vp;
  for(int i = 0; i < n-1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
    vp.push_back(make_pair(a,b));
  }
  int k = 0;
  for(int i = 0; i < n; i++){
    int size = tree.at(i).size();
    k = max(k, size);
  }
  cout << k << endl;

  queue<int> todo;
  vector<int> seen(n, 0);
  vector<int> cs(n, 0);
  map<pair<int, int>, int> I;

  todo.push(0);
  seen[0] = 1;
  while(!todo.empty()){
    int now = todo.front(); todo.pop();
    int cnt = 1;
    for(auto next: tree[now]){
      if(seen[next] == 1) continue;
      if(cnt == cs[now]) cnt ++;
      cs[next] = I[make_pair(now, next)] = I[make_pair(next, now)] = cnt++;
      seen[next] = 1;
      todo.push(next);
    }
  }
  for(auto i: vp) cout << I[i] << endl;

  return 0;
}

Measured memory_bytes: 22944
n,m = map(int, input().split())

x = m //n
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

y = make_divisors(m)

res = 1

for i in y:
    if i <=x:
        res = i
        
print(res)

Measured memory_bytes: 9056
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
s = input()
if s.isupper(): print('a'.upper())
else: print('A'.lower())

Measured memory_bytes: 9232
import sys
from itertools import starmap
import math
readline = sys.stdin.readline
EPS = 1e-9
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2
class Circle(object):
    __slots__ = ('c', 'r')
    def __init__(self, c, r):
        self.c = c
        self.r = r
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
Line = Segment
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se),
               getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))
def getCrossPoint(s1, s2):
	base = s2.se - s2.fi
	d1 = abs(cross(base, s1.fi - s2.fi))
	d2 = abs(cross(base, s1.se - s2.fi))
	t = d1 / (d1 + d2)
	return s1.fi + (s1.se - s1.fi) * t
def getCrossPoints(c, l):
	pr = project(l, c.c)
	e = (l.se - l.fi) / abs(l.se - l.fi)
	base = math.sqrt(c.r * c.r - norm(pr - c.c))
	return Segment(pr + e * base, pr - e * base)
x, y, r = map(int, readline().split())
ci = Circle(complex(x, y), r)
n = int(readline())
for _ in [0] * n:
    p0, p1 = starmap(complex, zip(*[map(int, readline().split())] * 2))
    ppp = getCrossPoints(ci, Line(p0, p1))
    if ppp.se.real < ppp.fi.real or (ppp.se.real == ppp.fi.real and ppp.se.imag < ppp.fi.imag):
        ppp.fi, ppp.se = ppp.se, ppp.fi
    print("{:.10f} {:.10f} {:.10f} {:.10f}".format(ppp.fi.real, ppp.fi.imag, ppp.se.real, ppp.se.imag))

Measured memory_bytes: 7980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; ++i)
        cin >> X[i];
    ll ans = 1e18;
    for (int i = 1; i <= 100; ++i) {
        ll tmp = 0;
        for (int j = 0; j < N; ++j)
            tmp += (X[j] - i) * (X[j] - i);
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int N,K;
int gcd(int a,int b){
	if (b==0){
		return a;
	}
	return gcd(b,a%b);
}

int main(){
	cin>>N>>K;
	int g,m;
	cin>>g;
	m=0;
	m=max(m,g);
	REP(i,N-1){
		int a;
		cin>>a;
		g=gcd(g,a);
		m=max(m,a);
	}
	if (K<=m && (m-K)%g==0){
		cout<<"POSSIBLE"<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

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

int main() {
  int n, ans;
  cin >> n;
  if (n%2==0) cout << n/2 <<endl;
  else cout << (n+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d %d %d", $X, $Y, $A, $B, $C);
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
$q = array_map('intval', explode(' ', trim(fgets(STDIN))));
$r = array_map('intval', explode(' ', trim(fgets(STDIN))));
rsort($p);
rsort($q);
$pp = array_slice($p, 0, $X);
$qq = array_slice($q, 0, $Y);
$s = array_merge($pp, $qq, $r);
rsort($s);
$ans = array_sum(array_slice($s, 0, $X + $Y));
printf("%d", $ans);


Measured memory_bytes: 47616
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int h, w, a ,b;
  cin >> h >> w >> a >> b;
  int x = h % a;
  int y = w % b;
  cout << x * w + y * h - x * y << endl;
  return 0;
}



Measured memory_bytes: 3184
from collections import deque
import sys
n,k=map(int,input().split())
s=input()
buf=s[0]
a = deque([]) 
count=0
ans=0
for i in range(n):
    if buf==s[i]:
        count+=1
    else:
        a.append(count)
        count=1
        buf=s[i]
    if i==n-1:
        a.append(count)
l=len(a)
c=0
for i in range(l):
    ans+=a[i]-1
for i in range(l//2):
    if c==k:
        break
    if 2*i+1!=l-1:
        ans+=2
        c+=1

if c<k:
    ans+=k-c
    ans=min(n-1,ans)
print(ans)
        

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

using namespace std;

int main(){
    int n, l, x, y;
    cin>>n>>l;
    int arr[n+1];
    bool posible = false;
    for (int i=1; i<=n; i++){
        cin>>arr[i];
    }
    for (int i=2; i<=n; i++){
        if (arr[i-1] + arr[i] >= l){
            posible = true;
            x = i-1, y = i;
        }
    }
    if (posible == false){
        cout<<"Impossible";
    }
    else{
        cout<<"Possible"<<endl;;
        for (int i=n-1; i>=y; i--){
            cout<<i<<endl;
        }
        for (int i=1; i<x; i++){
            cout<<i<<endl;
        }
        cout<<x<<endl;
    }
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

bool isPrime(ll x){
  ll root_x = (ll)sqrt((double)x);
  bool prime = true;
  for(ll i=2;i<=root_x;++i){
    if(x%i==0){
      prime = false;
      break;
    }
  }
  return prime;
}

int main() {
  ll x;cin>>x;
  if(x%2LL==0&&x!=2LL)++x;
  while(true){
    if(isPrime(x)){
      break;
    } else {
      x+=2LL;
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(int a, int e, int k);

void solve(int a, int e, int k) {
  if (e - a > k) {
    printf(":(\n");
  } else {
    printf("Yay!\n");
  }
}

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  solve(a, e, k);
  return 0;
}


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

using namespace std;

int gcd(int maxn,int minn)
{
    return minn==0?maxn:gcd(minn,maxn%minn);
}

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int maxn=a,minn=b;
    if(a<b){
        swap(maxn,minn);
    }
    printf("%d\n",gcd(maxn,minn));
    return 0;
}


Measured memory_bytes: 3196
K,N=map(int,input().split())
A=list(map(int,input().split()))
A.append(K+A[0])
B=[]
C=0
for i in range(N):
  B.append(A[i+1]-A[i])
  if A[i+1]-A[i]>C:
    C=A[i+1]-A[i]
print(sum(B)-C)

Measured memory_bytes: 26444
using System;
using System.Collections.Generic;

namespace AIZU {
	class Program {
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }

		static void Main(string[] args) {
			Stack<decimal> Dnalop = new Stack<decimal>();
			string[] syntax;
			string s0;
			decimal j,a1,a2;
			while (true) {
				s0 = Console.ReadLine();
				if (string.IsNullOrEmpty(s0)) break;
				syntax = s0.Split(' ');
				foreach (string s in syntax) {
					if (decimal.TryParse(s, out j)) {
						Dnalop.Push(j); continue;
					}
					a1 = Dnalop.Pop();
					a2 = Dnalop.Pop();
					switch (s) {
						case "+":
							j = a2 + a1;
							break;
						case "-":
							j = a2 - a1;
							break;
						case "*":
							j = a2 * a1;
							break;
						case "/":
							j = a2 / a1;
							break;
					}
					Dnalop.Push(j);
				}
				print(Dnalop.Pop());
			}
		}
	}
}

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

for i in range(1,3501):
    for j in range(1,3501):
        if (4*i*j-n*i-n*j)>0 and float((n*i*j)/(4*i*j-n*i-n*j)).is_integer():
            print(i,j,int((n*i*j)/(4*i*j-n*i-n*j)))
            exit()









Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
#define TIME (chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
vector<string> in;
vector<vi> sums;
int k;
int h, w;
inline int sum(int r, int c1, int c2){
    c2--;
    c1--;
 //   debug(c2);debug(c1);
    return sums[r][c2] - ((c1  >= 0) ? sums[r][c1] : 0);
}
vi tot(10);
int solve(int cuts){
    // if ith bit is set then cut after i columns
    int ans = 0;
    int prev = 0;
    int ind = 0;
    fill(all(tot), 0);
    for(int r = 0; r < h; r++){
        prev = 0;
        ind = 0;
        for(int b = 0; b < w- 1; b++){
            if(cuts & (1 << b)){
               int adder = sum(r, prev, b+1);
               if(adder > k)return 1e9;
               tot[ind] += adder;
//               debug(adder);
               prev = b+1;
               ind++; 
            }
        }
        tot[ind] += sum(r, prev, w);
        if(sum(r, prev, w) > k)return 1e9;
        for(int j = 0; j < ind + 1; j++){
            if(tot[j] > k){
                r--;
                ans++;
                fill(all(tot), 0);
                break;
            }
        }
    }
    return ans;

}
void solve(){

    cin >> h >> w;
    cin >> k;
    in.resize(h);
    FOR(i, h)cin >> in[i];

    vector<string> in2;
    FOR(i, w){
        string temp = "";
        FOR(j, h){
           temp += in[j][i]; 
        }
        in2.pb(temp);
    }
    swap(in2, in);
    swap(h, w);
    sums.assign(h, vi(w));
    FOR(i, h){
        int tot = 0;
        FOR(j, w){
            tot += (in[i][j] == '1'); 
            sums[i][j] = tot;
        }
    }
    int ans = 1e18;
    for(int i = 0; i < (1 << (w-1)); i++){
       ans = min(ans, __builtin_popcount(i) + solve(i)); 
    }

    cout << ans;

}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int t = 1;
   // cin >> t;
    while(t--)solve();
}




Measured memory_bytes: 512
N = gets.to_i

dic = {}
N.times do |i|
  s, point = gets.chomp.split
  unless dic[s]
    dic[s] = []
  end
  dic[s] << [i+1, point.to_i]
end

dic.keys.sort.each do |k|
  dic[k].sort_by! do |d|
    d[1]
  end
  dic[k].reverse.each do |d|
    p d[0]
  end
end

Measured memory_bytes: 1788
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]
lastd = [0] * 26

for i in range(1, d + 1):
    ans = 0
    tmp = 0
    for j in range(26):
        if tmp < s[i - 1][j] + (i - lastd[j]) * c[j]:
            tmp = s[i - 1][j] + (i - lastd[j]) * c[j]
            ans = j + 1
    lastd[ans - 1] = i
    print(ans)

Measured memory_bytes: 9292