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

const int N = 200000;

struct Point{ int id, x, y; } p1[N+5], p2[N+5];

int main(){
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i){
        p1[i].id = i;
        scanf("%d %d", &p1[i].x, &p1[i].y);
    }
    memcpy(p2, p1, (n+2) * sizeof(Point));
    sort(p1 + 1, p1 + n + 1, [](const Point &a, const Point &b){ return a.x + a.y < b.x + b.y; });
    sort(p2 + 1, p2 + n + 1, [](const Point &a, const Point &b){ return a.x - a.y < b.x - b.y; });
    int ans = 0;
    for (int i = 1; i <= n; ++i){
        if (p1[1].id != p1[i].id){
            ans = max(ans, abs(p1[i].x - p1[1].x) + abs(p1[i].y - p1[1].y));
        }
        if (p1[n].id != p1[i].id){
            ans = max(ans, abs(p1[i].x - p1[n].x) + abs(p1[i].y - p1[n].y));
        }
        if (p2[1].id != p1[i].id){
            ans = max(ans, abs(p1[i].x - p2[1].x) + abs(p1[i].y - p2[1].y));
        }
        if (p2[n].id != p1[i].id){
            ans = max(ans, abs(p1[i].x - p2[n].x) + abs(p1[i].y - p2[n].y));
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 8480
#include <iostream>

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;

    int five = 0;
    int seven = 0;

    if(a == 5) {
        five++;
    } else if(a == 7) {
        seven++;
    }

    if(b == 5) {
        five++;
    } else if(b == 7) {
        seven++;
    }

    if(c == 5) {
        five++;
    } else if(c == 7) {
        seven++;
    }

    if(five == 2 && seven == 1) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 256
N = int(input())
S = input()

flag = 1

if N % 2 == 1:
    print("No")

else:
    n = N//2

    for i in range(n):
        if S[i] != S[n+i]:
            flag = 0
            break

    print("Yes" if flag == 1 else "No")

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

int main(void) {

  int n;
  int sum = 0;
  cin >> n;
  vector<int> vec(n);

  for (int i = 0; i < vec.size(); i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  vec.at(0) /= 2;

  for (int i = 0; i < vec.size(); i++) {
    sum += vec.at(i);
  }

  cout << sum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
//static const ll MOD=1e9+7;
static const ll MOD=998244353;
//for(i=0; i<N; i++) cin >> a[i];


int main() {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[MAX];
  map<ll, ll> mp;
  ll s=0;
  for(i=0; i<N; i++) {
    cin >> a[i];
    s+=a[i];
    mp[a[i]]++;
  }
  
  ll Q;
  cin >> Q;
  for(i=0; i<Q; i++) {
    ll b, c;
    cin >> b >> c;
    
    s+=(c-b)*mp[b];
    mp[c]+=mp[b];
    mp[b]=0;
    pt(s);
  }
  
  
}




Measured memory_bytes: 10208
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

int a[100000];
int d[100000];

int main(void){
    int n; cin >> n; for(int i = 0;i < n;i++)cin >> a[i];
    fill(d, d + n, -2);
    for(int i = 0;i < n;i++){
        *(lower_bound(d, d + n, a[i]) - 1) = a[i];
    }
    printf("%d\n", n - (lower_bound(d, d + n, -1) - d));
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;

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

int main() {
  int n;
  cin >> n;
  REP(datan,n) {
    if (datan) cout << endl;
    int ba[9][9];
    REP(y,9)
      REP(x,9)
      cin >> ba[x][y];
    multiset<int> block[3][3];
    multiset<int> yoko[9];
    multiset<int> tate[9];
    REP(i,3)
      REP(j,3)
        for (int x = i*3; x<(i+1)*3; x++)
          for (int y = j*3; y<(j+1)*3; y++)
            block[i][j].insert(ba[x][y]);
    REP(i,9) {
      REP(x,9)
        yoko[i].insert(ba[x][i]);
      REP(y,9)
        tate[i].insert(ba[i][y]);
    }
    REP(y,9) {
      REP(x,9) {
        int a = ba[x][y];
        if (block[x/3][y/3].count(a) > 1 || yoko[y].count(a) > 1 || tate[x].count(a) > 1)
          cout << "*";
        else
          cout << " ";
        cout << a;
      }
      cout << endl;
    }
  }
}

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

int comp(const void *a,const void *b){
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return -1;
  if (*A < *B) return 1;
  return 0;
}

int main()
{
    int N,M;
    scanf("%d%d",&N,&M);
    long long x[N],y[N],z[N];
    long long sum=0,max=-1;
    int i,j,k,l;
    for(i=0;i<N;i++){
        scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
    }

    for(i=-1;i<=1;i+=2){
        for(j=-1;j<=1;j+=2){
            for(k=-1;k<=1;k+=2){
                sum = 0;
                long long a[N];
                for(l=0;l<N;l++){
                    a[l] = i*x[l] + j*y[l] + k*z[l];
                }
                qsort(a,N,sizeof(long long),comp);
                for(l=0;l<M;l++){
                    sum += a[l];
                }
                if( sum > max ){
                    max = sum;
                }
            }
        }
    }

    printf("%lld\n",max);

    return 0;
}

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

int main() {
	int n,ans = 0;
	vector<int> a(200010,0),b(200010,0);
	cin >> n;
	for (int i = 0;i < n;++i) cin >> a[i];
	for (int i = 0;i < n;++i) cin >> b[i];

	for (int i = 29;i > 0;--i) {
		int cnt = 0;
		int T = (1 << i-1);
		for (int j = 0;j < n;++j) b[j] %= 2*T;
		sort(b.begin(),b.begin()+n);
		for (int j = 0;j < n;++j) {
			a[j] %= 2*T;
			cnt += lower_bound(b.begin(),b.begin()+n,2*T-a[j])-lower_bound(b.begin(),b.begin()+n,T-a[j]);
			cnt += lower_bound(b.begin(),b.begin()+n,4*T-a[j])-lower_bound(b.begin(),b.begin()+n,T*3-a[j]);
			cnt %= 2;
		}
		if (cnt) ans += T;
	}

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

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

int main() {
    const vector<ll> dama{10000, 5000, 1000};
    cin >> N >> Yen;
    rep(x,N)rep(y,N-x){
        ll z = N - x - y;
        if (x*dama[0] + y*dama[1] + z*dama[2] == Yen) {
            cout << x << " " << y << " " << z << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a+b) cout<<min(k,a);
	else cout<<a-(k-a-b);	
	return 0;
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;


int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    string str;
    cin >> str;
    int ans = str.size() - 1;
    forn(i, 'a', 'z') {
        string s = str;
        int cnt = 0;
        for (auto c : s)
            if (c == char(i)) ++cnt;
        if (cnt == 0) continue;
        int cur = 0;
        for (;; ++cur) {
            cnt = 0;
            for (auto c : s)
                if (c == i) ++cnt;
            if (cnt == s.size()) break;
            string t = s;
            t.pop_back();
            forn(j, 0, t.size() - 1)
                if (s[j] == i || s[j + 1] == i) t[j] = i;
            s = t;
        }
        ans = min(ans, cur);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define MOD 1000000007
using namespace std;

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

    int n,k;
    cin >> n >> k;
    int height[n+1];
    height[0]=0;
    for (int i=1;i<=n;i++)
    {
        cin >> height[i];
    }

    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    for (int i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for (int j=1;j<=k;j++)
        {
            if (i-j>=1)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(height[i]-height[i-j]));
            }
            else
            {
                break;
            }
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

// #define NMAX 1000000000
int N;
vi A;

void solve(){
	vvi ans(N+1,vi());

	rp(i,2,N+1){
		int ai = A[i];
		ans[ai].push_back(i);
	}
	rp(i,1,N+1){
		cout<<ans[i].size()<<"\n";
		// if(i<N-1) cout<<"\n";
		// else cout<<"\n";
	}
}

int main(){
	cin>>N;

	A.resize(N+1);
	rp(i,2,N+1) cin>>A[i];
	solve();
}


Measured memory_bytes: 14720
from fractions import gcd
from functools import reduce

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

if n == 1:
    print("POSSIBLE" if k == a[0] else "IMPOSSIBLE")
else:
    g = reduce(gcd, a)
    print("POSSIBLE" if k % g == 0 and k <= max(a) else "IMPOSSIBLE")


Measured memory_bytes: 16280
import java.math.*;
import java.util.*;

public class Main {
    static int sol(int n) {
        if (n == 1) {
            return 0;
        }
        else {
            int tmp = n * (n - 1);
            return tmp / 2;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 0;
        ans = sol(n) + sol(m);
        System.out.println(ans);
        }
    }

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<cstring>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	int n;cin >> n;
	vector<int> v(n);
	int cou = 0;
	REP(i,n)
	{
		cin >> v[i];
		if(v[i]%2 == 1)cou++;
	}
	
	if(cou % 2 == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	map<int, int>num;
	int ans = 0;
	for (int i = 0;i < n;i++) {
		long long x;
		cin >> x;
		if (x > n)ans++;
		else num[x-1]++;
	}
	for (int i = 0;i < n;i++) {
		if (num[i] > i + 1)ans += num[i] - i - 1;
		if (num[i] < i + 1)ans += num[i];
	}
	cout << ans << endl;
}



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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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



int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,k;
    cin>>n>>k;

    vector<int> a(n,0);


    rep(i,n){
        cin>>a[i];
    }

    int newT = k;
    while(newT < n){
        if(a[newT] > a[newT-k]){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}

        ++newT;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 3836
#include<iostream>

#define secondMAX (23*60*60+59*60+59)
using namespace std;

int main(){

	int n;
	int h,m,s;
	char gav;
	int table[secondMAX+1];
	int max;

	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<=secondMAX;i++) table[i]=0;
		for(int i=0;i<n;i++){
			cin>>h>>gav>>m>>gav>>s;
			table[h*60*60+m*60+s]+=1;
			cin>>h>>gav>>m>>gav>>s;
			table[h*60*60+m*60+s]-=1;
		}
		for(int i=1;i<=secondMAX;i++) table[i]+=table[i-1];
		max=0;
		for(int i=0;i<=secondMAX;i++){
			if(max<table[i]) max=table[i];
		}

		cout<<max<<endl;
	}

	return 0;
}

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

int main() {
  
    string S;

    cin >> S;

    if(S[0]!=S[1] && S[0]!=S[2] && S[1]!=S[2]) {
      
      cout << "Yes" << endl;
     
    } else {
      
      cout << "No" << endl;

    }
  
}


Measured memory_bytes: 256
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}

int main()
{
	fast;
	ll n,k;cin>>n>>k;
	ll a[n+1],dp[n+1];
    for(ll i=0;i<n;i++)cin>>a[i];
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
        dp[i]=1e18;
        for(ll j=1;j<=k;j++)
        {
            ll p=i-j;
            if(p<0)break;
            dp[i]=min(dp[i],dp[p]+abs(a[p]-a[i]));
        }
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
def p(n):
    import math
    a = math.floor(n**(1/2))
    if n == 2:
        return n
    elif n == 1:
        return 1
    elif n%2 == 0:
        return 1
    else:
        for i in range(3,a+1):
            if n%i == 0:
               return 1
    return n
N = int(input())           
c = 0
for i in range(N):
    n = int(input())
    if p(n) != 1:
        c += 1
print(c)



Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <limits.h>
#include <math.h>

double check(int n, int k, int a)
{
    double ans;
    // 最初にa点がでた
    ans = 1;
    while(a < k) {
        ans /= 2;
        a *= 2;
    }

    return ans;
}

int main(int argc, char *argv[])
{
    int n, k;
    int i;
    double ans;

    scanf("%d %d", &n, &k);

    ans = 0;

    for (i = 1; i <= n; i++) {
        ans += check(n, k, i) / n;
    }

    printf("%.12f\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <math.h>
#include <vector>
#include <stdio.h>

/*   #include <complex>
complex p(0.0, 0.0);   // 初期化
    // 演算  p + q, p - q, p * 2.0
    // リテラル  complex(1.0, 1.0)
    // リテラル(極座標)  polar(r, a)  長さr, x軸となす角a
	// なす角  angle(p)  pとx軸のなす角
	// なす角  angle(p / q)  pとqのなす角
p.real() = 2.0;
p.imag() = 1.0;   // x, y座標

    // 長さ  abs(p), norm(p)
	// ベクトル回転  p * polar(1.0, M_PI / 2)
*/

using namespace std;

typedef complex<double> Point;    // 座標型

// 座標ソート
bool xycomp(const Point &a, const Point &b){
	if(a.real() != b.real())
		return a.real() < b.real();
	return a.imag() < b.imag();
}


// 偏角と長さでソート
bool argcomp(const Point &a, const Point &b){
	double aa = arg(a) < 0.0 ? 2 * M_PI - arg(a) : arg(a);
	double bb = arg(b) < 0.0 ? 2 * M_PI - arg(b) : arg(b);
	if(aa != bb)
		return aa < bb;
	return abs(a) < abs(b);
}



double dot(Point a, Point b){     // 内積
	return real(conj(a) * b);
}

double cross(Point a, Point b){   // 外積  |a||b|sinθ
	return imag(conj(a) * b);
}

// 三角形の面積  ||v||u|sinθ/ 2| = abs(cross(v, u) / 2)

    // 多角形の面積
double area(vector<Point> poly){    //poly[] 多角形の頂点
	int n = poly.size();
	double a = 0.0;
	
	for(int i = 0; i < n; i++){
		
		a += cross(poly[i], poly[(i + 1)%n]) / 2;
	}
	
	return abs(a);
}


/*   // 多角形の外接円
Point circumcircle(Point poly[]){
	Point c = Point(0.0, 0.0);
	double ratio = 0.5;
	
	for(int k = 0; k = 100; k++){
		for(int i = 0; i < 100; i++){
			Point p = ;// 一番離れている点
			c += (p - c) * ratio;
		}
		ratio *= 0.5;
	}
	return c;
}
*/


int main(){
	while(1){
		int m;
		cin >> m;
		if(m == 0)
			break;
		
		vector<int> v1(m);
		for(int i = 0; i < m-1; i++)
			cin >> v1[i];
		
		int n;
		cin >> n;
		
		vector<int> v2(n);
		for(int i = 0; i < n-1; i++)
			cin >> v2[i];
		
		vector<Point> p1(m);
		
		p1[0] = Point(1.0, 0);
		
		for(int i = 1, j =0; i < m; i++){
			j += v1[i - 1];
			p1[i] = polar(1.0, j * M_PI / 180);
		}
		
		double s1 = area(p1);
		
		
		
		vector<Point> p2(n);
		
		
		
		p2[0] = Point(1.0, 0);
		
		for(int i = 1, j =0; i < n; i++){
			j += v2[i - 1];
			p2[i] = polar(1.0, j * M_PI / 180);
		}
		
		double s2 = area(p2);
		
		if(s1 == s2)
			puts("0");
		else if(s1 > s2)
			puts("1");
		else
			puts("2");
	}
	
	return 0;
}

Measured memory_bytes: 1164
let s = read_line ()
let k = ref @@ read_int ()
let f c = Char.(chr @@ (code c - 97 + !k) mod 26 + 97)
let _ = String.(mapi (fun i c -> let d = 123 - Char.code c in if i = length s - 1 then f c else if d <= min 25 !k then (k := !k - d; 'a') else c) s) |> print_endline

Measured memory_bytes: 2816
//@author Khaled Alam(Ninjo) ~ KhaledAlam.net
#include <bits/stdc++.h>
#include<iomanip>
using namespace std;
// v0.0.1  |  Github.com/khaledalam/templates/tree/master/cpp
typedef long long ll;
typedef vector<int> vi;
typedef stringstream ss;
typedef pair<int, int> pii;
//#########################
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define out(x)       return cout<<x,0
#define all(x)       x.begin(),x.end()
#define sz(x)        ((int)(x.size()))
#define clr(x)       memset(x,0,sizeof x)
#define rep(i,n)     for(int i=0;i<n;i++)
#define ifile(x)     freopen(#x,"r",stdin)
#define ofile(x)     freopen(#x,"w",stdout)
#define pin0(x)      size_t x = time(NULL)
#define pin1(x)      fprintf(stderr,"time: %.2fs\n",(float)time(NULL)-x)
#define foreach(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();i++)
#define ios          ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define val(x)       cerr<<"[l#: "<<__LINE__<<"] "<< " "<<#x<<" = "<<x<<endl
//##########################################################################

#define MAXN 101
int n, m;
int main()
{
	ios;
//	ifile(input.txt); //ofile(output.txt);

	int a,b,c;
	cin>>a>>b>>c;
	cout<< (a == b ? c : (a == c ? b: a));
	

}


Measured memory_bytes: 256
var a,b,c:longint;
begin
  readln(a,b,c);
  writeln(a,' ',b,' ',-a-b+3*c);
  writeln(-2*a-b+4*c,' ',c,' ',2*a+b-2*c);
  writeln(a+b-c,' ',-b+2*c,' ',-a+2*c);
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i = 1; i < s.size(); i++){
    if(s[i-1] == s[i]){ cout << "Bad" << endl; return 0;}
  }
  cout << "Good" << endl;
}

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

using namespace std;

#define INF 1e18
#define ll long long
ll n, a, b, c, d;
vector<ll> x;
vector<ll> co;
map<ll, ll> mp;
ll dp[7];

void gen()
{
    dp[1] = d;
    dp[2] = min(2*d, d+a);
    dp[3] = min(3*d, 2*d+a);
    dp[3] = min(dp[3], d+b);
    dp[3] = min(dp[3], 3*d+c);
    dp[4] = min(4*d, d+2*a);
    dp[4] = min(dp[4], 2*d+b);
    dp[4] = min(dp[4], 2*d+c);
}

ll nows(ll x, ll inc)
{
    if(x == 1) return d;
    ll mins = INF;
    if(x%2 == 0) mins = min(mins, nows(x/2, inc)+a);
    if(x%3 == 0) mins = min(mins, nows(x/3, inc)+b);
    if(x%5 == 0) mins = min(mins, nows(x/5, inc)+c);
    mins = min(mins, nows(x-1, inc)+d);
    if(inc > 0) mins = min(mins, nows(x+1, inc-1)+d);
    return mins;
}

ll mul(ll a, ll b)
{
    if(a >= INF/b) return INF;
    return (a*b);
}

ll calc(ll n)
{
    if(n == 0) return 0;
    if(n == 1) return d;
    if(mp.find(n) != mp.end()) return mp[n];
    ll mins = mul(n, d);
    for(int i=0; i<x.size(); i++){
        ll p = x[i], cost = co[i];
        if(n%p == 0){
            ll newN = n/p;
            mins = min(mins, cost+calc(newN));
            newN = (n+p)/p;
            if(newN < n) mins = min(mins, min(mul(n-newN, d), cost)+calc(newN)+p*d);
        }
        else if(n < p){
            ll hi = p - n%p;
            ll newN = (n+hi)/p;
            mins = min(mins, min(mul(n-newN, d), cost)+calc(newN)+hi*d);
        }
        else {
            ll lo = n%p;
            ll hi = p - lo;
            ll newN1 = (n-lo)/p;
            mins = min(mins, min(mul(n-newN1, d), cost)+calc(newN1)+lo*d);
            ll newN2 = (n+hi)/p;
            mins = min(mins, min(mul(n-newN2, d), cost)+calc(newN2)+hi*d);
        }
    }
    //cout << n << " " << mins << endl;
    return mp[n] = mins;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    int cases;
    scanf("%d", &cases);
    while(cases--){
        scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
        for(int i=1; i<=6; i++){
            dp[i] = nows(i, 4);
        }
        x = {2, 3, 5};
        co = {a, b, c};
        ll ans = calc(n);
        cout << ans << endl;
        mp.clear();
    }
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k, a[305][305][305], ans;
char s[305];
int main(){
	scanf("%s\n%d", s, &k);
	n = (int)strlen(s);
	rep(i,n) rep(j,n-1-i) rep(l,k+1){
		if(s[i] == s[n-1-j]) a[i+1][j+1][l] = a[i][j][l] + 1;
		else a[i+1][j+1][l] = max({a[i][j+1][l], a[i+1][j][l], l ? a[i][j][l-1]+1 : 0});
	}
	rep(i,n+1) ans = max({ans, (i!=n?a[i][n-1-i][k]*2:0)+1, a[i][n-i][k]*2});
	printf("%d\n", ans);
}

Measured memory_bytes: 110464
N,M=gets.split.map(&:to_i)

ks = []
M.times.map do
  a,b = gets.split.map(&:to_i)
  c = gets.split.inject(0) {|n,i| n += 1 << (i.to_i-1) }
  ks << [a,c]
end
ks.sort!

target = 2**N-1

idxs = [0]
arr = [0]
ks.each do |a,c|
  idxs.length.times do |i|
    idx = idxs[i]
    t = arr[idx|c]
    if t.nil?
      idxs << (idx|c)
      arr[idx|c] = arr[idx]+a
    elsif arr[idx]+a < t
      arr[idx|c] = arr[idx]+a
    end
  end
end

if arr[target]
  puts arr[target]
else
  puts -1
end


Measured memory_bytes: 2172
#include<iostream>
#include<stack>
#include<vector>
using namespace std;

struct TPond
{
	int DownPoint;
	int Surface;
};

void ConstructPond(vector<TPond> &PondRow, stack<int> &DownPointRow, int InputCount)
{
	TPond Pond;
	Pond.DownPoint = DownPointRow.top();
	Pond.Surface = InputCount - DownPointRow.top();
	//????????´???????±????????????§???????±????????????????????????°?±?list???????????????
	//????????´???????±????????????§???????±????????????????????????°????????´???????±???????????????????
	while(!PondRow.empty() && Pond.DownPoint < PondRow.back().DownPoint){
		Pond.Surface += PondRow.back().Surface;
		PondRow.pop_back();
	}
	PondRow.push_back(Pond);
	DownPointRow.pop();
}

void Output(vector<TPond> PondRow)
{
	//?????¢???????±???????
	int SumOfSurface = 0;
	for(int i = 0; i < PondRow.size(); i++){SumOfSurface += PondRow[i].Surface;}
	//?????¢?????¨??°??¨?????????????????¢??????????????????
	cout << SumOfSurface << endl; 
	cout << PondRow.size();
	for(int i = 0; i < PondRow.size(); i++){cout << ' ' << PondRow[i].Surface;}
	cout << endl;
}

int main()
{
	//?±?(????????????????????°??¨??¢???????????±?????????)????????????list???????????????
	vector<TPond> PondRow;
	//????????????????????°????????????stack???????????????
	stack<int>   DownPointRow;
	//????????????????????°???????????????????????????????????°???????????????
	int InputCount = 0;
	while(true){
		//??????????????????????????\???????????\?????????
		char Input;
		cin >> Input;
		if(cin.good() == false){break;}
		InputCount += 1;
		//???????????\???????????????DownPointRow???????????????
		//???????????\????????????????????´?????????????????????????±?????§??????????
		if(Input == '\\'){
			DownPointRow.push(InputCount);
		}else if(Input == '/' && !DownPointRow.empty()){
			ConstructPond(PondRow, DownPointRow, InputCount);
		}
	}
	Output(PondRow);
	return 0;
}

Measured memory_bytes: 1284
A, B, C, D = (int(i) for i in input().split())
if D > B and A > C:
    E = (C - (D - B))
    F = D - (A - C)
    G = (A - (D - B))
    H = B - (A - C)
    print(E, F, G, H)
elif A > C and B > D:
    E = C + (B - D)
    F = D - (A - C)
    G = A + (B - D)
    H = B - (A - C)
    print(E, F, G, H)
elif B > D and C > A:
    E = (C + (B - D))
    F = D + (C - A)
    G = (A + (B - D))
    H = B + (C - A)
    print(E, F, G, H)
else:
    E = C - (D - B)
    F = D + (C - A)
    G = A - (D - B)
    H = B + (C - A)
    print(E, F, G, H)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
X, Y = list(map(int, input().split()))

# 求解処理
result = False
for crane in range(X+1):
    turtle = X - crane
    if math.isclose(2*crane + 4*turtle, Y):
        result = True
        break

# 結果出力
if result:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
package main

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

func main() {
	r := getStdinInt()
	fmt.Printf("%d\n", 3*r*r)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2180
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a, b;
char c;
while (cin >> a >> c >> b) {
switch(c) {
case '?':
 return 0;
case '+':
 cout << a + b << "\n";
 break;
case '-':
 cout << a - b << "\n";
 break;
case '*':
 cout << a * b << "\n";
 break;
case '/':
 cout << a / b << "\n";
 break;
}
}
}

Measured memory_bytes: 3172
using System;
class p
{
  static void Main()
  {
    int A = int.Parse(Console.ReadLine());
    int B = int.Parse(Console.ReadLine());
    if ((A == 1 && B == 2) || (A == 2 && B == 1)) {
      Console.WriteLine(3);
    } else if ((A == 1 && B == 3) || (A == 3 && B == 1)) {
      Console.WriteLine(2);
    } else if ((A == 2 && B == 3) || (A == 3 || B == 2)) {
      Console.WriteLine(1);
    }
  }
}


Measured memory_bytes: 9044
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

int main() {
	ll n, a[100010], rui[100010] = {0};
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 1;i < n;i++) {
		rui[i] = rui[i - 1] + a[i - 1];
	}
	int t = 0;
	for (int i = 1;i < n;i++) {
		if (rui[i] * 2 < a[i]) {
			t = i;
		}
	}
	cout << n - t << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> del(N);

    for (int i = 0; i < N; i++) {
        cin >> del.at(i);
    }

    int S = 0;

    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            S += del.at(i) * del.at(j);
        }
    }

    cout << S << endl;
}

Measured memory_bytes: 256
//??-2015-11-8
# include <cstdio>
# include <algorithm>
# include <iostream>
# include <string>
# include <cstring>
# include <map>
# include <queue>

using namespace std;

int direction[4] = { -4, 4, -1, 1 };                   //4个方向，上下左右
map<string, int>dp;                                   //事先将?果保存在?里
void Bfs()
{
	string p = "01234567";
	queue<string>Q;
	Q.push(p);
	dp[p] = 0;                                          //在?个地方是不用??的

	while (!Q.empty())
	{
		//printf("出不去\n");
		string q = Q.front();
		Q.pop();
		int v,w,i,j;
		for (v = 0; v < q.length(); v++)
		{
			if (q[v] == '0')
			{
				w = v;                                       //??0的位置，然后以他?中心?行走?
				break;
			}
		}
		for (i = 0; i < 4; i++)
		{
			string temp2 = q;
			int r = w + direction[i];
			if (r >= 0 && r < 8 && !(w == 3 && i == 3) && !(w == 4 && i == 2))         //特?看清楚?个限制条件
			{
				char c;                                                                //交?位置
				c = temp2[r];
				temp2[r] = temp2[w];
				temp2[w] = c;
				//必?要是map中没有的，?才??列，要不永不停止
				if (dp.find(temp2) == dp.end())                        //没找到,一定要想?法知道是否已??找?
				{
					Q.push(temp2);
					dp[temp2] = dp[q] + 1;
				}
			}
		}
	}
}
int main(void)
{
	//freopen("in.txt", "r", stdin);
	string s;
	Bfs();
	while (getline(cin, s))
	{
		int i;
		string temp;
		for (i = 0; i < s.length(); i++)
		{
			if (s[i] != ' ')
				temp.push_back(s[i]);
		}
		cout << dp[temp] << endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> v(n);
  int l=0,r=0;
  string s;
  rep(i,n){
    cin >> s;
    stack<int> st;
    rep(j,s.length()){
      if(s[j]=='('){
        l++;
        st.push(0);
      }else{
        r++;
        if(st.size()>0){
          if(st.top()==0) st.pop();
          else st.push(1);
        }else{
          st.push(1);
        }
      }
    }
    int x=0,y=0;
    while(!st.empty()){
      if(st.top()==1) x++;
      else y++;
      st.pop();
    }
    v[i]={x,y};
  }
  if(l!=r){
    CNO;
    return 0;
  }
  vector<bool> usd(n,false);
  int now=0;
  int count=0;
  for(int i=0;i<n;i++){
    pair<int,int> ma(-IINF,-1);
    for(int j=0;j<n;j++){
      if(v[j].first<=now&&(!usd[j])) ma=max(ma,{v[j].second-v[j].first,j});
    }
    if(ma.second==-1){
      CNO;
      return 0;
    }
    if(ma.first<0) break;
    now+=ma.first;
    usd[ma.second]=true;
    count++;
    if(now<0){
      CNO;
      return 0;
    }
  }
  now=0;
  for(int i=0;i<n-count;i++){
    pair<int,int> ma(-IINF,-1);
    for(int j=0;j<n;j++){
      if(v[j].second<=now&&(!usd[j])) ma=max(ma,{v[j].first-v[j].second,j});
    }
    if(ma.second==-1){
      CNO;
      return 0;
    }
    now+=ma.first;
    usd[ma.second]=true;
    if(now<0){
      CNO;
      return 0;
    }
  }
  CYES;
  return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define N 333
#define mod 1000000007

int n,m,f[N][N][N],ans;
vector<pair<int,int> > q[N];

void pls(int &x,int y){x=(x+y)%mod;}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();
	for (int i=1;i<=m;i++){
		int x=read(),y=read(),z=read();
		q[y].push_back(make_pair(x,z));
	}
	f[1][0][0]=3;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++)
			for (int k=0;k<=n;k++){
				for (int l=0;l<(int)q[i].size();l++)
					if (1+(j>=q[i][l].first)+(k>=q[i][l].first)!=q[i][l].second) f[i][j][k]=0;
				if (i==n) pls(ans,f[i][j][k]);
				else pls(f[i+1][j][k],f[i][j][k]),
					pls(f[i+1][i][k],f[i][j][k]),
					pls(f[i+1][i][j],f[i][j][k]);
			}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 130816
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
    h, w = map(int, input().split())
    hoge = []
    for i in range(h):
        hoge.append(input())
    print("#"*(w+2))
    for i in range(h):
        print("#"+hoge[i]+"#")
    print("#"*(w+2))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 21528
S = input()
while len(S) > 0:
	n = len(S)
	if S[-5:] == "dream":
		S = S[:-5]
	if S[-7:] == "dreamer":
		S = S[:-7]
	if S[-5:] == "erase":
		S = S[:-5]
	if S[-6:] == "eraser":
		S = S[:-6]
	if len(S) == n:
		break
if len(S) == 0:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int n,D,d[99],x[99],c1[99],c2[99];
LL Ans,Pi;

int main()
{
#ifdef h10
	freopen("mirrored.in","r",stdin);
	freopen("mirrored.out","w",stdout);
#endif
	int i,j,S,tmp;
	bool flag;

	for (i=0;i<10;i++)
	for (j=0;j<10;j++) c1[i-j+10]++;
	for (i=0;i<10;i++)
	for (j=1;j<10;j++) c2[i-j+10]++;

	scanf("%d",&D);
	for (tmp=D;tmp;tmp/=10) d[n++]=tmp%10;

	for (S=0;S<1<<n<<n;S++)
		if (S>>(n+n-1))
		{
			memset(x,0,sizeof(x));
			for (i=0;i<n+n;i++)
				if ((S>>i)&1) x[i]+=d[i];
				else x[i]-=10-d[i],x[i+1]++;

			flag=1;
			for (i=0;i<n+n;i++)
				flag&=x[i]!=10&&x[i]!=-10;
			if (!flag) continue;


			for (i=n+n-1;i>=0;i--)
			{
				flag=1;
				for (j=0;j<=i;j++)
					flag&=x[j]+x[i-j]==0;
				if (flag) break;
				if (x[i]) break;
			}
			if (!flag) continue;


			Pi=1; j=i;



//			for (i=0;i<=j;i++)
//				printf("%d ",x[i]);
//			puts("");

//			0 1
//			0 1 2

			for (i=(j+1)/2;i<j;i++)
			{
				Pi*=c1[x[i]+10];
//				printf("*%d(c1[%d])\n",c1[x[i]+10],x[i]+10);
			}

			Pi*=c2[x[j]+10];
//			printf("*%d(c2[%d])\n",c2[x[j]+10],x[j]+10);
			Ans+=Pi;

		}
	printf("%lld\n",Ans);
}


Measured memory_bytes: 256
// 山登り法しか思いつかない
#include <bits/stdc++.h>
using namespace std;

int D;
int res[365];  // 解答
long long c[26];
long long s[365][26];

long long evaluate() {
    static int LatestProb[26];
    long long score = 0;
    memset(LatestProb, -1, sizeof(LatestProb));
    for (int d = 0; d < D; ++d) {
        score += s[d][res[d]];
        LatestProb[res[d]] = d;
        for (int j = 0; j < 26; ++j) {
            if (LatestProb[j] == -1) continue;
            score -= c[j] * (d - LatestProb[j]);
        }
    }
    return score;
}

int main() {
    cin >> D;
    for (int i = 0; i < 26; ++i) {
        cin >> c[i];
    }
    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    random_device rnd;                         // 非決定的な乱数生成期を生成
    mt19937 mt(rnd());                         // メルセンヌ・ツイスタの32bit版、引数は初期シード値
    uniform_int_distribution<> rand26(0, 25);  // [0, 25]範囲の一様乱数
    uniform_int_distribution<> rand365(0, 364);

    for (int i = 0; i < D; ++i) {
        res[i] = rand26(mt);
    }
    // 山登り法をして、解を大きくしていく。
    long long score = evaluate();
    int IterationNum = 5000;
    while (IterationNum--) {
        // 二つ変える
        int ch1 = rand365(mt);
        int ch2;
        while ((ch2 = rand365(mt)) == ch1)
            ;
        // どの問題にするか決める
        int ct1 = rand26(mt), ct2 = rand26(mt);
        // 変える前の情報を格納
        int prev1 = res[ch1], prev2 = res[ch2];
        // 変更
        res[ch1] = ct1, res[ch2] = ct2;
        // スコア計算
        long long nxt = evaluate();
        if (score < nxt) {
            score = nxt;
        } else {
            // 元に戻す。
            res[ch1] = prev1, res[ch2] = prev2;
        }
    }

    for (int i = 0; i < D; ++i) {
        cout << res[i] + 1 << endl;
    }
    //cout << "score: " << score << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define sz(el) (int)el.size()

const int inf = 1e18;

int max(int &a, int b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}

const int maxN = 1e5 + 100;

vector<int> topi;
int dp[maxN];

int used[maxN];

vector<int> g[maxN];
vector<int> gr[maxN];

void dfs(int v) {
    used[v] = 1;
    for (int to : g[v]) {
        if (!used[to]) {
            dfs(to);
        }
    }
    topi.pb(v);
}

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        gr[b].pb(a);
    }
    
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            dfs(i);
        }
    }
    
    reverse(topi.begin(), topi.end());
    
    dp[topi[0]] = 0;
    
    for (int i = 1; i < n; i++) {
        for (int to : gr[topi[i]]) {
            max(dp[topi[i]], dp[to] + 1);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        max(ans, dp[i]);
    }
    cout << ans;
    return 0;
    
}


Measured memory_bytes: 15868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int day=24*3600+60*60+60;
	int n;
	while(cin>>n&&n){
		int a[day]={};
		for(int i=0;i<2*n;i++){
			int time;
			string s; cin>>s;
			time=(s[0]-'0')*36000+(s[1]-'0')*3600+(s[3]-'0')*600+(s[4]-'0')*60+(s[6]-'0')*10+(s[7]-'0');
			if(i%2==0) a[time]++;
			else a[time]--;
		}
		for(int i=1;i<day;i++){
			a[i]=a[i]+a[i-1];
		}
		sort(a,a+day); reverse(a,a+day);
		cout<<a[0]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3472
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = n* -1;i <=  n; i++)
typedef long long int ll;
ll sum = 0, n; 
map<ll, ll> l, r;
int main() {
    cin >> n; vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        l[i + a[i]]++;
        r[i - a[i]]++;
    }req(i, n) {
        sum += l[i] * r[i];
    }cout << sum << endl;
}

Measured memory_bytes: 69972
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if((c - a - b) > 0 && (c - a - b) * (c - a - b) > (4 * a * b)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

// (?????????, ??????, ?????????, ??????)
struct edge{ int to,cap,cost,rev; };

int V; // TODO:initialize
const int MAX_V = 222; // TODO:initialize
const int INF = 19191919; // TODO:initialize
vector<edge> G[MAX_V];
int h[MAX_V]; // ??????????????£???
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V]; // ??´??????????????¨???

void add_edge(int from, int to, int cap, int cost){
    G[from].pb({to,cap,cost,(int)G[to].size()});
    G[to].pb({from,0,-cost,(int)G[from].size()-1});
}

// s??????t????????????f???????°??????¨???(???????????????-1)
int min_cost_flow(int s, int t, int f){
    int res = 0;
    fill(h,h+V,0);
    while(f>0){
        // dijkstra??§h?????´??°
        priority_queue<pi,vector<pi>,greater<pi>> pq;
        fill(dist,dist+V,INF);
        dist[s]=0;
        pq.push(pi(0,s));
        while(!pq.empty()){
            pi p = pq.top();
            pq.pop();
            int v = p.se;
            if(p.fi>dist[v]) continue;
            rep(i,G[v].size()){
                edge &e = G[v][i];
                if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                    dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    pq.push(pi(dist[e.to],e.to));
                }
            }
        }

        // ????????\???????????????
        if(dist[t]==INF) return -1;

        rep(v,V) h[v] += dist[v];

        // s-t???????????????????????£??????????????????
        int d=f;
        for(int v=t; v!=s; v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
        f -= d;
        res += d*h[t];

        for(int v=t; v!=s; v=prevv[v]){
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

const int B = 10000;

int main()
{
    int n,m,k;
    int a[100],b[100][100],t[100];

    scanf(" %d %d %d", &n, &m, &k);
    rep(i,n) scanf(" %d", &a[i]);
    rep(i,m)rep(j,n) scanf(" %d", &b[i][j]);
    rep(i,m) scanf(" %d", &t[i]);

    V = m+n+3;
    int Z = m+n;
    int S = m+n+1, T = m+n+2;

    add_edge(S,Z,k,-B);
    add_edge(S,Z,n,0);
    rep(i,m) add_edge(S,i,t[i],0);

    rep(i,n) add_edge(Z,m+i,1,-a[i]);
    rep(i,m)rep(j,n) add_edge(i,m+j,1,-b[i][j]);

    rep(i,n) add_edge(m+i,T,1,0);

    printf("%d\n", -min_cost_flow(S,T,n)-k*B);
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main (){
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int num;
	for(int i=0;i<s.size();i++){
		num = int(s[i]);
		num = num + n;
		if (num > 90) num = num - 26;
		s[i] = char(num);
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();

		if(s.equals(u)) {
			a--;
		} else {
			b--;
		}

		System.out.println(a + " " + b);
	}

}


Measured memory_bytes: 22228
from collections import deque


def solve(n, q, a, b, p, x):
    counter = [0] * n
    q_sum = [0] * n
    for i in range(q):
        q_sum[p[i]] += x[i]
    # pprint(q_sum)

    edges = {}
    for i in range(n-1):
        if a[i] not in edges:
            edges[a[i]] = []
        edges[a[i]].append(b[i])
    # pprint(edges)

    counter[0] = q_sum[0]
    children = deque()
    for child in edges[0]:
        counter[child] = q_sum[0]
        children.append(child)
    while children:
        child = children.popleft()
        counter[child] += q_sum[child]
        # print("child")
        # print(child, counter[child])
        if child in edges:
            for c in edges[child]:
                counter[c] = counter[child]
                # print("c")
                # print(c, counter[c])
                children.append(c)

    print(" ".join(list(map(str, counter))))

if __name__ == "__main__":
    n, q = list(map(int, input().strip().split(" ")))
    a = []
    b = []
    for _ in range(n-1):
        a_i, b_i = list(map(int, input().strip().split(" ")))
        a.append(a_i - 1)
        b.append(b_i - 1)

    p = []
    x = []
    for _ in range(q):
        p_i, x_i = list(map(int, input().strip().split(" ")))
        p.append(p_i-1)
        x.append(x_i)
    solve(n, q, a, b, p, x)

Measured memory_bytes: 124888
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       string s,t;
       cin>>s;
       cin>>t;
       ll n = s.size(),m = t.size();
       ll ans = m;
       for(ll i=0; i<=n-m; i++){
           ll cnt = 0;
           for(ll j=0; j<m; j++){
               if(t[j]!=s[i+j])cnt++;
           }
           ans = min(ans,cnt);
       } 
       pp(ans);

     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    cout << ((s > "2019/04/30") ?"TBD\n":"Heisei\n");
    return 0;
}

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

int main() {
  int64_t N, y = 0;
  cin >> N;
  vector<int> xs(N);
  for (auto& x : xs) {
    cin >> x;
    y += x;
  }
  int64_t x = 0, abs_min = numeric_limits<int64_t>::max();
  for (int i = 0; i <= N - 2; ++i) {
    x += xs[i];
    y -= xs[i];
    abs_min = min(abs_min, abs(x - y));
  }
  cout << abs_min << endl;
}


Measured memory_bytes: 1024