akhauriyash/Code-Regression huggingface dataset:
while True:
    N,K=map(int,raw_input().split())
    if N==K==0:break
    S=map(int,raw_input().split())
    L=[0]*K
    for i in range(N):
        temp=map(int,raw_input().split())
        for j in range(K):
            L[j]+=temp[j]
    for i in range(K):
        if S[i]-L[i]<0:
            print "No"
            break
    else:
        print "Yes"

Measured memory_bytes: 4328
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
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-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll x[100001] = {};
int main() {
	ll n, k; cin >> n >> k;
	rep(i, 0, n)cin >> x[i];

	ll minV = MAX_L;
	rep(i, 0, n - k + 1) {
		ll minD = min(abs(x[i]), abs(x[i + k - 1]));
		minV = abs(min(minV, x[i + k - 1] - x[i] + minD));
	}

	cout << minV << endl;
	return 0;
}

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

int divisor(int num,int d[])
{
	int i,j=0,c[(int)sqrt(num)+10],k,e=0;
	int castle=0;
	for(i=1;i<=(int)sqrt(num);i++)
	{
		if(num%i==0)
		{
			d[j] = i;j++;
			if(i != num/i){
				c[e] = num/i;
				e++;
			}
		}
	}
	k = e;
	for(i = j; i < j+e;i++)
	{
		k--;
		d[i] = c[k];
	}
	/*
	for(i = 0; i < j+e; i++)
	{
		printf("d[%d] = %d\n",i,d[i]);
	}
	*/
	return (e+j);
}

int main(void)
{
	int N;
	scanf("%d",&N);
	int i,a[N+1],b[N+1],ans[N+1],M=0,c[N+1],kate,j;
	for(i=1; i < N+1 ; i++)
	{
		scanf("%d",&a[i]);
		c[i] = 0;		b[i] = 0;		ans[i] = 0;
	}
	
	for(i=N; i > 0; i--)
	{
		kate = 0;
		if(a[i] == 0 && b[i] % 2 == 1)
		{
			kate = divisor(i,c);
			ans[i] = 1;
		}
		else if(a[i] == 1 && b[i] % 2 == 0)
		{
			kate = divisor(i,c);
			ans[i] = 1;
		}
		for(j = 0; j < kate; j++)
		{
			b[c[j]]++;
		}
	}
	for(i = 1; i < N+1; i++)
	{
		if(ans[i] == 1) M++;
	}
	
	printf("%d\n",M);
	for(i = 1; i < N+1; i++)
	{
		if(ans[i] == 1) printf("%d ",i);
	}
	return 0;
}



Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=998244353;
const int HASH=131;

ll l[maxn],r[maxn];
ll sum[maxn],ans[maxn];
int main()
{
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=k;i++)
    {
        cin>>l[i]>>r[i];
    }
    sum[1]=1;
    ans[1]=1;
    for(ll i=2;i<=n;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            ans[i]=(ans[i]+sum[max((ll)0,i-l[j])]-sum[max((ll)0,i-r[j]-1)])%MOD;
        }
        sum[i]=(sum[i-1]+ans[i])%MOD;
    }
    cout<<(ans[n]+MOD)%MOD<<endl;
    return 0;
}


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

int main() {
    int H, W, K;
    cin >> H >> W >> K;

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

    int output = 0;

    for (int bit = 0; bit < (1 << W); ++bit) {
        vector<int> SW;
        for (int i = 0; i < W; i++) {
            if (bit & (1 << i)) {
                SW.push_back(i);
            }
        }

        for (int bith = 0; bith < (1 << H); ++bith) {
            vector<string> c_tmp = c;
            vector<int> SH;
            for (int j = 0; j < H; j++) {
                if (bith & (1 << j)) {
                    SH.push_back(j);
                }
            }
            for (int w = 0; w < SW.size(); w++) {
                for (int j = 0; j < H; j++) {
                    c_tmp[j][SW[w]] = '.';
                }
            }
            for (int h = 0; h < SH.size(); h++) {
                for (int j = 0; j < W; j++) {
                    c_tmp[SH[h]][j] = '.';
                }
            }
            int count = 0;
            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    if (c_tmp[h][w] == '#') {
                        count++;
                    }
                }
            }
            if (count == K) {
                output++;
            }
        }
    }
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
	//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
	#include <bits/stdc++.h>
	using namespace std;
	//#include <ext/pb_ds/assoc_container.hpp>
	//#include <ext/pb_ds/tree_policy.hpp>
	//using namespace __gnu_pbds;
	//#ifndef rd
	#define endl '\n'
	//#endif
	#ifdef rd
	#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
	template<typename Arg1>
	void __f(const char* name, Arg1&& arg1) {
		cout<<name<<" : "<<arg1<<endl;
	}
	template<typename Arg1, typename ... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* comma=strchr(names+1,',');
		cout.write(names,comma-names)<<" : "<<arg1<<" | ";
		__f(comma+1,args...);
	}
	#else
	#define trace(...)
	#endif
	#define pb push_back
	#define fi first
	#define se second
	#define mkp make_pair
	//#define int long long
	typedef long long ll;
	typedef long double f80;
	//#define double long double
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define sz(x) ((long long)x.size())
	#define fr(a,b,c) for(int a=b; a<=c; a++)
	#define frdec(a,b,c) for(int a=b; a>=c; a--)
	#define rep(a,b,c) for(int a=b; a<c; a++)
	#define trav(a,x) for(auto &a:x)
	#define all(con) con.begin(),con.end()
	const ll infl=2e18;
	const int infi=2e9;
	const int mod=1e9+7;
	typedef vector<int> vi;
	//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
	mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
	auto clk=clock();
	int rng(int lim) {
		uniform_int_distribution<int> uid(0,lim-1);
		return uid(rang);
	}
	template<class t1, class t2, class t3>
	t1 fast_expo(t2 x, t3 p) {
		if(p == 0) return 1;
		t1 r = fast_expo(x,p/2);
		if(p%2 != 0) return r * r * x;
		return r * r;
	}
	// Code from here...

	void solve() {
		int n; cin >> n;
		map<int, int> m;
		
		fr(i, 1, n) {
			int x; cin >> x;
			m[x+1]++; m[x]++; m[x-1]++;
		}
		
		int ans = 0;
		for(auto i : m) {
			ans = max(i.se, ans);
		}
		cout << ans;
	}

	signed main() {
		ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
		srand(chrono::high_resolution_clock::now().time_since_epoch().count());
		cout<<fixed<<setprecision(10);
		int t=1;
		// cin>>t;
		while(t--)
			solve();
	#ifdef rd
		cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
		return 0;
	}

Measured memory_bytes: 4736
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
　 let N = xs[0];
   let M = xs[1];
   
   let ans = 0;
   for(let i=0; N>i; i++){
   ans += i;
   }
   let ans1=0;
   for(let i=0; M>i; i++){
   ans1 += i;
   }
   console.log(ans+ans1);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int x,y,z; cin >> x >> y >> z;
  x -= z;
  int ans = 0;
  while(x >= y+z){
    ans++;
    x -= y+z;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
dt = {}

ans = {}


towns = []
for _ in range(M):
    p, y = map(int, input().split())
    if dt.get(p):
        dt[p].append(y)
    else:
        dt[p] = [y]
    towns.append((p, y))

for key in dt.keys():
    for i, item in enumerate(sorted(dt[key]), 1):
        ans[(key, item)] = i

for town in towns:
    num = ans[town]
    print("{0:06}{1:06}".format(town[0], num))

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

int main(){
    vector<int> v;
    rep(i,3){
      	int a;
        cin>>a;
      	v.push_back(a);
;    }
  sort(v.begin(),v.end());
  if(v[0]%2==0||v[1]%2==0||v[2]%2==0){
  cout<< 0 <<endl;
  }else{
  cout << (long)v[0]*v[1] <<endl;
  }
 // cout << v[1] <<endl;
}

Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;


int solve() {
    string s;cin>>s;

    int n = sz(s);
    rep(x, 1, sz(s)-1){
        if ((sz(s)-x)%2==1) continue;
        string p = s.substr(0, (n-x)/2);
        string q = s.substr((n-x)/2, (n-x)/2);
        if (p==q){
            cout << sz(s)-x << endl;
            return 0;
        }
    }
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Sum of Three Integers
            var line = Console.ReadLine();
            var array = line.Split(' ');
            int k = int.Parse(array[0]);
            int s = int.Parse(array[1]);

            int count = CountXyzPairs(k, s);
            Console.WriteLine(count);            
        }

        static int CountXyzPairs(int k, int s)
        {
            int count = 0;

            for (int x = 0; x <= k; x++)
            {
                for (int y = 0; y <= k; y++)
                {
                    int z = s - x - y;

                    if (z >= 0 && z <= k)
                    {
                        count++;
                    }
                }
            }

            return count;
        }
    }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 2e6 + 5;

int n,a;
bool f = 1;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	REP(i,n){
		cin>>a;
		if(a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0))
			f = 0;
	}
	if(f)
		cout<<"APPROVED";
	else
		cout<<"DENIED";
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define repr(i, n) for(int i = n;i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    int n,k,ans = 1;
    cin >> n >> k;

    rep(i,n){
        if(ans * 2 < ans + k) ans = ans * 2;
        else ans = ans + k;
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    num = 0
    for j in range(i):
        if s[j] not in s[:j] and s[j] in s[i:]: num += 1
    if num > ans: ans = num
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int main(){
    int X,Y,Z; cin >> X >> Y >> Z;
    int A,B,C;
    A=X;
    B=Y;
    C=Z;
    swap(A,B);
    swap(A,C);
    cout << A << " " << B << " " << C << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect

INF = 1 << 30


def main():
    n = int(input())
    a = [int(input()) for i in range(n)]

    dp = [INF for i in range(n+1)]
    for i in range(1, n+1):
        idx = bisect.bisect_left(dp, a[i-1])
        dp[idx] = a[i-1]

    ans = bisect.bisect_left(dp, INF)
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 10356
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
ll p=1000000007;
ll fac[4000010];
ll ifac[4000010];
ll inv[4000010];
void init(int n)
{
    int i;
    fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
    for(i=2;i<=n;i++)
    {
        inv[i]=-(p/i)*inv[p%i]%p;
        fac[i]=fac[i-1]*i%p;
        ifac[i]=ifac[i-1]*inv[i]%p;
    }
}
ll c(int x,int y)
{
    if(x<y)
        return 0;
    return fac[x]*ifac[y]%p*ifac[x-y]%p;
}
ll f[2010][2010];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k<=1)
    {
        printf("1\n");
        return 0;
    }
    init(n*k);
    int i,j;
    f[0][0]=1;
    for(i=1;i<=n;i++)
        for(j=n;j>=0;j--)
        {
            if(j<=i)
                f[i][j]+=f[i-1][j-1]*c(k*i-j-1,k-2)%p;
            f[i][j]=(f[i][j]+f[i][j+1])%p;
        }
    ll ans=(f[n][0]%p+p)%p;
    ans=ans*fac[n]%p;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 125440
// coding on smartphone
#include<iostream>
using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		if(n == 1){
			cout << "deficient number\n";
			continue;
		}
		int sum = 1;
		for(int i = 2; i*i <= n; i++){
			if(n % i) continue;
			sum += i + n/i;
			if(i*i == n) sum -= i;
		}
		
		if(sum < n) cout << "deficient number\n";
		else if(sum > n) cout << "abundant number\n";
		else cout << "perfect number\n";
	}
	return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N;
  cin >> N;
  int64_t a = 0;
  int64_t b = 0;
  vector<int64_t> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  if(vec.at(i) < 0){
    a++;
  vec.at(i) *= -1;}
  b += vec.at(i);
}
  
  sort(vec.begin(),vec.end());
  
  if(a % 2 == 0){
    cout << b << endl;}
  else{cout << b - vec.at(0)*2 << endl;}
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

// 綺麗なコードでは無い

int n, m, ans;
vector<int> pre, low;
vector<bool> used;

int dfs(const vector<vector<int>>& g, int from, int v, int count) {
	pre[v] = count++;
	low[v] = pre[v];
	used[v] = true;

	for (auto to : g[v]) {
		if (from == to) {
			continue;
		}

		if (!used[to]) {
			low[v] = min(low[v], dfs(g, v, to, count));
			ans += low[to] == pre[to];
		} else {
			low[v] = min(low[v], low[to]);
		}
	}

	return low[v];
}

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

	cin >> n >> m;

	vector<vector<int>> g(n);

	vector<int> cnt(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	pre.resize(n);
	low.resize(n);
	used.resize(n);

	dfs(g, -1, 0, 0);

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
#include<string>
using namespace std;
int main(){
string str;
getline(cin,str);
	for(int i=0;i<str.size();i++){
	if(islower(str[i]))str[i]=toupper(str[i]);
	else str[i]=tolower(str[i]);
	}
	cout<<str<<endl;
 return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}


static void ABC102C_LinearApproximation();

#if 1
int main()
{
	ABC102C_LinearApproximation();
	fflush(stdout);
	return 0;
}
#endif

static void ABC102C_LinearApproximation()
{
	int N;
	get1int(N);

	auto seqA = new LLONG[N + 1];
	auto seqB = new LLONG[N + 1];

	for (int i = 0; i < N; i++) {
		get1int<LLONG>(seqA[i]);
		seqB[i] = seqA[i] - (i + 1);
	}
	
	std::sort(seqB, seqB + N);
	LLONG center = seqB[N / 2];
	LLONG center2 = center;
	if ((N / 2 - 1) >= 0) {
		center2 = seqB[N / 2 - 1];
	}
	LLONG sad1 = 0, sad2 = 0;
	for (int i = 0; i < N; i++) {
		sad1 += tp_abs<LLONG>(seqA[i] - (center + i + 1));
		sad2 += tp_abs<LLONG>(seqA[i] - (center2 + i + 1));
	}

	printf("%lld\n", tp_min<LLONG>(sad1, sad2));

	delete[] seqA;
	delete[] seqB;
}


Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef pair<int, int> P;
typedef pair<double, P> S;
double sq(double x, double y){
  return x*x + y*y;
}
struct Edge{
  int src, dst;
  Edge(int s, int d) : src(s), dst(d) {}
};
typedef vector< vector<Edge> > Graph;
int N, M;
bool dfs(Graph& G, int u, vector<int>& to, vector<bool>& used){
  if(u < 0) return true;
  FORIT(e, G[u])if(!used[e->dst]){
    used[e->dst] = true;
    if(dfs(G, to[e->dst], to, used)){
      to[e->src] = e->dst;
      to[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int matching(Graph& G){
  vector<int> to(N + M, -1);
  int res = 0;
  for(int i = 0; i < N; i++){
    vector<bool> used(N + M, false);
    if(dfs(G, i, to, used)) res++;
  }
  return res;
}
bool C(int B, vector<S>& sv){
  Graph G(N + M);
  for(int i = 0; i <= B; i++){
    P p = sv[i].second;
    p.second += N;
    G[p.first].push_back(Edge(p.first, p.second));
    G[p.second].push_back(Edge(p.second, p.first));
  }
  if(matching(G) == M) return true;
  else return false;
}
int main(){
  while(cin>>N>>M && N){
    double tx[100], ty[100], tv[100];
    double bx[100], by[100];
    REP(i, N) cin>>tx[i]>>ty[i]>>tv[i];
    REP(i, M) cin>>bx[i]>>by[i];
    vector<S> sv;
    REP(i, N)REP(j, M){
      double d = sqrt(sq(tx[i] - bx[j], ty[i] - by[j]));
      sv.push_back(S(d / tv[i], P(i, j)));
    }
    sort(sv.begin(), sv.end());
    int lb = -1, ub = sv.size();
    while(ub - lb > 1){
      int m = (ub + lb) / 2;
      if(C(m, sv)){
        ub = m;
      }else{
        lb = m;
      }
    }
    printf("%.8lf\n", sv[ub].first);
  }
  return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

string S, T;

int main() {
	cin >> S >> T;

	reverse(S.begin(), S.end());
	reverse(T.begin(), T.end());
	for (int i = 0; i < S.size() - T.size()+1; i++) {
		int check = 1;
		for (int j = 0; j < T.size(); j++) {
			if (S[i + j] == T[j] || S[i + j] == '?')continue;
			else {
				check = 0; break;
			}
		}
		if (check) {
			for (int k = 0; k < T.size(); k++) {
				S[i + k] = T[k];
			}
			reverse(S.begin(), S.end());
			for (int i = 0; i < S.size(); i++) {
				if (S[i] == '?')S[i] = 'a';
			}
			cout << S << endl;
			return 0;
		}
	}

	cout << "UNRESTORABLE" << endl;




	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

M = 10**6
r = [0]*(M+1)
for i in a:
    r[i] += 1


isp = True
for x in range(2,M+1):
    c = sum(r[x::x])
    if c == n:
        print("not coprime")
        exit()
    if c >= 2:
        isp = False
else:
    if isp:
        print("pairwise coprime")
    else:
        print("setwise coprime")









Measured memory_bytes: 218348
#include <bits/stdc++.h>
using namespace std;
int a[1000010], b[100010];
int main()
{
    int A, B, M;
    scanf("%d%d%d", &A, &B, &M);
    int ans = 0;
    int mia = 1e9, mib = 1e9;
    for (int i = 1; i <= A; i++)
    {
        scanf("%d", &a[i]);
        mia = min(mia, a[i]);
    }
    for (int i = 1; i <= B; i++)
    {
        scanf("%d", &b[i]);
        mib = min(mib, b[i]);
    }
    ans = mia + mib;
    int aa, bb, cc;
    for (int i = 1; i <= M; i++)
    {
        scanf("%d%d%d", &aa, &bb, &cc);
        ans = min(a[aa] + b[bb] - cc, ans);
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int kto[11][11];//kogo zapalam jak sie wlacze
bool stan[11];
int n,m;

void dane() {
	cin>>n>>m;
	F(i,0,m) {
		int ile;
		cin>>ile;
		F(j,0,ile) {
			int b;
			cin>>b;
			kto[b-1][i] = true;
		}
	}
	F(i,0,m) {
		int a;
		cin>>a;
		stan[i] = a==1;
	}

	int ans = 0;
	F(wlacz,0,(1<<n)) {
		int* dod = new int[11];
		//sprobj wszystkie
		int temp = 1;
		int idx = 0;
		while(idx != n) {
			//cout<<wlacz<<" "<<temp<<" "<<(wlacz & temp)<<endl;
			if((wlacz & temp) != 0) {
				F(i,0,m) {
					if(kto[idx][i] == true) { dod[i]++; }
				}
			}
			temp*=2;
			idx++; 
		}
		//sprawdz dzy dziala
		bool dziala = true;
		F(i,0,m) {
			int war = (stan[i]==true?1:0) + dod[i];
			//cout<<"DOD : "<<war<<endl;
			if(war % 2 ==1) dziala = false;
		}
		//cout<<"PROBUJE : "<<wlacz<<" "<<dziala<<endl;
		if(dziala) ans++;
	}
	cout<<ans<<endl;
}    


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

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

int main() {
	int r, g, b;
	cin >> r >> g >> b;

	int n = 100 * r + 10 * g + b;

	if (n % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int H,W;
vector<string> s;
bool seen[400][400];

void dfs(int h, int w, int &black, int &white){
  seen[h][w] = true;
  if(s[h][w] == '#') black++;
  else white++;

  rep(dir,4) {
    int nh = h + dh[dir];
    int nw = w + dw[dir];
    if(nh < 0 || nh == H || nw < 0 || nw == W) continue;
    if(seen[nh][nw]) continue;
    if(s[h][w] == s[nh][nw]) continue;
    dfs(nh, nw, black, white);
  }
}

int main(){
  cin >> H >> W;
  s.resize(H); rep(h,H) cin >> s[h];
  memset(seen, false, sizeof(seen));

  ll ans = 0;
  rep(h,H) rep(w,W) {
    if(seen[h][w]) continue;
    int black = 0, white = 0;
    dfs(h,w,black, white);
    ans += (ll)black*white;
  }

  cout << ans << endl;


}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 998244353;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N+1,0);
    for(int i=1;i<=N;i++){
        cin >> A[i];
        A[i] += A[i-1];
    }
    ll ans = INF;
    for(int i=1;i<N;i++){
        ans = min(ans,abs(A[i]-(A[N]-A[i])));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
// d.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N, C;
	cin >> N >> C;
	vector<vector<int>> d(C);
	vector<vector<int>> c(N);

	for (int i = 0; i < C; ++i) {
		d[i] = vector<int>(C);
		for (int j = 0; j < C; ++j) {
			cin >> d[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		c[i] = vector<int>(N);
		for (int j = 0; j < N; ++j) {
			cin >> c[i][j];
		}
	}
	vector<vector<int>> s(3);
	for (int i = 0; i < 3; ++i) {
		s[i] = vector<int>(C);
		for (int j = 0; j < C; ++j)
			s[i][j] = 0;
	}
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			for (int k = 0; k < C; ++k)
				s[(i + j) % 3][k] += d[c[i][j] - 1][k];
	long long m = 500 * 500 * 1000;
	for (int i = 0; i < C; ++i)
		for (int j = 0; j < C; ++j)
			for (int k = 0; k < C; ++k)
				if (i != j && j != k && k != i)
					m = ((m < s[0][i] + s[1][j] + s[2][k]) ? m : s[0][i] + s[1][j] + s[2][k]);
	cout << m << endl;
	return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;
LL a[maxn],k;
LL cut[maxn];
int n;
LL L=1,R=0;
 
bool check(LL t){
	LL cnt=0;
	for(int i=1;i<=n;i++){
		cut[i]=(a[i]/t)-1+(a[i]%t>0);
		cnt+=cut[i];
	}
	if(cnt<=k)return 1;
	else return 0;
}
 
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)R=max(R,a[i]);
	R++;
	while(L+1<R){
		LL mid=L+R>>1;
	//	cout<<L<<" "<<R<<" "<<mid<<endl;
		if(check(mid))R=mid;
		else L=mid;
	}
	if(check(L))cout<<L<<endl;
	else cout<<R<<endl;
}

Measured memory_bytes: 6720
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
 
int L[(MAX/2)+2],R[(MAX/2)+2];
int cnt;
 
void merge(int[],int,int,int);
void mergeSort(int[],int,int);
 
 
int main()
{
  int A[MAX],n,i;
  cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  
 
  for(i=0;i<n-1;i++){
   printf("%d ",A[i]);
  }
   printf("%d\n",A[n-1]);
   printf("%d\n",cnt);
 
  return 0;
}
 
void merge(int A[],int left,int mid,int right)
{
  int i,j,k;
 
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++){
  L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
  R[i]=A[mid+i];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
      cnt++;
      if(L[i]<=R[j]){
        A[k]=L[i];
	i+=1;
      }
      else {
      A[k]=R[j];
      j+=1;
      }
    }
}
 
void mergeSort(int A[],int left,int right)
{
  int mid;  
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4504
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
  
  const [A, B, C, X, Y] = input.trim().split(' ').map(Number)
  
  const c1 = A * X + B *Y
  const c2 = C * Math.max(X,  Y)  * 2
  const c3 = A * Math.max(X - Y, 0) + B * Math.max(Y - X, 0) + C * Math.min(X,  Y)  * 2
  
  console.log(Math.min(c1, c2, c3))
  
})(input)


Measured memory_bytes: 29568
#include<bits/stdc++.h>
using namespace std;
const long long a=(1e9);
long long s;
int main()
{
	cin>>s;
	cout<<"0 0 1 "<<a<<" ";
	if(s==(1e18))
	{
		cout<<a<<" "<<0<<endl;
		return 0;
	}
	long long n=s/a,b=s%a;
	cout<<n+1<<" "<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
x = gets()
y = x.split()
h = y[0].to_i
w = y[1].to_i

until h == 0 && w ==0
 i = 1
 while i <= h
  if i % 2 == 1
   if w % 2 ==1
    k = "#" * ((w + 1) / 2)
    s = k.split("")
    puts s.join(".")
   else
    puts "#." * (w / 2)
   end
   i += 1
  else
   if w % 2 ==1
    k = "." * ((w + 1) / 2)
    s = k.split("")
    puts s.join("#")
   else
    puts ".#" * (w / 2)
   end
   i += 1
  end
 end
 puts ""
 x = gets()
 y = x.split()
 h = y[0].to_i
 w = y[1].to_i
end 



Measured memory_bytes: 7068
import math
import numpy as np
a,b,x = map(int,input().split())
d = x/a
if d > a*b/2:
    e = (a*b-d)*2/a
    print(math.degrees(math.atan(e/a)))
else:
    e = d*2/b
    print(math.degrees(math.atan(b/e)))
    

Measured memory_bytes: 12396
#include <bits/stdc++.h>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N, T;
const int MAX_N = 1000;
int c[MAX_N], t[MAX_N];

int main() {
    cin >> N >> T;
    for (int i = 0; i < N; i++) cin >> c[i] >> t[i];
    int ans = INF;
    for (int i = 0; i < N; i++) {
        if (t[i] <= T && c[i] < ans) ans = c[i];
    }
    if (ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int N, X;
	cin >> N >> X;
	int m[1000];
	int min = 100001;

	for (int i = 0; i < N; i++){
		cin >> m[i];
		X -= m[i];
		if (min > m[i]){
			min = m[i];
		}
	}

	cout << N + X / min << endl;

	return 0;

}

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

signed main(){
  int N,M,WA=0,AC=0;
  cin>>N>>M;
  vector<int> ac(N),wa(N);
  rep(i,M){
    int prob;
    string check;
    cin>>prob>>check;
    prob-=1;
    if(ac[prob])continue;
    if(check=="AC"){
      ac[prob]=1;
    }else{
      wa[prob]+=1;
    }
  }
  rep(i,N){
    AC+=ac[i];
    if(ac[i])WA+=wa[i];
    //正解してない問題はペナにならんのではじく。
  }
  cout<<AC<<" "<<WA<<endl;
  return 0;
}

Measured memory_bytes: 4840
def main():
    n = int(input())
    a = ord("a")
    orda = lambda x: ord(x)-a
    s = list(map(orda, list(input())))
    q = int(input())
    bits = [BIT(n) for _ in range(26)]
    for i, si in enumerate(s, 1):
        bits[si].add(i, 1)
    for _ in range(q):
        t, i, c = input().split()
        i = int(i)
        if t == "1":
            bits[s[i-1]].add(i, -1)
            bits[ord(c)-a].add(i, 1)
            s[i-1] = ord(c)-a
        else:
            c = int(c)
            cnt = 0
            for bit in bits:
                is_in = bit.sum_(c) - bit.sum_(i-1)
                if is_in:
                    cnt += 1
            print(cnt)
            
            
class BIT:
    __slots__ = ["length", "data"]
    def __init__(self, length):
        self.data = [0]*(length+1)
        self.length = length
    
    def add(self, i, x):
        while i < self.length+1:
            self.data[i] += x
            i += i&-i
    
    def sum_(self, i):
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i&-i
        return x


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;







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


	return 0;

}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';				

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const int N = 1e5;
const int INF = 1e9;
int n;
vector<int> g[N];
bool vis[N];
int dp[N];
int in[N];
vector<int> topo;

void dfs(int v){
	if(vis[v])
		return;	
	vis[v] = 1;
	for(int x : g[v]){
		if(!vis[x])
			dfs(x);
	}
	topo.push_back(v);
}

void topological_sort(){
	for(int i = 0;i < n;i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	reverse(all(topo));
}

int main(){

	int m;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int u,v;
		cin >> u >> v;
		u--;v--;
		g[u].push_back(v);
		in[v]++;
	}
	fill(vis, vis + n, 0);
	topological_sort();

	fill(dp, dp + n, -INF);

	for(int i = 0;i < n;i++){
		if(in[i] == 0)
			dp[i] = 0;
	}

	for(int x : topo){
		if(dp[x] != -INF){
			for(int y : g[x]){
				if(dp[y] < dp[x] + 1){
					dp[y] = 1 + dp[x];
				}
			}
		}
	}
	int ans = -INF;

	for(int i = 0;i < n;i++){
		ans = max(ans, dp[i]);
	}
	cout << ans << '\n';

}

Measured memory_bytes: 9208
def main():
  n = int(input())
  t = [0] * n
  x = [0] * n
  y = [0] * n
  for i in range(n):
    t[i], x[i], y[i] = map(int, input().strip().split())
  
  ct = 0
  cx = 0
  cy = 0
  for nt, nx, ny in zip(t, x, y):
    diff = abs(nx - cx) + abs(ny - cy)
    if diff > nt or (diff - (nt - ct)) % 2 == 1:
      print('No')
      return
    ct, cx, cy = nt, nx, ny
  print('Yes')


if __name__ == '__main__':
  main()


Measured memory_bytes: 11636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a,b;
        
        a = sc.nextInt();
        b = sc.nextInt();
        
        if(b * 2 >= a){
            System.out.println(0);
        }else{
            System.out.println(a - (b * 2));
        }
        
    }
}

Measured memory_bytes: 22484
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, A[SIZE], Q;
  int counter[SIZE];

  scanf("%d", &N);

  ll sum = 0;

  for (int i = 0; i < N; i++) {
    scanf("%d", A + i);
    sum += A[i];
    counter[A[i]]++;
  }

  scanf("%d", &Q);

  for (int i = 0; i < Q; i++) {
    int B, C;
    scanf("%d%d", &B, &C);
    sum += (ll)(C - B) * counter[B];
    counter[C] += counter[B];
    counter[B] = 0;
    printf("%lld\n", sum);
  }

  return 0;
}


Measured memory_bytes: 4588
#include<iostream>
using namespace std;
#define m long long
#define d(s,i,n) for(m i=s;i<n;i++)
#define z else
m l[90][90],r[90][90];
int main(){m n;cin>>n;d(0,i,89){l[i][0]=1,r[i][0]=1;d(1,j,90){if(i==j)r[i][j]=r[i][j-1]*2+l[i][j-1];z r[i][j]=r[i][j-1]+l[i][j-1];l[i][j]=r[i][j-1];}}d(0,i,n){m a,b; cin>>a>>b;if(b>a)swap(a,b);m k=0;d(0,j,90)if(a>=r[0][j]&&b>=l[0][j])k=j;m g;if(k==0)k=1,g=1;z if(k==1)if(b==1)g=a;z g=4;z{g=1;if(b>=r[0][k]&&a>=l[0][k]&&l[0][k]<r[0][k])g++;d(1,j,k+1)if(r[j][k]<=a&&l[j][k]<=b)g+=1+(a-r[j][k])/l[j][k];d(1,j,k+1)if(r[j][k]<=b)g+=1+(b-r[j][k])/l[j][k];}cout<<k<<" "<<g%1000000007<<" ";}}	

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

using namespace std;

long d[1111111], m[1111111], dm[1111111];
int main() {
	int n, q;
	string s;
	cin >> n >> s >> q;
	for (int i = 0; i < n; i++)
		d[i + 1] = d[i] + (s[i] == 'D'), m[i + 1] = m[i] + (s[i] == 'M'),
		dm[i + 1] = dm[i] + d[i] * (s[i] == 'M');
	for (int i = 0; i < q; i++) {
		int k;
		cin >> k;
		k--;
		long r = 0;
		for (int j = 2; j < n; j++) {
			if (s[j] != 'C') continue;
			int l = max(0, j - k);
			r += dm[j] - dm[l] - d[l] * (m[j] - m[l]);
		}
		cout << r << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 26500
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

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

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	vector<int> P(N);
	REP(i,0,N) cin >> P[i];
	vector<int> dp(N,INF);
	dp[0]=0;
	REP(i,0,N){
		int pos=i;
		while(P[pos]!=0){
			if(dp[pos+P[pos]]<=dp[pos]) break;
			dp[pos+P[pos]]=dp[pos];
			pos+=P[pos];
		}
		if(pos<i) i=pos;
		if(P[i]==0){
			REP(j,1,7){
				if(i+j>=N) continue;
				dp[i+j]=min(dp[i+j],dp[i]+1);
			}
		}
	}
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define lli long long int
#define test                lli t;cin>>t;while(t-->0)
#define ainput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define vec vector<lli>v;
vec
#define avinput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];v.push_back(a[i]);}
#define vp  for(lli i=0;i<v.size();i++) {cout<<v[i]<<" ";}cout<<endl;
#define vp1  for(lli i=0;i<v1.size();i++) {cout<<v1[i]<<" ";}cout<<endl;
#define vp2  for(lli i=0;i<v2.size();i++) {cout<<v2[i]<<" ";}cout<<endl;
#define vp3  for(lli i=0;i<v3.size();i++) {cout<<v3[i]<<" ";}cout<<endl;
#define vp6  for(lli i=0;i<v6.size();i++) {cout<<v6[i].first<<" "<<v6[i].second<<endl;}
#define vp16  for(lli i=0;i<v16.size();i++) {cout<<v16[i].first<<" "<<v16[i].second<<endl;}
#define ln cout<<endl;
  //cout << fixed << setprecision(10) <<((double)((sum*1.0)/((n*1.0-k*1.0)+1.0))) << endl;
set<lli>s1;
set<lli>s2;
set<string>st2;
vector<lli>v1;
vector<lli>v2;
vector<lli>v3;
vector<lli>v4;
vector<lli>v5;
vector<pair<lli,lli> >v6;
vector<pair<lli,lli> >v16;
vector<string>v7;
vector<string>v8;
vector<char>v9;
vector<double>v11;
list<lli>l;
//****coding start****
int main(){
lli n;cin>>n;
lli a[n],b[n],c[n-1],d[n+1];
for(lli i=0;i<n;i++){
    cin>>a[i];
}
for(lli i=0;i<n;i++){
    cin>>b[i];
}
for(lli i=0;i<n-1;i++){
    cin>>c[i];
}
for(lli i=0;i<n+1;i++){
    d[i]=0;
}
lli sum=0;
for(lli i=0;i<n;i++){
        //d[a[i]]=1;
    sum=sum+b[a[i]-1];
    if(i>0&&a[i]==a[i-1]+1){
        sum=sum+c[a[i-1]-1];
    }
}
cout<<sum<<endl;
return 0;
}

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

#define ll long long int

const ll MAX = (ll)1e11 + 1ll;

bool check(ll b,ll n, ll s){
		ll sum = 0;
		while(n != 0){
				sum += n % b;
				n /= b;
		}
		if(sum == s)
			return true;
		else 
			return false;
}
int main(){
    ios_base::sync_with_stdio(false) , cin.tie(0) ,cout.tie(0);
	
	ll n,s;
	cin>>n>>s;
	
	if(n == s){
			cout<<(n+1);
			return 0;
	}
	else if(s > n){
			cout<<-1;
			return 0;
	}else{
			ll diff =  n - s;
			ll ans = MAX;
			ll sqr = (ll)(sqrt((double)diff));
			for(ll i=1;i<=sqr;i++){
					if(diff % i == 0){
						if(check(i+1,n,s))
							ans = min(ans , i+1);
						if(check(diff / i + 1 , n, s))
							ans = min(ans , diff/i+1);
					}
			} 
			
			if(ans == MAX){
				cout<<-1;
			}else
				cout<<ans;
				
	}
	return 0;
} 


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);
        if (a % 2 == 0 || b % 2 == 0)
        {
            Console.WriteLine("Even");
        }
        else
        {
            Console.WriteLine("Odd");
        }
    }
}


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

using namespace std;

int main()
{
  int n;
  scanf("%d", &n);
  while(n--){
    string s;
    cin >> s;
    int cnt = 0;
    while(s.size() > 1){
      int a = s[0] - '0' + s[1] - '0';
      if(a / 10 != 0) s[0] = a / 10 + '0', s[1] = a % 10 + '0';
      else{
	s[1] = a + '0';
	s = s.substr(1, s.size());
      }
      cnt++;
    }
    if(cnt % 2 != 0) puts("Fabre wins.");
    else puts("Audrey wins.");
  }
  
  return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

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

    vector<string> slist(N);
    for (ll i = 0; i < N; i++)
        cin >> slist[i];

    sort(slist.begin(), slist.end());
    ll ans = std::distance(slist.begin(), unique(slist.begin(), slist.end()));

    printf("%lld", ans);
}


Measured memory_bytes: 9620