akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

class Info{
public:
	int id, ac, penalty;
	Info(int i=0, int a=0, int p=0) : id(i), ac(a), penalty(p) {}
	bool operator < (const Info& i) const {
		if(ac != i.ac) return ac > i.ac;
		if(penalty != i.penalty) return penalty < i.penalty;
		return id < i.id;
	}
};

int main(){
	int cnt[50][10];
	int T, P, R;
	while(cin >> T >> P >> R && T){
		for(int i=0;i<T;i++){
			for(int j=0;j<P;j++){
				cnt[i][j] = 0;
			}
		}
		vector<Info> vi(T);
		for(int i=0;i<T;i++) vi[i].id = i+1;
		for(int i=0;i<R;i++){
			int tID, pID, time;
			string message;
			cin >> tID >> pID >> time >> message;
			tID--; pID--;
			if(cnt[tID][pID] == -1) continue;
			if(message == "CORRECT"){
				vi[tID].ac++;
				vi[tID].penalty += time + 1200*cnt[tID][pID];
				cnt[tID][pID] = 0;
			} else {
				++cnt[tID][pID];
			}
		}
		sort(vi.begin(), vi.end());
		for(Info in : vi){
			cout << in.id << " " << in.ac << " " << in.penalty << endl;
		}
	}
}

Measured memory_bytes: 1220
#define		_CRT_SECURE_NO_WARNINGS

#include <cstdio>

int main()
{
	int		a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	int		Cnt = 0;

	for (int i = a; i <= b; i++)
	{
		if (c % i == 0)
		{
			Cnt++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 2756
program Libra
 implicit none
 integer :: A, B, C, D, L, R
 read(*,*) A, B, C, D
 L = A + B
 R = C + D
 if (L > R) then
 	write(*,*) "Left"
 else if(L < R) then
 	write(*,*) "Right"
 else 
 	write(*,*) "Balanced"
 end if
end program Libra

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

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
    int mmc = c*d/__gcd(c, d);
    
    int fmc, fmd, fm;
    if(a%c == 0) fmc = a;
    else fmc = c * (a/c + 1);
    
    if(a%d == 0) fmd = a;
    else fmd = d * (a/d + 1);
    
    if(a%mmc == 0) fm = a;
    else fm = mmc * (a/mmc + 1);
    
	//cout << fmc << ' ' << fmd << ' ' << fm << '\n';
	
	int lmc, lmd, lm;
	lmc = b - (b%c);
	lmd = b - (b%d);
	lm = b - (b%mmc);
	
	int qtdc = lmc/c - fmc/c + 1;
	int qtdd = lmd/d - fmd/d + 1;
	int qtd  = lm/mmc - fm/mmc + 1;
	
	cout << b - a + 1 - (qtdc + qtdd - qtd) << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define un unsigned
using namespace std;
int main()
{
    ll a,b,c,d,x,y;
    cin>>a>>b>>c>>d;
    x=max(a*c,a*d);
    y=max(b*c,b*d);
    cout<<max(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define F first
#define S second
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define N 200010
using namespace std;
void solve()
{
    ll n; cin>>n;
    map<string,int> m;
    rep(i,0,n)
    {
        string tmp; cin>>tmp;
        m[tmp]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int t=1;
  //cin>>t;
  //freopen("b2.in", "r", stdin);
  //freopen("output2.txt", "w", stdout);
  for(int i=1;i<=t;i++)
  {
      solve();
  }
  return 0;
}


Measured memory_bytes: 3664
# -*- coding: utf-8 -*-

import os
import datetime

def main():
    val_1 = int(input())
    val_2 = input()
    val_2_list = val_2.split()

    flag = True

    for i in range(val_1):
        num = int(val_2_list[i])
        if num % 2 == 0:
            if num % 3 != 0 and num % 5 != 0:
                flag = False
                break

    if flag:
        print("APPROVED")
    else:
        print("DENIED")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n;
  double d;
  cin >> n >> d;
  int ans = 0;
  while (n--)
  {
    ll x, y;
    cin >> x >> y;
    double dist = sqrt(x * x + y * y);
    // cout << dist << endl;
    if (dist <= d)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3776
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int X,Y;
	scan(X);scan(Y);
	prin(X+Y/2);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

struct edge{
    int to,cost;
};
vector<edge> G[1010];
int d[1010];
bool used[1010];
int main(void){
    int n,m,u,v;
    bool flag=false;
    while(true){
        cin>>n>>m;
        if((n==0)&&(m==0))break;
        for(int i=1;i<=n;i++){
            G[i].clear();
            d[i]=-1;
            used[i]=false;
        }
        for(int i=0;i<m;i++){
            cin>>u>>v;
            G[u].push_back({v,0});
            G[v].push_back({u,0});
        }
        queue<P> que;
        d[1]=0;
        que.push(P(1,d[1]));
        flag=false;
        while(!que.empty()){
            P p=que.front();
            que.pop();
            for(int i=0;i<(int)G[p.first].size();i++){
                int x=G[p.first][i].to;
                if(used[x])continue;
                if(d[x]==d[p.first])flag=true;
                d[x]=(d[p.first]+1)%2;
                que.push(P(x,d[x]));
            }
            used[p.first]=true;
        }
        
        int num0=0,num1=0;
        for(int i=1;i<=n;i++){
            if(d[i])num1++;
            else num0++;
        }
        if(flag)cout<<0<<endl;
        else{
            if((num0%2==0)&&(num1%2==0)){
                if(num0/2==num1/2){
                    cout<<1<<endl;
                    cout<<num0/2<<endl;
                }
                else{
                    cout<<2<<endl;
                    cout<<min(num0/2,num1/2)<<endl;
                    cout<<max(num0/2,num1/2)<<endl;
                }
            }
            else{
                if(num0%2==0){
                    cout<<1<<endl;
                    cout<<num0/2<<endl;
                }
                else{
                    if(num1%2==0){
                        cout<<1<<endl;
                        cout<<num1/2<<endl;
                    }
                    else{
                        cout<<0<<endl;
                    }
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3312
#include <stdio.h>

char img[50][50];
char temp[50][50];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf(" %c", &img[j][i]);
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			scanf(" %c", &temp[j][i]);
		}
	}
	bool ret = false;
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			bool f = true;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (temp[l][k] != img[j + l][i + k]) {
						f = false;
						goto NEXT;
					}
				}
			}
		NEXT:
			if (f) {
				ret = true;
				goto END;
			}
		}
	}
END:
	if (ret) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {
    int A, B, flag = 1;
    char S[20];
    scanf("%d %d %s", &A, &B, S);
    for (int i = 0; S[i] != '\0'; i++) {
        if (i < A || i > A) {
            if (S[i] < '0' || S[i] > '9') {
                flag = 0;
            }
        }
        else {
            if (S[i] != '-') {
                flag = 0;
            }
        }
    }
    flag ? puts("Yes") : puts("No");
    return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

struct UnionFind{
	int n;
	vector<int> par;
	UnionFind(int n) : n(n), par(n, -1){}
	int Find(int x){return par[x] < 0 ? x : Find(par[x]);}
	bool Unite(int x, int y){
		x = Find(x), y = Find(y);
		if(x == y)
			return false;
		if(par[x] > par[y])
			swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
};

template<typename T>
struct Segtree{
	const int n;
	const T op;
	vector<T> elm;
	function<T(T, T)> f;

	Segtree(int n, T init, function<T(T, T)> f, T op = T()) :
			n(n),
			op(op),
			f(f),
			elm(2 * n, init)
	{
	}

	void set(int x, T val){
		x += n;
		elm[x] = val;
		while(x >>= 1)
			elm[x] = f(elm[2 * x], elm[2 * x + 1]);
	}

	void update(int x, T val){
		x += n;
		elm[x] = f(val, elm[x]);
		while(x >>= 1)
			elm[x] = f(elm[2 * x], elm[2 * x + 1]);
	}

	T get(int x, int y) const{
		T val = op;
		for(x += n, y += n - 1; x <= y; x >>= 1, y >>= 1){
			if(x & 1)
				val = f(val, elm[x++]);
			if(!(y & 1))
				val = f(val, elm[y--]);
		}
		return val;
	}
};


signed main(){

	int n, d;
	cin >> n >> d;
	vector<int> v(n);
	for(auto& x : v)
		cin >> x;


	auto f = [](pair<i64,int> x, pair<i64,int> y){
		return min(x, y);
	};

	Segtree<pair<i64,int>> seg_a(n, pair<i64,int>(), f, pair<i64,int>(INF, 0));
	Segtree<pair<i64,int>> seg_b(n, pair<i64,int>(), f, pair<i64,int>(INF, 0));

	auto s = [&](int i){
		seg_a.set(i, make_pair(v[i] + i64(1) * d * i, i));
		seg_b.set(i, make_pair(v[i] + i64(1) * d * (n - i - 1), i));
	};

	auto t = [&](int i){
		seg_a.set(i, make_pair(INF, i));
		seg_b.set(i, make_pair(INF, i));
	};

	for(int i = 0; i < n; ++i)
		s(i);

	UnionFind u(n);

	i64 ans = 0;

	while(u.par[u.Find(0)] != -n){
		// 子ノードの一覧
		vector<vector<int>> ch(n);
		// 接合するノード
		vector<pair<i64, int>> nex(n, make_pair(INF, 0));

		for(int i = 0; i < n; ++i)
			ch[u.Find(i)].push_back(i);

		for(int i = 0; i < n; ++i){
			if(ch[i].empty())
				continue;
			for(auto& x : ch[i])
				t(x);

			pair<i64,int> val(INF, 0);

			for(auto& x : ch[i]){
				auto p_a = seg_a.get(x + 1, n);
				p_a.first -= i64(1) * d * x;
				p_a.first += v[x];
				val = f(val, p_a);

				auto p_b = seg_b.get(0, x);
				p_b.first -= i64(1) * d * (n - 1 - x);
				p_b.first += v[x];
				val = f(val, p_b);
			}

			for(auto& x : ch[i])
				s(x);

			nex[i] = val;
		}

		for(int i = 0; i < n; ++i){
			if(nex[i].first != INF && u.Unite(i, nex[i].second))
				ans += nex[i].first;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 28416
#include <iostream>
#include <list>
#include <stack>
#include <set>
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	string s;
	cin >> s;
	ll a, b, c, d;
	a = s[0] - '0'; b = s[1] - '0'; c = s[2] - '0'; d = s[3] - '0';
	if (a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	else if (a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
	return 0;
}



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

int main(){
	int a, b, c, d;
  	int inputNumber;
  	cin >> inputNumber;
  
  	d = inputNumber % 10;
  	inputNumber /= 10;
  	c = inputNumber % 10;
  	inputNumber /= 10;
  	b = inputNumber % 10;
  	inputNumber /= 10;
  	a = inputNumber;

  
  	if (b != c) {
    	cout << "No" << endl;
    } else if (a != b) {
    	if (c != d) {
        	cout << "No" << endl;
        } else {
        	cout << "Yes" << endl;
        }
    } else {
    	cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int i,j,s;
char a[1000000],b;
int main() {
	while((b=getchar())!='\n'){
		s++;
		if(b=='S')
			a[i++]=b;
		if(b=='T')
			a[i++]=b;
		if(a[i-2]=='S'&&a[i-1]=='T'){
			s-=2;
			i-=2;
		}
	}
	cout<<s;
	return 0;
}

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

int main() {
  int n;
  int b, f, r, v;
  // ?????????
  int houses[4][3][10];
  for (b = 0; b < 4; b++) {
    for (f = 0; f < 3; f++) {
      for (r = 0; r < 10; r++) {
        houses[b][f][r] = 0;
      }
    }
  }

  // ??\????????????
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    houses[b-1][f-1][r-1] += v;
    if (houses[b-1][f-1][r-1] < 0) {
      houses[b-1][f-1][r-1] = 0;
    }
  }

  // ??????
  for (b = 0; b < 4; b++) {
    for (f = 0; f < 3; f++) {
      for (r = 0; r < 10; r++) {
        cout << " " << houses[b][f][r];
      }
      cout << endl;
    }
    if (b == 3) {
      continue;
    }
    cout << "####################" << endl;
  }
}

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

using namespace std;

const int maxn=1e5+5;

int a,b,c,x,y;
long long ans1=0,ans2=0,ans3=0,ans=0;
int main()
{
    cin>>a>>b>>c>>x>>y;
    ans1=x*a+y*b;
    if(x<y)
    {
        ans2+=2*x*c;
        ans3+=2*x*c;
        y-=x;
        ans2+=b*y;
        ans3+=2*y*c;
    }
    else
    {
        ans2+=2*y*c;
        ans3+=2*y*c;
        x-=y;
        ans2+=a*x;
        ans3+=2*x*c;
    }
    ans=min(ans1,ans2);
    ans=min(ans,ans3);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  LL sum = 0;
  REP(i,0,n){
    int a,b;
    cin>>a>>b;
    sum += b - a + 1;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,ans;
    cin>>x;
    if(x>=400 && x<=599)
        ans=8;
    else if(x>=600 && x<=799)
        ans=7;
    else if(x>=800 && x<=999)
        ans=6;
    else if(x>=1000 && x<=1199)
        ans=5;
        else if(x>=1200 && x<=1399)
        ans=4;
        else if(x>=1400 && x<=1599)
        ans=3;
        else if(x>=1600 && x<=1799)
        ans=2;
        else if(x>=1800 && x<=1999)
        ans=1;
        cout<<ans<<endl;
}


Measured memory_bytes: 3628
n,m=map(int,input().split())
via=set()
viaa=set()
for i in range(m):
  a,b=map(int,input().split())
  if a ==1 : 
    via.add(b)
  if b ==n:
    viaa.add(a)
if via.isdisjoint(viaa):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE') 

Measured memory_bytes: 18892
def main():
    n = int(input())
    x = [tuple(map(int, input().split())) for _ in range(n)]

    dp = [[0, 0, 0] for _ in range(n + 1)]

    for i in range(n):
        a, b, c = x[i]
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a)
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][2] + a)
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b)
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] + b)
        dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c)
        dp[i + 1][2] = max(dp[i + 1][2], dp[i][1] + c)

    res = max(dp[-1])

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 106056
// abc047_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int a, b, c;
    cin >> a >> b >> c;
    
    if (a + b == c || b + c == a || c + a == b){
        print("Yes");
    } else {
        print("No");
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define INF 100000000
int main(){
    ll A,B;
    cin>>A>>B;
    if(A>=13)cout<<B;
    else if(6<=A&&A<13)cout<<(B/2);
    else cout<<0;
}

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

using namespace std;

long long MOD = 1000000007;
long long prod(long long a, long long b){
    return (a*b)%MOD;
}

int main(){
    int n, m;
    cin >> n >> m;
    long long vert[n], hori[m];
    for(int one = 0; one < n; one++){
        cin >> vert[one];
    }
    for(int one = 0; one < m; one++){
        cin >> hori[one];
    }

    long long xaxis = 0, yaxis = 0, temp = 0, temp2 = 0, ans = 0;
    for(int one = 1; one < n; one++){
        temp = prod(one, n-one);
        temp2 = vert[one] - vert[one-1];
        temp = prod(temp, temp2);
        xaxis = (xaxis+temp)%MOD;
    }
    for(int one = 1; one < m; one++){
        temp = prod(one, m-one);
        temp2 = hori[one] - hori[one-1];
        temp = prod(temp, temp2);
        yaxis = (yaxis+temp)%MOD;
    }
    ans = prod(xaxis, yaxis);
    cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<29
#define EPS 1e-9
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

const int MAX_V = (int)1e5 + 5;
int V, E;
vector<int> G[MAX_V];
vector<char> v;
bool used[26];

int main()
{
//	cut here before submit 
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	v.clear();
	rep (i, MAX_V ) G[i].clear();
	ios_base::sync_with_stdio(0);
	cin >> V >> E;
 	v.resize (V, 0 );
	rep (i, V ) cin >> v[i];
	rep (i, E ){
		int s, t;
		cin >> s >> t;
		G[s].push_back (t );
		G[t].push_back (s );
	} // end rep

	rep (i, V ){
		if (v[i] == '?' ){
			memset (used, false, sizeof (used ) );
			rep (j, G[i].size() ){
				int u = G[i][j];
				if (v[u] != '?' ) used[(int)(v[u] - 'a')] |= true;
			} // end rep
			rep (j, 26 ){
				if (!used[j] ){
					v[i] = (char)(j+'a');
					break;
				} // end if
			} // end rep
		} // end if
	} // end rep

	rep (i, V ) cout << v[i];
	cout << endl;
#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif			
	return 0;
}


Measured memory_bytes: 8112
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def nu_of_factors1(n):
    result_set = set()
    sqrtn = int(n**0.5)
    for i in range(1,sqrtn+1):
        q, r = n/i, n%i
        if r == 0:
            result_set.add(q)
            result_set.add(i)
    return len(result_set)


def getDivisors(n):
    # Note that this loop runs till square root
    factors = []
    i = 1
    while i <= sqrt(n):

        if (n % i == 0):

            # If divisors are equal, print only one
            if (n / i == i):
                factors.append(i)
            else:
                # Otherwise print both
                factors.append(i)
                factors.append(n//i)
        i = i + 1
    return factors

n = INT()
ans = 0

ans+=nu_of_factors1(n-1) - 1

divisors = getDivisors(n)


for el in divisors:
    if(el!=1):
        temp = n
    else:
        continue

    flag = 1
    while(temp!=1):
        if((temp/el).is_integer()):
            temp/=el
            continue
        else:
            if(temp%el==1):
                ans+=1
            flag = 0
            break

    if(flag==1):
        ans+=1
print(ans)

Measured memory_bytes: 69508
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){for(s=26;s--;)r=i.replace(/[a-z]/g,function(j){return String.fromCharCode((j.charCodeAt(0)+s)%26+97)}),r.match(/th(e|i|a)/)?console.log(r):0})

Measured memory_bytes: 9308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      StringBuilder buf = new StringBuilder();

      while(true) {
        int n = Integer.parseInt(in.readLine());

        if(n == 0) break;

        int maxX = 0, minX = 0;
        int maxY = 0, minY = 0;

        int[][] boxes = new int[n][2];
        boxes[0][0] = 0;
        boxes[0][0] = 0;
        int x=0, y=0;
        int ni,di;
        String[] lines;

        for(int i=1; i<n; i++) {
          lines = in.readLine().split(" ");
          ni = Integer.parseInt(lines[0]);
          di = Integer.parseInt(lines[1]);
          x = boxes[ni][0];
          y = boxes[ni][1];

          switch(di) {
            case 0:
              boxes[i][0] = --x;
              boxes[i][1] = y;
              minX = Math.min(minX,x);
              break;
            case 1:
              boxes[i][0] = x;
              boxes[i][1] = --y;
              minY = Math.min(minY,y);
              break;
            case 2:
              boxes[i][0] = ++x;
              boxes[i][1] = y;
              maxX = Math.max(maxX,x);
              break;
            case 3:
              boxes[i][0] = x;
              boxes[i][1] = ++y;
              maxY = Math.max(maxY,y);
              break;
            default:
          }
        }

        buf.append(maxX - minX + 1)
           .append(" ")
           .append(maxY - minY + 1)
           .append("\n");
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 28956
// Contest: AtCoder Beginner Contest 155 (https://atcoder.jp/contests/abc155)
// Problem: A: Poor (https://atcoder.jp/contests/abc155/tasks/abc155_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int a, b, c; cin >> a >> b >> c;
    int eq = (a == b) + (b == c) + (a == c);
    cout << (eq == 1 ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int odd(int i){
   int digit=0;
   while(i){
      i=i/10;
      digit++;
   }
   return (digit % 2);
}
int main(){
   int n;
   int ans=0;
   cin>>n;
   for(int i=0; i<=n; i++){
      ans += odd(i);
   }
   cout<<ans;
   
}

Measured memory_bytes: 256
#include<math.h>
#include <stdio.h>
int main(void)
{
	double x1, y1, x2, y2,r,kyori;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    r=pow(x2-x1,2)+pow(y2-y1,2);
	kyori = sqrt(r);
	printf("%f\n", kyori);
	return 0;
}

Measured memory_bytes: 652
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0086

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    for line in sys.stdin:
        routes = []
        a, b = map(int, line.split())
        if a == 0 and b == 0:
            break
        while a != 0 or b!= 0:
            routes.append([a, b])
            a, b = map(int, input().split())

        degrees = [0] * 101
        for a, b in routes:
            degrees[a] += 1
            degrees[b] += 1
        odds = [x for x in degrees if x%2==1]
        # evens = [x for x in degrees if x%2==0]
        # print(degrees)

        if len(odds) == 2 and degrees[1]%2==1 and degrees[2]%2==1:
            print('OK')
        else:
            print('NG')


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7664
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

int main() {
  INIT;
  
  char c;
  cin >> c;
  if (c == 'a' ||c == 'i' ||c == 'u' ||c == 'e' ||c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int ans=0;
    // int d=0, y = n;
    // while (y) {
    //     y/=10;
    //     d++;
    // }
    // int p=n;
    // while (p>=10) p/=10;
    // int k=n%10 + p*10;
    // int mid = n;
    // // cout << pow(10,d-1);
    // mid %= (int)pow(10, d-1);
    // mid/=10;
    // // cout << mid << endl;
    // // cout << k << endl;
    // for (int i=1;i<=n;i++) {
    //     int f,l;
    //     int x = i;
    //     l = x%10;
    //     while (x>=10) x/=10;
    //     f = x;
    //     int q=l*10+f;
    //     if (l == 0) continue;
    //     if (l == f) ans++;
    //     if (q<k) {
    //         int dd=d;
    //         while (dd>=2) {
    //             ans += pow(10,dd-2);
    //             dd--;
    //         }
    //     }
    //     else if (q == k && l == f) {
    //         int dd = d;
    //         while (dd >= 3) {
    //             ans += pow(10,dd-3);
    //             dd--;
    //         }
    //         ans += mid+1;
    //     } else {
    //         int dd=d;
    //         while (dd>=3) {
    //             ans += pow(10,dd-3);
    //             dd--;
    //         }
    //     }
    //     // cout << i << " " << ans << endl;
    // }
    // cout << ans << endl;
    int cnt[100];
    memset (cnt,0,sizeof(cnt));
    for (int i=1;i<=n;i++) {
        int x = i;
        int f = 0, l = x%10;
        while (x>=10) x/=10;
        f = x;
        cnt[l*10+f]++;
    }
    for (int i=1;i<=n;i++) {
        int x = i;
        int f = 0, l = x%10;
        while (x>=10) x/=10;
        f = x;
        ans += cnt[f*10+l];
    }
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,M;cin >> N >> M;
  for(int i=M/N;i>=1;i--){
    if(M%i==0){
      cout << i << endl;
      return 0;
    }
  }
}

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

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N, K;
  cin >> N >> K;

  cout << (ll)(K*pow(K-1,N-1)) << "\n";
  return 0;
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7){
		cout<<"YES"<<endl;
	}
	else if(a==5&&b==7&&c==5){
		cout<<"YES"<<endl;
	}
	else if(a==7&&b==5&&c==5){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
N = len(S)

c = Counter(S)
if N < 26:
    for s in ascii_lowercase:
        if s not in c:
            print(S + s)
            exit()
else:
    # プレフィックスを1つずつ短くして試していく
    for i in range(N-1, -1, -1):
        pref = S[:i]
        S2 = S[i:]
        # 降順並び替え
        S3 = ''.join(sorted(S2, reverse=True))
        # 動かしたい場所が降順に並んでいたらもう動かせない
        if S2 != S3:
            # 交換対象の中で、置き換える文字より1つ大きいもの
            print(pref + S3[S3.index(S2[0])-1])
            exit()
    print(-1)


Measured memory_bytes: 5404
#include <bits/stdc++.h>
using namespace std;
int n,m,i,x,y;
int a[200001]={0},b[200001]={0};
int main(void)
{
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> x >> y;
		if(x==1)a[y-1]=1;
		if(y==n)b[x-1]=1;
	}
	for(i=0;i<n;i++){
		if(a[i]==1 && b[i]==1){
			cout << "POSSIBLE" << endl;
			break;
		}
	}
	if(i==n) cout << "IMPOSSIBLE" << endl;
	return 0;
}
	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  int M,cnt=0;
  M=N;
  while(M){
    cnt++;
    M/=10;
  }
  int ans=0;
  rep(i,cnt) if(i%2) ans=ans*100+9;
  int X=1;
  rep(i,cnt-1) X*=10;
  if(cnt%2) ans+=N-X+1;
  if(N<10) ans=N;
  cout<<ans<<endl;
}

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

void sort(int N, int *Ls){
    for(int i = N - 1; i >= 1; i --){
        for(int j = 0; j < i; j ++){
            if(Ls[j] > Ls[j + 1]){
                int tmp = Ls[j];

                Ls[j] = Ls[j + 1];
                Ls[j + 1] = tmp;
            }
        }
    }
}
int count_if(int i_max, int *Ls, int num_min){
    int i_start = 0;
    int i_end = i_max;

    if(Ls[0] >= num_min){
        return i_max + 1;
    }
    int i_mid;

    while(1){
        i_mid = (i_start + i_end) / 2;

        if(Ls[i_mid] == num_min){
            break;
        }
        else if(i_start + 1 >= i_end){
            if(Ls[i_start] >= num_min){
                i_mid = i_start;
            }else{
                i_mid = i_end;
            }
            break;
        }
        else if(Ls[i_mid] < num_min){
            i_start = i_mid;
        }
        else if(Ls[i_mid] > num_min){
            i_end = i_mid;
        }
    }
    int i_min = i_mid;

    if(Ls[i_min] < num_min){
        return 0;
    }

    for(int i = i_min; i >= 0; i --){
        if(Ls[i - 1] == Ls[i_mid]){
            i_min = i;
        }
    }
    return i_max - i_min + 1;
}

int main(){
    int N;

    scanf("%d", &N);

    int *Ls = (int *) malloc(sizeof(int) * N);

    for(int i = 0; i < N; i ++){
        scanf("%d", Ls + i);
    }
    sort(N, Ls);

    long long int count = 0;

    for(int i = N - 1; i >= 2; i --){
        for(int j = i - 1; j >= 1; j --){
            for(int k = j - 1; k >= 0; k --){
                if(Ls[k] + Ls[j] > Ls[i]){
                    count ++;
                }
            }
        }
    }
    printf("%lld\n", count);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
class activity{
  public:
  int a,b,c;
};
int solve(vector<activity> v,int n){
    int dp[n+1][3];
    dp[1][0] = v[0].a;
    dp[1][1] = v[0].b;
    dp[1][2] = v[0].c;
    for(int i=2;i<=n;i++){
        dp[i][0] = v[i-1].a + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = v[i-1].b + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = v[i-1].c + max(dp[i-1][1],dp[i-1][0]);
    }
    return max(dp[n][0], max(dp[n][1],dp[n][2]));
}
int main(){
  int n;
  cin>>n;
  vector<activity> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i].a;
    cin>>v[i].b;
    cin>>v[i].c;
  }
  cout<<solve(v,n)<<endl;
}












 /*int solve(vector<activity> v,int n){
    int dp[n+1][3];
    dp[1][0]=v[0].a;
    dp[1][1]=v[0].b;
    dp[1][2]=v[0].c;
    for(int i=2;i<=n;i++){
        dp[i][0]=v[i-1].a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i-1].b+max(dp[i-1][2],dp[i-1][0]);
        dp[i][2]=v[i-1].c+max(dp[i-1][1],dp[i-1][0]);
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));
}*/ 


Measured memory_bytes: 6588
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


def is_harshad(n):
    p = n
    tmp = 0
    while p >= 10:
        p, q = divmod(p, 10)
        tmp += q
    tmp += p

    if n % tmp == 0:
        return True
    else:
        return False


N = int(input())

if is_harshad(N):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll h,w,n;

ll check(ll a,ll b){
  if(a==0||a==h)return 1;
  if(b==0||b==w)return 1;
  return 0;
}

int main() {
  cin>>h>>w>>n;
  vector<pair<ll,ll> > v;
  rep(i,0,n){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(check(a,b)==1&&check(c,d)==1){
      vector<pair<ll,ll> > v1;
      if(a==0){
        v1.pb(mp(b,i));
      }
      else if(a==h){
        v1.pb(mp(2*w+h-b,i));
      }
      else if(b==0){
        v1.pb(mp(2*w+2*h-a,i));
      }
      else if(b==w){
        v1.pb(mp(w+a,i));
      }
      if(c==0){
        v1.pb(mp(d,i));
      }
      else if(c==h){
        v1.pb(mp(2*w+h-d,i));
      }
      else if(d==0){
        v1.pb(mp(2*w+2*h-c,i));
      }
      else if(d==w){
        v1.pb(mp(w+c,i));
      }
      sort(all(v1));
      v.pb(mp(v1[0].fi,v1[0].se));
      v.pb(mp(v1[1].fi,v1[1].se+n));
    }
  }
   sort(all(v));
  stack<ll> st;
  rep(i,0,v.size()){
    if(v[i].se>=n){
      if(st.size()>0&&st.top()+n==v[i].se)st.pop();
      else{
        cout<<"NO"<<endl;
        return 0;
      }
    }else{
      st.push(v[i].se);
    }
  }
  if(st.empty()){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 6256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>


using namespace std;

int c[30];
int main()
{
  string s;
  int sum;
  while(cin >> s)
  {
    if(s == "..")
      break;
    for(int i = 0; i < s.length(); i++)
    {
      if(s[i] >= 'A' && s[i] <= 'Z')
        c[s[i] - 'A']++;
      if(s[i] >= 'a' && s[i] <= 'z')
        c[s[i] - 'a']++;
    }
  }
  for(int i = 0; i < 26; i++)
  {
    cout << (char)('a' + i) << " : " << c[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N, K;
    cin>>N>>K;
    ll P[6000], C[6000];
    rep(i, N) cin>>P[i];
    rep(i, N) cin>>C[i];
    ll ALLMAXIMA=-500000000000000;
    rep(i, N){
        ll sc=0;
        ll coc=0;
        ll thisc=i;
        pair<ll, ll> ard[6000];
        rep(i, N) ard[i]={-10000000000, N+1};
        ard[i]={0, coc};
        ll otid=i;
        while(true){
            sc+=C[P[thisc]-1];
            thisc=P[thisc]-1;
            coc++;
            ard[thisc]={sc ,coc};
            //cout<<sc<<sp<<coc<<sp<<thisc<<endl;
            if(thisc==otid) break;
        }
       // cout<<endl;
        ll Maximall=-10000000000;
        ll Maximlim=-10000000000;
        ll sabun=K%coc;
        rep(i, N){
            if(ard[i].second!=N+1){
                Maximall=max(Maximall, ard[i].first);
                if(ard[i].second<=sabun) Maximlim=max(Maximlim, ard[i].first);
            }
        }
        ll thismax;
        //cout<<sc<<sp<<coc<<endl;
        if(sc>0){
           thismax=(K/coc)*sc+Maximlim;
            if(K/coc>0) thismax=max(thismax, (K/coc-1)*sc+Maximall);
        }
        else{
            if(K>=coc) thismax=Maximall;
            else thismax=Maximlim;
        }
        //cout<<Maximlim<<sp<<Maximall<<sp<<thismax<<endl<<endl;
        ALLMAXIMA=max(ALLMAXIMA, thismax);
    }
    cout<<ALLMAXIMA<<endl;
    return 0;
}


Measured memory_bytes: 3700
while(True):
  a,op,b=input().split(' ')
  a=int(a)
  b=int(b)
  if op=='+':
    print(a+b)
  elif op=='-':
    print(a-b)
  elif op=='/':
    print(a//b)
  elif op=='*':
    print(a*b)
  else:
    break


Measured memory_bytes: 5596
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
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)
typedef long long ll;

int main(void) {
  int n, m;
  cin >> n >> m;
  set<ll> ds;
  for(int d = 1; d*d <= m; ++d) {
    if(m % d == 0) {
      ds.insert(d);
      ds.insert(m / d);
    }
  }
  int res = 1;
  for(ll d : ds) {
    if(d * n <= m) {
      res = d;
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
def mapt(fn, *args):
    return tuple(map(fn, *args))

def Input():
    return mapt(int, input().split(" "))

def main():
    n = int(input())
    b = Input()
    data = 0
    for i in range(n-1):
        if i == 0:
            data += b[i]
            continue
        data += min(b[i], b[i-1])
    data += b[-1]
    print(data)
main()

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
int main(){
	signed long long a,b,c=0,d=0;
	cin>>a>>b;
	for(signed long long i=a;i<=b;i++){
		if(i<0){
			c++;
		}
		if(i==0){
			d=1;
		}
	}
	if(d==1){
		cout<<"Zero"<<endl;
	}else{
		if(c%2==0){
			cout<<"Positive"<<endl;
		}else{
			cout<<"Negative"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=sorted(map(int,input().split()))
m=max(a)+1
t=[0]*m
cnt=0
for i in a:
    if t[i]==0:
        cnt+=1
    elif t[i]==1:
        cnt-=1
    if t[i]<2:
        t[i]+=1
        for j in range(i*2,m,i):
            t[j]=2
print(cnt)

Measured memory_bytes: 116884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;


llint n;
llint l[100005], r[100005];
vector<P> vec;
llint mn[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> l[i] >> r[i];
	
	llint rmin = inf, rmin_i, lmax = -inf, lmax_i;
	for(int i = 1; i <= n; i++){
		if(rmin > r[i]){
			rmin = r[i], rmin_i = i;
		}
		if(lmax < l[i]){
			lmax = l[i], lmax_i = i;
		}
	}
	llint lenmax = -inf;
	for(int i = 1; i <= n; i++){
		if(i == rmin_i || i == lmax_i) continue;
		lenmax = max(lenmax, r[i]-l[i]+1);
	}
	if(rmin_i == lmax_i){
		cout << r[rmin_i]-l[rmin_i]+1 + lenmax << endl;
		return 0;
	}
	
	llint ans = max(0LL, r[rmin_i]-l[lmax_i]+1) + lenmax;
	for(int i = 1; i <= n; i++){
		if(i == rmin_i || i == lmax_i) continue;
		vec.push_back(P(l[i], r[i]));
	}
	sort(vec.begin(), vec.end());
	vec.insert(vec.begin(), P(l[rmin_i], r[rmin_i]));
	vec.push_back(P(l[lmax_i], r[lmax_i]));
	
	llint x = inf, m = vec.size();
	for(int i = m-1; i>=1; i--){
		x = min(x, vec[i].second);
		mn[i] = x;
	}
	
	llint L = -inf, tmp;
	for(int i = 0; i < m-1; i++){
		L = max(L, vec[i].first);
		tmp = max(0LL, r[rmin_i]-L+1);
		tmp += max(0LL, mn[i+1]-l[lmax_i]+1);
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4336
y, x = map(int, input().split())

tsuru = (x-2*y)/2
kame = (4*y-x)/2
if tsuru < 0 or kame < 0:
  print('No')
elif (x-2*y)%2 == 0 and (4*y-x)%2 == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9124
function main(input) {
  const lines = input.split('\n');
  lines.pop();
  lines.forEach(line => {
    const parsed = line.split(' ');
    console.log(fn(
      parseInt(parsed[0], 10),
      parseInt(parsed[1], 10),
      parseInt(parsed[2], 10)
    ));
  });
}

function fn(a, b, c) {
  const answer = c - a + b;
  if (answer < 0) {
    return 0;
  }
  return answer;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372