akhauriyash/Code-Regression huggingface dataset:
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e,t){"use strict";function n(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=Number(r[0]),t=new Array(e),o=0;o<e;o++)t[o]=[];for(var u=n(r[e].split(" ").map(function(r){return Number(r)}),2),i=u[0],f=u[1],a=0;a<e-1;a++){var l=r[a+1].split(" ").map(function(r){return Number(r)});l[1]!=f&&t[l[0]-1].push([l[1]-1,l[2]]),l[0]!=f&&t[l[1]-1].push([l[0]-1,l[2]])}for(var c=new Array(e).fill(-1),p=[f-1],s=[0];p.length>0;)for(var d=p.pop(),v=s.pop(),y=t[d].length,b=0;b<y;b++){var m=t[d][b];if(-1==c[m[0]]){var h=v+m[1];c[m[0]]=h,p.push(m[0]),s.push(h)}}for(var g=0;g<i;g++){var x=r[g+e+1].split(" ").map(function(r){return Number(r)-1}),j=c[x[0]]+c[x[1]];console.log(j)}}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 94576
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int num;
    num = a*100 + b*10 + c;
    if (num % 4 == 0) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, i, j, a, cards[4][13] = {};
	char egara, egara2[5] = "SHCD";

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%c", &egara);
		scanf("%c %d", &egara, &a);

		for (j = 0; j < 4; j++)
		{
			if (egara2[j] == egara)
			{
				cards[j][a-1] = 1;
			}
		}
	}

	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 13; j++)
		{
			if (cards[i][j] == 0)
			{
				printf("%c %d\n", egara2[i], j + 1);
			}
		}
	}

	return 0;
}


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

int main(){
  int N; cin >> N;
  set<long> s;
  long inp;
  
  for(int i=0; i<N; i++){
    cin >> inp;
    if(s.find(inp)!=s.end()){s.erase(inp);}
    else{s.insert(inp);}
  }
  
  cout << s.size();
  
  return 0;
}

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

int main() {
  
  int n; cin >> n; vector<int> vec(n);
  
  for (int i = 0; i < n; i++) cin >> vec.at(i);
  
  for (int i = 0; i < n; i++) {
    
    if (i) cout << " ";
    
    cout << vec.at(n - 1 - i);
    
  }
  
  cout << endl;
  
}


Measured memory_bytes: 3092
n = int(input())
l=[{} for i in range(2)]
mod = 10**9+7

def judge(s):
  t=list(s)
  if ''.join(t).find('AGC') != -1:
    return False
  t[0],t[1]=t[1],t[0]
  if ''.join(t).find('AGC') != -1:
    return False
  t[0],t[1]=t[1],t[0]
  t[1],t[2]=t[2],t[1]
  if ''.join(t).find('AGC') != -1:
    return False
  t[1],t[2]=t[2],t[1]
  t[2],t[3]=t[3],t[2]
  if ''.join(t).find('AGC') != -1:
    return False
  return True

l[1]['XXX']=1

for i in range(n):
  l[i%2].clear()
  for s in l[(i+1)%2]:
    for c in 'ACGT':
      l[i%2][s[1:]+c] = 0

  t = 0
  for s in l[(i+1)%2]:
    for c in 'ACGT':
      if judge(s+c):
        l[i%2][s[1:]+c] = (l[i%2][s[1:]+c]+l[(i+1)%2][s]) % mod
        t = (t + l[(i+1)%2][s]) % mod
print(t)


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

using namespace std;

int main(void) {
    string s;
    int K;
    cin >> s >> K;
    int N = s.size();
    vector<int> d[255];
    for (int i = 0; i < N; i++) {
        d[s[i]].push_back(i);
    }
    set<string> set;
   for(char c='a';c<='z';c++)
   {
       for(int i:d[c]){
           for(int j=N-i;j>0;j--){
               string sub=s.substr(i,j);
               if(set.count(sub))break;
               set.insert(sub);
           }
       }
       if(set.size()>K)break;
   }
    auto itr = set.begin();
    for (int k = 0; k < K - 1; ++k) {
        itr++;
    }
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 992000
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

ll get_score(char c, ll R, ll S, ll P) {
    switch (c) {
        case 'r':
            return P;
        case 's':
            return R;
        case 'p':
            return S;
    }
}
int run(istream& in, ostream& out) {
    ll N, K, R, S, P;
    string T;
    in >> N >> K;
    in >> R >> S >> P;
    in >> T;
    ll ans = 0;
    // solution here
    vector<bool> is_win(N, false);
    REP(i, N) {
        ll score = 0;
        if (i < K || (!is_win[i-K] || (is_win[i-K] && T[i-K] != T[i]))) {
            ans += get_score(T[i], R, S, P);
            is_win[i] = true;
        }
    }
    out << ans << endl;
    debug(ans);
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxi = 100005;

int len [100005];

vector<int>adj[maxi];

int fun(int u)
{
	if(len[u])return len[u];
	
	for(int i =0;i<adj[u].size();i++)
	len[u]=max(1+fun(adj[u][i]),len[u]);
	return len[u];
}

int main()
{
	int n,m;cin>>n>>m;
	for(int i =0;i<m;i++)
	{
		int x,y;cin>>x>>y;
		adj[x].push_back(y);
	}
	
	int maxi =0;
	for(int i =1;i<=n;i++)
	{
		if(len[i]==0)
		{
			maxi = max(maxi,fun(i));
		}
		
	}
	cout<<maxi<<endl;
}

Measured memory_bytes: 11496
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int w,n,s[100],sp,x,y;
	char c;
	while(cin>>w>>n,w||n){
		memset(s,-1,sizeof(s));
		for(int i=0;i<n;i++){
			cin>>c;
			if(c=='w'){
				cin>>x;
				for(int j=0;j<w;j++){
					if(s[j]==x)
					s[j]=-1;
				}
			}else{
				int j,k;
				cin>>x>>y;
				for(j=0;j<w;j++){
					if(s[j]==-1){
						for(k=j;k<w;k++){
							if(-1!=s[k]){
								break;
							}
						}
						sp=k-j;
						if(sp>=y){
							cout<<j<<endl;
							for(int h=j;h<y+j;h++)
							s[h]=x;
							break;
						}
					}
				}
				if(j==w)
				cout<<"impossible"<<endl;
			}
			
		}
		cout<<"END"<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N];
    string s[8] = {"gray", "brown", "green", "rightblue", "blue", "yellow", "orange", "red"};
    map<string, int> mp;
    REP(i, N) cin >> a[i];
    REP(i, N) {
        if(a[i] >= 1 && a[i] < 400) {
            mp[s[0]]++;
        } else if(a[i] >= 400 && a[i] < 800) {
            mp[s[1]]++;
        } else if(a[i] >= 800 && a[i] < 1200) {
            mp[s[2]]++;
        } else if(a[i] >= 1200 && a[i] < 1600) {
            mp[s[3]]++;
        } else if(a[i] >= 1600 && a[i] < 2000) {
            mp[s[4]]++;
        } else if(a[i] >= 2000 && a[i] < 2400) {
            mp[s[5]]++;
        } else if(a[i] >= 2400 && a[i] < 2800) {
            mp[s[6]]++;
        } else if(a[i] >= 2800 && a[i] < 3200) {
            mp[s[7]]++;
        } else if(a[i] >= 3200){
            mp["other"]++;
        }
    }
    int min = 0;
    REP(i, 8) {
        if(mp[s[i]] > 0) min++;
    }
    int max = min + mp["other"];
    if(min == 0) min = 1;
    cout << min << " " << max << "\n";
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

struct UnionFind {
    vector<int> par;
    vector<int> sizes;

    UnionFind(int n) :
            par(n), sizes(n, 1) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int find(int x) {
        if (x == par[x]) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

};

int main() {

    int N, M;
    cin >> N >> M;

    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i], p[i]--;

    UnionFind UF(N);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y, x--, y--;
        UF.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) if (UF.same(i, p[i])) ans++;
    cout << ans << endl;

}














































Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define PI 3.141592653589793238
//ang=(PI*ang)/180.0 in radian
#define Max(a,b,c) max(a,max(b,c));
#define all(v) v.begin(),v.end()
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int ar[5];
	for (int i = 0; i < 5; i++)cin >> ar[i];

	for (int i = 0; i < 5; i++)
		if (ar[i] == 0)
		{	cout << i + 1 << endl;
			break;
		}
	return 0;
}

Measured memory_bytes: 3520
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a*b>c*d)
	{
		cout<<a*b<<endl;
	}
	else
	{
		cout<<c*d<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long N,M,K,ans,a[200005],b[200005];
int main(){
	cin>>N>>M>>K;
	for(long long i=1;i<=N;i++)cin>>a[i],a[i]=a[i-1]+a[i];
	for(long long i=1;i<=M;i++)cin>>b[i],b[i]=b[i-1]+b[i];
	for(long long i=0;i<=N;i++)
		if(K>=a[i])
			ans=max(ans,upper_bound(b+1,b+M+1,K-a[i])-b-1+i);
	cout<<ans;
}


Measured memory_bytes: 6712
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
    int V, E, R;
    cin >> V >> E >> R;
    vector<int> d(V, 2e9);
    d[R] = 0;
    vector<int> S(E), T(E), D(E);
    for (int i = 0; i < E; i++) cin >> S[i] >> T[i] >> D[i];
    for (int t = 0; t < V; t++)
    {
        bool no_chng = true;
        for (int i = 0; i < E; i++)
        {
            if (d[S[i]] < 2e9 && d[T[i]] > d[S[i]] + D[i])
            {
                d[T[i]] = d[S[i]] + D[i];
                no_chng = false;
            }
        }
        if (no_chng) break;
    }
    for (auto i : d) cout << ((i == 2e9) ? "INF" : to_string(i).c_str()) << endl;
    return 0;
}


Measured memory_bytes: 8748
n=int(input())
l=list(map(int,input().split()))
import collections
c = collections.Counter(l)
ans1=[]
ans2=[0]
for x in c.keys():
  if c[x]>1:
    ans1.append(x)
  if c[x]>3:
    ans2.append(x)
ans1.sort()
if len(ans1)<2:
  print(0)
else:
  print(max(ans1[-1]*ans1[-2],max(ans2)**2))

Measured memory_bytes: 18216
#include<cstdio>
#include<stdlib.h>
/*http://climpet.hatenablog.com/entry/2013/01/01/225142#f5を参考*/
int main(int argc, char *argv[])
{
  int pow3[16],c[16];
  int n,m,i,j,k,d,x,y,p;

  pow3[0] = 1;
  for(i = 1;i <=15;i++){
    pow3[i] = pow3[i-1]*3;/*i枚#0から#2または#2から#0へ移動するのに必要なステップ数*/
}

  while(scanf("%d%d",&n,&m),n){
    for(i = 0;i < 3;++i){
      for(scanf("%d",&j);j > 0;--j){
	scanf("%d",&k);
	c[n-k] = i;/*番号付け替え,ハノイの塔に変換。大きいコップを小さい円盤にする*/
      }
    }
    p = 0;//全ての円盤が0の位置にあると仮定する
    x = 0;
    for(i = n-1;i >= 0;--i){//
      d = abs(p -c[i]);//移動させる円盤の距離を求める。
      /*n = 3の時、i = 2で円盤2を#1に移動させるには円盤1と円盤0を#2に移動させる*/
      x += pow3[i]*d;
      if(d == 1){
	p = 2-p;/*反対側に移動,距離がd = 1ならば0~i-1番の円盤を反対側に移動する。*/
      }
    }
    y = pow3[n] -1 -x;
    if(x > y){
      x = y;
    }
    printf("%d\n",x > m?-1:x);
  }
  return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

const int MAX = 510000; //nCrのr
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> w(N); rep(i, N) cin >> w[i];

  int ans = INF;
  for (int T = 0; T < N - 1; ++T){
    int s1 = 0, s2 = 0;
    for (int i = 0; i <= T; ++i){
      s1 += w[i];
    }
    for (int i = T + 1; i < N; ++i){
      s2 += w[i];
    }
    ans = min(ans, abs(s1 - s2));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
char s[200010];
bool check(int x,int y,int l)
{
	for(int i=1;i<=l;i++)
		if(s[x+i-1]!=s[y+i-1])
			return false;
	return true;
}
int dp[200010][2];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	dp[1][0]=1;
	if(s[2]!=s[1]) dp[2][0]=2;
	dp[2][1]=1;
	for(int i=3;i<=n;i++)
	{
		for(int j=0;j<=1;j++)
		{
			for(int k=0;k<=1;k++)
			{
				if(j==k&&check(i-j,i-j-k-1,j+1))
					continue;
				dp[i][j]=max(dp[i][j],dp[i-j-1][k]+1);
			}
		}
	}
	printf("%d",max(dp[n][0],dp[n][1]));
	return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
       System.out.print("");  int a = stdIn.nextInt();
       System.out.print("");  int b = stdIn.nextInt();
       System.out.print("");  int c = stdIn.nextInt();
       
       if (a <= c && b >= c)
           System.out.println("Yes");
       else
           System.out.println("No");
    }   
}

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

int main() {
  string s, t;
  cin >> s >> t;
  t += s;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k,x;cin>>n>>k;int sb[200005];
for(int i=0;i<k;i++)cin>>sb[i];int maxn=sb[0]+n-sb[k-1];
for(int i=1;i<k;i++){
	maxn=max(maxn,sb[i]-sb[i-1]);
}
cout<<n-maxn<<"\n";
}

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

vector<int> edge[55];
map<int, map<int, int>> idx;

bool dfs(int from, int par, int goal, bitset<55> &path) {
	if(from == goal) return true;
	bool ret = false;
	for(int to : edge[from]) {
		if(to == par) continue;
		bool tmp = dfs(to, from, goal, path);
		if(tmp) {
			ret = true;
			path.set(idx[from][to], true);
		}
	}
	return ret;
}

int main() {
	int n; cin >> n;
	for(int i = 0; i < n - 1; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		idx[a][b] = idx[b][a] = i;
	}
	int m; cin >> m;
	bitset<55> path[m];
	for(int i = 0; i < m; ++i) {
		int u, v; cin >> u >> v;
		--u, --v;
		dfs(u, -1, v, path[i]);
	}
	int64_t ans = 0;
	for(int mask = 1; mask < (1 << m); ++mask) {
		bitset<55> OR;
		for(int i = 0; i < m; ++i) {
			if(mask >> i & 1) {
				OR |= path[i];
			}
		}
		int cnt = __builtin_popcount(mask);
		if(cnt % 2 == 0) {
			ans -= (1ll << (int64_t)(n - 1 - OR.count()));
		} else {
			ans += (1ll << (int64_t)(n - 1 - OR.count()));
		}
	}
	cout << (1ll << (n - 1)) - ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, k;
  cin >> n >> k;
  vi a(n);
  for(int& x : a){
    cin >> x;
  }
  vi dp(k + 1);
  dp[0] = 1;
  for(int i = 1; i <= n; i++){
    vi newdp(k + 1);
    for(int j = 1; j <= k; j++){
      dp[j] = add(dp[j], dp[j - 1]);
    }
    for(int x = 0; x <= k; x++){
      int res = dp[x];
      if(x - a[i - 1] - 1 >= 0) res = sub(res, dp[x - a[i - 1] - 1]);
      newdp[x] = res;
    }
    swap(newdp, dp);
  }
  cout << dp[k];
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  char input;
  int flg = 0;

  scanf("%c",&input);
  
  if((input == 'a')||
     (input == 'i')||
     (input == 'u')||
     (input == 'e')||
     (input == 'o')){
    flg++;
  }
  else{
    flg = 0;
  }
  if(flg!=0){
    printf("vowel\n"); 
  }  
  else{
    printf("consonant\n");
  }
  return 0;
}

Measured memory_bytes: 2024
#include<bits/stdc++.h>
const int maxn=101;
using namespace std;
int main(){
	string a,b;
	cin>>a;
	cin>>b;
	if(a.size()!=b.size()){
		cout<<"No";
		return 0;
	}
	for(int i=a.size()-1;i>=0;i--){
		if(b==a.substr(i,a.size()-i)+a.substr(0,i)){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl; 
	return 0;
} 

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << (b-a == c-b? "YES" : "NO") << endl;
  return 0;
}


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

using namespace std;
using vi = vector<int>;

int main(void)
{
    string s, t;
    cin >> s >> t;

    int n = s.size(), m = t.size();

    int k = -1;

    bool ok;

    if (n < m)
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for (int i = 0; i < n - m + 1; ++i)
    {
        ok = true;
        for (int j = 0; j < m; ++j)
        {
            if (s[i + j] != t[j] and s[i + j] != '?')
            {
                ok = false;
            }
        }
        if (ok)
            k = i + m - 1;
    }

    if (k != -1)
    {
        for (int i = 0; i < n; ++i)
        {
            if (i >= k - m + 1 and i <= k)
            {
                cout << t[i - k + m - 1];
            }
            else
            {
                if (s[i] == '?')
                    cout << 'a';
                else
                    cout << s[i];
            }
        }
    }
    else
        cout << "UNRESTORABLE" << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

ll MOD = 1000000007;

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

    ll sum = 0;

    for (ll i = 0; i < (ll)n.size(); i++)
    {
        sum += n[i] - '0';
    }

    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    
		
		ld a, b, n;
		cin >> a >> b >> n;
		
		if (b == 1)
			cout << "0\n";
		else if (b <= n)
			cout << floor((a * (b - 1)) / b) << "\n";
		else
			cout << floor((a * n) / b) << "\n";
	//code
	return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int n,m;
    cin>>n>>m;
    int l,r;
    int lvl[n+1]={0};
    int marked[n+1]={0};
    vector<int>v[n+1];
    queue<int>q;
    q.push(1);
    for(int i = 0 ; i< m; i++){
        cin>>l>>r;
        v[l].push_back(r);
        v[r].push_back(l);
    }
    int e =0 ;
    while(!q.empty()){
        e = q.front();
        q.pop();
        if(marked[e] == 1){
            continue;
        }
        else{
            marked[e] = 1;
            for(int i = 0 ; i < v[e].size() ; i++){
                if(marked[v[e][i]]==0){
                    q.push(v[e][i]);
                    if(lvl[v[e][i]]==0)
                    lvl[v[e][i]] = e;
                }
            }
        }
    }
    for(int i = 2 ; i <= n ; i++){
        if(lvl[i] == 0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i = 2 ; i <= n ; i++){
        cout<<lvl[i]<<endl;
    }
}


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

using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

int32_t main()
{
   IOS;
    ll n,l,i,sum=0;

    cin>>n>>l;
     ll a[n];
    for(i=0;i<n;i++)
    {
        a[i]=l+(i+1)-1;
    }
    if(l>0)
    {
        for(i=1;i<n;i++)
        {
            sum+=a[i];
        }
    }
    else if(l==0)
    {
        for(i=1;i<n;i++)
        {
            sum+=a[i];
        }
    }
    else if(l<0&&n>-l)
    {
        for(i=0;i<n;i++)
        {
            sum+=a[i];
        }
    }
    else if(l<0&&n<-l)
    {
        for(i=0;i<n-1;i++)
        {
            sum+=a[i];
        }
    }
     else if(l<0&&n==-l)
    {
        for(i=0;i<n;i++)
        {
            sum+=a[i];
        }
        sum=sum+1;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = input()
n = int(input())
# n,m = map(int, input().split())
# a = list(map(int,input().split()))
# a = [int(input()) for i in range()]


xl=[]
for i in range(n):
    x,l = map(int, input().split())
    xl.append((x,l))


def main():
    p = []
    for x,l in xl:
        p.append([x-l,x+l])
    p = sorted(p, key=lambda x:x[1])

    ans = 0
    mx = -10**10
    for st in p:
        s,t = st[0],st[1]
        if s>=mx:
            ans+=1
            mx=t
    print(ans)



    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 35700
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

LL f(LL s, LL N, vector<LL> &q, vector<LL> &x) {
    for (int i = 0; i < N; i++) {
        if (q[i] == 1) s *= x[i];
        if (q[i] == 2) s += x[i];
        if (q[i] == 3) s -= x[i];
    }
    return s;
}

int main() {

    LL N;
    cin >> N;

    vector<LL> q(N), x(N);
    for (int i = 0; i < N; i++) cin >> q[i] >> x[i];

    LL s1 = 1;
    LL s2 = 2;

    LL r1 = f(s1, N, q, x);
    LL r2 = f(s2, N, q, x);

    LL B = (r2 - r1) / (s2 - s1);
    LL A = B * s1 - r1;

    cout << A << " "<< B << endl;

    return 0;
}





































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

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

using namespace std;

string s[2000];
int ans[2000][2000];

int main() {
	int H, W;
	int count;
	int n = 0;

	cin >> H >> W;

	REP(i, H) REP(j, W) ans[i][j] = 0;
	REP(i, H) cin >> s[i];

	REP(i, H) {
		count = 0;
		REP(j, W) {
			if (s[i][j] == '#') count = 0;
			else count += 1;
			ans[i][j] += count;
		}
	}

	RREP(i, H) {
		count = 0;
		RREP(j, W) {
			if (s[i][j] == '#') count = 0;
			else count += 1;
			ans[i][j] += count;
		}
	}

	REP(i, W) {
		count = 0;
		REP(j, H) {
			if (s[j][i] == '#') count = 0;
			else count += 1;
			ans[j][i] += count;
		}
	}

	RREP(i, W) {
		count = 0;
		RREP(j, H) {
			if (s[j][i] == '#') count = 0;
			else count += 1;
			ans[j][i] += count;
		}
	}

	REP(i, H) REP(j, W)	n = max(n, ans[i][j]);
		
	cout << n-3 << endl;

	return 0;
}

Measured memory_bytes: 19968
import sys
H,W=map(int, raw_input().split())
S=[ sys.stdin.readline().strip() for i in range(H)] 

LSUM=[  [ 0 for w in range(W) ] for h in range(H) ]
RSUM=[  [ 0 for w in range(W) ] for h in range(H) ]
USUM=[ [ 0 for h in range(H) ] for w in range(W) ]
DSUM=[ [ 0 for h in range(H) ] for w in range(W) ]

for h in range(H):
	for w in range(W):
		if S[h][w]==".":
			if w==0:
				LSUM[h][w]=1
			else:
				LSUM[h][w]=LSUM[h][w-1]+1
		elif S[h][w]=="#":
				LSUM[h][w]=0


for h in range(H):
	for w in range(W-1,-1,-1):
		if S[h][w]==".":
			if w==W-1:
				RSUM[h][w]=1
			else:
				RSUM[h][w]=RSUM[h][w+1]+1
		elif S[h][w]=="#":
				RSUM[h][w]=0


for w in range(W):
	for h in range(H):
		if S[h][w]==".":
			if h==0:
				USUM[w][h]=1
			else:
				USUM[w][h]=USUM[w][h-1]+1
		elif S[h][w]=="#":
				USUM[w][h]=0


for w in range(W):
	for h in range(H-1,-1,-1):
		if S[h][w]==".":
			if h==H-1:
				DSUM[w][h]=1
			else:
				DSUM[w][h]=DSUM[w][h+1]+1
		elif S[h][w]=="#":
				DSUM[w][h]=0



ans=0
for h in range(H):
	for w in range(W):
		ans=max(ans , LSUM[h][w]+RSUM[h][w]+USUM[w][h]+DSUM[w][h]-3 )


print ans


Measured memory_bytes: 165148
#include "bits/stdc++.h"
using namespace std;
int b[200001];
signed main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1, a; i < n; ++i)
	{
		scanf("%d", &a);
		++b[a - 1];
	}
	for(int i = 0; i < n; ++i)
	{
		printf("%d\n", b[i]);
	}
}


Measured memory_bytes: 4504
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>
#include <list>

using namespace std; 

int main()
{
    int n,i;
    cin>>n;
    int a[n+1];
    for(i=1;i<=n;i++)
    {
    	cin>>a[i];
    }
   	if(n==2)
   	{
   		cout<<abs(a[2]-a[1]);
   		return 0;
   	}
    int ans[n+1];
    ans[1] = 0;
    ans[2] = abs(a[2]-a[1]);
    for(i=3;i<=n;i++)
    {
    	ans[i] = min(ans[i-2]+abs(a[i]-a[i-2]),ans[i-1]+abs(a[i]-a[i-1]));
    }
    cout<<ans[n];
    return 0;
}

Measured memory_bytes: 1024
import heapq
N,M = map(int,input().split())
A = [-i for i in map(int,input().split())]
heapq.heapify(A)
for i in range(M):
    a = (-(heapq.heappop(A)))//2
    heapq.heappush(A,-a)
print(-sum(A))

Measured memory_bytes: 14188
#include<iostream>
#include<stdio.h>
#include<cstdlib>

int top,S[1000];

void pop(int x) {
	S[++top] = x;
}

int push() {
	top--;
	return S[top + 1];
}

int main(){
	int a,b;
	top = 0;
	char s;
	
	while (scanf("%s", &s) != EOF) {
		if (s == '+') {
			a = push();
			b = push();
			pop(a + b);
		} else if (s == '-') {
			b = push();
			a = push();
			pop(a - b);
		} else if (s == '*') {
			a = push();
			b = push();
			pop(a * b);
		} else {
			pop(std::atoi(&s));
		}
	}
	
	std::cout << push() << std::endl;
	
	return 0;
}



Measured memory_bytes: 3236
//Reflection
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

static const double ESP = 1e-10;

bool equals(double a, double b) { return fabs(a - b) < ESP; }

class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector v1, Vector v2) {
    return equals(cross(v1, v2), 0.0);
}

bool isOrthogonal(Vector v1, Vector v2) {
    return equals(dot(v1, v2), 0.0);
}

int main() {
    int q;
    double x, y, x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    Point p1 = Point(x1, y1), p2 = Point(x2, y2);
    Vector v1, v2;
    v1 = p2 - p1;
    for(int i = 0; i < q; i++) {
        cin >> x >> y;
        Point p = Point(x, y);
        Vector v2 = p - p1;
        Point m = Point(), x = Point();
        m = p1 + (v1 * (dot(v1, v2) / v1.norm()));
        x = p + (m - p) * 2;
        cout << setprecision(15) << x.x << " " << x.y << endl;
    }
}


Measured memory_bytes: 3288
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// in, out
#include <iostream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias templates
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m; cin >> n >> m;
    int a[m], b[m];
    rep(i, m) cin >> a[i] >> b[i];
    vector<pii> v;
    rep(i, m){
        v.emplace_back(b[i], a[i]);
    }

    sort(all(v));

    int before = -1;
    int cnt = 0;

    rep(i, m){
        if (v[i].second <= before) continue;
        else {
            before = v[i].first - 1; ++cnt;
        }
    }
    print(cnt);

    return 0;
}

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

int main() {
	int A, B, C, D;
	char a, b, c, d;
	cin >> a >> b >> c >> d;
	A = a - '0';
	B = b - '0';
	C = c - '0';
	D = d - '0';

	char pm[2] = { '+','-' };

	for (int AB = 0; AB < 2; AB++) {
		for (int BC = 0; BC < 2; BC++) {
			for (int CD = 0; CD < 2; CD++) {
				int ans = A;
				ans += AB == 0 ? B : -B;
				ans += BC == 0 ? C : -C;
				ans += CD == 0 ? D : -D;
				if (ans == 7) {
					cout << A << pm[AB] << B << pm[BC] << C << pm[CD] << D << "=7";
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    t = [0] * 3
    for c in a:
        t[c-1] += 1
    A,B,C = t
    D = C + 1
    E = B + D
    F = A + E

    r = [[[0]*(F-k-j) for j in range(E-k)] for k in range(D)]
    for k in range(1):
        z = r[k]
        G = F - k
        for j in range(E-k):
            x = z[j]
            if j > 0:
                m = z[j-1]
            l = k + j
            for i in range(G-j):
                if not(i or l):
                    continue
                w = n
                if i > 0:
                    w += x[i-1] * i
                if j > 0:
                    w += m[i+1] * j
                x[i] = w / (i+l)


    y = r[0]
    for k in range(1, D):
        z = r[k]
        G = F - k

        x = z[0]
        p = y[1]
        x[0] = (n + p[0] * k) / k

        for i in range(1,G):
            x[i] = (n + x[i-1] * i + p[i] * k) / (i+k)

        for j in range(1,E-k):
            x = z[j]
            m = z[j-1]
            p = y[j+1]
            l = j + k
            x[0] = (n + m[1] * j + p[0] * k) / l

            for i in range(1,G-j):
                x[i] = (n + x[i-1] * i + m[i+1] * j + p[i] * k) / (i+l)

        y = z


    return "{:0.9f}".format(r[C][B][A])


print(main())


Measured memory_bytes: 162416
n,m,x = map(int,input().split())
books = []

for i in range(n):
    arr = list(map(int,input().split()))
    books.append(arr)

def tobin(x,n):
    return format(x,'b').zfill(n)

ans = 1e10
for i in range(2**n):
    b = format(i,'b').zfill(n)
    # print(b)
    buf = [0 for i in range(m)]
    temp = 0
    for j in range(n):
        if b[j]=="1":
            temp += books[j][0]
            for k in range(1,m+1):
                buf[k-1] += books[j][k]
        else:
            continue
    # print(buf)
    flag = True
    for val in buf:
        if val < x:
            flag = False

    if flag and ans > temp:
        ans = temp
    else:
        continue

if ans > 1e9:
    print(-1)
else:
    print(ans)




Measured memory_bytes: 68784
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll x, ll y){
     ll t;
 
     while (y != 0) {
         t = x % y;  x = y;  y = t;
     }
     return x;
}

int main(){
ll ans=1,a,b,c;
cin>>a>>b;
c=gcd(a,b);

ll buf=0;
for(ll i = 2; i * i <= c; i++) {
    while(c % i == 0) {
      if(buf!=i){
        buf=i;
        ans++;
      }
      c /= i;
    }
  }
  if(c != 1) ans++;

    cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
uint64_t factorial(int n) {
  uint64_t f = 1;
  for(int i = 2; i <= n; ++i) {
    f *= i;
  }
  return f;
}
vector<int> get_sequence(int n) {
  vector<int> seq(n);
  for(vector<int>::iterator it = seq.begin(); it != seq.end(); ++it) {
    cin >> (*it);
  }
  return seq;
}
int in_order(vector<int> v, int n) {
  sort(v.begin(), v.end());
  int o = 0;
  for(vector<int>::const_iterator it = v.begin(); it != v.end(); ++it, ++o)
    if(n==*it) break;
  return o;
}
int order(vector<int>& v) {
  int o = 0;
  for(int i = 0; i < v.size() - 1; ++i) {
    o+=in_order(vector<int>(v.begin() + i, v.end()), v[i])*factorial(v.size()-(i+1));
  }
  return o + 1;
}
int main() {
  int n;
  cin >> n;
  vector<int> p = get_sequence(n);
  vector<int> q = get_sequence(n);
  cout << abs(order(p) - order(q)) << endl;
  return 0;
}

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

string str, rep, cmd;
int main() {
	int num, beg, end;
	cin >> str >> num;
	for (int i = 0; i < num; i++) {
		cin >> cmd;
		if (cmd == "print") {
			cin >> beg >> end;
			for (int j = beg; j <= end; j++) {
				cout << str[j];
			}
			cout << endl;
		}
		else if (cmd == "reverse") {
			cin >> beg >> end;
			reverse(str.begin() + beg, str.begin() + end + 1);
		}
		else if (cmd == "replace") {
			cin >> beg >> end >> rep;
			str.replace(beg, rep.size(), rep);
		}
	}
	return 0;
}


Measured memory_bytes: 3148
// Last Change: 04/11/2019 23:33:40.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

void Mark() {
  static ll index = 0;
  ++index;
  cout << index << " is here!" << endl;
}

int main() {
  ll N, M;
  cin >> N >> M;

  vector<priority_queue<pair<ll, ll>>> pref(N + 1);
  vector<pair<ll, ll>> city(M + 1);

  ll year;
  for (ll i = 0; i < M; ++i) {
    // prefNum, year
    cin >> city[i].first >> year;
    pref[city[i].first].push(make_pair(year, i));
  }

  ll cnt;
  for (ll i = 1; i <= N; ++i) {
    cnt = pref[i].size();
    while (!pref[i].empty()) {
      city[pref[i].top().second].second = cnt;
      pref[i].pop();
      --cnt;
    }
  }

  cout << setfill('0');

  for (ll i = 0; i < M; ++i) {
    cout << setw(6) << city[i].first;
    cout << setw(6) << city[i].second;
    cout << '\n';
  }
  cout << flush;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 9344
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  s <- B.getLine
  print $ solve s

solve :: B.ByteString -> Int
solve s = 2 * min c0 c1
  where
    c0 = B.count '0' s
    c1 = B.length s - c0


Measured memory_bytes: 636
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
typedef long long ll;
int main()
{
//    fast

    int d,t,s;
    cin>>d>>t>>s;
    if(d<=s*t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;




}


Measured memory_bytes: 3620
S = list(input().split("T"))
x, y = map(int, input().split())

X_act = [len(i) for i in S[::2]]
Y_act = [len(i) for i in S[1::2]]

X_reached = {X_act[0]}
del X_act[0]
for xa in X_act:
    tmp = set()
    for xr in X_reached:
        tmp.add(xr+xa)
        tmp.add(xr-xa)
    X_reached = tmp

Y_reached = {0}
for ya in Y_act:
    tmp = set()
    for yr in Y_reached:
        tmp.add(yr+ya)
        tmp.add(yr-ya)
    Y_reached = tmp

if x in X_reached and y in Y_reached:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3816
import java.util.*;
import java.io.*;
class Main{
  public static void main(String []args) {
      Scanner sc=new Scanner(System.in);
      int w=sc.nextInt();
      int h=sc.nextInt();
      int x=sc.nextInt();
      int y=sc.nextInt();
      int r=sc.nextInt();
      if(0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h){
          System.out.println("Yes");
      }else{
        System.out.println("No");
      }
  }
}


Measured memory_bytes: 26360
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		int x, y, b, p;
		int sum = 0;
		
		scanf("%d %d %d %d", &x, &y, &b, &p);
		sum = x * b + y * p;
		
		if (b >= 5 && p >= 2){
			sum *= 0.8;
		}
		else {
			if (b < 5){
				b = 5;
			}
			if (p < 2){
				p = 2;
			}
			if (sum > (x * b + y * p) * 0.8){
				sum = (x * b + y * p) * 0.8;
			}
		}
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
set<char> st;
map<char,ll> mp;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    rep(i,Size(s)){
        st.insert(s[i]);
    }
    if(Size(st)==2){
        rep(i,Size(s)){
            mp[s[i]]++;
        }
        rep(i,Size(s)){
            if(mp[s[i]]!=2){
                Cout("No");
                return 0;
            }
        }
        Cout("Yes");
    }
    else Cout("No");
    return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
L = list(map(int,input().split()))

L.sort()

ans = 0

for a in range(N-2):
  for b in range(a+1,N-1):
    c = bisect.bisect_left(L, L[a]+L[b])
    ans += c - (b+1)
print(ans)

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

#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int MAXN = 5e5+5;
const int MOD= 998244353;
int n,m,k;
int pre[MAXN],num[MAXN],ans[MAXN],dp[MAXN];
int Find(int x){
    return pre[x]==x?x:pre[x]=Find(pre[x]);
}
map<pair<int,int>,int >mp;
int main(){
    while(cin>>n>>m>>k){
        rep(i,1,n)pre[i]=i;
        memset(num,0,sizeof(num));
        memset(ans,0,sizeof(ans));
        mp.clear();
        while(m--){
            int x,y;
            cin>>x>>y;
            num[x]++;num[y]++;
            int xx=Find(x);int yy=Find(y);
            pre[xx]=yy;
        }
        rep(i,1,n){
            ans[Find(i)]++;
        }
        rep(i,1,n){
            dp[i]=ans[Find(i)]-num[i]-1;
        }
        while(k--){
            int x,y;
            cin>>x>>y;
            int xx=Find(x);int yy=Find(y);
            if(xx==yy)dp[x]--,dp[y]--;
        }
        rep(i,1,n){
            printf("%d%c",dp[i],i==n?'\n':' ');
        }
    }
}


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

main(){
  int data[10000], p, i, j, k, n;

  data[0]=2;
  data[1]=3;

  k=2;
  for(i=5;i<100000;i+=2){
    p=0;
    for(j=0;;j++){
      if((double)data[j]>sqrt((double)i))break;
      if(i%data[j]==0){
        p=1;
        break;
      }
    }
    if(p==0){
      data[k]=i;
      k++;
    }
    if(k>=6000) break;
  }
  
  while(1){
    if(scanf("%d", &n)==EOF) break;

    for(i=0;i<6000;i++){
      if(data[i]==n){
	printf("%d %d\n", data[i-1], data[i+1]);
	break;
      }
      else if(data[i]>n){
	printf("%d %d\n", data[i-1], data[i]);
	break;
      }
    }
  }

  return 0;
}

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

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

    // p == 2, 5
    if (10%p == 0) {
        long long ans = 0;
        for (int r = 0; r < n; r++) {
            if ((s[r]-'0')%p == 0) {
                ans += r+1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> d(n+1);
    int ten = 1;
    for (int i = n-1; 0 <= i; i--) {
        int a = (s[i]-'0') * ten % p;
        d[i] = (d[i+1] + a)%p;
        ten *= 10; ten %= p;
    }
    vector<int> cnt(p);
    long long ans = 0;
    for (int i = n; 0 <= i; i--) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define cps(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 1003;
int n, m, A, B, C, D, d[n0][n0], inf;
char s[n0][n0];

bool ok(int x, int y) {
	return x >= 1 && x <= n && y >= 1 && y <= m && s[x][y] == '.';
}

void bfs() {
	memset(& d, 0x3f, sizeof(d));
	inf = d[0][0];
	deque <array <int, 2>> q;
	d[A][B] = 0;
	q.pb({A, B});
	while (!q.empty()) {
		auto P = q.front();
		q.pop_front();
		int x = P[0], y = P[1];
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int X = x + i, Y = y + j;
				if (!ok(X, Y) || (X == x && Y == y)) continue;
				int adj = 0;
				if ((i == -1 && j == 0) || (i == 0 && j == -1) || (i == 0 && j == 1) || (i == 1 && j == 0))
					adj = 1;
				if (adj) {
					if (d[X][Y] > d[x][y]) {
						d[X][Y] = d[x][y];
						q.push_front({X, Y});
					}
				}	else {
					if (d[X][Y] > d[x][y] + 1) {
						d[X][Y] = d[x][y] + 1;
						q.pb({X, Y});
					}
				}
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	cin >> n >> m >> A >> B >> C >> D;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> s[i][j];
		}
	}
	bfs();
	if (d[C][D] == inf) cout << -1;
	else cout << d[C][D];
}


Measured memory_bytes: 8564