akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
    int f = F/100+1;
    bool can[f]; REP(i,f) can[i] = false; can[0] = true;
    FOR(i,0,f){
        if(can[i]){
            if(i+A < f) can[i+A] = true;
            if(i+B < f) can[i+B] = true;
        }
    }
    double ans=0;
    int mizu=0,satou=0;
    FOR(i,A,f){
        if(can[i]){
            int s = min(i*E, F-100*i)+1;
            bool sugar[s]; REP(j,s) sugar[j] = false; sugar[0] = true;
            int maxi = 0;
            REP(j,s){
                if(sugar[j]){
                    if(j+C < s){
                        sugar[j+C] = true; chmax(maxi, j+C);
                    }
                    if(j+D < s){
                        sugar[j+D] = true; chmax(maxi, j+D);
                    }
                }
            }
            double a = (double)100*i, b = (double)maxi;
            if(chmax(ans, b/(a+b))){
                mizu = 100*i; satou = maxi;
            }
        }
    }
    cout << mizu+satou << " " << satou << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int k,a,b;
    cin >> k >> a >> b;

    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    int N, L;
    cin >> N >> L;
    int aji=0;
    rep(i, N){
        aji += L + i - 1;
    }
    if (L <= 0 && 1 <= N + L){
        cout << aji;
        return 0;
    }
    if (L + N - 1 < 0){
        cout << aji - (L + N - 1);
    }
    else {
        cout << aji - L;
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

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

	ll dp[n+1][n+1];
	rep(i, n+1) rep(j, n+1) dp[i][j] = 0;
	// dp[i][j] :
	//  ai+1からajでゲームをするときのX-Yの最大値
	//  ただし、手番は「元のゲームを行ってその局面になった時の手番」とする

	for(int len = 1; len <= n; len++){
		for(int l = 0; l < n - len + 1; l++){
			int r = l + len;
			if((n - len) % 2 == 0){
				dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1]);
			}else{
				dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1]);
			}
		}
	}

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


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

using namespace std;

int main() {
    long long int n, k;
    cin >> n >> k;
    long long int count = 0;
    if(k == 0)
    {
        cout << n * n << endl;
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        if(i <= k) continue;
        long long int pre = n / i;
        count += pre * (i - k);
        long long int rest = n % i;
        if(rest == 0) continue;
        if(rest - k + 1 >= 0) count += rest - k + 1;
    }
    cout << count << endl;
    return 0;
}


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

int N, M;
vector<int> V[100000];
deque<int> ANS;
bool visit[100000] = {};

void DFS1(int P) {
	visit[P] = true;
	for (int Q : V[P]) {
		if (!visit[Q]) {
			ANS.push_back(Q);
			DFS1(Q);
			return;
		}
	}
}

void DFS2(int P) {
	visit[P] = true;
	for (int Q : V[P]) {
		if (!visit[Q]) {
			ANS.push_front(Q);
			DFS2(Q);
			return;
		}
	}
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		V[A].push_back(B);
		V[B].push_back(A);
	}
	ANS.push_back(0);
	DFS1(0), DFS2(0);
	cout << ANS.size() << endl;
	while (ANS.size()) {
		cout << ANS.front() + 1;
		ANS.pop_front();
		if (ANS.size()) cout << " ";
	}
}

Measured memory_bytes: 9600
M, D = map(int, input().split())
c = 0
for m in range(3, M + 1):
    for d in range(21, D + 1):
        a = d % 10
        b = d // 10
        if a > 1 and b > 1 and a * b == m:
            c += 1
print(c)

Measured memory_bytes: 39408
S = input()
l=len(S)
if l%2==0:
    count=0
    s=S[int(l/2)]
    for i in range(int(l/2)):
        if S[int(l/2)-1-i]!=s or S[int(l/2)+i]!=s:
            break
        count+=1
    print(int(l/2)+count)
else:
    s=S[int(l/2)]
    count=0
    for i in range(int(l/2)):
        if S[int(l/2)-1-i]!=s or S[int(l/2)+1+i]!=s:
            break
        count+=1
    print(int(l/2)+1+count)

Measured memory_bytes: 3188
n = int(input())
name = ""
 
while(True):
  i = n % 26
  c = "zabcdefghijklmnopqrstuvwxyz"[i]
  name = c + name
  
  if(i==0):
    i=26
  n = int((n-i) / 26)
  if(n==0):
    break
    
print(name)

Measured memory_bytes: 9128
<?php
$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
$cnt = 0;
for ($i=1; $i <= $n ; $i++) { 
	if ($input[$i-1] != $i) {
		++$cnt;
	}
}
if ($cnt <= 2) {
	echo 'YES';
}else{
	echo 'NO';
}

Measured memory_bytes: 4728
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int X = 0; X <= 60000; ++X) {
    if (int(X * 1.08) != N)continue;
    cout << X << endl;
    return 0;
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	ll n;
	cin >> n;
	ll ans = 20;

	for (ll i = 1; i * i <= n; i++){
		if (n % i == 0){
			string a = to_string(i);
			string b = to_string(n/i);
			ans = min(ans, max((ll)a.size(), (ll)b.size()));
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
s=int(input())
x1,y1=0,0

if s<=10**9:
  x2=1
  y3=s
  y2=0
  x3=0
elif s==10**18:
    x2=0
    y2=10**9
    x3=10**9
    y3=0
else:
  x2=10**9
  y2=1
  a=s//x2
  b=s%x2
  y3=a+1
  x3=x2-b
print(x1, y1, x2, y2, x3, y3)

Measured memory_bytes: 38256
/*****************************************************************************************
******************************AUTHOR:***************************************************
****************************ASHISH RANJAN***********************************************
*****************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
#include<stack>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<(int)n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define fvs(i,a,b) for(int i=a;i>=b;i--)
#define meme(a,b,c) memset(a,b,sizeof(c)); //works only for 0 and -1
int main(){
  fast();
 stack<char> a;
stack<char> b;
stack<char> c;
string s1,s2,s3;
int x,y,z;
cin>>s1>>s2>>s3;
fvs(i,s1.size()-1,0)a.push(s1[i]);
fvs(i,s2.size()-1,0)b.push(s2[i]);
fvs(i,s3.size()-1,0)c.push(s3[i]);
x:;
if(a.empty()){cout<<"A";return 0;}
else{
int t = a.top();
  a.pop();
  if(t=='b')goto y;
  if(t=='c')goto z;
  else goto x;
}
y:;
if(b.empty()){cout<<"B";return 0;}
else{
int t = b.top();
  b.pop();
  if(t=='a')goto x;
  if(t=='c')goto z;
  else goto y;
}
z:;
if(c.empty()){cout<<"C";return 0;}
else{
int t = c.top();
  c.pop();
  if(t=='b')goto y;
  if(t=='a')goto x;
  else goto z;
}
 return 0;
  
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const int MAX_N = 100;
const int MAX_W = 100000;
ll dp[MAX_N+1][MAX_W+1];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, w; cin >> n >> w;
   rep(i,n){
      int wi, vi; cin >> wi >> vi;
      rep(j,w+1){
         dp[i+1][j] = dp[i][j];
         if (j-wi>=0) 
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-wi] + vi);
      }
   }
   cout << dp[n][w] << endl;
}

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

ll inf =1e9+7;

#define pi 3.14159265358979323846L
bool isprime(ll a)
{
	
	ll cnt=0;	
	for(ll i=1;i*i<a;i++)
	{
		
	 	if(a%i==0)
	 	{
	 		cnt+=2;
		 }
		
		
	}
	
		if(cnt==2)
		return true;
		else
		return false;
		
}
ll mod(ll a)
{
	if(a<inf)return a;
	else
	return a%inf;
}
void solve()
{

ll a,b,c,k;
cin>>a>>b>>c>>k;

ll ans=0;
if(a+b>=k)
{
	if(a>=k)
	ans=k;
	else
	ans=a;
}
else
{
	ans=a-(k-a-b);
}


cout<<ans;
}

int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 3536
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define MAXN 100010
vector<int> adj_list[MAXN];
bitset<MAXN> visited;
int h[MAXN];

int main(){
	ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<ii> vs(n);
	for(int i=0; i<n; ++i){
		cin >> vs[i].ff;
		h[i+1] = vs[i].ff;
		vs[i].ss = i+1;
	}
	sort(all(vs), greater<ii>());
	for(int i=0; i<m; ++i){
		int a, b;
		cin >> a >> b;
		adj_list[a].push_back(b);
		adj_list[b].push_back(a);
	}
	int ans = 0;
	for(auto x:vs){
		int u = x.ss;
		if(not visited[u]){
			bool can = true;
			visited[u] = true;
			for(auto v:adj_list[u]){
				if(h[u]>h[v])
					visited[v] = true;
				else
					can = false;
			}
			if(can) ++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9596
<?php
  $str = trim(fgets(STDIN));
  for($i=1;$i<=strlen($str);$i++) {
      if($i%2==0) {
          if($str[$i-1]=="R") {
              echo "No";
              break;
          }
      }
      else {
          if($str[$i-1]=="L") {
              echo "No";
              break;
          }
      }
      if($i==strlen($str)) {
          echo "Yes";
      }
   }

Measured memory_bytes: 4604
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] buttons = new int[n];
		for(int i=0;i<n;i++){
			buttons[i] = sc.nextInt();
		}
		sc.close();
		
		int glowinBtn = 1;
		Set<Integer> pshdBtn = new HashSet<Integer>();
		do{
			pshdBtn.add(glowinBtn);
			glowinBtn = buttons[glowinBtn-1];
			
		}while(!(glowinBtn==2 || pshdBtn.contains(glowinBtn)));
		
		int result = -1;
		
		if(glowinBtn==2){
			result = pshdBtn.size();
		}
		
		System.out.print(result);
		
		return;
	}
}

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

int main() {
	string sentence; string num_tmp; int num=0;
	while(cin>>sentence) {
		num_tmp = "";
		for (int i = 0; i < sentence.size(); i++) {
			if (47 < sentence[i] &&sentence[i]< 58) {
				num_tmp += sentence[i];
			}
			else {
				num += atoi(num_tmp.c_str());
				num_tmp = "";
			}
		}
		num += atoi(num_tmp.c_str());
	}
	cout << num << endl;
}


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

int main(void)
{
	int w, a, b;
	while((cin >> w >> a >> b) && w != NULL)
	{
		if(b >= a && b <= a+w)
			cout << 0 << endl;
		else if(a >= b && a <= b+w)
			cout << 0 << endl;
		else 
		{
			if(b - (a+w) > a-(b+w))
			{
				if(a-b-w >= 0)
					cout << a-(b+w) << endl;
				else
					cout << b-(a+w) << endl;
			}
			else
			{
				if(b-a-w >= 0)
					cout << b-(a+w) << endl;
				else
					cout << a-(b+w) << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  char slopes[20001];
  int heights[20001];
  size_t end = 0;
  heights[end] = 0;

  scanf("%s", slopes);
  for (size_t i = 0;; i++) {
    char slope = slopes[i];
    if (slope == '/') {
      heights[end + 1] = heights[end] + 1;
      end++;
    } else if (slope == '_') {
      heights[end + 1] = heights[end];
      end++;
    } else if (slope == '\\') {
      heights[end + 1] = heights[end] - 1;
      end++;
    } else {  // EOS
      break;
    }
  }

  // printf("end:%zu max:%d min:%d\n", end, max, min);

  vector<pair<size_t, size_t> > lakes;

  for (size_t i = 0; i <= end - 1; i++) {
    if (heights[i] > heights[i + 1]) {
      for (size_t j = i + 1; j <= end; j++) {
        if (heights[j] == heights[i]) {
          lakes.push_back(make_pair(i, j));
          i = j - 1;
          break;
        }
      }
    }
  }

  int totalArea = 0;
  size_t numLakes = lakes.size();
  int areas[numLakes];
  for (size_t i = 0; i < numLakes; i++) {
    // printf("%zu %zu\n", it->first, it->second);
    int depth = 0;
    float area = 0;
    for (size_t j = lakes[i].first; j < lakes[i].second; j++) {
      if (slopes[j] == '/') {
        area += (float)depth - 0.5;
        depth--;
      } else if (slopes[j] == '_') {
        area += depth;
      } else if (slopes[j] == '\\') {
        area += (float)depth + 0.5;
        depth++;
      }
    }
    areas[i] = (int)area;
    totalArea += area;
    // printf("left:%zu right:%zu area:%d\n", it->first, it->second, area);
  }

  printf("%d\n", (int)totalArea);
  printf("%zu", lakes.size());
  for (size_t i = 0; i < numLakes; i++) {
    printf(" %d", areas[i]);
  }
  printf("\n");
}


Measured memory_bytes: 2884
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
x = I()
if x < 1200:
    print("ABC")
else:
    print("ARC")
#B

#C
"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""

#D
"""
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.values())
k = len(l)+sum(l)
for i in d.keys():
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int N = input[0];
		int T = input[1];
		List<int> cost = new List<int>();
        for(int i = 0; i < N; i++)
		{
			var input2 = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
			if (input2[1] <= T)
			{
				cost.Add(input2[0]);
			}
		}
		if (cost.Count > 0)
		{
			cost.Sort();
			Console.WriteLine(cost[0]);
		}
		else { Console.WriteLine("TLE"); }
	}
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int matrixChainOrder(int *,int );
int min(int ,int);

int main() {
  int n;
  int array[100];
  int i;
  int count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d %d",&array[i],&array[i+1]);

  count = matrixChainOrder(array,n+1);

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

int matrixChainOrder(int *p,int length) {
  int n;
  int m[100][100];
  int l,k;
  int i,j;
  int q;
  int count=0;
  n = length-1;
  for(i=1;i<=n;i++) m[i][i] = 0;
  for(l=2;l<=n;l++) {
    for(i=1;i<=n-l+1;i++) {
      j = i+l-1;
      m[i][j] = INT_MAX;
      for(k=i;k<j;k++) {
	q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	m[i][j] = min(m[i][j],q);
	count=m[i][j];
      }
    }
  }
  return count;
}

int min(int a,int b) {
  if(a <= b) return a;
  else return b;
}



Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100000;
bool sieve[MAX_N];
int n;

void solve() {
	int res = 0;

	for (int i = 2; i < n/2 + 1; i++) {
		if (sieve[i] && sieve[n-i]) {
			res++;
		}
	}
	cout<<res<<endl;
}

int main(int argc, const char *argv[]) {
	// make sieve
	//fill(sieve, sieve+MAX_N-1, true);
	memset(sieve, true, sizeof sieve);
	for (int i = 2; i < MAX_N; i++) {
		if (sieve[i]) {
			for (int j = i+i; j < MAX_N; j+=i) {
				sieve[j] = false;
			}
		}
	}

	// solve
	while (cin>>n, n) {
		solve();
	}	
	
	return 0;
}

Measured memory_bytes: 964
#include <iostream>
#include <cstdio>
#include <cstring> 
#define maxn 20010
#define maxm 200010
using namespace std;

int ver[maxm], tail[maxn], past[maxm];
int dfn[maxn], low[maxn], bridge[maxm];
int N, M, num, tot, root;

void add(int u,int v)
{
	ver[++tot]=v;
	past[tot]=tail[u]; tail[u]=tot;
}

void tarjan(int u,int in_edge)
{
	dfn[u]=low[u]=++num;
	for (int i=tail[u]; i; i=past[i])
	{
		int v=ver[i];
		if (dfn[v]==0)
		{
			tarjan(v,i);
			low[u]=min(low[u],low[v]);
			if (dfn[u]<low[v]) bridge[i]=bridge[i^1]=1;
		}
		else if (i!=(in_edge^1)) low[u]=min(low[u],dfn[v]);
	}
}

int main()
{
	memset(dfn,0,sizeof(dfn));
	memset(tail,0,sizeof(tail));
	scanf("%d%d",&N, &M);
	tot=1;
	for (int i=1; i<=M; i++)
	{
		int u,v;
		scanf("%d%d",&u, &v);
		add(u,v); add(v,u);
	}
	for (int i=1; i<=N; i++)
	if (!dfn[i]) tarjan(i,-1);
	int ans=0;
	for (int i=2; i<tot; i+=2) if (bridge[i]) ans++;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
 int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    c = c-b;
    if(c<=0){
      cout<<"Yes"<<endl;
      break;
    }
    a = a-d;
    if(a<=0){
      cout<<"No"<<endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3552
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
    int N; cin >> N;
    int ans = 0;
    if(N % 2 == 0){
        ans = N/2-1;
    }
    else{
        ans = N/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    ll x,y;
    cin >> x >> y;
    ll n = x;
    ll cnt = 0;
    while(n <= y){
        cnt++;
        n *= 2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
L, R = (map(int, input().split()))

if R // 2019 - L // 2019 >= 1:
	print(0)
else:
	min = 2018
	for i in range(L, R):
		for j in range(i + 1, R + 1):
			val = (i * j) % 2019
			if val < min:
				min = val
	print(min)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
 
#define N (600 + 5)
 
struct node{int a, b;};
vector<node> ans[4];
 
bool vis[2][N][N];
int n, nn, t1, t2, t3, t4, d[2], col[2][N][N];
 
void Dfs(int x, int y, int o, int c){
	if(x > nn || y > nn || x < 0 || y < 0 || col[o][x][y]) return;
	vis[o][x][y] = true; col[o][x][y] = 3 - c;
 
	int a = -1;
	while(true){
		++a;
		if(a * a > d[o]) return;
 
		int b = sqrt(d[o] - a * a);
		if(a * a + b * b != d[o]) continue;
		
		Dfs(x + a, y + b, o, 3 - c); Dfs(x + a, y - b, o, 3 - c);
		Dfs(x - a, y - b, o, 3 - c); Dfs(x - a, y + b, o, 3 - c);
	}
}
 
void Print(int o){
	For(i, 0, n * n - 1) printf("%d %d\n", ans[o][i].a, ans[o][i].b);	
}
 
int main(){
	scanf("%d%d%d", &n, &d[0], &d[1]);
 
	nn = (n << 1) - 1;
	For(i, 0, nn) For(j, 0, nn) if(!vis[0][i][j]) Dfs(i, j, 0, 2);
	For(i, 0, nn) For(j, 0, nn) if(!vis[1][i][j]) Dfs(i, j, 1, 2);
	
	For(i, 0, nn) For(j, 0, nn){
		node o = (node){i, j};
 
		if(col[0][i][j] == 1){
			if(col[1][i][j] == 1) ans[0].pb(o); else ans[1].pb(o);
		}else{
			if(col[1][i][j] == 2) ans[2].pb(o); else ans[3].pb(o);
		}
	}
 
	if((int)ans[0].size() >= n * n) Print(0);
	else if((int)ans[1].size() >= n * n) Print(1);
	else if((int)ans[2].size() >= n * n) Print(2);
	else Print(3);
	
	return 0;
}

Measured memory_bytes: 41176
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() ;
const ll linf = numeric_limits<ll>::max() ;
const ull ulinf = numeric_limits<ull>::max();
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
    int a,b,c,d,e,f;
    cin >>a>>b>>c>>d>>e>>f;

    int ww = 0,ws = 0;
    double nou = 0.0;
    
    rep(i,0,31){
        rep(j,0,31){
            int w = 100*a*i + 100*b*j;
            if(w <= f){
                rep(k,0,3001){
                    rep(l,0,3001){
                        int s = c*k + d*l;
                        if(w+s <= f){
                            if(w+s > 0 && e*(w/100) >= s){
                                if(nou <= 100.0*s/(w+s)){
                                    nou = 100.0*s/(w+s);
                                    ww = w;
                                    ws = s;
                                }
                            }
                        }else break;
                    }
                }
            }else break;
        }
    }

    cout << ww+ws << " " << ws <<endl;
    
	return  0;
}

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

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        rank.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

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

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

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

int main(){
    int N, A[100001], B[100001];
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];

    map<int, int> mpA, mpB, mpV;
    A[N] = B[N] = 0;
    for(int i=0; i<N; i++){
        mpA[A[i]]++;
        mpB[B[i]]++;
        A[N] ^= A[i];
        B[N] ^= B[i];
    }
    mpA[A[N]]++;
    mpB[B[N]]++;
    for(auto p : mpA){
        mpV[p.first] = mpV.size() - 1;
        if(p.second != mpB[p.first]){
            cout << -1 << endl;
            return 0;
        }
    }
    
    int ans = -1;
    UnionFind uf(mpV.size());
    for(int i=0; i<N; i++){
        if(A[i] != B[i]){
            ans++;
            uf.unite(mpV[A[i]], mpV[B[i]]);
        }
    }
    uf.unite(mpV[A[N]], mpV[B[N]]);

    bitset<100001> ok;
    for(int i=0; i<=N; i++){
        if(i<N && A[i] == B[i]) continue;
        if(!ok[uf.find(mpV[A[i]])]) ans++;
        ok[uf.find(mpV[A[i]])] = 1;
    }

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

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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    cout<<arr[n/2]-arr[(n/2)-1]<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int a[n+1];
  for ( int i = 1; i <= n; i++ ) { cin >> a[i]; }
  
  vector<int> ans(n+1);
  int use_bool = 0;
  for ( int i = n; i >= 1; i-- ) {
    int sm = 0;
    for ( int j = 2; i*j <= n; j++ ) {
      sm += ans[i*j];
    }
    ans[i] = (
      (sm%2 == 0 && a[i] == 1) ||
      (sm%2 == 1 && a[i] == 0)
    ) ? 1 : 0;
    use_bool += ( ans[i] == 1 ) ? 1 : 0;
  }

  cout << use_bool << endl;
  for ( int i = 1; i <= n; i++ ) {
    if ( ans[i] == 1 ) { cout << i << ' '; }
  }
  if ( use_bool > 0 ) { cout << '\n'; }
  return 0;
}


Measured memory_bytes: 4824
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))

t = []
for i in range(D):
    t.append(int(input()))

### input end ###

# last(d, i)
last = [0] * 26

v = 0

for d in range(D):
    v += s[d][t[d]-1]
    last[t[d]-1] = d+1
    for j in range(26):
        v -= c[j] * ((d + 1) - last[j])
    print(v)

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
/// lcm(a,b)=a/gcd(a,b)*b (handle overflow)


bool sortinrev1(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second>b.second);
    else return (a.first > b.first);
}
bool sortinrev2(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second<b.second);
    else return (a.first > b.first);
}



int main()
{
    /*int n,a;
    cin>>n;
    a=n;
    n/=1000;
    //cout<<a<<endl;
    if(a%1000!=0)n+=1;
    int ans=(n*1000)-a;
    cout<<ans<<endl;*/
    int n;
    string str;
    map<string,int>mp;
    cin>>n;
    getchar();
    while(n--){
        cin>>str;
        mp[str]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    
}



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

int main(){
  int n;
  cin >> n;
  int sum = 0;
  int cnt = 0;
  while(sum == 0 || sum % 360 != 0){
    sum += n;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
  


Measured memory_bytes: 3596
n, k = map(int, input().split())
list_D = list(map(str, input().split()))
num = n
ans = -1

while True:
    S = list(str(num))
    cnt = 0
    for s in S:
        if s  in list_D:
           cnt += 1
    if cnt == 0:
        ans = num
        break
    num += 1

print(ans)

Measured memory_bytes: 3060
N = int(input())
r = [list(map(int, input().split())) for _ in range(N)]
b = [list(map(int, input().split())) for _ in range(N)]

r.sort(key=lambda val:val[1], reverse=True)
b.sort()

ans = 0

for bb in b:
    for i in range(N):
        if bb[0] > r[i][0] and bb[1] > r[i][1]:
            ans += 1
            N -= 1
            r.pop(i)
            break

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 100000000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int a[200001];
ll res[200001];

struct data{
	ll val,lazy;
	data(){}
	data(ll va,ll la){
		val=va;
		lazy=la;
	}
};

const int N=1<<18;
data dat[2][1<<20];

void lazy_upd(int id,int k){
	dat[id][k].val+=dat[id][k].lazy;
	if(k<N-1){
		dat[id][k*2+1].lazy+=dat[id][k].lazy;
		dat[id][k*2+2].lazy+=dat[id][k].lazy;
	}
	dat[id][k].lazy=0;
}

void add(int a,int b,ll x,int id,int k=0,int l=0,int r=N){
	lazy_upd(id,k);
	if(r<=a || b<=l)return;
	if(a<=l && r<=b){
		dat[id][k].lazy+=x;
		lazy_upd(id,k);
		return;
	}
	add(a,b,x,id,k*2+1,l,(l+r)/2);
	add(a,b,x,id,k*2+2,(l+r)/2,r);
}

ll query(int a,int b,int id,int k=0,int l=0,int r=N){
	lazy_upd(id,k);
	if(r<=a || b<=l)return 0;
	if(a<=l && r<=b){
		return dat[id][k].val;
	}
	ll vl=query(a,b,id,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,id,k*2+2,(l+r)/2,r);
	return vl+vr;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n-1;i++){
		int f=a[i];
		int t=a[i+1];
		int v;
		if(f<t){
			v=t-f;
			
			add(f+1,f+2,v,1);
			add(f+2,t+2,-1,1);

			add(t+1,m+1,v,0);
			add(1,f+1,v,0);
		}else{
			v=m-f+t;
			
			add(f+1,f+2,v,1);
			add(f+2,m+1,-1,1);
			add(1,2,t,1);
			add(2,t+2,-1,1);

			add(t+1,f+1,v,0);
		}
	}
	ll ans=INF;
	for(int i=0;i<=m;i++){
		query(i,i+1,1);
	}
	for(int i=N;i<=N-1+m;i++){
		dat[1][i].val=dat[1][i].val+dat[1][i-1].val;
	}
	for(int i=1;i<=m;i++){
		ans=min(ans,query(i,i+1,0)+dat[1][N-1+i].val);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13312
import java.util.*;

class P{
	int x,y,k;
	P(int x,int y,int k){
		this.x=x;
		this.y=y;
		this.k=k;
	}
}

public class Main {
	int ans;
	int maze[][];
	int n,m;
//	int bx[]={1,0,-1,0};
//	int by[]={0,1,0,-1};
//	int mx[]={2,0,-2,0};
//	int my[]={0,2,0,-2};

//	void dfs(int x,int y,int d){
//		int nx,ny;
//		if(x==n-1 && y==m-1){
//			if(ans==0 || d<ans)
//			ans=d+1;
//			return;
//		}
//		maze[y][x]=2;
//		for(int i=0;i<4;i++){
//			nx=x+mx[i];
//			ny=y+my[i];
//			if(0<=nx && nx<n && 0<=ny && ny<m && maze[y+by[i]][x+bx[i]]!=1 && maze[ny][nx]!=2){
//				System.out.println(nx+" "+ny);
//				dfs(nx,ny,d+1);
//			}
//		}
//	}
	void bfs(){
		Queue<P> q=new LinkedList<P>();
		q.offer(new P(0,0,1));
		while(!q.isEmpty()){
			P np=q.poll();
			if(np.x==n-1 && np.y==m-1){
				ans=np.k;
				return;
			}
			if(np.x+2<n && maze[np.y][np.x+1]!=1){
				q.offer(new P(np.x+2,np.y,np.k+1));
				maze[np.y][np.x+1]=1;
			}
			if(np.y+2<m && maze[np.y+1][np.x]!=1){
				q.offer(new P(np.x,np.y+2,np.k+1));
				maze[np.y+1][np.x]=1;
			}
			if(0<=np.x-2 && maze[np.y][np.x-1]!=1){
				q.offer(new P(np.x-2,np.y,np.k+1));
				maze[np.y][np.x-1]=1;
			}
			if(0<=np.y-2 && maze[np.y-1][np.x]!=1){
				q.offer(new P(np.x,np.y-2,np.k+1));
				maze[np.y-1][np.x]=1;
			}
		}
	}

	void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			int a=sc.nextInt();
			int b=sc.nextInt();
			if((a|b)==0) break;
			n=a*2-1;
			m=b*2-1;
			maze=new int[m][n];
			for(int i=0;i<m;i++){
				for(int j=0;j<n;j++){
					if((i+j)%2==0){
						maze[i][j]=0;
						continue;
					}
					maze[i][j]=sc.nextInt();
				}
			}
			ans=0;
			//dfs(0,0,0);
			bfs();
			System.out.println(ans);
		}
	}

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

	}

}

Measured memory_bytes: 13000
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
typedef struct Card {
    int i;
    int n;
    char c;
} Card;

// retard desu LMAO
void *partition(Card *first, Card *last) {
    Card pivot = *(last - 1);
    Card *p = first - 1;
    for(Card *it = first; it != last - 1; ++it) {
        if(it->n <= pivot.n) {
            p++;
            Card tmp = *p;
            *p = *it;
            *it = tmp;
        }
    }
    Card tmp = *++p;
    *p = pivot;
    *(last - 1) = tmp;
    return p;
}
void quicksort(void *first, void *last, size_t N) {
    if(last - first <= N) return;
    void *mid = partition(first, last);
    quicksort(first, mid, N);
    quicksort(mid, last, N);
}

int main(int argc, char **argv) {
    int n = get_uint();
    Card a[n];
    for(int i = 0; i < n; ++i) {
        a[i].c = getchar_unlocked();
        getchar_unlocked();
        a[i].n = get_uint();
        a[i].i = i;
    }
    quicksort(a, a + n, sizeof(Card));

    int flag = 0;
    for(int i = 1; i < n; ++i) {
        // check inverted index
        if(a[i].n==a[i-1].n && a[i].i < a[i-1].i){
            flag = 1;
            break;
        }
    }
    puts(flag ? "Not stable" : "Stable");
    for(int i = 0; i < n; ++i) {
        putchar_unlocked(a[i].c), putchar_unlocked(' ');
        put_uint(a[i].n), putchar_unlocked('\n');
    }
    return 0;
}



Measured memory_bytes: 2672
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
int n,m;
vector<P> v,v1;
int s[100001];
string f(int x){
    if(x<10)return "00000";
    else if(x<100)return "0000";
    else if(x<1000)return "000";
    else if(x<10000)return "00";
    else if(x<100000)return "0";
    else return "";
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(P(a,b));
        v1.push_back(P(a,b));
        s[a]++;
    }
    for(int i=0;i<100000;i++){
        s[i+1]+=s[i];
        //cout<<s[i]<<endl;
    }
    
    sort(v.begin(),v.end());
    for(int i=0;i<m;i++){
        cout<<f(v1[i].first)<<v1[i].first;
        int mid=upper_bound(v.begin(),v.end(),v1[i])-v.begin();
        mid-=s[v1[i].first-1];
        cout<<f(mid)<<mid<<endl;
    }
}


Measured memory_bytes: 3820
//                                   mdsaqib
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    fast;
    int n,k;
    cin >> n >> k;
    vector <int> H(n,0);
    for(int i=0;i<n;i++)cin >> H[i];
    if(k>n-2)k=n;
    vector <int> A(n,0);
    for(int i=1;i<=k;i++){
        A[i]=abs(H[i]-H[0]);
    }
    if(k==n){
        cout << A[n-1];
        return 0;
    }
    for(int i=k+1;i<n;i++){
        int mn=1e9+5;
        for(int j=0;j<k;j++){
            mn=min(mn,abs(H[i]-H[i-1-j])+A[i-1-j]);
        }
        A[i]=mn;
    }
    cout << A[n-1];
}



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

int main() {
	int N; cin >> N;
	int h[110], hmax=0, ans=0;
	for(int i=0; i<N; ++i){
	    cin >> h[i];
	    hmax=max(hmax, h[i]);
	}
	while(hmax>0){
	    bool f=true;
	    for(int i=0; i<N; ++i){
	        if(h[i]>0){
	            if(f){
	                f=false;
	                ++ans;
	            }
	            --h[i];
	        }
	        else if(!f) f=true;
	    }
	    --hmax;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;

void main() {
  long S, W;
  scanln(S, W);
  writeln(W >= S ? "unsafe" : "safe");
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 2900
#include<iostream>
#include<string>
#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

using namespace std;



int main(){
	string n;
  	cin>>n;
  	int sum=0;
  	r(i,n.size()){
      sum+=(n.at(i)-'0');
    }
  int number=0,hun=1;
  for(int i=n.size()-1;i>=0;i--){
    number+=(n.at(i)-'0')*hun;
    hun*=10;
    //cout<<n.at(i)-'0'<<endl;
  }
  //int x=n;
  
  //cout<<number<<endl;
  
  if(number%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  	



    return 0;
}



Measured memory_bytes: 256
y, m ,d = map(int, input().split('/'))

A = None

if y > 2019 :
    A = 'TBD'
elif m > 4 :
    A = 'TBD'
elif d > 30 :
    A = 'TBD'
else:
    A = 'Heisei'
    
print(A)

Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m,dp[110][110][110],sum[110][110],ans;
char s[110];bool a[110][110];
int getsum(int l,int r,int u,int d){
//	cout<<"		getsum "<<l<<' '<<r<<' '<<u<<' '<<d<<' '<<sum[r][d]-sum[l-1][d]-sum[r][u-1]+sum[l-1][u-1]<<'\n';
	return sum[d][r]-sum[d][l-1]-sum[u-1][r]+sum[u-1][l-1];
}
int main(){
//	freopen("1.in","r",stdin);
	int l,r,u,d,i,j,liml,limr,limu,limd,edx,edy;
	n=read();m=read();
	for(i=1;i<=n;i++){
		scanf("%s",s);
		for(j=0;j<m;j++){
			if(s[j]=='o') a[i][j+1]=1;
			if(s[j]=='E') edx=i,edy=j+1;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+a[i][j];
//			cout<<i<<' '<<j<<' '<<sum[i][j]<<'\n';
		}
	}
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			for(l=0;l<=n;l++){
				dp[i][j][l]=-1e9;
			}
		}
	}
	dp[0][0][0]=0;
//	cout<<"start "<<edx<<' '<<edy<<'\n';
	for(l=0;l<m;l++){
		if(edy-l<=0) break;
		for(r=0;r<m;r++){
			if(edy+r>m) break;
			liml=max(edy-l,1+r);
			limr=min(edy+r,m-l);
			if(liml>limr) continue;
			for(u=0;u<n;u++){
				if(edx-u<=0) break;
				for(d=0;d<n;d++){
					if(edx+d>n) break;
					limu=max(edx-u,1+d);
					limd=min(edx+d,n-u);
					if(limu>limd) continue;
//					cout<<l<<' '<<r<<' '<<u<<' '<<d<<' '<<dp[r][u][d]<<'\n';
//					if(dp[r][u][d]==-1) continue;
					ans=max(ans,dp[r][u][d]);
					if(edy+r+1<=m-l){
//						cout<<"	type 1 "<<l<<' '<<r+1<<' '<<u<<' '<<d<<'\n';
						dp[r+1][u][d]=max(dp[r+1][u][d],dp[r][u][d]+getsum(edy+r+1,edy+r+1,limu,limd));
					}
					if(edx-u-1>=1+d){
//						cout<<"	type 2 "<<l<<' '<<r<<' '<<u+1<<' '<<d<<'\n';
						dp[r][u+1][d]=max(dp[r][u+1][d],dp[r][u][d]+getsum(liml,limr,edx-u-1,edx-u-1));
					} 
					if(edx+d+1<=n-u){
//						cout<<"	type 3 "<<l<<' '<<r<<' '<<u<<' '<<d+1<<'\n';
						dp[r][u][d+1]=max(dp[r][u][d+1],dp[r][u][d]+getsum(liml,limr,edx+d+1,edx+d+1));
					} 
					if(edy-l-1>=1+r){
//						cout<<"	type 4 "<<l+1<<' '<<r<<' '<<u<<' '<<d<<'\n';
						dp[r][u][d]=max(dp[r][u][d],dp[r][u][d]+getsum(edy-l-1,edy-l-1,limu,limd));
					}
				}
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5120
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
 
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN; 
int main()
{
  fast();

  
  ll t;
  string s;
  cin >> t;
  cin >> s;
  string ans;
  f(i,0,s.length())
  {
    s[i] = 'A' + (s[i] - 'A' + t) % 26 ;
    //s[i] = (s[i]+t)%90;
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 256