akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

struct Info
{
    string word;
    int cnt;
};

int main()
{
    int n;
    char c;

    while( cin >> n )
    {
        if( !n )
            break;

        string s;
        vector<string> v;

        getline( cin, s );
        for( int i = 0; i < n; i++ )
        {
            getline( cin, s );

            s += " ";
            string t = "";
            for( int j = 0; j < s.size(); j++ )
            {
                if( s[j] == ' ' )
                {
                    v.push_back( t );
                    t = "";
                    continue;
                }
                t += s[j];
            }
        }

        cin >> c;

        vector<Info> w;

        for( int i = 0; i < v.size(); i++ )
            if( c == v[i][0] )
            {
                Info x;
                x.word = v[i];
                x.cnt = 0;

                bool judge = true;
                for( int j = 0; j < w.size(); j++ )
                    if( w[j].word == v[i] )
                    {
                        w[j].cnt++;
                        judge = false;
                        break;
                    }

                if( judge )
                    w.push_back( x );
            }

        for( int i = 0; i < w.size(); i++ )
            for( int j = w.size() - 1; j > i; j-- )
                if( w[j].cnt > w[j-1].cnt )
                {
                    Info temp = w[j];
                    w[j] = w[j-1];
                    w[j-1] = temp;
                }

        for( int i = 0; i < w.size(); i++ )
            for( int j = w.size() - 1; j > i; j-- )
                if( w[j].cnt == w[j-1].cnt && w[j].word < w[j-1].word )
                {
                    Info temp = w[j];
                    w[j] = w[j-1];
                    w[j-1] = temp;
                }
        if( w.size() == 0 )
            cout << "NA" << endl;
        else
        {
            cout << w[0].word;
            for( int i = 1; i < 5 && i < w.size(); i++ )
                cout << " " << w[i].word;
            cout << endl;  
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<vector<int>> cd(2, vector<int>(N));
  vector<int> sum(N);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
       cin>>cd.at(i).at(j);
    }
  }
	//cout<<cd[0][3]<<endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<=i;j++){
      sum[i] += cd[0][j];
    }
    for(int k=i;k<=N-1;k++){
      sum[i] += cd[1][k];
    }
    //cout<<sum[i]<<endl;
  }

  sort(sum.begin(),sum.end());
  cout<<sum[N-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x;
  cin >> n >> x;

  vector<int> a(n);
  int sum = 0;
  int min_a = 1001;

  for (int i = 0 ; i < n ; i++) {
    cin >> a[i];
    sum += a[i];
    if (min_a > a[i]) min_a = a[i];
  }

  cout << n + (x - sum) / min_a << endl;

}

Measured memory_bytes: 256
/**********************
    Vikas Kumar Jha
    vkjha1010
**********************/
#include<bits/stdc++.h>
using namespace std;

#define ll          long long int 
#define ld          long double
#define mod         1000000007
#define fi          first
#define se          second
#define pb          push_back
#define mp          make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vb          vector<bool>
#define mii         map<ll,ll>
#define pqb         priority_queue<ll>
#define pqs         priority_queue<ll, vi, greater<ll> >
#define ps(x,y)     fixed << setprecision(y) << x
#define fast        ios_base::sync_with_stdio(0);   cin.tie(0); cout.tie(0);
#define w(t)        ll t; cin >> t; for(ll zx=1;zx<=t;++zx)  
#define fr(be,en)   for(ll i = be; i < en; i++)
ll pow(ll x,ll y){ if(y==0) return 1; if(y%2==1) return (((pow(x,y/2)*pow(x,y/2)%mod)*x)%mod); else return (pow(x,y/2)*pow(x,y/2))%mod;}
vb prime;   vi spf; 
void sieve(ll n) 
{   prime.resize(n+1,true); prime[0]=prime[1]=false;
    spf.resize(n+1,1);  spf[2]=2;
    for(ll i=4;i<=n;i+=2){ prime[i]=false; spf[i]=2; } 
    for (ll p=3; p*p<=n; p+=2) 
    {   if (prime[p] == true) 
        {   spf[p]=p;
            for (ll i=p*p; i<=n; i += p) 
            {   if(prime[i]==true)
                {   spf[i]=p;
                    prime[i] = false;
                }
            } 
        } 
    } 
} 

int main() {
    
    fast;
    ll n,m;
    cin >> n >> m;
    char arr[n][m];
    vector<vector<ll> > dp(n,vector<ll>(m));
    fr(0,n)
    {
        for(ll j=0;j<m;++j)
            cin >> arr[i][j];
    }
    for(ll i=0;i<n && arr[i][0]!='#';++i)
    {
        dp[i][0]=1;
    }
    for(ll i=0;i<m && arr[0][i]!='#';++i)
    {
        dp[0][i]=1;
    }
    for(ll i=1;i<n;++i)
    {
        for(ll j=1;j<m;++j)
        {
            if(arr[i][j]=='#')
                dp[i][j]=0;
            else
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout << dp[n-1][m-1] ;
    return 0;
}

Measured memory_bytes: 9088
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
//# pragma GCC target ("sse4")
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static int p[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>p[i];
    int ans = 0;
    for (int i = 1;i <= n;++i)
        ans += p[p[i]] == i;
    fo << ans / 2 << '\n';
    return 0;
}

Measured memory_bytes: 640
var b=["":0]
for _ in 0..<Int(readLine()!)!{
    let s=readLine()!
    b[s]=(b[s] ?? 0)+1
}
for _ in 0..<Int(readLine()!)! {
    let t=readLine()!
    b[t]=(b[t] ?? 0)-1
}
print(b.sort{$0.1>$1.1}[0].1)

Measured memory_bytes: 6256
n = int(input())
COM = [list(input().split()) for _ in range(n)]

class Node:
    def __init__(self,data):
        self.data = data #int
        self.left = None #Node
        self.right = None #Node
        self.parent = None #Node

    def inorder(self,List):
        if self.data != None:
            if self.left != None:
                self.left.inorder(List)
            List.append(self.data)
            if self.right != None:
                self.right.inorder(List)
        return List

    def preorder(self,List):
        if self.data != None:
            List.append(self.data)
            if self.left != None:
                self.left.preorder(List)
            if self.right != None:
                self.right.preorder(List)
        return List

class BTree:
    def __init__(self):
        self.root = None

    def insert(self,z):
        y = None
        x = self.root
        while x != None:
            y = x
            if z.data < x.data:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.data < y.data:
            y.left = z
        else:
            y.right = z

    def find(self,data):
        pt = self.root
        flag = 0
        while pt != None:
            if pt.data == data:
                flag = 1
                print("yes")
                break
            elif pt.data > data:
                pt = pt.left
            else:
                pt = pt.right
        if flag == 0:
            print("no")

    def print(self):
        print(""," ".join(map(str,self.root.inorder([])))) #なぜかjoinを使ったら速くなった
        print(""," ".join(map(str,self.root.preorder([]))))

btree = BTree()
cnt = 0
for i in range(n):
    if COM[i][0] == "insert":
        node = Node(int(COM[i][1]))
        btree.insert(node)
        cnt += 1
    elif COM[i][0] == "find":
        btree.find(int(COM[i][1]))
    else:
        btree.print()



Measured memory_bytes: 227868
count = 0
ans = 0

xmax, num = gets.split.map &:to_i

preans = 0

for i in 0..xmax

  jmax = [num-i, xmax].min
  for j in 0..jmax

   if num-i-j >= 0 && num-i-j <= xmax then ans += 1 end

  end
end

puts ans

Measured memory_bytes: 1788
from collections import deque

n = int(input())
a = deque(map(int, input().split()))
a.appendleft(0)
a.append(0)
a = list(a)

sum = sum([abs(a[i + 1] - a[i]) for i in range(len(a) - 1)])
ans = 0

for i in range(n):
    ans = sum
    ans = ans - abs(a[i + 1] - a[i]) - abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i])
    print(ans)

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)



int main() {
	set <li> st;
	rep(i, 3) {
		li a;
		cin >> a;
		st.insert(a);
	}
	cout << (st.size() == 2 ? "Yes" : "No") << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i=0;i<N;i++) cin>>h[i];
  int ans=0;
  int con=-11;
  for(int i=0;i<N-1;i++){
    if(i<=con) continue;
    int hi=0;
    int tmp=h[i];
    for(int j=i+1;j<N;j++){ 
      if(h[j]<=tmp){
        hi++;
        tmp= h[j];
        //cout<<h[j]<<endl;
        con=j;
      }
      else break;
    }
    ans = max(ans,hi);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include<cmath>

using namespace std;

int ketasum(int num){
    int sum=0;
    while(num!=0){
        sum+=num%10;
        num=num/10;
    }
    return sum;
}

int main() {
  int N;
  cin>>N;
  int min=100000;
  for(int i=1;i<N;++i){
      int tmp=ketasum(i)+ketasum(N-i);
      if(tmp<min){
          min=tmp;
      }
  }
  cout<<min<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
 

int cnt[100010];
// a^n mod を計算する
// O(logn)
ll modpow(ll a, ll n, ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    rep(i,n){
        int a;
        cin>>a;
        cnt[a]++;
    }

    if(n%2==0){
        for(int i=1;i<n;i+=2){
            if(cnt[i]!=2){
                cout<<0<<endl;
                return 0;
            }
        }
        cout<<modpow(2,n/2)<<endl;
    }
    else{
        if(cnt[0]!=1){
            cout<<0<<endl;
            return 0;
        }
        for(int i=2;i<n;i+=2){
            if(cnt[i]!=2){
                cout<<0<<endl;
                return 0;
            }
        }
        cout<<modpow(2,n/2)<<endl;
    }
}


Measured memory_bytes: 3984
N=int(input(""))

onei = N%10

hons = [2,4,5,7,9]
pons = [0,1,6,8]
bons = [3]

if( onei in hons ):
    print("hon")
elif( onei in pons ):
    print("pon")
elif( onei in bons):
    print("bon")
    

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n;
    if (n == 1)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3644
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
# input = sys.stdin.readline
# def ii(): return int(input())
# def mi(): return map(int, input().rstrip().split())
# def lmi(): return list(map(int, input().rstrip().split()))
# def li(): return list(input().rstrip())
# template


if __name__ == '__main__':

    # write code
    N = int(input())
    ans = []
    for i in range(N):
        S, P = input().split()
        # print(S, int(P))
        ans.append([i, S, int(P)])
    ans.sort(key=lambda x: x[2], reverse=True)
    ans.sort(key=lambda x: x[1])
    # print(ans)
    for i in range(N):
        print(ans[i][0]+1)


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  cin >> n;
  int sum = 0;
  for (auto c : n) {
    sum += c - 0x30;
  }
  if (atoi(n.c_str()) % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s.size()&1)
	{
		puts("No");
		return 0;
	}
	else for(int i=0;i<s.size();i+=2)if(s[i]!='h'||s[i+1]!='i')
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include<set>
#include<tuple>
#define f first
#define sec second
#define t 2
using namespace std;
/*
12
13
*/

ll min(ll a, ll b)
{
    if(a<b)
    return a;
    return b;
}
ll max(ll a, ll b)
{
    if(a>b)
    return a;
    return b;
}

ll DP(ll n , ll val[], ll weight[], ll target)
{
   ll dp[n+1][target+1];
   for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=target;j++)
       {
           if(i==0 || j==0)
           {
               dp[i][j]=0;
           }
           else
           if(val[i-1]<=j)
           {
               dp[i][j]=max(weight[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
           }
           else
           {
               dp[i][j]=dp[i-1][j];
           }
           
           
       }
   }
   return dp[n][target];
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n=0,target=0;
    cin>>n>>target;

    ll val[n],weight[n];
    for(int i=0;i<n;i++)
    {
        cin>>val[i]>>weight[i];
    }
    

    cout<<DP(n,val,weight,target) ;


}

Measured memory_bytes: 79104
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
void solve(){

}

int main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int n,k;
    cin>>n>>k;
    vll vec(n+1);
    rep1(i,1,n) cin>>vec[i];
    vll dp(n+1,MOD);
    dp[1]=0;
    rep1(i,1,n){
        rep1(j,1,k){
            if(i+j<=n){
                dp[i+j]=min(abs(vec[i]-vec[i+j])+dp[i],dp[i+j]);
            }
        }
    }
    cout<<dp[n]<<endl;

     return 0;

}
///Alhamdulillah



Measured memory_bytes: 1920
S = input()
n = len(S)
prev = '-1'
ans = 0
obj = S[0]
for i in range(n):
    # print(prev, obj)
    if prev != obj:
        prev = obj
        ans += 1
        if i+1 < n:
            obj = S[i+1]
    else:
        if i+1 < n:
            obj += S[i+1]
    # if prev != S[i]:
    #     ans += 1
    #     prev = S[i]
    # else:
    #     prev += S[i]
    # print(prev)

print(ans)

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int dt = h2 * 60 + m2 - (h1 * 60 + m1);

	int tmp = dt - k;

	cout << max(tmp, 0) << endl;
}

Measured memory_bytes: 3620
#import numpy as np
import math
from bisect import bisect

N, D, A = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(N)]
xh.sort(key=lambda x: x[0])
x = [i[0] for i in xh]
h = [i[1] for i in xh]
#h_int = np.ceil(h/A)

cnt=0
damage=[0]*(N+1)

for i in range(len(x)):
    damage[i] += damage[i-1]
    h[i] -= damage[i]
    if h[i]<=0: continue
    h_int =  math.ceil(h[i]/A)
    cnt+=h_int
    damage[i]+=h_int*A
    r=bisect(x,x[i]+2*D)
    #print(damage[i])
    damage[r]-= A*h_int
    

print(int(cnt))


Measured memory_bytes: 69216
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    H = [None]
    H.extend(list(map(int, input().split())))
    bad = set([])
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A] > H[B]:
            bad.add(B)
        elif H[A] < H[B]:
            bad.add(A)
        else:
            bad.add(A)
            bad.add(B)
    print(N - len(bad))


if __name__ == '__main__':
    main()


Measured memory_bytes: 88856
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
	char c = getchar(); int w = 1; int x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
inline ll readll() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define MAXN 210
int k,n;
char a[MAXN];
int dp[110][5][2];
int dfs(int now,int cnt,bool limit){
	if(now==n+1)return cnt==k;
	if(cnt>k)return 0;
	if(dp[now][cnt][limit]>=0&&!limit)return dp[now][cnt][limit];
	int maxv=0;
	if(limit==1)maxv=a[now]-'0';
	else maxv=9;
	int ans=0;
	for(int i=0;i<=maxv;i++){
		ans+=dfs(now+1,cnt+(i!=0),limit&&(i==maxv));
	}
	return dp[now][cnt][limit]=ans;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>(a+1)>>k;
	n=strlen(a+1);
	cout<<dfs(1,0,1)<<endl;
}
/* stuff to remember
	* int overflow, array bounds
	* special cases (n=1? n=0?)
	* do something instead of nothing and stay organized
	* USE STATIC ARRAYS
	* DEFINING ARRAYS BEFORE main()
	* DO NOT DEFINE ARRAYS IN main()
	* USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
int main(){
    int n;
    std::cin >> n;
    string s;
    std::cin >> s;
    ll r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    ll ans=r*g*b;
    rep(i,n){
        rep(j,n+1){
            if(i+2*j>=n)break;
            if(s[i]!=s[i+j]&&s[i+j]!=s[i+2*j]&&s[i]!=s[i+2*j]){
         //       pppri(i,i+j,i+j*2);
                ans--;
            }
        }
    }
    std::cout << ans << std::endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    vector<i64> P(N);
    REP(i, N) cin >> P[i];
    sort(P.begin(), P.end());
    i64 ans = 0;
    REP(i, K) ans += P[i];
    cout << ans << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    ll mod = 1e9+7;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll A = 1, B = 1, C = 1;
    for (int z = 0; z < N; z++) {
        A = A*10%mod;
        B = B*9%mod;
        C = C*8%mod;
    }
    ll ans = A - B*2 + C;
    ans = (ans%mod+mod)%mod;
    cout << ans << endl;
    return 0;
    
}


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

int main(){
    int h,n; cin>>h>>n;
    vector<int> dp(h+1,1e9);
    dp[0] = 0;
    rep(i,n){
        int a,b; cin>>a>>b;
        rep(j,h){
            int x = min(j+a,h);
            dp[x] = min(dp[x],dp[j]+b);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////


int main(){fastio;
    ll n;cin>>n;
    vector<ll>v;
    ll ans=0;
    rep(i,0,n-1){
        ll a,b;cin>>a>>b;ans+=a;
        if(a>b)v.pb(b);
    }
    sort(v.begin(),v.end());
    if(v.size()!=0)ans-=v[0];
    else ans=0;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] order = new int[5];
		order[0] = sc.nextInt();
		order[1] = sc.nextInt();
		order[2] = sc.nextInt();
		order[3] = sc.nextInt();
		order[4] = sc.nextInt();
		sc.close();
		int[] time = new int[5];
		for(int i = 0; i < 5; i++) {
			time[i] = (order[i] / 10) * 10 + (order[i] % 10 != 0 ? 10 : 0);
		}
		int max = 0;
		int ans = 0;
		for(int i = 0; i < 5; i++) {
			max = Math.abs(time[i] - order[i]) > max ? Math.abs(time[i] - order[i]) : max;
			ans += time[i];
		}
		System.out.println(ans - max);
	}
}


Measured memory_bytes: 35500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace ETC
{
    class AOJ0168
    {
        static void Main(string[] args)
        {
            int N = 30;
            int[] dpCases
             = Enumerable.Repeat<int>(0, N + 3).ToArray();
            dpCases[0] = 1;
            for (int n = 0; n < N; n++)
            {
                for (int u = 1; u <= 3; u++)
                {
                    dpCases[n + u] += dpCases[n];
                }
            }

            int[] requiredDays = new int[N + 1];
            int[] result = new int[N + 1];
            for (int i = 1; i <= N; i++)
            {
                requiredDays[i] = (dpCases[i] + 9) / 10;
                result[i] = (requiredDays[i] + 364) / 365;
            }

            while(true)
            {
                int n = int.Parse(ReadLine());

                if (n == 0) break;
                WriteLine(result[n].ToString());
            };

            ReadKey();
        }
    }
}


Measured memory_bytes: 18332
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <complex>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const ll mod = 100003;
const int cons = 100001;
const double pi = 3.141592653589793;

int cnt[101];

int main()
{
	int n;
	scanf("%d", &n);

	int maxlen = 0;

	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
		maxlen = max(maxlen, x);
	}

	int rootlen = (maxlen + 1) / 2;

	if (cnt[maxlen] < 2)
	{
		puts("Impossible");
		return 0;
	}

	if (maxlen % 2)
	{
		for (int i = maxlen; i > rootlen; i--)
		{
			if (cnt[i] < 2)
			{
				puts("Impossible");
				return 0;
			}
		}
		if (cnt[rootlen] != 2)
		{
			puts("Impossible");
			return 0;
		}
	}
	else
	{
		for (int i = maxlen; i > rootlen; i--)
		{
			if (cnt[i] < 2)
			{
				puts("Impossible");
				return 0;
			}
		}
		if (cnt[rootlen] != 1)
		{
			puts("Impossible");
			return 0;
		}
	}

	for (int i = 0; i < rootlen; i++)
	{
		if (cnt[i] > 0)
		{
			puts("Impossible");
			return 0;
		}
	}

	for (int i = maxlen + 1; i < n; i++)
	{
		if (cnt[i] > 0)
		{
			puts("Impossible");
			return 0;
		}
	}

	puts("Possible");

	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))

cycle=[]
for i in range(0,N):
    cycle.append(-1)
    A[i]-=1

count=0
cycle[0]=count
town=0
mod=0
while True:
    count+=1
    K-=1
    town=A[town]
    if K==0:
        mod=1
        break
    if cycle[town]==-1:
        cycle[town]=count
    else:
        mod=count-cycle[town]
        break

K%=mod
while K>0:
    town=A[town]
    K-=1

print(town+1)


Measured memory_bytes: 32328
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long D = scan.nextLong();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            long X = scan.nextLong();
            long Y = scan.nextLong();
            if (X * X + Y * Y <= D * D) {
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}


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

int main(){
    string s;
    cin >> s;
    int l=s.size()/2 - 1;
    int c=0;
    for(int i=0;i<=l;i++){
        if(s[i]!=s[s.size()-1-i])
            c++;
    }
    cout << c << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    
    cin>>n;
    vi a(n);
    vi b(n);
    REP(i,n){
        cin>>a[i];
        b[i] = a[i];
    }
    sort(ALL(a));
    a.erase(unique(ALL(a)), a.end());

    if(b.size()==a.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	int** dist = new int* [h+2];
	string tmp;
	int siro = 0;
	for (int i = 1;i <= h;i++) {
		dist[i] = new int[w + 2];
		cin >> tmp;
		for (int j = 1;j <= w;j++) {
			if (tmp[j - 1] == '#')dist[i][j] = -2;
			else {
				dist[i][j] = -1;
				siro++;
			}
		}
	}
	dist[0] = new int[w + 2];
	dist[h + 1] = new int[w + 2];
	for (int i = 0;i < w + 2;i++) {
		dist[0][i] = dist[h + 1][i] = -2;
	}
	for (int i = 0;i < h + 2;i++) {
		dist[i][0] = dist[i][w + 1] = -2;
	}
	queue<pair<int, pair<int, int>>> q;
	q.push(make_pair(0, make_pair(1, 1)));
	dist[1][1] = 0;
	while (!q.empty()) {
		pair<int, pair<int, int>> p = q.front();
		q.pop();
		int x = p.second.second;
		int y = p.second.first;
		if (dist[x - 1][y] == -1) {
			q.push(make_pair(p.first + 1, make_pair(y,x - 1)));
			dist[x - 1][y] = p.first + 1;
		}
		if (dist[x + 1][y] == -1) {
			q.push(make_pair(p.first + 1, make_pair(y,x + 1)));
			dist[x + 1][y] = p.first + 1;
		}
		if (dist[x][y-1] == -1) {
			q.push(make_pair(p.first + 1, make_pair( y-1,x)));
			dist[x][y-1] = p.first + 1;
		}
		if (dist[x][y+1] == -1) {
			q.push(make_pair(p.first + 1, make_pair( y+1,x)));
			dist[x][y+1] = p.first + 1;
		}
	}
	if (dist[h][w] == -1) {
		cout << -1 << endl;
	}
	else {
		cout << siro - dist[h][w]-1 << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long R,G,B,N,i,j,k,ans;
    cin>>R>>G>>B>>N;
    ans=0;
    for(i=0;i*R<N+1;i++){
        for(j=0;i*R+j*G<N+1;j++){
            if((N-i*R-j*G)%B==0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pii acos(-1)
#define fo(i0n) for(i=0;i<n;i++)
#define fo(i1n) for(i=1;i<=n;i++)
#define fo(j0n) for(j=0;j<n;j++)
#define fo(j1n) for(j=1;j<=n;j++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define pu push
#define bg begin
#define en end
using namespace std;

int main()
{
    fast();
    ll i,j,k,c,d,a,b,e,f,p,q,n,t,m,r,u,g,x,y,l;
    ld bb,cc,aa;
    string st,et,ft;
    priority_queue<ll,vector<ll>,greater<ll> > pq,aq,dq;
    map<ll,ll> ma,ta;
    map<ll,ll,greater<ll> >sa;
    set<ll> se,pe,me;
    vector<ll > vv,v,s,ss;

    
    cin>>a>>b>>c>>d>>e;
    if(a==0)cout<<1<<endl;
    if(b==0)cout<<2<<endl;
    if(c==0)cout<<3<<endl;
    if(d==0)cout<<4<<endl;
    if(e==0)cout<<5<<endl;

}


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

int main() {
  long long N,X,x,y,ans,g;
  cin>>N;
  vector<long long>a(N+1),b(N+1);
  for(int i=0;i<N+1;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  b[0]=0;
    for(int i=0;i<N+1;i++){
    b[i]=a[i]-a[i-1];
  }
  x=b[1];
      for(int i=2;i<N+1;i++){
   y=b[i];
        if(x<y){
          swap(x,y);
        }
        g=x%y;
        while(g!=0){
          x=y;
          y=g;
          g=x%y;
        }
        x=y;
      }
        
  cout<<x<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

void maxh(int* ,int);
int i,num,a[2000000];
int main()
{int n,e;
  char s[10];
  
  while(1){
    scanf("%s",s);
    if(s[2]=='d')break;
    else if(s[0]=='i'){
      num++;   
      i=num;
      scanf("%d",&n);
      a[i] = n;
      while (i > 1 && a[i/2] < a[i]){
	e= a[i]; 
	a[i]= a[i/2];
	a[i/2]=e;
	i = i/2;
      }
    }
    else {
      printf("%d\n",a[1]);

      a[1]=a[num];
      num--;

      maxh(a,1);
   
    }

  }


  return 0;
}
void maxh(int a[], int i){
  int l,r,e,largest;        


  l = 2*i;
  r = 2*i+1;
  if (l <= num && a[l] > a[i])
    largest = l;
  else 
    largest = i;
  if (r <= num && a[r] > a[largest])
    largest = r;
  if (largest != i){
    e=a[i]; 
    a[i]=a[largest];         
    a[largest]=e;    
    maxh(a, largest);
  }

} 

Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2;
  cin>>s1>>s2;
  int count = 0;
  for(int i=0;i<s1.size();i++)
  {
    if(s1[i]==s2[i])
      count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
#
# abc082 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """yx
axy"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ratcode
atlas"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """cd
abc"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """w
ww"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """zzz
zzz"""
        output = """No"""
        self.assertIO(input, output)


def resolve():
    s = input()
    t = input()
    S = sorted(s)
    T = sorted(t, reverse=True)

    if S < T:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main()
{
    string g;
    int y, m, d;
    while(true){
        cin >> g;
        if(g == "#") break;
        cin >> y >> m >> d;
        if(y >= 32 || (y >= 31 && m >= 5)){
            g = "?";
            y -= 30;
        }
        cout << g << " " << y << " " << m << " " << d << endl;
    }
}



Measured memory_bytes: 3156
#include <stdio.h>
#include <algorithm>

using namespace std;

int div_up(int a, int b){
    int res = a/b;
    if (a%b != 0){
        res += 1;
    }
    return res;
}



int main(){
    int n;
    int a[212345];
    int as[212345];
    scanf("%d", &n);
    for(int i=0; i < n; i++){
        scanf("%d", a + i);
        as[i] = a[i];
    }
    sort(as, as+n);
    reverse(as, as+n);
    int res;
    for(int i=0; i < n; i++){
        if(as[0] == a[i]){
            res = as[1];
        }else{
            res = as[0];
        }
        printf("%d\n", res);
    }
    
    return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>
#define BLACK 2
#define GRAY 1
#define WHITE 0
#define N 101
 
int color[N];
int n, G[N][N],f[N],d[N],time;
 
void visit(int u){
  int i; 
  color[u]=GRAY;
  d[u]= ++time;
  for(i=0; i<n; i++){
    if(G[u][i] == 1){
      if(color[i] == WHITE)visit(i);
    }
  }
 
  color[u]= BLACK;
  f[u]=++time;
}

int main(){
  int i,j,v,vnext,k;
  
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    color[i] = WHITE;
    for(j=0;j<n;j++) {
      G[i][j] = 0;
    }
  }
 
  for(i=0; i<n; i++){
    scanf("%d %d",&v,&k);
    for(j=0; j<k; j++){
      scanf("%d",&vnext);
      G[v-1][vnext-1] = 1; 
    }
  }
 
  for(i=0; i<n; i++){
    if(color[i]==WHITE) visit(i);
  }
 
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#define up 1
#define right 2
#define down 3
#define left 4
#define mod 1000000007
#define ll long long

using namespace std;


int main(){
    cin.sync_with_stdio(false);
    int n;
    int d;
    int x;
    cin >> n >> d >> x;
    int ans = x;
    while(n--){
        int y;
        cin >> y;
        int st = 1;
        while(st <= d){
            ++ans;
            st += y;
        }
    }
    cout << ans;

}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-

n = input()
ti = input().split()
sum_ti = sum(map(int, ti))

m = input()
for m in range(int(m)):
    px = input().split()
    sum_p = sum_ti - int(ti[int(px[0])-1]) + int(px[1])
    print(sum_p)


Measured memory_bytes: 3064
K , N = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = []

max = K - A[-1] + A[0]
B.append(max)
ind = 0
for i in range(1, N):
	_max = A[i] - A[i-1]
	B.append(_max)
	if _max < 0:
		_max = K + _max
	if _max > max:
		max = _max
		ind = i
dis1 = 0

for i in range(1, N):
	if i + ind >= N:
		dis1 += B[(i + ind) - N]
	else:
		dis1 += B[(i + ind)]
        
print(dis1)

Measured memory_bytes: 26444
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

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


Measured memory_bytes: 256
n, k, c = map(int, input().split())
s = input()
lst = [True] * n
l = []
for i in range(n):
  if s[i] == 'o' and lst[i]:
    l.append(i)
    if len(l) >= k:
      break
    for j in range(c):
      if i + 1 + j < n:
        lst[i+1+j] = False
if len(l) == k:
  lst = [True] * n
  r = []
  for i in range(n - 1, -1, -1):
    if s[i] == 'o' and lst[i]:
      r.append(i)
      if len(r) >= k:
        break
      for j in range(c):
        if i - 1 - j >= 0:
          lst[i-1-j] = False
  if len(r) == k:
    for i in range(k):
      if l[i] == r[k-i-1]:
        print(l[i] + 1)

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size())cout << "GREATER" << endl;
	else if (a.size() < b.size())cout << "LESS" << endl;
	else {
		REP(i, a.size()) {
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if (a[i] < b[i]) {
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
S=input()
x=int(S[:2])
y=int(S[2:])

if 1<=x<=12 and 1<=y<=12:
    print("AMBIGUOUS")
elif 1<=x<=12:
    print("MMYY")
elif 1<=y<=12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main() {
  int n, m;
  string in;
  cin>>n;
  set<string> t;
  for (int i=0; i<n; ++i) {
    cin>>in; t.insert(in);
  }
  cin>>m;

  bool open = false;
  for (int i=0; i<m; ++i) {
    cin>>in;
    if (t.find(in) == t.end()) {
      cout<<"Unknown "<<in<<endl;
    } else {
      cout<<(open?"Closed":"Opened")<<" by "<<in<<endl;
      open ^= true;
    }
  }
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long n;
    cin>>n;
    vector<long long>A(n+1);

    rep2(i,n)cin>>A[i];

    map<long long,int>tree;

    rep2(i,n){
        tree[-A[i]+i]++;
    }
    //m[i]:=i番目以降の最大値
    long long m[n];
    m[n-1]=A[n-1];

    for(int i=n-2;i>-1;i--){
        m[i]=max(m[i+1],A[i]);
    }
    long long ans=0;
    for(long long  i=1;i<=n;i++){
        //for(long long  k=i+A[i]+1;k<n;k++){
            //if(A[i]+A[k]==k-i)ans++;
            ans+=tree[A[i]+i];
            //if(m[k]<k-i-A[i])break;
        //}
    }

    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 28976
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, 0, n) cin >> p[i];

	int count = 0;
	rep(i, 1, n - 1) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1] || p[i + 1] < p[i] && p[i] < p[i - 1]) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

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

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

  vector<int> vec(26, 0);
  rep(i, s.size()) vec[s[i] - 'a'] = 1;

  char ans = ' ';
  rep(i, 26) {
    if (vec[i] == 0) {
      ans = i + 'a';
      break;
    }
  }

  if (ans == ' ') 
    cout << "None" << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		if(a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}

	}

}


Measured memory_bytes: 21716