akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
class Main{
    public static void main(String [] arghs){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        int [] arr=new int[]
        {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
        };
        System.out.println(arr[t-1]);
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int x = 500 * N ;
  
  if(x >= M){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            int n;
            cin >> n;
            string s;
            cin >> s;
            int dp[n+10] = {0};
            int total = 0;
            for(int i = 0; i < n; i++)
            {
                if(s[i] == 'W')
                    dp[i+1] = dp[i] + 1;
                else 
                {
                    dp[i+1] = dp[i];
                    total++;
                }
            }
            int ans = n;
            for(int i = 0; i <= n; i++)
            {
                // cout << dp[i] << " " << total-(i-dp[i]) << endl;
                ans = min(ans, max(dp[i], total - (i-dp[i])));
            }
            cout << ans << endl;

           return 0;
        }
          

Measured memory_bytes: 5288
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
 
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int a =  s.nextInt();
		String se = s.next();
		if(a>=3200)System.out.println(se);
		else System.out.println("red");
		
	}
	
}


Measured memory_bytes: 32788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	}

}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int X, Y;
  cin >> X >> Y;
  int ans = 0;
  if (X <= 3)ans += 100000 * (4-X);
  if (Y <= 3)ans += 100000 * (4-Y);
  if (X == 1 && Y == 1)ans += 400000;
  cout << ans << endl;
}


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

int main(){
    int  d,n ;
    cin >> d >> n ;
    if(d==0&&n==100) cout << 101 << endl ;
    else if(d==0) cout << n << endl ;
    else if(d==1&&n==100) cout << 10100 << endl ;
    else if(d==1) cout << 100*n << endl ;
    else if(d==2&&n==100) cout << 1010000 << endl ;
    else cout << 10000*n << endl ;
}


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

typedef long long ll;

const ll MAX = 1000000;
const ll MOD = 1000000007;

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

// 二項係数計算
long long COM(ll n, ll 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() {
  ll x, y;
  cin >> x >> y;
  COMinit();
  ll ans = 1;
  bool flag = true;
  for (ll p = 0; p <= x; p++) {
    ll q = y - 2*p;
    if (q < 0 || (p + 2*q) != x) {
      continue;
    }
    if (flag) {
      flag = false;
    }
    ans *= COM(p + q, p);
    ans %= MOD;
  }
  ans %= MOD;
  if (flag) {
    cout << 0 << endl;
  }
  else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 23680
import sys
input = sys.stdin.buffer.readline
import copy

def main():
    N,S = map(int,input().split())
    a = list(map(int,input().split()))
    MOD = 998244353

    dp = [0]*(S+1)
    dp[0] = 1
    for num in a:
        dp2 = dp.copy()
        for i in range(S-num+1):
            dp2[num+i] += dp[i]
        for i in range(S+1):
            dp[i] += dp2[i]
            dp[i] %= MOD
    
    print(dp[-1]%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69348
N = int(input())
A = [int(i) for i in input().split()]
t = 0
for i in range(N):
    a = A[i]
    if a%2 == 0:
        if a%3 != 0 and a%5 != 0:
            t += 1
            break

if t == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 9164
#include <iostream>
using namespace std;
#define N 1000000
int main(){
  int a,d,n;
  bool is_prime[N];

  for( int i=0;i<N;i++ )
    is_prime[i] = true;

  is_prime[0] = is_prime[1] = false;
  for( int i=2;i<N;i++ ){
    if( !is_prime[i] )
      continue;
    for( int j = 2*i; j<N;j+=i )
      is_prime[j] = false;
  }

  while(cin>>a>>d>>n,a){
    while( n ){
      if( is_prime[a] ){
	n--;
	if( !n )
	  break;
      }

      a += d;
    }
    cout << a << endl;
  }

  return 0;
}

Measured memory_bytes: 2132
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
  
    int w[100];
    for (int i = 0; i < n; i++) cin >> w[i];
    
    int start, end, sum;
    sum = 0;
    start = 0;
    end = n - 1;
    while (start <= end) {
      if (sum >= 0) {
        sum -= w[end--];
      } else {
        sum += w[start++];
      }
    }
    cout << abs(sum) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
#define ll long long
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
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; }
using namespace std;
ll n, k, cnt, cur = 1, a[2000000], ac[2000000] = {-1};
int main() {
    cin >> n >> k;
    REP(i,n) {
        cin >> a[i + 1];
        ac[i + 1] = -1;
    }
    while(k > 0) {
        cnt++;
        k--;
        cur = a[cur];
        if(ac[cur] >= 0) {
            k = k % (cnt - ac[cur]);
        } else {
            ac[cur] = cnt;
        }
    }
    cout << fixed << cur;
}


Measured memory_bytes: 6768
#include <iostream>
#include <list>
#include <string>

int main() {
	std::list<int> list;
	int n;
	std::cin >> n;
	std::string command;
	for (int i = 0; i < n; i++) {
		std::cin >> command;
		if (command[0] == 'i') {
			int x;
			std::cin >> x;
			list.push_front(x);
		} else if (command[6] == 'F') {
			list.pop_front();
		} else if (command[6] == 'L') {
			list.pop_back();
		} else if (command[0] == 'd') {
			int x;
			std::cin >> x;
			for(auto i = list.begin(); i != list.end(); i++) {
				if (*i == x) {
					list.erase(i);
					break;
				}
			}
		}
	}

	auto i = list.begin();
	std::cout << *i;
	for(i++; i != list.end(); i++) {
		std::cout << " " << *i;
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 34380
N=int(input())
lst=[list(map(int, input().split())) for _ in range(N)]
dp=[[0 for _ in range(3)] for _ in range(N)]
dp[0][0], dp[0][1], dp[0][2]=map(int, lst[0])
for i in range(1, N):
  dp[i][0]=lst[i][0]+max(dp[i-1][1], dp[i-1][2])
  dp[i][1]=lst[i][1]+max(dp[i-1][0], dp[i-1][2])
  dp[i][2]=lst[i][2]+max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))

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

#define int long long
#define ll long long
#define pb push_back

main(){
    int n, m;
    cin >> n >> m;
    char a[n][m];
    vector<vector<int>> dp(n);
    for(int i = 0; i < n; i++){
        dp[i].resize(m);
        for(int j = 0; j < m; j++) dp[i][j] = 1000000;
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            char r;
            cin >> r;
            a[i][j] = r;
        }
    }
    if (a[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if (i == 0 && j == 0) continue;
            if (i == 0){
                if (a[i][j] == '#' && a[i][j - 1] == '.') dp[i][j] = dp[i][j - 1] + 1;
                else dp[i][j] = dp[i][j - 1];
                continue;
            }
            if (j == 0){
                if (a[i][j] == '#' && a[i - 1][j] == '.') dp[i][j] = dp[i - 1][j] + 1;
                else dp[i][j] = dp[i - 1][j];
                continue;
            }
            if (a[i][j] == '#'){
                if (a[i - 1][j] == '.') dp[i][j] = dp[i - 1][j] + 1;
                else dp[i][j] = dp[i - 1][j];
                if (a[i][j - 1] == '.') dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
                else dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            }
            else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    cout << dp[n - 1][m - 1];
}


Measured memory_bytes: 384
def divs(num):
    ans = []
    for i in range(1,int(num**(1/2)+1)):
        if num%i == 0:
            ans += [i,num//i]
    return set(ans)
n = int(input())
a = list(map(int,input().split()))
fin = []
ans = [0]*(n+1)
for i in range(n,0,-1):
    # print(i,a[i-1],ans[i])
    if a[i-1]^ans[i]:
        fin += [i]
        div = divs(i)
        # print(div)
        for j in div:
            ans[j] ^= 1
print(len(fin))
print(*fin)

Measured memory_bytes: 98820
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
         ll n;
         cin>>n;
         ll ans = 0;
         for(ll i=1;i*i<=n;i++)
         {
              if(n%i==0)
              {
                  ll n1 = n;
                  if(i!=1)
                  while(n1%i==0)
                  {
                    n1/=i;
                  }
                  if(n1%i==1)
                    ans++;
                  ll n2 = n;
                  if(i!=(n/i) && (n/i)!=1)
                  {
                       while(n2%(n/i)==0)
                       {
                          n2/=(n/i);
                       }
                       if(n2%(n/i)==1)
                        ans++;
                  }
              }
         }
         for(ll i=1;i*i<=n-1;i++)
         {
               if((n-1)%i==0)
               {
                  if(i!=1) ans++;
                  if(i!=(n-1)/i && (n-1)/i!=1)
                    ans++;
               }
         }
         cout<<ans<<endl;
      }
      






}



























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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
const int tree_size = (1 << 19);
int n;
vector<int>a, p;
vector<int> mx(tree_size, -2e18);

struct tree {
    int mx;
    tree* l;
    tree* r;
    tree() {
        mx = -2e18;
        l = r = nullptr;
    }
};

tree* rt = new tree;

tree* get_l(tree* v) {
    if (!v->l) {
        v->l = new tree;
    }
    return v->l;
}

tree* get_r(tree* v) {
    if (!v->r) {
        v->r = new tree;
    }
    return v->r;
}

int get_max(tree* v, int l, int r, int L, int R) { // l , r - границы L,R запрос
    // если не перес
    // полуинтервал
    if(R <= l || L >= r)
        return -2e18;
    if(L <= l && r <= R)
        return v->mx;
    int m = (r + l)/2;
    return max(
                get_max(get_l(v), l, m, L, R),
                get_max(get_r(v), m, r, L, R)
              );
}

void relax(tree* v, int l, int r, int i, int x) {
    v->mx = max(v->mx, x);
    if (r-l==1)
        return;
    int m = (l + r)/2;
    if(i < m)
        relax(get_l(v), l, m, i, x);
    else
        relax(get_r(v), m, r, i, x);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    p.resize(n);
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        cin >> p[i];
    int ans = 0;
    forn(i, n)
    {
        int cur = max(get_max(rt, 0, 1e9 + 1, 0, a[i]), 0ll) + p[i];
        ans = max(ans, cur);
        relax(rt, 0, 1e9 + 1, a[i], cur);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 22944
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)

Measured memory_bytes: 44252
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

int main() {
    string s;
    cin >> s;
    map<string, string> m;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";
    cout << m[s] << '\n';
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let a: Vec<Vec<char>> = {
        let mut a = vec![];
        for _ in 0..H {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            a.push(line.trim().chars().collect());
        }
        a
    };

    let wall = (0..(W + 2)).map(|_| "#").collect::<Vec<_>>().join("");
    let ans = format!(
        "{}\n{}\n{}",
        wall,
        a.iter()
            .map(|r| format!(
                "#{}#",
                r.iter()
                    .map(std::string::ToString::to_string)
                    .collect::<Vec<_>>().join("")
            ))
            .collect::<Vec<_>>()
            .join("\n"),
        wall
    );

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int l, r;
    int ans = 0;
    for(int i = 0; i < N; i++){
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;
#define f first
#define s second
#define Mp make_pair
#define pb push_back
#define Lb lower_bound
#define Ub upper_bound
#define all(x) x.begin(), x.end()
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

const ll Maxn = 100000+5, N = 100+5, Mod = 1000*1000*1000 + 7, inf = (ll)1000*1000*1000*1000*1000*1000;
int n, dp[3][Maxn], ha[3][Maxn];
int main(){
    fast_io
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> ha[0][i] >> ha[1][i] >> ha[2][i];
    }
    dp[0][0] = ha[0][0], dp[1][0] = ha[1][0], dp[2][0] = ha[2][0];
    for (int i = 1; i < n; i++){
        dp[0][i] = max(dp[1][i-1], dp[2][i-1])+ha[0][i];
        dp[1][i] = max(dp[0][i-1], dp[2][i-1])+ha[1][i];
        dp[2][i] = max(dp[0][i-1], dp[1][i-1])+ha[2][i];
    }
    cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1])) << '\n';
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,c=0;
  char a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a=='R') c++;
  }
  if(c>n-c)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int a, b;
	cin >> a >> b;
	vector<int> ans(a);
	ff(i, 0, a) {
		ans.at(i) = 0;
	}
	int x;
	ff(i, 0, 2 * b) {
		cin >> x;
		ans.at(x-1)++;
	}
	ff(i, 0, a) {
		cout << ans.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define freop freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define st string
typedef long long ll;
 
int sm(ll x){
    if(x == 0){
        return x;
    }
    return x%10 + sm(x / 10);
}
 
void solve(){
     st a;
     ll ans = 0;
     cin >> a;
     for(ll i = 0; i < (ll) a.length(); i++){
         ans += a[i] - '0';
     }
     ans = sm(ans);
     if(ans%9 == 0){
         cout << "Yes";
     }
     else{
         cout << "No";
     }
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

typedef long long ll;

ll a[105]={0};
ll c[100005];


int main()
{
	ll n;
	cin>>n;
	bool flag=false;
	for(ll i=1;i<=n;i++){
		cin>>c[i];
		if(c[i]==0){
			flag=true;
		}
	}
	if(flag){
		cout<<0<<endl;
		return 0;
	}
	a[0]=a[1]=1;
	for(ll i=1;i<=n;i++){
		ll temp=0;
		for(ll j=1;j<=a[0];j++){
			temp=temp+a[j]*c[i];
			a[j]=temp%10;
			temp/=10;
		}
		while(temp>0){
			a[0]++;
			a[a[0]]=temp%10;
			temp/=10;
		}
		if(a[0]>19){
			cout<<"-1"<<endl;
			return 0;
		}
	}
//	cout<<a[0]<<endl;
//	for(int i=1;i<=a[0];i++){
//		cout<<a[i];
//	}
//	cout<<endl;
	
	if(a[0]==19){
		if(a[19]==1){
			for(ll i=1;i<19;i++){
				if(a[i]!=0){
					cout<<"-1"<<endl;
					return 0;
				}
			}
		}
		else {
			cout<<"-1"<<endl;
			return 0;
		}
	}
	for(ll i=a[0];i>=1;i--){
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 4416
Blue=[]
Red=[]

n=int(input())
for i in range(n):
    s=input()
    Blue.append(s)
    
m=int(input())
for i in range(m):
    t=input()
    Red.append(t)

ans=0
for a in Blue:
    plus = Blue.count(a)
    minus = Red.count(a)
    point = plus - minus
    ans = max(ans, point)
print(ans)

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

using namespace std;

int main() {

	string s, t;
	cin >> s >> t;

	// Length of the longest common subsequence between the first x characters of s and y characters of t
	int longestSubsequence[s.length()+1][t.length()+1];

	// The previous position
	pair<int, int> longestSubsequencePos[s.length()+1][t.length()+1];

	for (int i = 0; i < s.length() + 1; i++) {
		for (int j = 0; j < t.length() + 1; j++) {
			longestSubsequence[i][j] = 0;
			longestSubsequencePos[i][j] = make_pair(-1, -1);
		}
	}

	for (int i = 1; i < s.length() + 1; i++) {
		for (int j = 1; j < t.length() + 1; j++) {
			longestSubsequence[i][j] = longestSubsequence[i-1][j-1];
			longestSubsequencePos[i][j] = make_pair(i-1, j-1);
			if (s[i-1] == t[j-1]) {
				longestSubsequence[i][j] += 1;
			}
			if (longestSubsequence[i-1][j] > longestSubsequence[i][j]) {
				longestSubsequence[i][j] = longestSubsequence[i-1][j];
				longestSubsequencePos[i][j] = make_pair(i-1, j);
			}
			if (longestSubsequence[i][j-1] > longestSubsequence[i][j]) {
				longestSubsequence[i][j] = longestSubsequence[i][j-1];
				longestSubsequencePos[i][j] = make_pair(i, j-1);
			}
		}
	}

	pair<int, int> currentPos = make_pair(s.length(), t.length());
	string output = "";
	while (currentPos != make_pair(-1, -1)) {

		// cout << currentPos.first << " " << currentPos.second << endl;

		pair<int, int> previousPos = longestSubsequencePos[currentPos.first][currentPos.second];
		if (longestSubsequence[currentPos.first][currentPos.second] > longestSubsequence[previousPos.first][previousPos.second]) {
			output = output + s[currentPos.first - 1];
		}
		currentPos = previousPos;

	}

	reverse(output.begin(), output.end());

	cout << output << endl;

	// for (int i = 0; i < s.length() + 1; i++) {
	// 	for (int j = 0; j < t.length() + 1; j++) {
	// 		cout << longestSubsequence[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	// cout << longestSubsequenceString[s.length()][t.length()] << endl;

}

Measured memory_bytes: 105856
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int s;
	cin>>s;
	map<int,int> mp;
	mp[s]=1;
	int cnt=1;
	while(1){
		if(s%2==0){
			s/=2;
		}else{
			s=3*s+1;
		}
		cnt++;
		if(mp[s]!=0){
			cout<<cnt<<endl;
			return 0;
		}else{
			mp[s]=cnt;
		}
	}
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    mint ans = 1;
    for(int i = 1; i <= n; i++) {
        ans *= mint(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int n;
	cin >> n;
	cout << 800 * n - (n / 15) * 200 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define MAX 500000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[MAX];       //    p---|  Unit
int *left2 = new  int[MAX]; // left2 --|--------> T
int *right2 = new int[MAX]; //right2---|
int *key = new int[MAX];     // key----|
  
void Init(){
  rep(i,MAX){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
  
bool SEARCH(int x,int k){
  if(k == key[x])return true;
  if(x == NIL)return false;
  if(k < key[x])return SEARCH(left2[x],k);
  else return SEARCH(right2[x],k);
}
 
  
void TREE_INSERT(int z){
  int y = NIL; 
  int x = root;
  
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
  
}
  
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
  
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
  
  
int main(){
  int val;
  string op;
  long long zr;                    
  
  
  scanf("%d",&n);
  Init(); 
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;        
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
    else if(op == "find"){
      scanf("%d",&val);
      if(SEARCH(root,val)){
    printf("yes\n");
      }else{
    printf("no\n");
      }
        
  
    }
  }
  
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
 
  return 0;
}

Measured memory_bytes: 8788
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

void redir() {
	#ifndef ONLINE_JUDGE
	freopen("../../input.txt", "r", stdin);
	freopen("../../output.txt", "w", stdout);
	#endif
}

bool connected(const string &s) {
	if (s.length() <= 1)
		return false;

	size_t i = 0;
	char last = s[i];
	for (i++; i < s.length(); i++) {
		char c = s[i];
		if (c != last) {
			return true;
		} else {
			last = c;
		}
	}

	return false;
}

void solve() {
	string S;
	cin	>> S;

	cout << (connected(S) ? "Yes" : "No") << endl;
}

int main() {
	
	solve();
}

Measured memory_bytes: 256
import bisect
from collections import deque
n = int(input())
l = deque([])
l.append(int(input()))
for i in range(n-1):
    a = int(input())
    if l[0] >= a:
        l.appendleft(a)
    else:
        l[bisect.bisect_left(l,a)-1] = a
print(len(l))


Measured memory_bytes: 7412
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long days = sc.nextLong();
		long num = sc.nextLong();
		for(long i=0;i<num;i++){
			long x = sc.nextLong();
			days-=x;
		}
		if(days>=0)
			System.out.println(days);
		else
			System.out.println("-1");
	}
}



Measured memory_bytes: 46192
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(a, b) = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      if (a > b) {
        ("" + b) * a
      } else {
        ("" + a) * b
      }
    )
  }
}


Measured memory_bytes: 25288
//10018???????????????
 
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
    while(kbd.hasNext()){
        String s = kbd.nextLine();
        solve(s);
    }
    }
 
    static void solve(String s){
    String ans = "";
    int i;
    String x;
    for(i=0; i<s.length(); i++){
        x = s.substring(i,i+1);
        x = change(x);
        ans += x;
    }
    System.out.println(ans);
    }
 
    static String change(String x){
    String[] s = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 
              "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", 
              "u", "v", "w", "x", "y", "z"};
    String[] b = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
              "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
              "U", "V", "W", "X", "Y", "Z"};
    int i=0;
    while(i<s.length && !x.equals(s[i])) i++;
    if(i<s.length) return b[i];
 
    i=0;
    while(i<b.length && !x.equals(b[i])) i++;
    if(i<b.length) return s[i];
 
    return x;
    }
}

Measured memory_bytes: 27420
s=int(input())

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

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

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

Measured memory_bytes: 3632
#include <stdio.h>

void swap(int *,int *);
int gcd(int *,int *);

int main(){
  int x,y,cd;

  while(1){
    scanf("%d %d",&x,&y);
    if((1 <= x && x <= 10*10*10*10*10*10*10*10*10)&&(1 <= y && y <= 10*10*10*10*10*10*10*10*10)) break;
  }
  cd = gcd(&x,&y);
  printf("%d\n",cd);

  return 0;
}

void swap(int *p,int *q){
  int tmp;
    tmp = *p;
    *p = *q;
    *q = tmp;
}

int gcd(int *r,int *s){
  int z;
  if(*r < *s) swap(r,s);
  while(*s > 0){
    z = *r%*s;
    *r = *s;
    *s = z;
  }
  return *r;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll x, ans;
    cin >> x;
    ans = x/500*1000;
    x %= 500;
    ans += x/5*5;
    cout << ans << endl;
}      

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


int main() {

    int n; cin >> n;
    int ans = 1000000;
    string s; cin >> s;
    vector<int> w(n,0),e(n,0);
    rep(i,n){
        if(s[i] == 'W') w[i] = 1;
        else e[i] = 1;
    }
    vector<int> sw(n+1,0),se(n+1,0);
    rep(i,n) {
        sw[i+1] = sw[i] + w[i];
        se[i+1] = se[i] + e[i];
    }

    rep(i,n){
        ans = min(ans,sw[i] + se[n]-se[i+1]);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 8188
#!/usr/bin/env python3
n, m, q = [int(item) for item in input().split()]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1] * n
        self.rank = [0] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
Forest = UnionFind(n)
circles = []
group_num = n
edge_num = 0
seen = set()
for i in range(q):
    a, b, c = [int(item) for item in input().split()]
    if a > b:
        a, b = b, a
    if (a, b, c) in seen:
        continue
    if c == 0:
        # loop with simple path
        if not Forest.same_check(a, b):
            Forest.union(a, b)
            group_num -= 1
            edge_num += 1
    else:
        circles.append((a, b, c))
    seen.add((a, b, c))

for a, b, c in circles:
    # multipath in tree
    if Forest.same_check(a, b):
        print("No")
        exit()
    # if group_num == 2:
    #     print("No")
    #     exit()

if len(circles) > 0:
    edge_min = edge_num + group_num
    edge_max = edge_num + group_num * (group_num - 1) // 2
else:
    edge_min = edge_num + group_num - 1
    edge_max = edge_num + group_num * (group_num - 1) // 2

if edge_min <= m <= edge_max:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 34080
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
    int64_t n,m;
    cin>>n>>m;
    if(n>=m) {
        rep(i,n){
            cout<<m;
        }
    }
    else{
        rep(i,m){
            cout<<n;
        }
    } 
   cout<<endl;
 
    
    
}

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

int main() {
  int K;
  string S;
  cin >> K >> S ;
  int s=S.size();
  if (s<=K){
  cout <<S << endl;
  }
  else {
    string k;
    for(int i=0;i<K;i++){
      k+=S.at(i);
    }
    
    cout<<k<<"..."<<endl;
  }
}


Measured memory_bytes: 3596
#include<string>
#include<iostream>
using namespace std;
string a;
int n,m;
int main()
{
	cin>>n>>m;
	for(int i=0;i<=-~m;i=-~i)
		putchar('#');
	puts("");
	for(;n;--n)
	{
		cin>>a;
		putchar('#');
		cout<<a;
		puts("#");
	}
	for(int i=0;i<=-~m;i=-~i)
		putchar('#');
	puts("");
	return 0;
}

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

int chk(int x1, int y1, int r1, int x2, int y2, int r2){
	if((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<(r1+r2)*(r1+r2))return 1;
	return 0;
}

string view(int t,int n){
	string s="";
	for(int i=0,b=1;i<n;i++,b<<=1){
		if(t&b)s+="1";
		else s+="0";
	}
	return s;
}

int main(){
	
	for(int n;cin>>n,n;){
		int X[24], Y[24], R[24], C[24];
		int edge[24]={};
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>X[i]>>Y[i]>>R[i]>>C[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0,b=1;j<n;j++,b<<=1){
				if(chk(X[i],Y[i],R[i],X[j],Y[j],R[j])&&i>j){
					edge[i]|=b;
					//cout<<i<<"-"<<j<<endl;
				}
			}
			
		}
		map<int,int>M;
		stack<int>S;
		M[0]=1;
		S.push(0);
		while(!S.empty()){
			int t=S.top();S.pop();
			int tmp=0;
			for(int i=0,b=1;i<n;i++,b<<=1)if(t&b)tmp++;
			ans=max(ans,tmp);
			int flg[24]={0};
			for(int i=0,b=1;i<n;i++,b<<=1){
				if(t&b)continue;
				if((t&edge[i])!=edge[i])continue;
				flg[i]=1;
			}
			
			for(int i=0,b=1;i<n;i++,b<<=1){
				if(flg[i]==0)continue;
				for(int j=0,b2=1;j<n;j++,b2<<=1){
					if(i>=j)continue;
					if(flg[j]==0)continue;
					if(C[i]!=C[j])continue;
					int t2=t+b+b2;
					if(M[t2])continue;
					M[t2]=1;
					S.push(t2);
					//cout<<view(t2,n)<<endl;
				}
			}
			
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 50356
# include <bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  int ans1,ans2,diff1,diff2;
  set<int> v;
  if(n!=0){
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    v.insert(a);
  }
  for(int i=0;i<=102;i++){
    if(v.count(x-i)==0) {
       ans1=x-i;
       diff1=i;
      break;
  }
  for(int i=0;i<=102;i++){
    if(v.count(x+i)==0) {
       ans2=x+i;
       diff2=i;
      break;
  }
}
}
if(diff1<=diff2) cout<<ans1;
else cout<<ans2;
}
else cout<<x;
  return 0;
}

Measured memory_bytes: 3632
import sys

read = sys.stdin.buffer.read
#input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	s=input()
	
	print("x"*len(s))
	
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38536
#include <iostream>

using namespace std;

int main()
{
	int a;
	int n;
	
	cin >> n >> a;
	
	if (((n % 500) <= a) || (n % 500 == 0)){
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
	
	return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    int n;
    cin>>n;
    pair<pair<string,int>,int> p[n];
    rep(i,n){
        cin>>p[i].first.first>>p[i].first.second;
        p[i].first.second*=-1;
        p[i].second=i+1;
    }
    sort(p,p+n);
    rep(i,n) cout<<p[i].second<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

int main(){
  bool Former=false;
  bool Latter=false;
  string S;
  cin >> S;
  if(S[0]=='0'&&S[1]!='0') Former=true;
  else if(S[0]=='1'&&S[1]=='1') Former=true;
  else if(S[0]=='1'&&S[1]=='2') Former=true;
  
  if(S[2]=='0'&&S[3]!='0') Latter=true;
  else if(S[2]=='1'&&S[3]=='1') Latter=true;
  else if(S[2]=='1'&&S[3]=='2') Latter=true;
  
  if(Former==true&&Latter==true) cout << "AMBIGUOUS" << endl;
  else if(Former==true) cout << "MMYY" << endl;
  else if(Latter==true) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main() {
	int H, A;
	cin >> H >> A;

	int ans = H / A;

	if (H % A != 0 || H / A == 0) {
		ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 380
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<bitset>
#include<stack>
#include<cctype>
#define sc(x) scanf("%d",&x);
#define pr(x) cout<<#x<<": "<<x<<" ";
#define prln(x) cout<<#x<<": "<<x<<endl;
#define bug() cout<<"bug: "<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps = 1e-4;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e3+7;
const int maxm = 1e6+7;
const double pi = acos(-1.0);

int main(){
	int a[maxn];
	memset(a,0,sizeof a);
	int l,r; cin>>l>>r;
	for(int i=l; i<=r; i++)
		a[i]++;
	cin>>l>>r;
	for(int i=l; i<=r; i++)
		a[i]++;
	int cnt=0;
	for(int i=0; i<=100; i++){
		if(a[i]==2)
			cnt++;
	//	pr(i) prln(a[i])
	}
	if(cnt!=0)
		cnt--;
	cout<<cnt<<endl;
}

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

ans = 1
l = 0;
flag = 0

for i in range(N):
    if A[i]== 0:
        print(0)
        exit(0)

    l+=(len(str(A[i])) -1)
    if l>18:
        flag=1
        continue
    
    ans*=A[i]
    if ans > 1000000000000000000:
        flag = 1

if flag == 0:
    print(ans)
else :
    print(-1)

Measured memory_bytes: 21528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

map<int,int> m;
vector<pair<int,int>> v;

int main() {
  int N,K;
  scanf("%d%d", &N,&K);
  int a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }

  FOR(i,0,N-1){
    ++m[a[i]];
  }
  FOR(i,1,N){
    if(m[i]!=0) v.PB(MP(m[i],i));
  }
  // cout << v[0].first << endl;
  sort(ALL(v),greater<pair<int,int>>());
  // cout << v[0].first << endl;

  if(SZ(v)<=K) cout << 0 << endl;

  else{

  int ans = 0;
  int count = SZ(v)-K;
  int ref = 0;
  while(count>0){
    ans += v[K+ref].first;
    --count;
    ++ref;
  }

  // cout << v[0].first << endl;
  // cout << v[0].second << endl;

  cout << ans << endl;

  }
  


}



Measured memory_bytes: 12536
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

void coutv(vector<ll> v)
{
	for (auto it : v)
		cout << it << " ";
	cout << "\n";
}

ll LCM(ll a, ll b)
{
	return (a * b) / __gcd(a, b);
}

bool is_prime(ll n)
{
	for (int i = 2; i <= n / i; i++)
		if (n % i == 0)
			return false;
	return true;
}
ll count_substring_in_string(string str, string substr)
{
	ll cnt = 0;
	ll pos = 0;
	while ((pos = str.find(substr, pos)) != string::npos)
	{
		cnt++;
		pos += substr.size();
	}
	return cnt;
}
int main()
{
	ll a;
	cin >> a;
	cout << (a) + (a * a) + (a * a * a) << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <time.h> 
#include <algorithm>
#include <string>

using namespace std;



int main(void){
    int n, i=0;
while(1){
    i++;
    cin >> n;
    if (n==0) break;
    else cout << "Case" << " " << i << ":" << " " << n << endl;
}
    return 0;
}

Measured memory_bytes: 2992
/* ex 9_1
   KitamoriFumiya */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 11
// stack型(格納最大数、データ数、データ配列、topへのポインタ)を定義
typedef struct stack{
	int size;
	int count;
	char data[SIZE];
	char *top;
} stack;

void initialize_stack(stack *stk);
void print_stack(stack *stk);
void push(stack *stk, char letter);
char pop(stack *stk);

// 文字列を格納するスタックを用意
stack stk;

int main(void){
	char input[11], *ptr_input; // キーボードでの入力を格納するための配列とポインタ
	initialize_stack(&stk); // スタックを初期化
	scanf("%s", input); // 文字列の入力
	ptr_input = input;
	while(*ptr_input){
		// 文字がBであり、その前の文字があればそれを消す
		if(*ptr_input == 'B'){
			if(stk.count>0){
				pop(&stk);
			}
		}else{
			push(&stk, *ptr_input);
		}
		++ptr_input;
	}
	// 出力
	print_stack(&stk);
}

// スタックの初期化
void initialize_stack(stack *stk){
	stk->count = 0;
	stk->size = SIZE;
	stk->top = &(stk->data[SIZE]);
}

// データを追加する
void push(stack *stk, char leter){
	if(stk->count >= stk->size){
		printf("Error: stack overflow. (leter=%c)\n", leter);
		exit(1);
	}else{
		stk->top--;
		*(stk->top) = leter;
		stk->count++;
	}
}

// データを取り出す
char pop(stack *stk){
	char now;
	if(stk->count <= 0){
		printf("Error: stack underflow.\n");
		exit(1);
	}else{
		now = *(stk->top);
		stk->top++;
		stk->count--;
		return now;
	}
}

// スタックの中身を逆順に取り出す
void print_stack(stack *stk){
	char output[11], *ptr_output;
	int i;
	ptr_output = stk->top;
	for(i = stk->count; i > 0; i--){
		output[i-1] = *ptr_output;
		ptr_output++;
	}
	printf("%s\n", output);
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;
typedef pair<ll, ll> pint;


void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int e = A / D;
    if (A % D != 0) e++;
    int l = C / B;
    if (C % B != 0) l++;
    if (e >= l) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3604