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

int main(){
        int n;
        int a,b;
        cin >> n >> a >> b;
        int p;
        int q1 = 0;
        int q2 = 0;
        int q3 = 0;

        for (int i=0; i<n; i++){
                cin >> p;
                if (p <= a) q1++;
                else if (a < p && p <= b) q2++;
                else q3++;
        }

        cout << min(min(q1,q2),q3) << endl;

        return 0;
}

Measured memory_bytes: 3604
nk = gets.split(' ').map(&:to_i)
pp = gets.split(' ').map(&:to_i)
pp =  pp.sort{|a, b| a.to_i <=> b.to_i }

res = 0
for i in 0..nk[1]-1 do
  res += pp[i]
end
p res

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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int choco[100010];
  rep(i,n) choco[i] = 0;
  rep(i,n) {
    int a;
    cin >> a;
    for (int j = 0; j <= 100; j++) choco[a*j+1]++; 
  }
  int sum = 0;
  for (int i = 1; i <= d;i++) sum += choco[i];
  cout << sum + x << endl;
}

Measured memory_bytes: 256
def findSumOfDigit(n):
  sum = 0
  while n>0:
    sum += n%10
    n //= 10
  return sum

N, A, B = map(int, input().split())
total = 0
for i in range(1,N+1):
  sum = findSumOfDigit(i)
  if sum>=A and sum<=B:
    total += i

print(total)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,N) for(int i = 0; i<(int)(N); i++)
#define REP(i,k,N) for(int i = k; i<(int)(N); i++)
#define INF 10000000
typedef long long ll;
using namespace std;
const int MAX_N = 1001;
int d[MAX_N][MAX_N];
int main(){
        string ch1,ch2;
        cin >> ch1;
        cin >> ch2;
        rep(y,ch1.size()+1) rep(x,ch2.size()+1){
                if(y==0) {d[y][x]=x; continue;}
                if(x==0) {d[y][x]=y; continue;}

                int m_l_u = min(d[y-1][x]+1,d[y][x-1]+1);
                if(ch1[y-1] == ch2[x-1]) {
                        d[y][x] = min(m_l_u,d[y-1][x-1]);
                }else{
                        d[y][x] = min(m_l_u,d[y-1][x-1]+1);
                }

        }
        cout << d[ch1.size()][ch2.size()] << endl;
        return 0;
}



Measured memory_bytes: 7028
/*s1190073  Rina Sato
  File name: prog4b.c
  This is a binary search program.
*/

#include <stdio.h>

int main(void){
  int S[100000],T[50000];
  int i,n,q,count=0;
  int mid=0,right=0,left=0;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&T[i]);
  }

  for(i = 0 ; i < q ; i++){

    right = n;
    left = 0;
    
    while(right > left){
      
      mid = (right+left)/2;
      
      if(S[mid] == T[i]){
	count++;
	break;
      }
      else if(S[mid] < T[i]){
	left = mid+1;
      }
      else {
	right = mid;
      }
    }
  } 
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 868
/**
 * @author: shashankchdhry
 * @made:   2020-03-30 15:24:37 
**/
#include <bits/stdc++.h>

using namespace std;

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

    int n, l;
    cin >> n >> l;
    vector<string> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    sort(arr.begin(), arr.end());

    for (auto i:arr)
        cout << i;
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int c,n,m,s,e;
    while(cin>>c>>n>>m>>s>>e,c+n+m+e+s){
        --s,--e;
        vector<vector<pii>>edge(n,vector<pii>());
        rep(i,m){
            int a,b,cost; cin>>a>>b>>cost;
            --a,--b;
            edge[a].push_back(pii(b,cost));
            edge[b].push_back(pii(a,cost));
        }
        typedef  pair<pii,int>piii;
        priority_queue<piii,vector<piii>,greater<piii>>que;
        vector<vector<int>>d(n,vector<int>(11,INF));
        que.push(piii(pii(0,c),s));
        d[s][c]=0;
        while(!que.empty()){
            piii now=que.top(); que.pop();
            if(d[now.second][now.first.second]<now.first.first)continue;
            for(int i=0; i<edge[now.second].size();i++){
                pii next=edge[now.second][i];
                if(d[next.first][now.first.second]>d[now.second][now.first.second]+next.second){
                    d[next.first][now.first.second]=d[now.second][now.first.second]+next.second;
                    que.push(piii(pii(d[next.first][now.first.second],now.first.second),next.first));
                }
                if(now.first.second>0){
                    if(d[next.first][now.first.second-1]>d[now.second][now.first.second]+(next.second)/2){
                        d[next.first][now.first.second-1]=now.first.first+(next.second)/2;
                        que.push(piii(pii(d[next.first][now.first.second-1],now.first.second-1),next.first));
                    }
                }
            }
        }
        int ans=INF;
        for(int i=0; i<=c; i++)cmin(ans,d[e][i]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3092
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long a[] = new long[n];
    List<P> ls = new ArrayList<>(n);
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      ls.add(new P(i, a[i]));
    }
    sc.close();
    // sort from big num to small num
    Collections.sort(ls);
    long[][] dp = new long[n + 1][n + 1]; // [left + right][left]

    for (int i = 0; i < n; i++) { // i is already set
      P p = ls.get(i);
      for (int j = 0; j <= i; j++) { // j equal next left num
        int lpos = j; // next left pos
        int rpos = n - 1 - (i - j); // next right pos
        // add right
        dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j] + p.num * Math.abs(rpos - p.pos));
        // add left
        dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + p.num * Math.abs(lpos - p.pos));
      }
    }

    long res = 0;
    for (int i = 0; i <= n; i++) {
      res = Math.max(res, dp[n][i]);
    }
    
    System.out.println(res);
  }

  static class P implements Comparable<P> { // sorted by num from big to small
    int pos;
    long num;
    P(int pos, long num) {
      this.pos = pos;
      this.num = num;
    }
    public int compareTo(P p) {
      return Long.compare(p.num, num);
    }
  }
}

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

typedef long long ll;
#define inf 1e9+7

int dp[1001][1001];
char x[1001],y[1001];

void init(){
    for(int i=0;i<1001;i++){
        dp[0][i]=0;
        dp[i][0]=0;
    }
}

void solve(int sn, int tn){
    for(int i=1;i<=sn;i++){
        for(int j=1;j<=tn;j++){
            if(x[i-1]==y[j-1])dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    }
}

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

    int n;
    cin >> n;
    string s,t;
    for(int i=0;i<n;i++){
        init();
        cin >> s >> t;
        int sn=s.size();
        int tn=t.size();
        for(int j=0;j<sn;j++){
            x[j]=s[j];
        }
        for(int j=0;j<tn;j++){
            y[j]=t[j];
        }

        solve(sn, tn);
        cout << dp[sn][tn] << endl;
    }

}



Measured memory_bytes: 7108
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int dp[110][10010];
int main(void){
    int n,W,i,j,k;
    cin >> n >> W;
    vector<int> v(n+1,0),w(n+1,0);
    for(i=1;i<=n;i++){
        cin >> v[i] >> w[i];
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=W;j++){
            if(j-w[i]>=0)dp[i][j]=max(dp[i][j-w[i]]+v[i],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    int ret=0;
    for(i=0;i<=W;i++)ret=max(dp[n][i],ret);
    cout << ret << endl;
}


Measured memory_bytes: 7028
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  vector<long long> a(3*n);
  REP(i,3*n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  long long ans;
  int f=0;
  int e=3*n-2;
  while(f<=e){
    ans += a[e];
    e -= 2;
    f++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
l = []
for i in range(n):
    l.append(ip())
if a in l and b in l and c in l:
    print(0)
    exit(0)
l.sort()
req = [a, b,c]


m  = pow(10,30)
set = [0 for i in range(n)]
set[0] = -1
while sum(set) < n*3:
    while sum(set) < n*3:
        d = 0
        set[d]+=1
        while set[d] == 4:
            set[d]=0
            d+=1
            set[d]+=1
        if 0 in set and 1 in set and 2 in set: break
    if 0 not in set or 1 not in set or 2 not in set:
        continue
    s = [0,0,0,0]
    mi = 0
    for i in range(n):
        s[set[i]]+= l[i]
    for i in range(3):
        mi += abs(s[i] - req[i]) + (set.count(i)-1) * 10
    m  = min(m,mi)
print(m)




Measured memory_bytes: 13684
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    char ch[3][3];
    for(int i = 0;i < 3;i++)
    {
        for(int j = 0;j < 3;j++)
        {
            cin >> ch[i][j];
        }
    }
    cout << ch[0][0] << ch[1][1] << ch[2][2] << "\n";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

namespace Contest
{
    class Program
    {
        public void Solve()
        {
            var sc = new Scanner();

            long N = sc.NextLong();
            long min = long.MaxValue;

            for (int i = 0; i < 5; i++)
            {
                min = Math.Min(min, sc.NextLong());
            }

            long div = (N + min - 1) / min;

            Console.WriteLine(4+div);
        }


        static void Main(string[] args) => new Program().Solve();
    }

    class Scanner
    {
        private char _separator = ' ';
        private StreamReader _stream = new StreamReader(Console.OpenStandardInput());
        private int _pos = 0;
        private string[] _line = new string[0];
        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }
            return _line[_pos++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);
            _pos = _line.Length;
            return _line;
        }
        public int[] IntArray()
        {
            var arr = Array();
            var res = new int[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = int.Parse(arr[i]);
            }
            return res;
        }
        public long[] LongArray()
        {
            var arr = Array();
            var res = new long[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = long.Parse(arr[i]);
            }
            return res;
        }
        public double[] DoubleArray()
        {
            var arr = Array();
            var res = new double[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = double.Parse(arr[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 13140
#!/usr/bin/env python3

def main():
    N = int(input())
    c = input()
    ans = 0
    j = N - 1
    for i in range(N):
        if c[i] == 'W':
            while j > i:
                if c[j] == 'R':
                    ans += 1
                    j -= 1
                    break
                j -= 1
            else:
                break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9480
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
typedef pair<long long, long long> pll;
const int MAX = 6000;
const long long INF = 1LL<<60;

pll input[MAX];
long long dp[MAX];

long long solve() {
  for (int i = 0; i < MAX; ++i) {
	dp[i] = INF;
  }

  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
	for (int j = i; j >= 0; --j) {
	  if (dp[j] <= input[i].first) {
		chmin(dp[j+1], dp[j] + input[i].second);
	  }
	}
  }
  int res = 0;
  for (int i = 0; i <= N; ++i) {
	if (dp[i] < INF) res = i;
  }
  return res;
}

bool cmp(pll a, pll b) {
  return (a.first + a.second < b.first + b.second);
  /*
  if (a.second < b.second) return true;
  else if (a.second > b.second) return false;
  else if (a.first < b.first) return true;
  else if (a.first > b.first) return false;
  return true;
  */
}

int main() {
  while (cin >> N) {
	for (int i = 0; i < N; ++i) {
	  cin >> input[i].first >> input[i].second;
	}
	sort(input, input+N, cmp);
	cout << solve() << endl;
  }
}


















Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,i,goukei;
	scanf("%d",&goukei);
	while(goukei!=0) {
		for(i=1;i<=9;i++) {
			scanf("%d",&a);
			goukei=goukei-a;
		}
		printf("%d\n",goukei);
	scanf("%d",&goukei);
	}
	return 0;
}

Measured memory_bytes: 600
object Main extends App {
	var Array(a, b, c) = scala.io.StdIn.readLine.split(" ").map(_.toLong)
	
	if(a%2 == 0 || b%2 == 0 || c%2 == 0){
		println(0)
	}else{
		println(math.min(math.min(b*c, a*b), a*c))
	}

}


Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から

int main(){
    int n; cin >> n;
    string s; cin >> s;
    stringstream ss;
    rep(i,s.size()) {
//        cout << (int)s[i] + n << endl;
        int c_num = (int)s[i] + n;
        c_num %= 91;
        if (c_num < 65) c_num += 65;
        
        ss << (char)c_num;
    }

    cout << ss.str() << endl;
}

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

int main()
{
  string a, b;
  cin >> a >> b;
  
  if(a.length() > b.length()){
    cout << "GREATER" << endl;
  }else if(a.length() < b.length()){
    cout << "LESS" << endl;
  }else{
    bool equal = true;
    for(unsigned int i = 0; i < a.length(); ++i){
      if(a[i] > b[i]){
        cout << "GREATER" << endl;
        equal = false;
        break;
      }else if(a[i] < b[i]){
        cout << "LESS" << endl;
        equal = false;
        break;
      }
    }
    if(equal) cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 3616
l = [int(input()) for i in range(5)]
ans = sum(l)
tmp_A = [0]*5
for i in range(5):
  tmp_A[i] = 10 - l[i]%10
tmp = 0
count = 0
for k in range(5):
  if tmp_A[k] != 10 and tmp_A[k] >= tmp:
    tmp = tmp_A[k]
  if tmp_A[k] == 10:
    count += 1
ans += sum(tmp_A)
ans = ans - tmp - 10*count
print(ans)
   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};


using namespace std;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<tuple<ll,ll,ll>> vec;
    rep(i,m){
        ll p,y;
        cin >> p >> y;
        vec.emplace_back(p,y,i);
    }  
    sort(all(vec),CompTupleBy<1>() );
    
    sort(all(vec));
    get<1>(vec[0]) = 1;
    for(int i=1;i<m;i++){
        if (get<0>(vec[i]) != get<0>(vec[i-1])){
            get<1>(vec[i]) = 1;
        }else{
            get<1>(vec[i]) = get<1>(vec[i-1])+1;
        }
    }
    
    sort(all(vec),CompTupleBy<2>() );
    rep(j,m){
        printf("%06d%06d",get<0>(vec[j]),get<1>(vec[j]));
        cout << endl;
    }
    
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
int main(void){
   string s;
   ll k;
   cin>>s>>k;
   int cnt=0;
   char ans;
   for(int i=0;i<s.size();i++){
       if(s[i]=='1'){
           cnt++;
       }else{
           ans=s[i];
           break;
       }
   }
   if(k<=cnt){
       cout<<1<<endl;
   }else{
       cout<<ans<<endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n; cin>>n;
    ll ans=n*(n+1)*(n+2)/6;
    for(ll i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b; a--; b--;
        ans-=(min(a,b)+1)*(n-max(a,b));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

int main() {
    int n;
    cin >> n;
    int p;
    cin >> p;
    int c[2] = {};
    int in;
    REP(i,0,n) {
        cin >> in;
        c[in%2]++;
    }
    LL cnt = 1;
    REP(i,0,c[0]) cnt *= 2;
    //if (cnt == 1) cnt = 0;
    LL pa[51][52] ={};
    pa[0][0] = 1;
    REP(i,1,51) {
        REP(j,0,i+1) {
            if (j == 0) pa[i][j] = pa[i-1][j];
            else pa[i][j] = pa[i-1][j] + pa[i-1][j-1];
        }
    }
    //REP(i,0,c[1]+1) cout << pa[c[1]][i] << endl;
    //if (c[1] % 2 == 0) {
        /*
        LL tmp = 1;
        REP(i,0,c[i]) tmp *= 2;
        tmp -= pa[c[1]][(c[1]+1)/2];
        tmp /= 2;
        if (p) tmp += pa[c[1]][(c[1]+1)/2];
        cnt += tmp;
        */
        LL tmp = 0;
        REP(i,0,c[1]+1) if (i % 2 == p) tmp += pa[c[1]][i];
        //cout << cnt << endl;
        //cout << tmp << endl;
        cnt *= tmp;
    //} else {
    //    LL tmp = 1;
    //    REP(i,0,c[i]) tmp *= 2;
    //    tmp /= 2;
    //    cnt += tmp;
    //}
    cout << cnt << endl;
    
     return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
#define hash hush
typedef long long ll;
typedef long double ld;
signed  main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= 10)
		cout << "error\n";
	else
		cout << a + b << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll x;
  cin>>x;
    ll count=0;
    ll n=100;
    while(n<x)
    {
        ll i=n/100;
        n=n+i;
      
        count++;
    }
    cout<<count<<endl;
    return 0;
    
}


Measured memory_bytes: 3648
def resolve():
    n, m = map(int, input().split())
    S = [tuple(map(int, input().split()))[1:] for _ in range(m)]
    P = tuple(map(int, input().split()))

    ans = 0
    for ps in range(2**n):
        fl = [False] * m
        for k, v in enumerate(S):
            cnt = 0
            for s in v:
                if ps & 1 << (s-1):
                    cnt += 1

            if cnt % 2 == P[k]:
                fl[k] = True

        if all(fl):
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()

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

int main(){
  int N,Q;
  cin >> N >> Q;
  string str;
  cin >> str;
  int l[Q],r[Q];
  for(int i = 0; i < Q; ++i) cin >> l[i] >> r[i];
  
  int S[N] = {0};
  for(int i = 0;i < N-1;++i){
    S[i+1] = S[i];
    if(str[i+1] == 'C'){
      if(str[i] == 'A') S[i+1] = S[i] + 1;
    }
  }
  
  int ans = 0;

  for(int i = 0; i<Q;++i){
    ans = S[r[i]-1] - S[l[i]-1];
    cout << ans << endl;
  }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long x;
    cin >> x;
    int res1 = 0;
    int res2 = 0;
    while(x > 0){
        
       
        res1 += 1;
         x -= 500;
    }
    if(x < 0) {
        x += 500;
        res1 --;
    }
    while(x > 0){
       x -= 5;
    res2 += 1;
    }
    if(x < 0) res2--;
   // cout << res2;
    cout << (res1)*1000 + (res2)*5;
}


Measured memory_bytes: 256
program example
	implicit none

	integer X,Y,Z,A
    
    read(*,*) X,Y,Z
    
    A=X
    
    X=Y
    
    Y=A
    
    A=X
    
    X=Z
    
    Z=A
    
    write(*,"(i3,1x,i3,1x,i3)") X,Y,Z
    

end program example

Measured memory_bytes: 768
N,M=map(int,input().split())
rM=M**(1/2)
MOD=10**9+7
i=2
s=0
ans=1
while i<=rM:
  if M%i==0:
    M=M//i
    s+=1
  elif s!=0:
    comb=1
    for j in range(s+N-1,N-1,-1):
      comb*=j
    for j in range(s,0,-1):
      comb//=j
    ans*=comb
    ans%=MOD
    i+=1
    s=0
  else:
    i+=1
if M!=1:
  ans*=N
  ans%=MOD
print(ans)
    
  

Measured memory_bytes: 3188
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M = MI()
    E = N+M-1
    edge = [set() for _ in range(N)]
    indegree = [0]*N
    for _ in range(E):
        a,b = MI_()
        edge[a].add(b)
        indegree[b]+=1
    
    queue = deque()
    for v in range(N):
        if not indegree[v]:
            queue.append(v)
    
    pop = queue.popleft
    ans = [0]*N
    topo_sort = []
    while queue:
        v = pop()
        topo_sort.append(v)

        for u in edge[v]:
            indegree[u]-=1
            if not indegree[u]:
                ans[u] = v + 1
                queue.append(u)
    print(*ans,sep="\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 41764
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
 
long long N, X[1009], Y[1009], H[1009]; vector<tuple<long long, long long, long long>>vec;
 
int main() {
	cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); V = max(V, 0LL); bool flag = true;
			for (int k = 1; k <= N; k++) {
				long long VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL);
				if (H[k] != VV) flag = false;
			}
			if (flag == true) vec.push_back(make_tuple(i, j, V));
		}
	}
	if (vec.size() == 1) {
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(2):
        m = min(a[i + j], b[i])
        ans += m
        a[i + j] -= m
        b[i] -= m
print(ans)

Measured memory_bytes: 82148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll h, w; cin >> h >> w;
  ll res = 0;
  if (h == 1 || w == 1) {
    puts("1");
    return 0;
  }
  for (auto i = 0; i < h; i++) {
    if (i % 2 == 0) res += (w % 2 == 0 ? w / 2 : w / 2 + 1);
    else res += w / 2;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		Array.Sort(A);
		string ans = "YES";
		for(var i=0;i<N-1;i++){
			if(A[i]==A[i+1]){
				ans = "NO";
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 36188
using System;
using System.Collections;
using System.Linq;


public class Test
{
	public static void Main()
	{
		string[] str = Console.ReadLine().Split(' ');
		int max = int.Parse(str[0]);
		int mokuhyou = int.Parse(str[1]);
		int cnt = 0;

		for(int i = 0 ; i <= max ; i++){
			for(int j = 0 ; j <= max ; j++){
				if(mokuhyou - i - j <= max && mokuhyou - i - j >= 0){
					cnt++;
				}
			}
		}
		
		Console.WriteLine(cnt);
	}
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (S.at(i - 1) == S.at(i)) ans++;
  }
  cout << N - ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    int a, b, q;
    scanf("%d %d %d", &a, &b, &q);

    ll s[a], t[b];
    for (int i = 0; i < a; i++)
        scanf("%lld", &s[i]);
    for (int i = 0; i < b; i++)
        scanf("%lld", &t[i]);
    sort(s, s + a);
    sort(t, t + b);

    for (int i = 0; i < q; i++) {
        ll num;
        scanf("%lld", &num);
        // printf("%lld\n", num);

        int r1 = lower_bound(s, s + a, num) - s;
        int l1 = r1 > 0 ? r1 - 1 : r1;
        if (r1 == a)
            r1--;
        int r2 = lower_bound(t, t + b, num) - t;
        int l2 = r2 > 0 ? r2 - 1 : r2;
        if (r2 == b)
            r2--;

        ll ans = LLONG_MAX;

        // printf("%d %d %d %d\n", l1, r1, l2, r2);
        if (s[r1] > num && t[r2] > num)
            ans = min(ans, max(s[r1], t[r2]) - num);
        if (s[l1] < num && t[l2] < num)
            ans = min(ans, num - min(s[l1], t[l2]));
        if (num > s[l1] && t[r2] > s[l1]) // LR
            ans = min(ans, num - s[l1] + t[r2] - s[l1]);
        if (s[r1] > num && s[r1] > t[l2]) // RL
            ans = min(ans, s[r1] - num + s[r1] - t[l2]);
        if (num > t[l2] && s[r1] > t[l2]) // LR
            ans = min(ans, num - t[l2] + s[r1] - t[l2]);
        if (t[r2] > num && t[r2] > s[l1]) // RL
            ans = min(ans, t[r2] - num + t[r2] - s[l1]);

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

    return 0;
}


Measured memory_bytes: 2944
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
# define mp make_pair
# define x first
# define y second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

static const ll mod = 1000000007LL;

int dp[100010];

int main() {
  int n, m; cin >> n >> m;
  vector<bool> a(n + 1, true);
  rep(i, n) {
    int x; cin >> x;
    a[x] = false;
  }

  dp[0] = 1;
  if(!a[1] && !a[2]) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, n + 1){
    if(a[i+1]) dp[i+1] = (dp[i+1] + dp[i]) % mod;
    if(a[i+2]) dp[i+2] = (dp[i+2] + dp[i]) % mod;
  }

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


Measured memory_bytes: 3964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

ll manhattan(ll x1, ll y1, ll x2, ll y2){
	return ((ll)(abs(x1-x2)+abs(y1-y2)));
}

ll digit(ll x){
	ll ans = 0ll;
	if(!x){
		return 0ll;
	}
	while(x>0){
		ans++;
		x /= 10;
	}
	return ans;
}

ll f(ll a, ll b){
	return max(digit(a),digit(b));
}

int main(void){
	ll i,n,ans=1ll;
	cin >> n;
	for(i=1ll; i<=n; ++i){
		mul_mod(ans,i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int y, m, d;
  
  scanf("%d/%d/%d", &y, &m, &d);
  
  if (y > 2019){
    printf("TBD");
  } else if (y < 2019){
    printf("Heisei");
  } else if (m > 4){
    printf("TBD");
  } else if (m < 4){
    printf("Heisei");
  } else if (d > 30){
    printf("TBD");
  } else {
    printf("Heisei");
  }
  
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int M, D;
  while(cin >> M >> D) {
    int c = 0;
    for(int i = 1; i <= M; ++i) {
      for(int j = 1; j <= D; ++j) {
        int val = j;
        if(val > 9) {
          int a = val % 10;
          val /= 10;
          int b = val % 10;
          if(a > 1 && b > 1 && (a * b) == i) ++c;
        }
      }
    }
    cout << c << '\n';
  }
  return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n;
 
bool isPrime(int x) {
	for (int i = 2; i * i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	cin >> n;
	while (!isPrime(n)) {
		++n;
	}
	cout << n << '\n';
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
string s;
int n;
map<pair<string,string>,ll> mp;
ll ans=0;
void make1(int m,string &a,string &b){
    if(m==n){
        reverse(all(b));
        mp[{a,b}]++;
        reverse(all(b));
        return;
    }
    a.push_back(s[m]);
    make1(m+1,a,b);
    a.pop_back();
    b.push_back(s[m]);
    make1(m+1,a,b);
    b.pop_back();
}
void make2(int m,string &a,string &b){
    if(m==2*n){
        reverse(all(a));
        if(mp.count({a,b}))ans+=mp[{a,b}];
        reverse(all(a));
        return;
    }
    a.push_back(s[m]);
    make2(m+1,a,b);
    a.pop_back();
    b.push_back(s[m]);
    make2(m+1,a,b);
    b.pop_back();
}
int main(){
    cin>>n;
    cin>>s;
    string a={},b={};
    make1(0,a,b);
    a={};b={};
    make2(n,a,b);
    cout<<ans<<"\n";
}


Measured memory_bytes: 32260
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    N = int(input())

    for i in range(1, N):
        for j in range(i + 1, N + 1):
            digit = 0
            while (i & (1 << digit)) == (j & (1 << digit)):
                digit += 1
            print('{} '.format(digit + 1), end='')
        print('')

sol()

Measured memory_bytes: 63192
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//BMI
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> l = new ArrayList<Integer>();
		while(sc.hasNext()){
			String[] s = sc.next().split(",");
			double w = Double.parseDouble(s[1]);
			double h = Double.parseDouble(s[2]);
			if(w/(h*h)>=25)l.add(Integer.parseInt(s[0]));
		}
		if(l.isEmpty())System.out.println("ツ該ツ督鳴づ按つオ");
		else for(Integer i:l)System.out.println(i);
	}
}

Measured memory_bytes: 12000
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<double, double>;
using tp = tuple<int, int, int>;
using tp4 = tuple<int, int, int, int>;
using tp5 = tuple<int, int, int, int, int>;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

int main()
{
	int n;
	while (cin >> n, n){
		int s = -n;
		for (int i = 1; i * i <= n; i++){
			if (n % i == 0){
				s += i;
				if (n / i != i){
					s += n / i;
				}
			}
		}
		if (s == n) cout << "perfect number\n";
		else if (s < n) cout << "deficient number\n";
		else cout << "abundant number\n";
	}
}

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)     for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    priority_queue<double,vector<double>,greater<double>> Q;
    rep(i,N){double v;cin>>v;Q.push(v);}
    rep(i,N-1){
        double cur=Q.top();
        Q.pop();
        cur+=Q.top();
        Q.pop();
        Q.push(cur/2.0);
    }
    printf("%.5f\n",Q.top());

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
using Graph = vector<vector<ll> >; // グラフ型
const ll INF=99999999999999;
const ll MOD=1000000007;

vector<ll> counter(200010);
vector<ll> purasu(200010);
void dfs(const Graph &G, ll v, ll p, ll c){
  counter[v] += c;
  
  for(auto nv : G[v]){
    if(nv == p) continue;
    dfs(G, nv, v, c+purasu[nv]);
  }
}
 
int main() {
  ll n,q;
  cin >> n >> q;
  Graph G(n);
  rep(i,n-1){
    ll x,y;
    cin >> x >> y;
    G[x-1].push_back(y-1);
    G[y-1].push_back(x-1);
  }
  purasu.assign(200010,0);
  
  rep(i,q){
    ll z,w;
    cin >> z >> w;
    purasu[z-1] += w;
  }
    

  counter.assign(200010, 0);
  

  dfs(G, 0, -1, purasu[0]);
  
  rep(i,n){
    cout << counter[i] << " ";
  }

  
 return 0;
}

Measured memory_bytes: 28928
#!/usr/bin/env pypy
 
import sys
import string

def get_int(): return int(sys.stdin.readline().strip())
def get_ints(): return map(int, sys.stdin.readline().strip().split()) 
def get_list(): return list(map(int, sys.stdin.readline().strip().split())) 
def get_string(): return sys.stdin.readline().strip()
def out(data): return sys.stdout.write(str(data))
def out_list(arr): return sys.stdout.write(' '.join(str(e) for e in arr))

MAX = 10**9
MOD = 10**9 + 7

s = get_string()
if 0<= ord(s) - ord("A") <= 25:
	out('A')
else:
	out('a')



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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; string s;
    cin >> n >> s;

    int ans = 1;
    char prev = s[0];
    for(int i = 1; i < n; i++){
        if(s[i] != prev) ans++;
        prev = s[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512