akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll  long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

ll int per(ll int n){
    if(n==0 || n==1)return 0;
    return n*(n-1)/2;               //to find the permutation of n
}

int main(){
  	
  	fastio();

    ll int n;
    cin >> n;

    ll int ar[n];
    map<ll int,ll int> mp;
    for(ll int i=0;i<n;i++){
        cin >> ar[i];
        mp[ar[i]]++;                //find the frequency of each digit
    }

    ll int sum =0;

    map<ll int, ll int>::iterator itr;
    for(itr=mp.begin();itr!=mp.end();itr++){
        sum+=per(itr->second);                  // sum of all permutations
                                                /*Example,  1 1 2 1 2. Freq of 1 is 3 and freq of 2 is 2.
                                                 So sum wil be 3C2 + 2C2=4*/
    }

    for(ll int i=0;i<n;i++){
        
           cout <<  sum-mp[ar[i]]+1<< endl;

        /* Eg 1 1 2 1 2
            Hence for arr[0] = 1, mp[arr[i]] = 3 so per(3) = 3C2=3
            and perless(3) = 2C2=1.
            hence final output is sum-3 +2 for arr[0]
        */
    }
}



Measured memory_bytes: 11136
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] l = new int[n];

        Arrays.setAll(l, i->sc.nextInt());
//        for (int i=0; i<n; i++) l[i] = sc.nextInt();

        Arrays.sort(l);

        long ans = 0;

        for (int i=0; i<n-2; i++){
            for (int j=i+1; j<n-1; j++){
                for (int k=j+1; k<n; k++){
                    if ((l[i]<l[j]+l[k]) && (l[j]<l[i]+l[k]) && (l[k]<l[j]+l[i])){
                        ans++;
                    }else {
                        break;
                    }
                }
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 27624
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
s = input()
res=0

for i in range(n-1):
    if s[i]==s[i+1]:
        res+=1

print(n-res)

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

int main()
{
    int N;
    cin >> N;
    int wrong_cnt = 0;
    for(int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        if(tmp != (i+1)) ++wrong_cnt;
    }
    if(wrong_cnt > 2) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
ans = [0]*N

for i in range(1,N+1):
  for j in range(i+1,N+1):
    d = min(j-i,abs(i-X)+abs(j-Y)+1)
    #print(i,j,d)
    ans[d]+=1

for i in range(1,N):
	print(ans[i])


Measured memory_bytes: 74156
n = int(input())
dam = list(map(int,input().split()))
mount = []
m1 = 0
for i in range(n):
    if i % 2 == 0:
        m1 += dam[i]
    else:
        m1 -= dam[i]
mount.append(m1)
for i in range(n):
    diff = mount[i]
    mount.append(dam[i]*2 - diff)
ans = mount[:-1]
print(*ans)


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

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b, k;
	cin >> a >> b >> k;
	int diff = max(0ll, a - k);
	k -= a - diff;
	cout << diff << ' ' << max(0ll, b - k) << '\n';
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int n;
        int[] mask;
        int[][] p;

        private int cnt(int x) {
            int res = 0;
            while (x != 0) {
                x = x & (x - 1);
                ++res;
            }
            return res;
        }

        private int gao(int x) {
            int res = 0;
            for (int i = 0; i < n; ++i) {
                res += p[i][cnt(mask[i] & x)];
            }
            return res;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            mask = new int[n];
            p = new int[n][11];

            int f;
            for (int i = 0; i < n; ++i) {
                mask[i] = 0;
                for (int j = 0; j < 10; ++j) {
                    f = in.nextInt();
                    mask[i] = (mask[i] << 1) | f;
                }
            }

            for (int i = 0; i < n; ++i) {
                for (int j = 0; j <= 10; ++j) {
                    p[i][j] = in.nextInt();
                }
            }

            int res = Integer.MIN_VALUE;

            for (int i = 1; i < 1024; ++i) {
                res = Math.max(res, gao(i));
            }

            out.println(res);
        }

    }
}



Measured memory_bytes: 25964
//#include    <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define N  100100
#define M 5
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
template<typename T> inline T max(T a,T b,T c){
    return max(a,max(b,c));
}
template<typename T> inline T min(T a,T b,T c){
    return min(a,min(b,c));
}
template<typename T> inline T max(T a,T b,T c,T d){
    return max(a,max(b,c,d));
}
template<typename T> inline T min(T a,T b,T c,T d){
    return min(a,min(b,c,d));
}
const int  dx[]={0,1,0,-1,0,1,-1,1,-1};
const int  dy[]={0,0,1,0,-1,1,-1,-1,1};
typedef long long ll;
using namespace std;
int a[N];
int dis[N];
int main(){
   int n,k;
   scanf("%d",&n);
   for (int i=1;i<=n;i++)
    scanf("%d",&a[i]);
   a[0]=0;
   a[n+1]=0;
   int sum=0;
   for (int i=1;i<=n+1;i++)
    dis[i]=a[i]-a[i-1];
   for (int i=1;i<=n+1;i++)
        sum+=abs(dis[i]);
   for (int i=1;i<=n;i++){
    cout << sum-abs(dis[i])-abs(dis[i+1])+abs(dis[i]+dis[i+1])<< endl;
   }
   return 0;
}


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

int main(void) {

    int n, m;
    cin >> n >> m;
    vector<int> height(n);
    for (int i = 0; i < n; i++) cin >> height[i];

    vector<int> isGood(n,true);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (height[a] <= height[b]) {
            isGood[a] = false;
        }
        if (height[b] <= height[a]) {
            isGood[b] = false;
        }
    }

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

    cout << sum << endl;

    return 0;

}


Measured memory_bytes: 4052
#include <iostream>
using namespace std;
int main(){

  int h,w;
  char c;
  cin>>w>>h>>c;
  cout<<"+";
  for(int i=0;i<w-2;i++) cout<<"-";
  cout<<"+"<<endl;

  for(int i=0;i<h-2;i++){
    cout<<"|";
    for(int j=0;j<w-2;j++) cout<<(i==(h-2)/2&&j==(w-2)/2?c:'.');
    cout<<"|"<<endl;
  }

  cout<<"+";
  for(int i=0;i<w-2;i++) cout<<"-";
  cout<<"+"<<endl;

  return 0;

}



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

int main(){
  int N;
  cin >> N;
  
  float prob = 0.0;
  
  if(N % 2 == 0) {
    prob = (N / 2.0) / N;
  } else {
    prob = (N / 2 + 1.0) / N;
  }
  
  cout << prob << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ms=[[] for _ in range(n)]
for i in range(n):
    ms[i]=list(map(int,input().split()))
x=[0 for _ in range(m)]
for j in range(m):
    x[j]=int(input())
y=[0 for _ in range(n)]
for i in range(n):
    for j in range(m):
        y[i] += ms[i][j] * x[j]
    print(y[i])

Measured memory_bytes: 8032
// depends on: -

/*
usage:

tools::floor(5, 3) // => 1
tools::ceil(5, 3) // => 2
*/

namespace tools {
  template <typename T> constexpr T floor(T lhs, T rhs);
  template <typename T> constexpr T ceil(T lhs, T rhs);

  template <typename T> constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T> constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}
#include <iostream>
#include <cstdint>
#include <algorithm>

int main() {
  std::int_fast64_t n;
  std::cin >> n;

  std::int_fast64_t prev_t = 1, prev_a = 1;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t t, a;
    std::cin >> t >> a;
    const std::int_fast64_t ratio = std::max(tools::ceil(prev_t, t), tools::ceil(prev_a, a));
    prev_t = t * ratio;
    prev_a = a * ratio;
  }
  std::cout << prev_t + prev_a << std::endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,p;
  while(true){
    cin >> n >> p;
    if(n==0 && p==0) break;
    int stone=p;
    int kouho[n];
    for(int i=0;i<n;i++) kouho[i]=0;
    int pos=0;
    while(true){
      if(stone>0){
        stone--;
        kouho[pos]+=1;
        if(stone==0 && kouho[pos]==p) break;
      }
      else if(stone==0){
        stone+=kouho[pos];
        kouho[pos]=0;
      }
      pos++;
      pos %= n;
    }
    cout << pos << endl;
  }
}

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
	static int co=0;
	static int K;
	static boolean ok = false;
	static long ans = 0;
	
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			 K= scan.nextInt();
			
			int count=0;
			int keta = 0;
		
			
			do {
				keta++;
				
				for(int i = 1;i<=9;i++) {
					po(i,keta,""+i+"");
				}
			}while(ok==false);
			
			
			
			
		}
		
		
	}
	
	
	private static void po(int n,int count,String s) {
		
		if(count==1) {
			co++;
			//System.out.print(s);
			//System.out.print(" ");
			//System.out.println(co);
			if(K==co) {
				ans = Long.valueOf(s);
				ok=true;
				System.out.println(ans);
				return;
			}
			
		}else {
			if(n==0) {
				po(n,count-1,s+""+n+"");
				po(n+1,count-1,s+""+(n+1)+"");
			}else if(n==9) {
				po(n-1,count-1,s+""+(n-1)+"");
				po(n,count-1,s+""+n+"");
				
			}else{
				po(n-1,count-1,s+""+(n-1)+"");
				po(n,count-1,s+""+n+"");
				po(n+1,count-1,s+""+(n+1)+"");
			}
		}
		
		
	}
		

}

Measured memory_bytes: 47724
s_a = input()
s_b = input()
s_c = input()
idx_a, idx_b, idx_c = 0, 0, 0
next = 'a'
while True:
    if next == 'a':
        if idx_a < len(s_a):
            next = s_a[idx_a]
        idx_a += 1
    elif next == 'b':
        if idx_b < len(s_b):
            next = s_b[idx_b]
        idx_b += 1
    else:
        if idx_c < len(s_c):
            next = s_c[idx_c]
        idx_c += 1
    if not (idx_a <= len(s_a) and idx_b <= len(s_b) and idx_c <= len(s_c)):
        break
if next == 'a':
    print('A')
elif next == 'b':
    print('B')
else:
    print('C')


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
const int MAX = 100005;
const int NIL = -1;

struct Node{int p,l,r;};
Node T[MAX];
int n,D[MAX];

void print(int u){
int i,c;
cout<<"node "<<u<<": ";
cout<<"parent = "<<T[u].p<<", ";
cout<<"depth = "<<D[u]<<", ";
if(T[u].p==NIL)cout<<"root, ";
else if(T[u].l==NIL)cout<<"leaf, ";
else cout<<"internal node, ";
cout<<"[";
for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)cout<<", ";
cout<<c;
}
cout<<"]"<<endl;
}

int rec(int u,int p){
D[u] = p;
if(T[u].r!=NIL)rec(T[u].r,p);
if(T[u].l!=NIL)rec(T[u].l,p+1);
}

int main(){
int i,j,d,v,c,l,r;
cin>>n;
for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;
for(i=0;i<n;i++){
    cin>>v>>d;
    for(j=0;j<d;j++){
        cin>>c;
        if(j==0)T[v].l = c;
        else T[l].r = c;
        l = c;
        T[c].p = v;
    }
}
for(i=0;i<n;i++){
    if(T[i].p==NIL)r=i;
}
rec(r,0);
for(i=0;i<n;i++)print(i);
return 0;
}



Measured memory_bytes: 7784
N, M = map(int, input().split())
 
if M % 2 == 0:
  l = 1
  for i in range(M//2):
    L = []
    L.append(l)
    L.append(2*(M//2-i)+l)
    print(*L)
    l += 1
  l = 2*(M//2)+2
  for i in range(M//2):
    L = []
    L.append(l)
    L.append(2*(M//2-i)+l-1)
    print(*L)
    l += 1
  
  
elif M % 2 == 1:
  l = 1
  for i in range(M//2):
    L = []
    L.append(l)
    L.append(2*(M//2-i)+l)
    print(*L)
    l += 1
  l = 2*(M//2)+2
  for i in range(M//2+1):
    L = []
    L.append(l)
    L.append(2*(M//2+1-i)+l-1)
    print(*L)
    l += 1

Measured memory_bytes: 9204
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n := scanInt(stdin)
	stdin.Scan()
	sort := scanIntArray(stdin)

	flag := true
	c := 0

	for flag {
		flag = false
		for j := n - 1; j >= 1; j-- {
			if sort[j] < sort[j-1] {
				tmp := sort[j-1]
				sort[j-1] = sort[j]
				sort[j] = tmp
				flag = true
				c++
			}
		}
	}
	fmt.Println(strings.Trim(fmt.Sprint(sort), "[]"))
	fmt.Println(c)
}

func scanInt(sc *bufio.Scanner) int {
	t := sc.Text()
	i, err := strconv.Atoi(t)
	if err != nil {
		panic(err)
	}
	return i
}

func scanIntArray(sc *bufio.Scanner) []int {
	t := sc.Text()
	ss := strings.Split(t, " ")
	is := []int{}
	for _, s := range ss {
		i, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		is = append(is, i)
	}
	return is
}



Measured memory_bytes: 1152
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int root[500001];
int size[500001];
void intialise()
{
	for (int i = 0; i < 500001; ++i)
	{
		root[i]=i;
	}
	for (int i = 0; i < 500001; ++i)
	{
		size[i]=1;
	}
}
int find_root(int v)
{
	if(root[v]==v)
	{
		return v;
	}
	else
	{
		root[v]=find_root(root[v]);
		return root[v];
	}
}
bool find(int a,int b)
{
	return find_root(a)==find_root(b);
}
void _union(int a,int b)
{
	int _rootA=find_root(a);
	int _rootB=find_root(b);
	size[_rootA]+=size[_rootB];
	size[_rootB]=0;
	root[_rootB]=_rootA;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //        freopen ("INPUT.txt" , "r" , stdin);
 //        // freopen ("OUTPUT.txt" , "w" , stdout);
 //    #endif

	int N,M;
	cin>>N>>M;
	intialise();
	for (int i = 0; i < M; ++i)
	{
		int x,y,z;
		cin>>x>>y>>z;
		if(!find(x,y))
		{
			_union(x,y);
		}
	}
	int ans=0;
	for (int i = 1; i <= N; ++i)
	{
		if(size[i]>0)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	

	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i=a; i<b; i++)
int mod = 1e9 + 7;
typedef long long ll;

const ll INF = 1 << 60;

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> G(n);
    x--; y--;
    rep(i, 1, n){
        G[i].push_back(i-1);
        G[i-1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    
    queue<int> q;
    vector<int> ans(n);

    rep(sn, 0, n){
        q.push(sn);
        vector<int> dist(n, INT_MAX);
        dist[sn] = 0;
        while(!q.empty()){
            int x = q.front(); q.pop();
            for(int j=0; j<G[x].size(); j++){
                if(dist[G[x][j]] == INT_MAX){
                    q.push(G[x][j]);
                    dist[G[x][j]] = dist[x] + 1;
                    ans[dist[G[x][j]]]++;
                }
            }
        }
    }
    rep(i, 1, n){
        cout << ans[i] / 2 << endl;
    }
}   


Measured memory_bytes: 384
import sys
s = sys.stdin.readline()
s = s[:-1]
q = int(input())

front = ''
back = ''
rv = False
for i in range(q):
    line = input()
    if line[0] == '1':
        rv = not rv
    else:
        ti, fi, ci = line.split()
        if (fi == '1' and rv) or (fi == '2' and not rv):
            back += ci
        else:
            front += ci

if rv:
    s = back[::-1] + s[::-1] + front
else:
    s = front[::-1] + s + back
print(s)

Measured memory_bytes: 4468
#include <iostream>
using namespace std;
int main(){

  int dp[8][5000]={};
  for(int i=0;i<=1000;i++) dp[1][i]=1;
  for(int i=1;i<=2;i++) for(int j=0;j<=1000*i;j++) for(int k=0;k<=1000*i;k++) dp[i*2][j+k]+=dp[i][j]*dp[i][k];
  for(int n;cin>>n;) cout<<dp[4][n]<<endl;
  return 0;

}



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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, cnt; cin >> n;
    map<ll,int> a;
    rep(i,n){
        ll p; cin >> p;
        auto itr = a.find(p);
        if(itr == a.end()) a.insert(make_pair(p, 1));
        else a.erase(p);
    }
    cout << a.size() << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 

int main() 
{
    fastio
    int n;
    cin>>n;
    ll sum = 0;
    for(int i = 1; i<=n; ++i) {
        if(i%3==0 || i%5==0) continue;
        sum += i;
    }
    cout<<sum<<endl;
}


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

using namespace std;
using int64 = long long int;

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

    int64 count = min(a, k);
    a -= count;
    k -= count;

    count = min(b, k);
    b -= count;
    k -= count;

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};



int main(){
  ll N; cin >> N;
  vector<pair<ll, ll>> AB(N);
  rep(i, N) cin >> AB[i].second >> AB[i].first;
  sort(AB.begin(), AB.end());
  bool l = 1;
  ll now = 0;
  rep(i, N){
    now += AB[i].second;
    if(now > AB[i].first) l = 0;
  }
  if(l){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}


Measured memory_bytes: 3328
#include <stdio.h>
void shokika(int x[],int a){
  for(int i=0;i<a;i++){
    x[i]=0;
  }
}
int main(void){
  int n,k,d;
  int ai;
  scanf("%d",&n);
  int a[n];
  shokika(a,n);
  scanf("%d",&k);
  
  for(int i=0;i<k;i++){
    scanf("%d",&d);
    for(int j=0;j<d;j++){
      scanf("%d",&ai);
      a[ai-1]=1;
    }
  }

  int m=0;   //ninzu
  int l;  //kurikaesi
  for(l=0;l<n;l++){
    if(a[l]==0){
      m++;
    }
  }
  printf("%d",m);

  return 0;
  }

Measured memory_bytes: 1732
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    char dif = 'A' - 'a';
    str a, b, c;
    cin >> a >> b >> c;
    printf("%c%c%c\n", a[0] + dif, b[0] + dif, c[0] + dif);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//カードの数
		int card = sc.nextInt();

		//太郎ポイント　花子ポイント
		int tp = 0;
		int hp = 0;

		//ループ
		for (int i = 0; i < card; i++) {

			//カード名：太郎　花子
			String t = sc.next();
			String h = sc.next();

			//文字列の比較
			//引き分けの場合
			if (t.equals(h)) {
				tp = tp + 1;
				hp = hp + 1;
			}

			//太郎が勝ちの場合
			else if (t.compareTo(h) > 0) {
				tp = tp + 3;
			}

			//花子が勝ちの場合(その他)
			else {
				hp = hp + 3;
			}
		}

		System.out.println(tp + " " + hp);

		sc.close();
	}

}



Measured memory_bytes: 31432
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
class Main{
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
      	int n=in.nextInt(), k=in.nextInt(),sum=0;
      	int a[]=new int[n];
      	for(int i=0;i<n;i++)
      		a[i]=in.nextInt();
      	Arrays.sort(a);
      	for(int i=0;i<k;i++){
      		sum+=a[i];
      	}
      	System.out.println(sum);
	} 
}


Measured memory_bytes: 38708
n = int(input())
key = []
if n%2:
  key.append("1")
  n -= 1
else:
  key.append("0")

bef_p, bef_q = 0, 0
n //= 2
while n:
  k_p, k_q = (n//2)%2, n%2
  if k_p == 0:
    if k_q == 0:
      key.append("0")
      key.append("0")
      bef_p, bef_q = 0, 0
    else:       
      key.append("1")
      key.append("1")
      bef_p, bef_q = 0, 0      
  else:
    if k_q == 0:
      key.append("0")
      key.append("1")
      bef_p, bef_q = 0, 0
    else:
      key.append("1")
      key.append("0")
      bef_p, bef_q = 1, 1
  n //= 4
  n = n + bef_p*2-bef_q
key.reverse()
print(int("".join(key)))

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextLine()) {
				String[] cards = sc.nextLine().split(",");
				Integer[] numbers = new Integer[5];
				for (int i = 0; i < cards.length; i++) {
					numbers[i] = Integer.parseInt(cards[i]);
				}
				Arrays.sort(numbers);
				List<Integer> numberList = Arrays.asList(numbers);
				int count = 1;
				int value = 1;
				// ???????????????????????????????????????????????\????????¢??????????????¢??????????????????????????????????????????
				for (int i = 1; i < numberList.size(); i++) {
					if (numberList.get(i - 1) == numberList.get(i)) {
						count += value;
						value++;
					} else {
						value = 1;
					}
				}
				if (count <= 1) {
					// ????????¬?????????????????????????????????
					int sum = 0;
					for (int num : numberList) {
						sum += num;
					}
					if ((sum == 47)
							|| (numberList.get(0) + 1 == numberList.get(1)
									&& numberList.get(1) + 1 == numberList
											.get(2)
									&& numberList.get(2) + 1 == numberList
											.get(3) && numberList.get(3) + 1 == numberList
									.get(4))) {
						count += 5;
					}
				}
				String hand = "null";
				switch (count) {
				case 7:
					hand = "four card";
					break;
				case 6:
					hand = "straight";
					break;
				case 5:
					hand = "full house";
					break;
				case 4:
					hand = "three card";
					break;
				case 3:
					hand = "two pair";
					break;
				case 2:
					hand = "one pair";
					break;
				default:
					break;
				}
				System.out.println(hand);
			}
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 17180
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;

int main(void)
{
  // freopen("aaa.in","r",stdin);
  int N;
  scanf("%d",&N);
  char s[100];
  int numA=0,numW=0,numT=0,numR=0;
  for (int i=1;i<=N;i++)
  {
    scanf("%s",s);
    if (s[0]=='A') numA++;
    if (s[0]=='W') numW++;
    if (s[0]=='T') numT++;
    if (s[0]=='R') numR++;
  }
  printf("AC x %d\n",numA);
  printf("WA x %d\n",numW);
  printf("TLE x %d\n",numT);
  printf("RE x %d",numR);


  return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;
#define N 100010
struct edge{
  ll to,cost;  
  edge(ll to,ll cost){
      this->to=to,this->cost=cost;
  }
};
ll n;
vector<edge> g[N];
ll d[N];
void dfs(ll x,ll from,ll dis){
    d[x]=dis;
    for(auto y:g[x])if(y.to!=from){
	dfs(y.to,x,dis+y.cost);
    }
}
int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
      ll a,b,c;cin>>a>>b>>c;
      g[a].push_back(edge(b,c));
      g[b].push_back(edge(a,c));
  }
  dfs(1,0,0);
  for(int i=1;i<=n;i++)cout<<d[i]%2<<endl;
  return 0;
}


Measured memory_bytes: 10240
import math
X = int(input())


def is_prime(n):
	if n <= 1:
		return False

	if n == 2:
		return True

	if n%2 == 0:
		return False

	for i in range(3,math.ceil(math.sqrt(n)),2):
		if n%i == 0:
			return False

	return True

inf = 10**20
if is_prime(X) == True:
	print(X)

else:
	for i in range(X+1,inf):
		if is_prime(i) == True:
			print(i)
			break


Measured memory_bytes: 3060
#include <iostream>

int main(void) {
  int h;
  int w;
  std::cin >> h >> w;
  int h_del;
  int w_del;
  std::cin >> h_del >> w_del;
  int total = h * w;
  std::cout << total - h_del * w - w_del * h + h_del * w_del << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int t,y,x;
int main()
{
	int n;
	scanf("%d",&n);
	bool ok = true;
	for(int i = 0; i < n; i++)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		int d = abs(a - t);
		int dis = abs(x - b) + abs(y - c);
//		cout << "dis: " << dis << ' ' << d << endl;
		if(dis == 0 && (d & 1))
		{
			ok = false;
		}
		if(dis > d)
		{
			 ok = false;
		}
		if(abs(d - dis) & 1)
		{
			ok = false;
		}
		t = a;
		x = b;
		y = c;
	}
	if(ok)
	{
		puts("Yes");
	}
	else
		puts("No");
	return 0;
}


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

int main() {
	string s,a;int n,b,c;cin>>s>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a=="print")
		{
			cin>>b>>c;
			for(int j=b;j<=c;j++)cout<<s[j];
			cout<<endl;
		}
		else if(a=="reverse")
		{
			cin>>b>>c;
			a=s;
			for(int j=b;j<=c;j++)s[j]=a[c-j+b];
		}
		else if(a=="replace")
		{
			cin>>b>>c>>a;
			s.erase(b,c-b+1);
			s.insert(b,a);
		}
	}
	return 0;
}

Measured memory_bytes: 3220
def sample_code(N):

 #   print('Prime factor')
    fct = factorize(N)
 #   print(fct,num(fct))

 #   print('divisor')
    for div in divisorize(fct):
        b = num(div)


def divisorize(fct):
    b,e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b,k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def factorize(N):
    fct = []
    b,e = 2, 0
    while b * b <= N:
        while N % b == 0:
            N = N // b
            e = e + 1
        if e > 0:
            fct.append((b,e))
        b,e = b + 1,0
    if N > 1:
        fct.append((N,1))
    return fct

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base ** exponent
        divisor_list.append(a)
    return a

N = int(input())
sum_m = 0
divisor_list = []
if N == 1:
    print(0)
else:
    sample_code(N)
    divisor_list = list(set(divisor_list))

    for c in divisor_list:
        if c != 1 and c!= 2:
            if N // (c-1) >= (c-1):
                continue
            else:
                sum_m += c - 1

    print(sum_m)

Measured memory_bytes: 6004
class Solver
  def main
    n, m = gets.split.map(&:to_i)
    ary = Array.new(n)
    n.times do |i|
      ary[i] = gets.split.map(&:to_i)
    end
    ary.sort!
    # puts ary

    ans = 0
    ary.each do |k, v|
      if m <= v
        # 足りる
        ans += k * m
        break
      else
        # 足りない
        ans += k * v
        m -= v
      end
    end

    puts ans
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 10360
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
int a,b;
  cin>>a>>b;
  cout<<6-a-b<<endl;
  
}
  


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

using namespace std;

using ll = long long;

using vi = vector<int>;
using vll = vector<ll>;

using pi = pair<int, int>;
using pll = pair<ll, ll>;

constexpr auto MOD = 1e9 + 7;
constexpr auto INF = 0x3f3f3f3f;

#define rep(i, a, b) for (auto i = a; i < b; ++i)

template <class T> inline T square(T x) { return x * x; };

template <class T> void print(const T &val) { cout << val << '\n'; }

template <class Iterator> void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; ++it) {
    cout << *it << ' ';
  }

  cout << '\n';
}

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

  int n;
  cin >> n;

  vi a(n + 1), b(n + 1), c(n + 1);

  rep(i, 1, n + 1) { cin >> a[i] >> b[i] >> c[i]; }

  int dp[n + 1][3];
  memset(dp, 0, sizeof(dp));

  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];

  for (auto i = 2; i <= n; ++i) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
    dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
  }

  print(max(dp[n][0], max(dp[n][1], dp[n][2])));
}


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


int main () {
  int n, k;
  string s;

  cin >> n >> k >> s;

  int acc = 0;
  vector<int> a, b;
  int i = 0, l = s.size();
  while(i < l) {
    if(i == 0) {
      while(s[i] == '1') {
        acc++;
        i++;
      }
    }

    int c1 = 0;
    int c0 = 0;
    while(i < l && s[i] == '0') {
      c0++;
      i++;
    }
    while(i < l && s[i] == '1')  {
      c1++;
      i++;
    }
    a.push_back(c1 + c0);
    b.push_back(c1);
  }

  vector<int> dpa(k+1, -1);
  vector<int> dpm(k+1, -1);
  dpa[k] = acc;
  dpm[k] = acc;

  for(int i = 0, l = a.size(); i < l; i++) {
    for(int j = 0; j < k; j++){
      if(dpa[j+1] == -1) continue;

      dpa[j] = dpa[j+1] + a[i];
      dpm[j] = max(dpm[j], dpa[j+1] + a[i]);
    }
    dpa[k] = b[i];
    dpm[k] = max(dpm[k], b[i]);
  }

  int ans = 0;
  for(int i = 0; i <= k; i++) ans = max(ans, dpm[i]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1280
N,M = list(map(int,input().split()))
H = list(map(int,input().split()))

lst = [[] for i in range(N)]

for i in range(M):
    A,B = list(map(int,input().split()))
    lst[A-1].append(B-1)
    lst[B-1].append(A-1)

ans = 0
for i in range(N):
    for h in lst[i]:
        if H[i] <= H[h]:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 29364
#include <iostream>
#include <vector>
#include <cmath>
#include <stack>

template<typename T>
auto print(std::vector<T> array,bool reverse = false) 
 -> void{
 	if(reverse){
		auto iterator = array.rbegin();
		std::cout<<*iterator;
		iterator++;
		for(;iterator != array.rend();++iterator){
			std::cout<<" "<< *iterator;
		}

	}else{
		auto iterator = array.begin();
		std::cout<<*iterator;
		iterator++;
		for(;iterator != array.end();++iterator){
			std::cout<<" "<< *iterator;
		}
	}
	std::cout<<"\n";
}

template<typename T>
auto println(std::vector<T> array) 
 -> void{
	for(auto v : array){
		std::cout<< v <<"\n";
	}
}

struct T
{
	long long int key;
	T *right;
	T *left;
	T *parent;
	T():key(0){};
};

T *root;

auto insert(T *z)
 -> void{


	T *y = nullptr;
	T *x = root;

	while(x != nullptr){
		y = x;
		if(z -> key < x -> key){
			x = x -> left;
		}else{
			x = x -> right;
		}
	}
	z->parent = y;

	if(y == nullptr){
		root = z;
	}else if(z -> key < y-> key){
		y -> left = z;
	}else{ 
		y -> right = z;
	}
}

auto inorder(T *t)
 -> void{

 	if(t -> left != nullptr){
		inorder(t -> left);
 	}

 	std::cout<<" "<< t -> key;

 	if(t -> right != nullptr){
		inorder(t -> right);
 	}
 }

auto preorder(T *t)
 -> void{

 	std::cout<<" "<< t -> key;

 	if(t->left != nullptr){
		preorder(t -> left);
 	}
 	
 	if(t->right != nullptr){
		preorder(t -> right);
 	}
 }

auto main()
 -> int{

	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	int n;
	std::cin>>n;
	std::string cmd;

	for(int i=0;i<n;i++){
		std::cin>>cmd;
		if(cmd=="insert"){
			T* z = new T();
			std::cin>>z->key;
			insert(z);
		}else{
			inorder(root);
			std::cout<<"\n";
			preorder(root);
			std::cout<<"\n";
		}
	}

	return 0;
}

Measured memory_bytes: 24664
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    int ans = 0;
    REP(i,3){
        if(s[i] == '1') ans++;
    }
    cout << ans;
    return 0;
}

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

const int MAXN = 500010;
char buf[MAXN]; int n;
struct kmp {
	int fail[MAXN];
	void build(char * buf, int n) {
		for (int i = 1; i <= n; ++i) {
			int t = fail[i - 1];
			while (t && buf[t + 1] != buf[i]) t = fail[t];
			fail[i] = t + 1 != i && buf[t + 1] == buf[i] ? t + 1 : 0;
		}
	}
	bool can(int x) { return !fail[x] || x % (x - fail[x]) != 0; }
} a, b;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> buf + 1; n = strlen(buf + 1);
	a.build(buf, n); std::reverse(buf + 1, buf + 1 + n); b.build(buf, n);
	if (a.fail[n] == n - 1) return std::cout << n << "\n1\n", 0;
	if (a.can(n)) return std::cout << "1\n1\n", 0;
	int ans = 0;
	for (int i = 1; i < n; ++i) ans += a.can(i) && b.can(n - i);
	std::cout << 2 << '\n' << ans << '\n';
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,d,c,sum,m;

signed main() {
    cin >> n;
    rep(i,n) cin >> d >> c, sum += d*c, m += c;
    cout << (sum-1)/9+m-1 << endl;
}


Measured memory_bytes: 256
import numpy as np
n=int(input())
a=[list(map(int,input().split()))]
b=[[i+1 for i in range(n)]]
a=np.array(a)
b=np.array(b)
c = np.concatenate([a,b])
d=np.argsort(c[0, :])
d=[d[i]+1 for i in range(n)]
print(' '.join(map(str, d)))

Measured memory_bytes: 26528
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

const int INFI = 1 << 29;
const int V = 40;

int n, now, farx;
int use[V];

struct MAT
{
	int lx,ly,rx,ry,id;
	void rd()
	{
		scanf("%d%d%d%d",&lx,&ly,&rx,&ry);
		//if (rx < lx) swap(lx,rx);
		//if (ry < ly) swap(ly,ry);
	}
	bool operator <(const MAT &a)const
	{
		return lx < a.lx || (lx == a.lx && ly < a.ly); 
	}
}mat[V];
void dfs(const vector<int> &rest)
{
	/*
	printf("dfs at  %d  ",rest.size());
	for (int i=0;i<rest.size();i++)
		printf("%d ",rest[i]);
	printf("\n");
	*/
	int topx = INFI, topy = INFI, c = rest[0];
	for (int i=0;i<rest.size();i++)
	{
		int u = rest[i];
		if (mat[u].lx < topx || (mat[u].lx == topx && mat[u].ly < topy) )
		{
			topx = mat[u].lx;
			topy = mat[u].ly;
			c = u;
		}
	}
	
	use[c] = ++now;
//	printf("c is %d %d\n",c,use[c]);
	
	/*
	int bx = mat[c].rx;
	int by = mat[c].ry;
	bool find;
	do
	{
		find = false;
		for (int k=0;k<rest.size();k++)
		if (rest[k] != c)
		{
			int u = rest[k];
			if (mat[u].lx == bx && mat[u].ry == by)
			{
				find = true;
				bx = mat[u].rx;
			}
		}		
	}while (find);
	*/
	int bx = 1000;
	int by = mat[c].ry;
    for (int i = 0; i < n; ++i) {
        if (mat[i].ly < by && mat[i].ry > by) {
            bx = min(bx, mat[i].lx);
        }
    }
	//if (bx > farx) bx /= 0; 
	//printf("bx is %d\n",bx);
	
	vector<int> nrest;
	vector<int> left;
	nrest.clear(); left.clear();
	for (int i=0;i<rest.size();i++)
	if (rest[i] != c)
	{
		int k = rest[i];
		if (mat[k].lx <= bx && mat[k].ry <= mat[c].ry)
		{
			nrest.push_back(k);		
			//printf("push %d\n",k);
		}else
			left.push_back(k);
	}
	if (nrest.size() != 0) dfs(nrest);	
	if (left.size() != 0) dfs(left);
}
int main()
{
	bool first = true;
	while (1)
	{
		scanf("%d",&n);
		if (n == 0) break;
		
		farx = 0;
		for (int i=0;i<n;i++)
		{
			mat[i].rd();
			mat[i].id = i;
			if (mat[i].rx > farx) farx = mat[i].rx;
		}
		memset(use,0,sizeof(use));	
		vector<int> rest;
		for (int i=0;i<n;i++)
			rest.push_back(i);
		
		now = 0;
		dfs(rest);
		
		if (!first) printf("\n"); 
		first = false;		
		
		for (int i=0;i<n;i++)
			printf("%d\n",use[i]);
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
int judgeTime500 (double x);
int judgeTime1000 (double y);
int rankTime (int a, int b);
int main () {
	double time1, time2;
	int i,j,k;
	while (scanf ("%lf %lf", &time1, &time2) != EOF) {
	
		i = judgeTime500 (time1);
		j = judgeTime1000 (time2);
		k = rankTime (i, j);
		switch (k) {
			case 1:
				printf ("AAA\n");
				break;
			case 2:
				printf ("AA\n");
				break;
			case 3:
				printf ("A\n");
				break;
			case 4:
				printf ("B\n");
				break;
			case 5:
				printf ("C\n");
				break;
			case 6:
				printf ("D\n");
				break;
			case 7:
				printf ("E\n");
				break;
			case 8:
				printf ("NA\n");
				break;
			default:
				break;
		}
	}
	
	return 0;	
}

int judgeTime500 (double x) {
	if (x < 35.50) {
		return 1;	// AAA
	} else if ((x >= 35.50) && (x < 37.50)) {
		return 2;	// AA
	} else if ((x >= 37.50) && (x < 40.00)) {
		return 3;	// A
	} else if ((x >= 40.00) && (x < 43.00)) {
		return 4;	// B
	} else if ((x >= 43.00) && (x < 50.00)) {
		return 5;	// C
	} else if ((x >= 50.00) && (x < 55.00)) {
		return 6;	// D
	} else if ((x >= 55.00) && (x < 70.00)) {
		return 7;	// E
	} else {
		return 8;	// NA
	}
}

int judgeTime1000 (double y) {
	if (y < 71.00) {
		return 1;	// AAA
	} else if ((y >= 71.00) && (y < 77.00)) {
		return 2;	// AA
	} else if ((y >= 77.00) && (y < 83.00)) {
		return 3;	// A
	} else if ((y >= 83.00) && (y < 89.00)) {
		return 4;	// B
	} else if ((y >= 89.00) && (y < 105.00)) {
		return 5;	// C
	} else if ((y >= 105.00) && (y < 116.00)) {
		return 6;	// D
	} else if ((y >= 116.00) && (y < 148.00)) {
		return 7;	// E
	} else {
		return 8;	// NA
	}
}

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

Measured memory_bytes: 608
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
int main() {
	string N;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N.size(); i++) sum += N[i] - '0';
	cout << max(((int)N.size() - 1) * 9 + (N[0] - '1'), sum) << endl;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL a,b,x;

LL ans = 0;

void solve(){
	ans = b/x - a/x + (a%x==0);
}

int main(){
    cin >> a >> b >> x;

    solve();

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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}

using namespace MyLib;


int main() {
	int n, m;
	int p;
	int x[100];
	while (cin >> n >> m >> p, n) {
		REP(i, n)
			cin >> x[i];
		int count = 0;
		REP(i, n)
			count += x[i];
		if (x[m - 1] == 0)
			cout << 0 << endl;
		else
			cout << count*(100 - p) / x[m - 1] << endl;



	}

	return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin>>N>>K;
  int sum=1;
  
  for(int i=0;i<N;i++){
    if(sum+K<sum*2){
      sum+=K;
    }
    else{
      sum*=2;
    }
  }
  cout<<sum<<endl;
}

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

using namespace std;


void solve() {
    int a,b,c,x,y;
    cin >> a >> b >> c;
    cin >> x >> y;
    int res = 0;
    if (2*c < a + b) {
        int z = min(x,y);
        res += z * 2*c;
        x-=z; y-=z;
    }
    res += x*min(a,2*c)+y*min(b,2*c);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	_, M, X := ReadInt(), ReadInt(), ReadInt()
	A := ReadInts(M)
	sort.Ints(A)

	l := 0
	r := 0
	for i := 0; i < M; i++ {
		if A[i] < X {
			l++
		} else {
			r++
		}
	}
	fmt.Println(Min(l, r))
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
let count_repitition str =
  let len = String.length str in
  let rec count offset acc =
    if offset >= len then List.rev acc
    else
      let c = str.[offset] in
      let rec count' i r =
        if i >= len || c <> str.[i] then r
        else count' (i + 1) (r + 1) in
      let r = count' offset 0 in
      count (offset + r) ((c, r) :: acc) in
  count 0 []

let rec apply_string_operation str n =
  if n = 0 then str
  else
    let char_repititions = count_repitition str in
    let applied =
      String.concat ""
      @@ List.map
           (fun (c, r) -> (string_of_int r) ^ (String.make 1 c))
           char_repititions in
    apply_string_operation applied (n - 1)

let rec solve () =
  let n = int_of_string @@ read_line () in
  if n = 0 then ()
  else
    let applied = apply_string_operation (read_line ()) n in
    print_endline applied;
    solve ()

let () = solve ()

Measured memory_bytes: 7532
#include<bits/stdc++.h>
using namespace std;
const int INF=INT_MAX;
const long long LLINF=LONG_MAX;
typedef long long ll;
const ll mod=998244353;
const int MX=4e5+7;
ll qpow(ll a ,ll b,int MOD=mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=ans*a%MOD;
        }
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll ans=1;
    int a,b;
    cin>>a>>b;
    cout<<a/b+(a%b!=0)<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
ll digit(ll a){
    ll ret=0;
    while(a){ret+=a%10; a/=10;}
    return ret;
}
int main(void){
    ll N, ans=1e15;
    in(N);
    for(ll i=1; 2*i<=N; i++) chmin(ans, digit(i)+digit(N-i));
    put(ans);
    return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll x;
cin>>x;
int cnt=0;
int t=1;
while(cnt<x){
    cnt+=t;
    t++;
}
cout<<t-1<<endl;
return 0;
}

Measured memory_bytes: 256