akhauriyash/Code-Regression huggingface dataset:
//01
#include<iostream>
#include<map>
#include<string>
#include<cstdio>
#include<cctype>

using namespace std;

map<string,int> m;
bool u;
int x;
char ms[81];

int at(){
  string a(1,ms[x++]);
  while(islower(ms[x])){
    a+=ms[x++];
  }
  if(!m.count(a)){
    u=true;
  }
  return m[a];
}

int rn(){
  int nu,nr;
  sscanf(ms+x,"%d%n",&nu,&nr);
  x+=nr;
  return nu;
}

int mol(){
  if(ms[x]=='('){
    x++;
    int r=mol();
    x++;
    r*=rn();
    return r+mol();
  }else if(isalpha(ms[x])){
    int r=at();
    if(isdigit(ms[x])){
      r*=rn();
    }
    return r+mol();
  }else{
    return 0;
  }
}

int main(){
  for(string s;cin>>s,s!="END_OF_FIRST_PART";){
    int n;
    cin>>n;
    m[s]=n;
  }
  while(cin>>ms,ms[0]!='0'){
    u=false;
    x=0;
    int r=mol();
    if(u){
      cout<<"UNKNOWN"<<endl;
    }else{
      cout<<r<<endl;
    }
  }
  return 0;
}
  

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

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

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

    for(int i = 0; i < n; i++){
        if(a[i]%2==1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i=0; i<N; i++) {
    cin >> x[i];
  }
  int ans = 1010101010;
  int term;
  for (int i=0; i<N-K+1; i++) {
    if (x[i] >= 0) {
      ans = min(ans,x[i+K-1]);
      continue;
    }
    if (x[i+K-1] <= 0) {
      ans = min(ans,abs(x[i]));
      continue;
    }
    term = min(x[i+K-1]*2 - x[i],x[i+K-1] - x[i]*2);
    ans = min(ans,term);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
s = input()

children = ""
count = 0
R_count = -1
reset_flag = True
for i, c in enumerate(s):
    if (c == 'R' and reset_flag == False) or i == len(s)-1:
        if i == len(s)-1:
            if R_count == -1:
                R_count = count
            count += 1
        L_count = count - R_count
        for j in range(count):
            if j < R_count - 1 or R_count < j:
                children += "0 "
            elif count % 2 == 0 and j == R_count-1:
                children += str(int(count/2)) + " "
            elif count % 2 == 0 and j == R_count:
                children += str(int(count/2)) + " "
            elif R_count > L_count:
                if R_count%2 == 0 and j == R_count-1:
                    children += str(int((count-1)/2)) + " "
                elif R_count%2 == 0 and j == R_count:
                    children += str(int((count-1)/2 + 1)) + " "
                elif R_count%2 == 1 and j == R_count-1:
                    children += str(int((count-1)/2 + 1)) + " "
                elif R_count%2 == 1 and j == R_count:
                    children += str(int((count-1)/2)) + " "
            elif L_count > R_count:
                if L_count%2 == 0 and j == R_count-1:
                    children += str(int((count-1)/2 + 1)) + " "
                elif L_count%2 == 0 and j == R_count:
                    children += str(int((count-1)/2)) + " "
                elif L_count%2 == 1 and j == R_count-1:
                    children += str(int((count-1)/2)) + " "
                elif L_count%2 == 1 and j == R_count:
                    children += str(int((count-1)/2 + 1)) + " "
        reset_flag = True
        count = 1
        R_count = -1
    elif c == 'R' and reset_flag == True:
        count += 1
    elif c == 'L' and reset_flag == True:
        reset_flag = False
        R_count = count # in R
        count += 1
    elif c == 'L' and reset_flag == False:
        count += 1
    
print(children)
    
    

Measured memory_bytes: 3956
unit = ("", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", \
        "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts")

while True:
    m, n = map(int, input().split())
    if m == 0 and n == 0: break
    val = m**n
    res = ""
    for u in unit :
        val, m = divmod( val, 10000 )
        if m :
            res = str(m) + u + res
    print( res )



Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
//		int w = Integer.parseInt(sa[1]);
		int n = Integer.parseInt(sa[2]);
		TreeMap<Integer, TreeSet<Integer>> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]);
			int y = Integer.parseInt(sa[1]);
			TreeSet<Integer> set = map.get(x);
			if (set == null) {
				set = new TreeSet<>();
				map.put(x, set);
			}
			set.add(y);
		}
		br.close();

		int x = 1;
		int y = 1;
		for (int k : map.keySet()) {
			TreeSet<Integer> set = map.get(k);
			y += k - x - 1;
			if (set.floor(y) != null) {
				System.out.println(k - 1);
				return;
			}
			if (!set.contains(y + 1)) {
				y++;
			}
			x = k;
		}
		System.out.println(h);
	}
}


Measured memory_bytes: 101828
n,k = map(int,input().split())
s = input()
k -= 1
ans = ''
for i in range(n):
    if i == k:
      if s[k] == 'A': ans += 'a'
      elif s[k] == 'B': ans += 'b'
      else: ans += 'c'
    else: ans += s[i]
print(ans)

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int H, W, h, w;

int t[510][510];

long long res;

int main()
{
	gii(H, W), gii(h, w);
	for (int i = 1; i <= H; ++i)
		for (int j = 1; j <= W; ++j)
			t[i][j] = 2000;
	for (int i = h; i <= H; i += h)
		for (int j = w; j <= W; j += w)
			t[i][j] = -((h * w - 1) * 2000 + 1);
	for (int i = 1; i <= H; ++i)
		for (int j = 1; j <= W; ++j)
			res += t[i][j];
	if (res <= 0)
	{
		puts("No");
	}
	else
	{
		puts("Yes");
		for (int i = 1; i <= H; ++i)
			for (int j = 1; j <= W; ++j)
				printf("%d%c", t[i][j], " \n"[j == W]);
	}
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	while(n--) {
		cin >> t >> x >> y;
		if(x + y > t || t - x - y & 1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

void finalize(string s){
    for(int i = 0;i < s.length();++i){
       if(s[i] == '?')
           s[i] = 'a';
    }
    cout << s << endl;
}

void finalize(string s,string c,int bias,int length){
    for(int i = 0;i < length;++i){
        s[i+bias] = c[i];
    }
    for(int i = 0;i < s.length();++i){
       if(s[i] == '?')
           s[i] = 'a';
    }
    cout << s << endl;
}

int main(){
    string x;
    string c;
    cin >> x;
    cin >> c;
   // cout << c << endl;
    for(int i = x.length()-1;i >= 0;--i){
        for(int j = c.length() -1; j >= 0;--j){
            if(j == 0 && (c[j] == x[i])){
                finalize(x);
                return 0;
            }
            if(c[j] != x[i+j])
                break;  
        }
    }
    
    for(int i = x.length()- c.length();i >= 0;--i){
        for(int j = c.length() -1; j >= 0;--j){
            //cout << j << " " << i+j << endl;
            if(j == 0 && (c[0] == x[i] || x[i]=='?')){
                finalize(x,c,i,c.length());
                return 0;
            }
            if(c[j] != x[i+j] && x[i+j] != '?')
                break;  
        }
    }
    
    cout << "UNRESTORABLE" << endl;
}

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

int main() {
    int n;
    int a[128];

    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if ((i & 1) && (a[i] & 1)) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
#define ll long long

using namespace std;


#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

const ll inf =1000000007;
typedef pair<ll,ll> Pair;


typedef vector<ll> vl;

void csolve(){
    long double a,b;
    cin >> a >>b;
    ll ans=floorl(a*b);
    kaku(ans);

}

void bsolve(){
    ll n;
    cin >> n;

    ll t=1000000000000000000;
    ll ans=1;
    bool u=false;//t超えた？
    bool ok=true;//０が出たか
    rep(i,n){
        ll a;
        cin >>a;

        if(ans!=0){
            if(t/ans < a) u=true;
        }

        ans*=a;

        if(a==0) ok=false;
    }
    if(u && ok) ans=-1;
    kaku(ans);
}

void asolve(){
    ll a,b;
    cin >> a >>b;
    kaku(a*b);
}

map< ll, ll > prime_factor(ll n) {
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void dsolve(){
    ll n;
    cin >> n;
    map<ll,ll> mp=prime_factor(n);
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){

        for(ll i=1;i<=60;i++){
            if(itr->second >=i){
                mp[itr->first]-=i;
                ans++;
            }
            else{
                break;
            }
        }

    }
    kaku(ans);
}

int main(){
    csolve();
}

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

typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<ll> h(n);
	for(int i=0 ; i < n ; i++ ){
		cin >> h[i];
	}
	sort(h.rbegin(), h.rend());
	ll ans = 0;
	for(int i=0 ; i < 4 ; i++ ){
		if( h.size() <= i ) break;
		ans += h[i];
	}
	for(int i=4 ; i < h.size() ; i++ ){
		ans += max( 0ll , h[i] - (i/4));
		if( h[0] < i/4 && 0 < h[i] + (- i / 4) ){
			ans++;
		}
		if( h[1] < i/4 && 0 < h[i] + (- i / 4) ){
			ans++;
		}
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 1204
n = int(input())
stairs = [int(i) for i in input().split()]
stairs[0] -= 1

res = True
if n == 1:
    print('Yes')
else:
    for i in range(1,n):
        if stairs[i] - stairs[i-1] > 0:
            stairs[i] -= 1
        elif stairs[i] - stairs[i-1] < 0:
            res = False
            break
    if res:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14396
import std.stdio,
       std.string,
       std.conv,
       std.math,
       std.algorithm;

void main() {
  int N = readln.chomp.to!(int);
  long[] a = readln.chomp.split.to!(long[]);
  sort(a);

  long n = a[a.length - 1];
  long r, diff = long.max;

  foreach (long e; a[0..(a.length - 1)]) {
    if (diff > abs(n - e * 2)) {
      diff = abs(n - e * 2);
      r = e;
    }
  }

  writeln(n, " ", r);
}


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

int main(){
  int a, b, c;
  cin>>a>>b>>c;
  long long int val1 = c - a - b;
  if(val1 > 0)val1 *= val1;
  
  long long int val2 = a*4LL*b;
  
  if(val1 > val2) cout<<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a, b;
int main() {
    cin >> a >> b;
    int ans = 0;
    ans = max(ans, a + a - 1);
    ans = max(ans, a + b);
    ans = max(ans, b + b - 1);
    cout << ans;
}

Measured memory_bytes: 256
using System;

namespace CF2016qA
{
    class C
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            char[] res = new char[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                int x = 26 - (s[i] - 'a');
                if (x <= K) { res[i] = 'a'; K -= x % 26; }
                else { res[i] = s[i]; }
            }

            if (0 < K)
            {
                res[s.Length - 1] = (char)(res[s.Length - 1] + K % 26);
            }

            Console.WriteLine(res);
        }
    }
}


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

using namespace std;

int main(){
   int a,b;
   scanf("%2d%2d",&a,&b);
   if((a>12 || a==0 )&& b>0 && b<=12)cout <<"YYMM";
   else if(a>0&&a<=12&&(b>12 ||b==0))cout <<"MMYY";
   else if(a>0&&b<=12&&a<=12&&b>0)cout<<"AMBIGUOUS";
   else if(a>12&&b>12 || a==0&&b==0)cout<<"NA";
   else cout <<"NA";
}

Measured memory_bytes: 256
#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; }

const long long INF = 1LL << 60;
long long dp[100100];

int main() {
    int A, B, K; cin >> A >> B >> K;

    int ans = 1;
    int cnt = 0;
    for(int i = min(A, B); i > 0; i--) {
        if(A % i == 0 && B % i == 0) cnt++;
        if(cnt == K) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const ll INF = 1 << 30;
ll ch[32][32], sum[3][32];

int main() {
	ll n, c; cin >> n >> c;
	for (ll i = 0; i < c; i++) {
		for (ll j = 0, now; j < c; j++) {
			cin >> now;
			ch[i][j] = now;
		}
	}
	for (ll i = 0; i < n; i++) {
		for (ll j = 0, now; j < n; j++) {
			cin >> now; now--;
			ll now1 = (i + j) % 3;
			sum[now1][now]++;
		}
	}

	ll ans = INF;
	for (ll i = 0; i < c; i++) {
		for (ll j = 0; j < c; j++) {
			for (ll k = 0; k < c; k++) {
				ll sum1 = 0;
				if (i == j || j == k || k == i) continue;
				for (ll l = 0; l < 3; l++) {
					for (ll m = 0; m <= c; m++) {
						if (l == 0) sum1 += sum[l][m] * ch[m][i];
						else if (l == 1) sum1 += sum[l][m] * ch[m][j];
						else sum1 += sum[l][m] * ch[m][k];
					}
				}
				ans = min(ans, sum1);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

using Graph = vector<vector<int>>;
Graph g;
int N, M;

bool rec(int v, int p, int depth) {
    if (depth == 2 && v == N-1) return true;
    if (depth > 2) return false;

    bool res = false;
    for (auto e : g[v]) {
        if (e == p) continue;
        if (rec(e, v, depth+1)) res = true;
    }
    
    return res;
}

void solve() {
    cin >> N >> M;
    g.resize(N);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    cout << (rec(0, -1, 0) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 14908
N = int(input())
AC = []
WA = []
TLE = []
RE = []

while N >= 1:
    Sn = input()
    if Sn == 'AC':
        AC.append(1)
    if Sn == 'WA':
        WA.append(1)
    if Sn == 'TLE':
        TLE.append(1)
    if Sn == 'RE':
        RE.append(1)
    N = N - 1
    
print('AC x ' + str(sum(AC)))
print('WA x ' + str(sum(WA)))
print('TLE x ' + str(sum(TLE)))
print('RE x ' + str(sum(RE)))

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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		Arrays.setAll(a, i -> sc.nextInt());

		int max = a[0] + k - a[n - 1];
		for (int i = 1; i < n; i++) {
			max = Math.max(max, a[i] - a[i - 1]);
		}
		int ans = k - max;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 87976
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

#define INF (1e+9)
struct range {
    int start;
    int end;
};

#define ROOT_NODE 1
#define BIG_INF (1e+15)

bool is_overlap(struct range r1, struct range r2) {
    return r1.end > r2.start && r2.end > r1.start;
}

bool is_contain(struct range r, struct range box) {
    return box.start <= r.start && r.end <= box.end;
}

int get_min(vector<int>& seg, struct range r, int node, struct range nr) {
    if(!is_overlap(r, nr)) return INF;
    if(is_contain(nr, r)) return seg[node];
    struct range left = {nr.start, (nr.start + nr.end)/2};
    struct range right = {(nr.start + nr.end) / 2, nr.end};
    int m1 = get_min(seg, r, node*2, left);
    int m2 = get_min(seg, r, node*2+1, right);
    return min(m1, m2);
}

int main(void) {
    int num;
    int64_t magic;
    cin >> num >> magic;
    vector<int> arr(num);
    cins(arr);
    int size = num * 2;
    int size2 = 1;
    while(size > size2) size2 *= 2;
    vector<int> seg(size2*2, INF+1);
    for(int i = 0; i < size; i++) {
        seg[size2+i] = arr[i%num];
    }
    for(int i = size2-1; i >= 0; i--) {
        seg[i] = min(seg[i*2], seg[i*2+1]);
    }

    int64_t ans = BIG_INF;
    struct range whole = {0, size2};
    for(int k = 0; k <= num-1; k++) {
        int64_t res = 0;
        // pick up slime
        for(int slime = num-1; slime >= 0; slime--) {
            int idx = slime + num;
            struct range r = {idx-k, idx+1};
            int change = get_min(seg, r, ROOT_NODE, whole);
            res += change;
            debug("%d -> %d\n", slime, res);
        }
        debug("k: %d -> %lld+%lld\n", k, res, magic*k);
        res += magic * k;
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e6+5;
const ll MOD = 1e6+3;

void solve(int n, double lx, double ly, double rx, double ry)
{
    if (!n)
    {
        printf("%.8f %.8f\n", rx, ry);
        return;
    }
    double tx = (rx - lx)/3.0, ty = (ry - ly)/3.0;
    double mx = lx+tx + tx * cos(PI/3) - ty * sin(PI/3);
    double my = ly+ty + tx * sin(PI/3) + ty * cos(PI/3);
    solve(n-1, lx, ly, lx+tx, ly+ty);
    solve(n-1, lx+tx, ly+ty, mx, my);
    solve(n-1, mx, my, rx-tx, ry-ty);
    solve(n-1, rx-tx, ry-ty, rx, ry);
}

int main()
{
    int n;
    cin >> n;
    printf("%.8f %.8f\n", 0, 0);
    solve(n, 0, 0, 100, 0);

    return 0;
}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s;
  cin >> s;
  unordered_set<char> used;
  for (char &c : s) used.insert(c);

  for (int i = 0; i < 26; i++) {
    char c = i + 97;
    if (used.find(c) == used.end()) {
      cout << c << '\n';
      return 0;
    }
  }
  cout << "None" << '\n';
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define oo 1e18
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed
#define sqr(x) ((x)*(x))
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
 
const ld pi=acos(-1);

ll n,l,r,x,y,i;

int main() {
    IO;
    cin>>n;
    cin>>l>>r;
    for (i=2;i<=n;i++) {
        cin>>x>>y;
        l=x*max((l+x-1)/x,(r+y-1)/y);
        r=y*max((l+x-1)/x,(r+y-1)/y);
    }
    cout<<l+r<<'\n';
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

int main(void) {

  int count;
  char str[120];

  char* p;
  int flag;

  int i;


  count=0;

  while(fgets(str,sizeof(str),stdin)!=NULL) {

    /*
    p=strrchr(str,'\n');

    strcpy(p,"");
    */

    str[strlen(str)-1]='\0';

    flag=1;

    for(i=0;i<strlen(str)/2;i++) {

      if(str[i]!=str[strlen(str)-i-1]) flag=0;

    }

    if(flag==1) {
      count++;
      //printf("OK\n");
    }

  }

  printf("%d\n",count);

  return 0;

}

    

Measured memory_bytes: 0
import numpy as np

N, K = map(int, input().split())
As_lis = list(map(int, input().split()))

As_arr = np.array(As_lis)
S = np.sum(As_arr)

smaller_factors = []
larger_factors = []
for i in range(1, int(S ** 0.5) + 1):
    if S % i == 0:
        smaller_factors.append(i)
        larger_factors.append(S // i)

for fac in larger_factors:
    mods = As_arr % fac
    k = np.sum(np.sort(mods)[:N - np.sum(mods) // fac])
    if k <= K:
        print(fac)
        exit()

for fac in reversed(smaller_factors):
    mods = As_arr % fac
    k = np.sum(np.sort(mods)[:N - np.sum(mods) // fac])
    if k <= K:
        print(fac)
        exit()



Measured memory_bytes: 27276
#!/usr/bin/env python

def f(n: str) -> str:
    """
    >>> f("1")
    'No'
    >>> f("8")
    'No'
    >>> f("9")
    'Yes'
    >>> f("123456789")
    'Yes'
    >>> f("0")
    'Yes'
    >>> f("31415926535897932384626433832795028841971693993751058209749445923078164062862089986280")
    'No'
    """
    n_sum = 0
    for index in range(0, len(n)):
        n_sum += int(n[index])
    return 'Yes' if n_sum % 9 == 0 else 'No'


if __name__ == '__main__':
    n = input()
    print(f(n))

Measured memory_bytes: 9284
#[allow(dead_code)]

pub struct Scanner {
    idx: usize, 
    buf: Vec<String>,
}

impl Scanner {
    pub fn new<T: std::io::Read>(inf: &mut T) -> Scanner {
        Self {
            idx:0,
            buf: {
                let mut s = String::new();
                inf.read_to_string(&mut s).expect("I/O error");
                s.split_whitespace().map(|x| x.to_owned()).collect()
            },
        }
    }

    pub fn read<T: std::str::FromStr> (&mut self) -> T 
    where
        <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        if self.empty() {
            panic!("reached the end of input")
        }
        let ret = self.buf[self.idx].parse::<T>().expect("parse error");
        self.idx += 1;
        return ret;
    }

    pub fn empty(&self) -> bool {
        return self.idx >= self.buf.len();
    }
}

fn main() {
    let mut sc = Scanner::new(&mut std::io::stdin());
    let n: usize = sc.read();
    let k: usize = sc.read();

    let mut ans = 0.0;

    for mut i in 1..=n {
        if i >= k {
            ans += 1.0 / n as f64;
        }
        else {
            let mut c = 1.0 / n as f64;
            while i < k {
                i *= 2;
                c /= 2.0;
            }
            ans += c;
        }
    }

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


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

string s;
int a[100005], n;

vector<P> ans;

int main() {
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '0') {
			a[i] = 0;
		}
		else a[i] = 1;
	}
	n = s.size();
	if (a[0] == 0 || a[n - 2] == 0 || a[n - 1] == 1) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < n / 2; i++) {
		if (a[i] != a[n - 2 - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	int now = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == 1) {
			ans.push_back({ now, i + 1});
			now = i + 1;
		}
		else {
			ans.push_back({ now, i + 1});
		}
	}
	rep(i, ans.size()) {
		cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
	}
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define FILENAME ""
#define __ fflush(stdout)

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef COMP
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		freopen(FILENAME".in", "r", stdin);
		freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2, MOD = 1e9 + 7;

char CH[N];

const ll INF = 1e18;

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

ll calc(int k, int n) {
	ll ret = 1ll;
	int j = 2;
	for (int i = k + 1; i <= n; i++) {
		ret = ret * 1ll * i;
		if (j <= n - k) {
			if (ret % j == 0) ret /= j, j++;
		}
	}	
	return ret;
}

int main() {

	#ifndef ONLINE_JUDGE
	//	FREOPEN();
	#endif	
	int n, p;
	cin >> n >> p;
	int one = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (x & 1) one++;
	}
	ll ans = 0;
	ll every = (1ll << (n - one));
	for (int i = p; i <= one; i += 2) {
		ans += every * 1ll * calc(i, one);			
	}    
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(NULL);    cout.tie(NULL);

    int a, b,k; cin>>k>>a>>b;

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

    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        int tot = (1<<(n+1)) - 2;
        int min = (1<<(n/2))*((1<<(n/2)) - 1);
        cout<<tot - 2*min<<"\n";

    }

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


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

long long f(long long a, long long b, long long x){
  return ((a * x) / b) - a * (x / b);
}

int main(){
  long long a, b, n;
  cin >> a >> b >> n;

  // long long right = n;
  // long long left = 0;

  // while(right - left > 1){
  //   long long mid = (right + left) / 2;

  //   if(f(a, b, mid) < f(a, b, right)) left = mid;
  //   else right = mid;
  // }

  // cout << f(a, b, right) << endl;

  // cout << 1000000 * 10000000000000 << endl;

  if (n < b){
    cout << f(a, b, n) << endl;
  }else{
    cout << f(a, b, b-1) << endl;
  }
  // for (int i=0; i<=n; i++){
  //   cout << i  << " " << f(a, b, i) << endl;
  // }
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String sd = sc.next().replaceAll("\\?", ".");
		String t = sc.next();
		if (sd.length() < t.length()) {
			System.out.println("UNRESTORABLE");
			sc.close();
			return;
		}
		for (int i = sd.length() - t.length(); i >= 0; i--) {
			String x = sd.substring(i, i + t.length());
			if (t.matches(x)) {
				System.out.println(sd.replaceFirst(
						sd.substring(0, i) + x, sd.substring(0, i) + t)
						.replaceAll("\\.", "a"));
				sc.close();
				return;
			}
		}
		System.out.println("UNRESTORABLE");
		sc.close();
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int A[310][310];
int B[310];
int C[310][310]; //i in the row j is located at k
int D[310];

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		rep(j, 0, M) {
			cin >> A[i][j]; A[i][j]--;
			C[A[i][j]][i] = j;
		}
	}
	int res = inf;
	rep(q, 0, M) {
		// rep(i, 0, N) {
		// 	rep(j, 0, M) {
		// 		cout << A[i][j] << " ";
		// 	}
		// 	cout << "\n";
		// }
		memset(D, 0, sizeof(D));
		rep(i, 0, N) {
			if(B[i] == M) continue;
			D[A[i][B[i]]]++;
		}
		int mv = -1, cnt = -1;
		rep(i, 0, M) {
			if(cnt < D[i]) {
				mv = i;
				cnt = D[i];
			}
		}
		MIN(res, cnt);
		rep(i, 0, N) {
			A[i][C[mv][i]] = -1;
		}
		rep(i, 0, N) {
			while(B[i] < M && A[i][B[i]] == -1) B[i]++;
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
map<string,long>mp;
int main()
{
    long i,j,t,a,b,n,c,temp;
    t=1;
    // cin>>t;
    while(t--)
    {
       string s,sp="",sn="";
       cin>>n;
       cin>>s;
       c=0;
       for(i=0;i<n;i++)
       {
           if(s[i]=='(')
           c++;
           else c--;
           if(c<0)
           {
               sp+='(';
               c=0;
           }
       }
       s=sp+s;
       c=0;
       for(i=0;i<s.length();i++)
       {
           if(s[i]=='(')
           c++;
           else c--;
           if(c<0)
           {
               sn+=')';
               c=0;
           }
       }
        cout<<s<<sn<<string(c,')');
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {
	static int[][] numbers;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String S = in.next();
        int max = 0;
         for(int i =0; i< 3; i++)  {
          int prev = S.charAt(i);
          if(prev=='R'){
        	  int to =1;
              for(int j =i+1; j<3; j++)  {
                 if(prev!=S.charAt(j)) break;
                to++;
              }
              max = Math.max(max, to); 
          }
        	       			 		
         }
         System.out.println(max);     
	}
	
	
}

Measured memory_bytes: 35548
#include<bits/stdc++.h>
using namespace  std;
#define ll long long
#define vll vector<long long>
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define nitro   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    nitro;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c=c-b;
        if(c<=0){cout<<"Yes";return 0;}
        a=a-d;
        if(a<=0){cout<<"No";return 0;}
    }


}


Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#define F(i,a,n) for(int i = (a); i < (n); ++i)
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int count = pow(2,M);
  cout << count *(1900 * M + 100 * (N-M)) << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n, k; cin >> n >> k;
  int ans = 1;
  int next = 2;
  int sum = 0;
  while(next - ans < k && sum < n){
    ans = next;
    next *= 2;
    sum++;
  }
  cout << (n - sum) * k + ans << endl;

  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

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

Measured memory_bytes: 3624
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005


#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first
 
int fpow(int x,int y,int m) {
     int temp;
     if( y == 0 || x == 1)
          return 1;
     temp = fpow(x, y/2,m);
     if (y % 2 == 0)
          return ((temp)*(temp)) % m;
     else
          return (((x) % m)*((temp*temp) % m)) % m;
}
int gcd(int a,int b)
{
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17;
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;
vi a(2*LIM);
//*************************************************************************************************************************


int32_t main()
{     fio;
      cin>>n;
      sum=0;
      forr(i,n){
            cin>>x;
            a[x]++;
            sum+=x;
      }
      int q;
      cin>>q;
      while(q--)
      {
            cin>>x>>y;
            a[y]+=a[x];
            sum+=(y-x)*a[x];
            a[x]=0;
            cout<<sum;nl;
      }
}


Measured memory_bytes: 4692
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskT solver = new TaskT();
        solver.solve(1, in, out);
        out.close();
    }
    
    

    static class TaskT {
    	static int counter = 0;
        public void solve(int testNumber, InputReader in, PrintWriter out) {

        	int N = in.nextInt();
        	int cnt = 0; 
        	String ans = "";
        	for(int i = 0; i < N; i++){
        		int Di1 = in.nextInt();
        		int Di2 = in.nextInt();
        		
        		if(Di1 == Di2){
        			cnt ++;
        			if(cnt == 3)
        				ans = "Yes";
        				
        		}
        		else
        			cnt = 0;
        	}
        	
        	out.print(ans.length() == 0? "No": ans);
        }
        
     
        
        

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}



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


#define N 1000000
#define M 1000000007


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while(b) {
        long long t = a / b;
        //cout << t << endl;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) {
        u += m;
    }

    return u;
}

int main() {
    int x, y;
    cin >> x >> y;

    if((x+y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int p, q;
    p = (2*y-x)/3;
    q = (2*x-y)/3;
    if((p < 0 || q < 0)) {
        cout << 0 << endl;
        return 0;
    }

    int pq = p+q;

    long long npr = 1;
    for(int i = pq; i >= pq-q+1; i--) {
        npr = npr * i % M;
    }
    long long factr = 1;
    for(int i = q; i >= 2; i--) {
        factr = factr * i % M;
    }
    cout << npr * modinv(factr, M) % M << endl;

    return 0;


}

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

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

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

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

int n, c;

int main() {
    while (cin >> n) {
        if (n == 0) break;
        int res = 0;
        for (int i = 0; i < n*(n-1)/2; ++i) {
            cin >> c; res += c;
        }
        cout << res/(n-1) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main()
{

string x;
cin>>x;
int count=0,small=0;


for(int i=2;i<x.length()-1;i++){
if(x[i]=='C'){count++;}
}
for(int i=0;i<x.length();i++){

    if(x[i]>96&&x[i]<123){small++;}
}
if(x[0]=='A'&&(small==x.length()-2)&&count==1){cout<<"AC"<<endl;}


else{cout<<"WA"<<endl;}

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(){
    int m,f,r;
    while(true){
        cin >> m >> f>> r;
        if(m==-1 and f==-1 and r==-1){
            break;
        }
        else{
            if(m==-1 or f==-1){
                cout << 'F' << endl;
            }
            else{
                if(m+f>=80){
                cout << 'A' << endl;
            }
            if(m+f<80 and m+f >= 65){
                cout << 'B' << endl;
            }
            if(m+f<65 and m+f >= 50){
                cout << 'C' << endl;
            }
            if(m+f<50 and m+f >= 30){
                if(r>=50){
                    cout << 'C' << endl;
                }
                else{
                    cout << 'D' << endl;
                }
            }
            if(m+f<30){
                cout << 'F' << endl;
                }
            }
        }
    }
    return 0;
}


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

int main()
{
    int n,days,rem;
    cin>>n>>days>>rem;
    int a[n];
    int i,sum=0;
    for( i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        for(int j=1;j<=days;j+=a[i-1])
        {
            sum++;
        }
    }
    cout<< sum+rem<<endl;

    return 0;

}


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

using namespace std;

int main()
{
	struct Elem
	{
		string city;
		int score;
		int index;
		Elem(int s = 0, int i = 0) :score(s) , index(i){};
	};
	int N;
	cin >> N;
	vector<Elem> vec(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> vec[i].city >> vec[i].score;
		vec[i].index = i + 1;
	}

	auto cmp = [](const Elem& a, const Elem& b) {
		return a.city < b.city || (a.city == b.city && a.score >= b.score);
	};
	sort(vec.begin(), vec.end(), cmp);

	for (int i = 0; i < N; ++i)
		cout << vec[i].index << endl;
	return 0;
}

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

int main() {
  long long n,sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      sum += 0;
    } else if (i % 3 == 0) {
      sum += 0;
    } else if (i % 5 == 0) {
      sum += 0;
    } else {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define reps(i,j,k) for(int i=(j); i<(k); i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define fr fs
#define sc second
#define pb push_back
#define mk make_pair
#define INF 1e9
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
int D[20][128][128];
int D2[128][128];
vi q[22];
vi r[22];
vi po[22];
int calcCost(int campany, int distance){
	rep(i,q[campany].size()){
		if(distance < q[campany][i]){
			return po[campany][i-1] + r[campany][i-1]*(distance-q[campany][i-1]);
		}
	}
	int t = po[campany].size()-1;
	if(distance >= INF)return INF;
	return po[campany][t] + r[campany][t]*(distance-q[campany][t]);
}

int main(){
	int N,M,C,S,G;
	while(cin >> N >> M >> C >> S >> G,N){
		--S;--G;
		
		rep(i,20)rep(j,128)rep(k,128){
			D[i][j][k] = INF*(j!=k);
		}
		rep(i,22){
			q[i].clear();
			r[i].clear();
			po[i].clear();
		}
		
		rep(i,M){
			int x,y,c,d;
			cin >> x >> y >> d >> c;
			--x;--y;--c;
			D[c][x][y] = D[c][y][x] = min(d,D[c][y][x]); 
		}
		vi p(C);
		rep(i,C){
			cin >> p[i];
		}

		rep(i,C){
			q[i].pb(0);
			rep(j,p[i]-1){
				int tmp;
				cin >> tmp;
				q[i].pb(tmp);
			}

			rep(j,p[i]){
				int tmp;
				cin >> tmp;
				r[i].pb(tmp);
			}
		}
		rep(i,C){
			po[i].pb(0);
			rep(j,p[i]-1){
				po[i].pb(po[i][j]+r[i][j]*(q[i][j+1]-q[i][j]));
			}
		}
		
		rep(t,C)rep(k,N)rep(i,N)rep(j,N){
			D[t][i][j] = min(D[t][i][j],D[t][i][k]+D[t][k][j]);
		}

		rep(i,N)rep(j,N){
			D2[i][j] = INF * (i != j);
		}
		rep(t,C)rep(i,N)rep(j,N){
			D2[i][j] = min(D2[i][j],calcCost(t,D[t][i][j]));
		}

		rep(k,N)rep(i,N)rep(j,N){
			D2[i][j] = min(D2[i][j],D2[i][k]+D2[k][j]);
		}
		if(D2[S][G] >= INF)cout << -1 << endl;
		else cout << D2[S][G] << endl;
	}
}

Measured memory_bytes: 4472