akhauriyash/Code-Regression huggingface dataset:
N,K,S = [int(hoge) for hoge in input().split()]
import math
#累積和数列であって、Ar-Al=Sを満たすものが丁度K個ある
if S==10**9:
    print(*([S]*K + [27]*(N-K)))

elif S:
    print(*([S]*K + [S+1]*(N-K)))
else:
    ans = []
    while 1:
        if K==2:
            ans +=[0,1,0]
            break            
        for R in range(N):
            if (R+1)*(R+2)//2 > K:break
        print(K)
        if K==0:break
        ans += [0]*R+[1]
        K = K - R*(R+1)//2 
        
    print(ans + [1]*(N-len(ans)))

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int x;
	cin >> x;
	cout << (x ^ 1) << endl;
	return 0;
}

//!

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

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

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(void)
{
    string c1,c2;
    cin >> c1 >> c2;
    if(c1[0] == c2[2] && c1[2] == c2[0] && c1[1] == c2[1]){cout << "YES" << endl;}
    else{cout << "NO" << endl;}
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int solve(int a, int b, int k, int borrow)
{
    if(a == 0 && b == 0)
        return 0;

    if(a % 10 - borrow >= b % 10)
        return solve(a/10, b/10, k, 0) * 10 + (a%10) - borrow - (b%10);

    int ret = solve(a/10, b/10, k, 1) * 10 + (a%10) - borrow + 10 - (b%10);
    if(k > 0)
        ret = max(ret, solve(a/10, b/10, k-1, 0) * 10 + (a%10) - borrow + 10 - (b%10));
    return ret;
}

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    cout << solve(a, b, k, 0) << endl;

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<deque>
#include<set>
#include<vector>
#include<map>
#define ll long long
#define itn int
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

const ll mod = 1e9+7;
int main()
{
    IOS
    int k;
    cin>>k;
    ll ans = 0;
    for(int a = 1;a<=k;a++)
    {
    	for(int b=1;b<=k;b++)
    	{
    		for(int c=1;c<=k;c++)
    		{
    			ans = ans + __gcd(__gcd(a,b),c);
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3660
def main6():
    str = input('');

    buf = str.split();
    num = [];
    result = 0;
    for i in range(2):
        num.insert(i,int(buf[i]));
    for i in range(num[1] - num[0] + 1):
        k = num[0] + i;
        k1 = int(k/10000)%10;
        k2 = int(k/1000)%10;
        k4 = int(k/10)%10;
        k5 = k%10;
        if k1 == k5 and k2 == k4:
            result = result + 1;
    print(result);



if __name__ == '__main__':
    #main4()
    #main5()
    main6()

Measured memory_bytes: 3064
import sys

def updiv(a,b):

    if a % b == 0:
        return a // b
    else:
        return a // b + 1

K = int(input())

A = list(map(int,input().split()))
A.reverse()

mini = 2
maxi = 2

for i in range(K):

    mini = updiv(mini, A[i]) * A[i]
    maxi = maxi // A[i] * A[i]

    if mini > maxi:
        print (-1)
        sys.exit()

    maxi += A[i]-1

print (mini,maxi)


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

using ll = long long;

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i=0, ai; i<m; i++) {
        cin >> ai;
        sum += ai;
    }
    cout << (sum <= n ? n - sum : -1) << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 2005
using namespace std;

typedef long long ll;
ll n, s, t, a[N];
ll f(ll p) {return p > 0 ? p : 0;}
int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			t = upper_bound(a, a + n, a[i] + a[j] - 1) - a;
			s += f(t - j - 1);
		}
	}
	cout << s;
    return 0;
}


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


int main(){
  std::string str;
  std::cin>>str;
  int size = str.size();
  int zero = 0 ,one = 0;
  for(int i = 0; i < size; i++){
    if(str[i] == '0'){
      zero ++;
    }
  }
  one = size - zero;
  std::cout<<2*std::min(zero,one)<<std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	char s[11];
	scanf("%s", s);
	int n=strlen(s), i;
	if(n%2==0){
		for(i=0; i<n; i++){
			if(i%2==0){
				if(s[i]!='h'){
					puts("No");
					return 0;
				}
			}else{
				if(s[i]!='i'){
					puts("No");
					return 0;
				}
			}
		}
		puts("Yes");
	}else{
		puts("No");
	}
}


Measured memory_bytes: 128
x1, y1, x2, y2 = gets.chomp.split.map(&:to_f)

a = y2 - y1
b = x2 - x1
a2 = a * a
b2 = b * b
p = y1 - a / b * x1

gets.to_i.times{
    x, y = gets.chomp.split.map(&:to_f)
    if a == 0
        puts "#{x} #{y1 + (y1 - y)}"
    elsif b == 0
        puts "#{x1 + (x1 - x)} #{y}"
    else
        q = y + b / a * x
        cx = a * b * (q - p) / (a2 + b2) 
        cy = (a2 * q + b2 * p) / (a2 + b2)
        puts "#{cx + (cx - x)} #{cy + (cy - y)}"
    end
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<ll> vec(10000 + 10);
vector<ll> ans;

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

    ll N;
    string S;
    cin >> N;

    

    REPS(i,vec.size()-1){
        vec.at(i) = vec.at(i - 1) + i;
    }

    while(N>=1){
        REP(i,vec.size())
        if (vec.at(i) >= N)
        {
            ans.push_back(i);
            N -= i;
            break;
        }
    }

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

    REP(i,ans.size()){
        cout << ans.at(i) << endl;
    }
}


Measured memory_bytes: 3824
#include <stdio.h>

int main() {
	int H, W;
	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int k = 0; k < W; k++) {
					if ((i == 0) || (i == H - 1)) {
						printf("#");
					}
					else {
						if ((k == 0) || (k == W - 1)) {
							printf("#");
						}
						else {
							printf(".");
						}
					}
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2124
from itertools import combinations_with_replacement
A, B, C = map(int, input().split())
K = int(input())
ans = 0
for comb in combinations_with_replacement([0, 1, 2], K):
  judge = [A, B, C]
  for i in comb:
    judge[i] *= 2
  # print(judge)
  if judge[2] > judge[1] and judge[1] > judge[0]:
    print('Yes')
    ans += 1
    break
if ans == 0:
  print('No')

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>

using namespace std;

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

	int Q = min({ A,B,C });
	int W = (A + B + C) - Q - max({ A,B,C });

	cout << Q * W / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			br.readLine();
			int[] A = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

			int count = 0;

			for (;; count++) {
				if (!can2Divs(A)) {
					break;
				}
			}

			System.out.println(count);
		}
	}

	private static boolean can2Divs(int[] a) {
		for (int i = 0; i < a.length; i++) {
			if (a[i] % 2 == 0) {
				a[i] = a[i] / 2;
			} else {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 26836
#include <cstdio>
using namespace std;

typedef long long llong;

const int N = 100500;

llong A[N];
llong B[N];

int main() {
    int n;
    scanf("%d", &n);
    llong s = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &A[i]);
        s += A[i];
    }
    llong step = 0;
    for (int i = 1; i <= n; i++)
        step += i;
    if (s % step != 0) {
        puts("NO");
        return 0;
    }
    llong k = s / step;
    llong tot = 0;
    for (int i = 0; i < n; i++) {
        B[i] = A[(i + 1) % n] - A[i];
        if ((k - B[i]) % n != 0) {
            puts("NO");
            return 0;
        }
        llong a = (k - B[i]) / n;
        if (a < 0 || a > k) {
            puts("NO");
            return 0;
        }
        tot += a;
    }
    if (tot != k) {
        puts("NO");
        return 0;
    }
    puts("YES");
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
   int a, b, c;
   cin >> a >> b >> c;
   if(a<=c && c<=b) out("Yes");
   else out("No");
}


Measured memory_bytes: 256
s = input()
a = s.count("R")
if a == 0:
    print("0")
if a == 1:
    print("1")
if a == 2 and (s[0] == s[1] or s[1] == s[2]):
    print("2")
elif a == 2 and (s[0] == s[2]):
    print("1")
if a == 3:
    print("3")

Measured memory_bytes: 61656
x,y=map(int,input().split())
s=[1,3,5,7,8,10,12]
t=[4,6,9,11]
u=[2]

if (x in s and y in s) or (x in t and y in t) or (x in u and y in u):
    print("Yes")
else:
    print("No")

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

int main(void) {
	char str1[201], str2[201];
	int flag;
	int i, j, count;

	while(1) {
		scanf("%s", str1);
		if(str1[0] == '.' && str1[1] == '\0') break;
		scanf("%s", str2);

		if(strcmp(str1, str2) == 0){
			printf("IDENTICAL\n");
			continue;
		}

		flag = -1;
		i = j = count = 0; 
		while(str1[i] != '\0' || str2[j] != '\0') {
			if(str1[i] != str2[j]) {
				if(flag == -1) {
					count = 2;
					break;
				} else{
					if(++count >= 2) break;
					flag = -1;
					while(str1[i] != '"') i++;
					while(str2[j] != '"') j++;
				}
			} else if(str1[i] == '"' && str2[j] == '"') {
				flag *= -1;
			}
			i++; j++;
		}

		if(count == 1){
			printf("CLOSE\n");
		} else{
			printf("DIFFERENT\n");
		}

	}
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int q, h, s, d;
    cin >> q >> h >> s >> d;
    int n; cin >> n;
    ll ans;
    int mn = min({q*4,h*2,s});
    if (2*mn < d) {
        ans = (ll)n*mn;
    } else {
        if (!(n&1)) ans = (ll)(n/2)*d;
        else ans = mn + (ll)(n/2)*d;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

int n, q, a[500005], rt[500005];
int L[500005 * 60], R[500005 * 60], sum[500005 * 60], tot = 0;
int la[2000005];
int build(int l, int r) {
    int pos = ++tot; 
    sum[pos] = L[pos] = R[pos] = 0;
    if (l < r) {
        int mid = (l + r) >> 1;
        L[pos] = build(l, mid);
        R[pos] = build(mid + 1, r);
    }
    return pos;
}
int update(int pre, int idx, int v, int l, int r) {
    int pos = ++tot;
    L[pos] = L[pre], R[pos] = R[pre]; 
    sum[pos] = sum[pre] + v;
    if (l < r) {
        int mid = (l + r) >> 1;
        if (idx <= mid) 
            L[pos] = update(L[pre], idx, v, l, mid);
        else 
            R[pos] = update(R[pre], idx, v, mid + 1, r);
    }
    return pos;
}
int query(int idx, int pre, int l, int r) {
    if (l == r) return sum[pre];
    int mid = (l + r) >> 1;
    if (idx <= mid) 
        return query(idx, L[pre], l, mid) + sum[R[pre]];
    else 
        return query(idx, R[pre], mid + 1, r);
}
void init(){
    n = read(), q = read();
    REP(i, 1, n)
        a[i] = read();
    memset(la, -1, sizeof(la));
    rt[0] = build(1, n);
    REP(i, 1, n){
        int v = a[i];
        if (la[v] == -1) {
            rt[i] = update(rt[i - 1], i, 1, 1, n);
        } else {
            int t = update(rt[i - 1], la[v], -1, 1, n);
            rt[i] = update(t, i, 1, 1, n);        
        }    
        la[v] = i;
    }
}
void solve(){
    while (q--) {
        int lb = read(), rb = read();
        printf("%d\n", query(lb, rt[rb], 1, n));
    }
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 261108
#!/usr/bin/python

import itertools
import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, M, R = map(lambda x: int(x), line.split(" ", 3))
        r  = map(lambda x: int(x) - 1, sys.stdin.readline().split(" "))
        weights = [[0 for i in xrange(N)] for j in xrange(N)]
        for i in xrange(M):
            a, b, c = map(lambda x: int(x), sys.stdin.readline().split(" ", 3))
            weights[a - 1][b - 1] = c
            weights[b - 1][a - 1] = c

        for k in xrange(N):
            for i in xrange(N):
                for j in xrange(N):
                    if j > i:
                        if weights[i][k] > 0 and weights[k][j] > 0:
                            length = weights[i][k] + weights[k][j]
                            if weights[i][j] == 0 or weights[i][j] > length:
                                weights[i][j] = length
                                weights[j][i] = length

        min_length = -1
        for p in itertools.permutations(r):
            length = 0
            previous = p[0]
            for i in p[1:]:
                length += weights[previous][i]
                previous = i
            if min_length == -1:
                min_length = length
            elif min_length > length:
                min_length = length
        print min_length

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 3420
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

const int MAX_N = int(1e5) + 10;
int N;
int A[MAX_N], B[MAX_N];
vector<int> C(MAX_N);

int main()
{
  cin >> N;
  REP(i,0,N) {
    cin >> A[i] >> B[i];
    C[i] = A[i] + B[i];
  }
  // 大きい順からソート
  sort(ALL(C), greater<int>());

  ll res = 0;
  REP(i,0,N) res -= B[i];
  REP(i,0,N) {
    // 高橋のみがポイントを得る (偶数回目; 0,2,4,..)
    // 実際は青木は食べていない
    if (i % 2 == 0) res += C[i];
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    long long int t,a,c=0;
    cin>>t;
    while(t--)
    {
        cin>>a;

            while(a%2==0)
            {
                c++;
                a=a/2;
            }

    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
       int d;

       scanf("%d", &d);

       if( d == 25 ) puts("Christmas");
       else if( d == 24 ) puts("Christmas Eve");
       else if( d == 23 ) puts("Christmas Eve Eve");
       else if( d == 22 ) puts("Christmas Eve Eve Eve");

       return 0;
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int nums[n];
  REP(i,n) {
    cin >> nums[i];
  }
  bool flag = true;
  map<int,int> mp;
  REP(i,n) {
    ++mp[nums[i]];
    if(mp[nums[i]] > 1) {
      flag = false;
      break;
    }
  }
  if(flag) cout << "YES";
  else cout << "NO";
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 10368
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

template<class T> class RangeMinQuery {
 public:
    vector<T> dat;
    int n;
    // you may need to change MAX!
    static T const MAX = 2147483647;

    RangeMinQuery() {}
    RangeMinQuery(int N) {
        n = 1;
        while (n < N) n *= 2;
        dat.resize(2 * n - 1, MAX);
    };

    void update(int k, T x) {
        k += n - 1;
        dat[k] = x;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    // get minimum val [a, b)
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return MAX;
        if (a <= l && r <= b) return dat[k];

        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

int main(void) {
    int n, q;
    cin >> n >> q;
    RangeMinQuery<int> a(n);
    for (int i = 0; i < q; i++) {
        int c, s, t;
        cin >> c >> s >> t;
        if (c == 0) a.update(s, t);
        else 
            cout << a.query(s, t + 1) << endl;
    }
    return 0;
}

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

int main() {
  int X,Y;
  cin >> X >> Y;
  
  int turu = (Y - (2 * X)) / 2;
  if (0 > turu || turu > X) {
    cout << "No" << endl;
  }
  else {
    if ((4 * turu + 2 * (X - turu)) == Y) {
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

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

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

fastio _fast_io;

string s;
int main() {
    cin >> s;
    int Cnt = 0;
    bool ok = true;
    if (s[0] != 'A')
        ok = false;
    for (int i = 0; i < s.length(); ++i) {
        char c = s[i];
        if (c != 'A' && c != 'C' && isupper(c)) {
            ok = false;
        }
        if (i >= 2 && i < s.length() - 1) {
            if (c == 'C') {
                ++Cnt;
            }
        }
    }
    if (Cnt != 1)
        ok = false;

    if (ok)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;
    return 0;
}


Measured memory_bytes: 3592
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-25 13:44:41 +0900
# LastModified: 2020-06-25 13:54:38 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, a, b = map(int, input().split())
    s = input()
    win = 0
    foreign = 0
    for i in range(n):
        if s[i] == 'a' and win < a+b:
            win += 1
            print("Yes")

        elif s[i] == 'b' and win < a+b and foreign < b:
            win += 1
            foreign += 1
            print("Yes")
        else:
            print("No")
            


if __name__ == "__main__":
    main()


Measured memory_bytes: 9240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOPSIC2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);

            string[] A= Console.ReadLine().Split(' ');
            int sum = 0;
            for(int i = 0; i < M; i++)
            {
                sum += int.Parse(A[i]);
            }

            Console.WriteLine(N - sum >= 0 ? N - sum : -1);
        }
    }
}


Measured memory_bytes: 18988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    int ans=0;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        if(i%2==0&&a%2==1) ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    int a,b,c;
    int k;
    cin>>a>>b>>c;
    cin>>k;
    while(b <= a && k > 0)
    {
        b = b*2;
        k--;
    }
    while(c <= b && k > 0)
    {
        c = c*2;
        k--;
    }

    if(b > a && c > b)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }

    return 0;
}

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

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

	int count = 0;
	for (int i = 0; i < n-2; i++) {
		if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
			count++;
			i += 2;
		}
	}
	cout << count << endl;
	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int A,B,C,D;cin >> A >> B >> C >> D;
	int battle = 0;
	while(1){
		if(battle&1) A -= D;
		else C -= B;
		if(A <= 0){
			cout << "No\n";
			break;
		}
		if(C <= 0){
			cout << "Yes\n";
			break;
		}
		battle++;
	}
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
   static final int SIZE = 6; //the number of sides
   public static void main(String[] args) {
      //variables
      Scanner sc = new Scanner(System.in);
      String[] input = sc.nextLine().split(" ");
      int[] sides = new int[SIZE];
      for(int i = 0; i < SIZE; i ++){
         sides[i] = Integer.parseInt(input[i]);
      }
      
      Dice d = new Dice(sides);
      
      String command = sc.nextLine();
      for(int i = 0; i < command.length(); i ++){
         switch (command.charAt(i)){
            case 'N':
               d.toNorth();
               break;
            case 'E':
               d.toEast();
               break;
            case 'W':
               d.toWest();
               break;
            case 'S':
               d.toSouth();
               break;
         }
      }//
      
      sides = d.getSides();
      System.out.println(sides[0]);
      
      
   
   
   }//close main method


   /**
   * Dice class
   *
   */
   public static class Dice {
      //instaice variables
      private int[] sides = new int[SIZE];
      
      /**
      *constructor
      *@param sides : the array of numbers indicating each side
      *
      */
      public Dice(int[] sides){
         for(int i = 0; i < SIZE; i ++){
            this.sides[i] = sides[i];
         }
      }
      
      /**
      *toNorth method
      */
      public void toNorth(){
         int temp = sides[0];
         sides[0] = sides[1];
         sides[1] = sides[5];
         sides[5] = sides[4];
         sides[4] = temp;
      }
      
      /**
      *toSouth method
      */
      public void toSouth(){
         int temp = sides[0];
         sides[0] = sides[4];
         sides[4] = sides[5];
         sides[5] = sides[1];
         sides[1] = temp;
      }
      
      /**
      *toWest method
      */
      public void toWest(){
         int temp = sides[0];
         sides[0] = sides[2];
         sides[2] = sides[5];
         sides[5] = sides[3];
         sides[3] = temp;
      }
      
      /**
      *toEast method
      *
      */
      public void toEast(){
         int temp = sides[0];
         sides[0] = sides[3];
         sides[3] = sides[5];
         sides[5] = sides[2];
         sides[2] = temp;
      }
      
      /**
      *getSides method
      *@return the int[] indicating the sides
      */
      public int[] getSides(){
         return sides;
      }
      
   }
}//close class


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;

    return 0;
}


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

vector<vector<int>> g;
vector<vector<int>> d;

void dfs(int crt, int mode)
{
  for (int nxt : g[crt])
  {
    if (d[nxt][mode] != -1)
      continue;
    d[nxt][mode] = d[crt][mode] + 1;
    dfs(nxt, mode);
  }
}

int main()
{
  int n, u, v;
  cin >> n >> u >> v;
  if (u == v)
  {
    puts("0");
    return 0;
  }
  u--;
  v--;
  g.resize(n);
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  d.resize(n);
  rep(i, n)
  {
    d[i].resize(2);
    fill(d[i].begin(), d[i].end(), -1);
  }
  d[u][0] = 0;
  dfs(u, 0);
  d[v][1] = 0;
  dfs(v, 1);
  int ans = 0;
  rep(i, n)
  {
    if (g[i].size() == 1 && d[i][0] < d[i][1])
      ans = max(ans, d[g[i][0]][1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 8
bool adj[N+1][N+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    memset(adj, false, sizeof adj);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        adj[a][b] = true;
        adj[b][a] = true;
    }
    vector<int> nodes(n);
    iota(nodes.begin(), nodes.end(), 1);
    int ans = 0;
    do {
        bool can = nodes[0] == 1;
        for(int i = 1; i < n and can; i++) {
            can &= adj[nodes[i - 1]][nodes[i]];
        }
        ans += can;
    } while(next_permutation(nodes.begin(), nodes.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>

#define ll long long

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	bool flag = true;
	for (int i = 0; i < n; ++i) {
		if (s[i] != t[i]) { flag = false; break; }
	}
	if (n != (m - 1)) flag = false;
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#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>;
const int MOD=1000000007;

int main() {
  int n, m, K;
  cin >> n >> m >> K;
  rep(i,n+1) {
    rep(j,m+1) {
      if(i*(m-j)+(n-i)*j==K) {
        cout << "Yes" << endl;
        return 0;
      }
    }

  }

  cout << "No" << endl;
  return 0;
}


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

int main()
{
	int N;
	long long t;
	scanf("%d",&N);
	scanf("%lld",&t);
	long long gb = t;
	for(int i = 1;i < N;i ++)
	{
		scanf("%lld",&t);
		long long a = max(gb,t);
		long long b = min(gb,t);
		while(b)
		{
			long long c = a%b;
			a = b;
			b = c;
		}
		gb = gb/a*t;
	}
	printf("%lld\n",gb);
}

Measured memory_bytes: 128
a,b = tuple(map(int,input().split()))

s = list(input())[::-1]

for _ in [0]*a:
  if not s.pop().isdigit():
    print("No")
    exit()
if s.pop() != '-':
    print("No")
    exit()

for _ in [0]*b:
  if not s.pop().isdigit():
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 38384
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
using namespace std;

int main(){
    bool flag = true;
    double voteSum = 0;
    int res = 0;
    double line;
    int N;
    double M;
    cin >> N >> M;
    vector<double> A(N);

    for(int i=0;i<N;i++){
        cin >> A[i]; 
        voteSum += A[i];
    }

    line = voteSum/(4.0*M);
    //cout << "line: " << line << endl;
    sort(A.begin(), A.end(), greater<int>());
    
    for(int i=0;i<N;i++){
        
        if(A[i] < line){
            break;
        } else{
            res++;
        }
        //cout << A[i] << " ";
    }

    if(res >= M){
        cout << "Yes";
    } else{
        cout << "No";
    }
}

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

typedef long long ll;
using namespace std;

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if(((abs(a - b) <= d) && (abs(b - c) <= d)) || (abs(a - c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string ser(string seq) {
  if (seq.size() == 6) {
    return seq;
  }
  return ser('0' + seq);
}

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<ll>> prefs(n+1, vector<ll>(0));
  vector<map<ll, int>> mps(n+1);
  vector<pair<int, ll>> cs;
  rep(i, m) {
    int x;
    ll y;
    cin >> x >> y;
    cs.push_back(make_pair(x, y));
    cs[i].first;
    prefs[cs[i].first].push_back(cs[i].second);
  } 
  rep(i, n+1) {
    if (prefs[i].size() > 0) {
      sort(prefs[i].begin(), prefs[i].end());
      prefs[i].erase(unique(prefs[i].begin(), prefs[i].end()), prefs[i].end());
    }
  }
  rep(i, m) {
    int id = lower_bound(prefs[cs[i].first].begin(), prefs[cs[i].first].end(), cs[i].second) - prefs[cs[i].first].begin();
    printf("%06d", cs[i].first);
    printf("%06d\n", id+1);
  }
  return 0;
}

Measured memory_bytes: 14824
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    } else if (a == c) {
        cout << b << endl;
    } else {
        cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
	LL N;
	cin >> N;

	vector<LL> A(N + 1, 0);
	vector<LL> B(N + 1, 0);

	FOR(i, 1, N + 1) {
		LL a;
		cin >> a;
		A[i] += A[i - 1] + a;
	}
	FOR(i, 1, N + 1) {
		LL a;
		cin >> a;
		B[i] += B[i - 1] + a;
	}

	LL max = -1;

	FOR(i, 1, N + 1) {
		LL sum=0;
		sum += A[i];
		sum += B[N] - B[i - 1];
		if (sum > max) { max = sum; }
	}

	cout << max << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        ArrayList al = new ArrayList();
        ArrayList al2 = new ArrayList();
        Array.Sort(a);
        for (int i = 0; i < n - 1; i++)
            if (a[i] != a[i + 1])
            {
                al.Add(a[i]);
                al2.Add(i);
            }
        al.Add(a[n - 1]);
        al2.Add(n - 1);
        int[] al3 = (int[])al.ToArray(typeof(int));

        //for (int i = 0; i < al3.Length; i++)
        //    Console.Write("{0} ", al3[i]);
        //Console.WriteLine();

        int[] al4 = (int[])al2.ToArray(typeof(int));

        //for (int i = 0; i < al4.Length; i++)
        //    Console.Write("{0} ", al4[i]);
        //Console.WriteLine();

        int[] al5 = new int[al4.Length];
        al5[0] = al4[0] + 1;
        for (int i = 1; i < al4.Length; i++)
        {
            al5[i] = al4[i] - al4[i - 1];
        }

        //for (int i = 0; i < al5.Length; i++)
        //    Console.Write("{0} ", al5[i]);
        //Console.WriteLine();

        long ans = 0;
        for (int i = 0; i < al4.Length; i++)
        {
            ans += (al5[i] > al3[i]) ? al5[i] - al3[i] : (al5[i] == al3[i]) ? 0 : al5[i];
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 32348
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N,K = MI()
A = LI()
minus,zero,plus = [], [], []
for i in A:
    if i<0:
        minus.append(i)
    elif i==0:
        zero.append(i)
    else:
        plus.append(i)
m = len(minus)
p = len(plus)
z = len(zero)
minus.sort()
plus.sort()

def count_lower_negpos(v): #pos*negでv以下のペアを数える
    if not minus or not plus:
        return 0
    m_idx = 0
    p_idx = 0
    ans = 0
    while True:
        val = minus[m_idx]*plus[p_idx]
        if val < v:
            ans += p - p_idx
            m_idx += 1
            if m_idx>m-1:
                break
        else:
            p_idx += 1
            if p_idx>p-1:
                break
    return ans

def count_lower_pospos(v): #pos同士でv以下のペアを数える
    if not plus:
        return 0
    left = 0
    right = p-1
    ans = 0
    while True:
        val = plus[left]*plus[right]
        if val < v:
            ans += right - left
            left += 1
            if left>=right:
                break
        else:
            right -= 1
            if left>=right:
                break
    return ans

def count_lower_negneg(v): #neg同士でv以下のペアを数える
    if not minus:
        return 0
    left = 0
    right = m-1
    ans = 0
    while True:
        val = minus[left]*minus[right]
        if val < v:
            ans += right - left
            right -= 1
            if left>=right:
                break
        else:
            left += 1
            if left>=right:
                break
    return ans


if K <= m*p: #答えがマイナス
    l = -10**18-5
    r = 0
    while l+1<r:
        x = (l+r)//2
        if count_lower_negpos(x) < K:
            l = x
        else:
            r = x
    print(l)


elif K <= m*p+z*(m+p)+z*(z-1)//2: #答えがゼロ
    print(0)

else: #答えがプラス
    K = K - (m*p+z*(m+p)+z*(z-1)//2)
    l = 0
    r = 10**18+5
    while l+1<r:
        x = (l+r)//2
        if count_lower_pospos(x)+count_lower_negneg(x) < K:
            l = x
        else:
            r = x
    print(l)


Measured memory_bytes: 110848
#include <iostream>
#include <vector>

using namespace std;

const int MAX_H = 50;

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> s(MAX_H);

    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    int Counter[MAX_H + 2][MAX_H + 2] = {0};

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                Counter[i][j]++;
                Counter[i][j+1]++;
                Counter[i][j+2]++;
                Counter[i+1][j]++;
                Counter[i+1][j+2]++;
                Counter[i+2][j]++;
                Counter[i+2][j+1]++;
                Counter[i+2][j+2]++;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                cout << "#";
            }
            else {
                cout << Counter[i + 1][j + 1];
            }
        }
        cout << endl;
    }



}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    long int n,i;
    long int min;
    long int max;
    long int sum=0;
    scanf("%ld",&n);
    long int a[n+1];
    for(i=0;i<n;i++){
        
        scanf("%ld",&a[i]);
    }
    max=a[0];
    min=a[0];
    for(i=0;i<n;i++){
        if(a[i]<min)min=a[i];
        if(a[i]>max)max=a[i];
        sum=a[i]+sum;
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}


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

mod = 1000000007

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return (a * b) % mod

def pow(p, k):
    ret = 1
    b = p
    while k > 0:
        if k % 2 == 1:
            ret = mul(ret, b)
        b = mul(b, b)
        k //= 2
    return ret

def inv(p, k):
    return pow(p, mod - k - 1)

lcm = {}
ps = []
for i in range(n): 
    ai = a[i]
    p = 2
    ps.append({})
    while ai > 1:
        if ai % p == 0:
            ps[i][p] = 0
            while ai % p == 0:
                ps[i][p] += 1
                ai //= p
            lcm[p] = max(lcm.get(p, 0), ps[i][p])
        p = p + 1 if p * p < ai else ai

lcmv = 1
for p in lcm:
    lcmv = mul(lcmv, pow(p, lcm[p]))

ret = 0
for i in range(n):
    prod = lcmv
    for p in ps[i]:
        prod = mul(prod, inv(p, ps[i][p]))
    ret = add(ret, prod)

print(ret)
        


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

int main(){
  int a,b;
  
  cin >> a >> b;
  
  if(a%2 != 0 && b%2 != 0){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 1e4 + 5;
const int INF = 1e9 + 5;

int h, n, a[N], b[N], dp[N];

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h;
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
	}
	for(int s = 1; s <= h; ++s) {
		dp[s] = INF;
	}
	for(int s = 1; s <= h; ++s) {
		for(int i = 1; i <= n; ++i) {
			dp[s] = min(dp[s], dp[max(s - a[i], 0)] + b[i]);
		}
	}
	cout << dp[h];
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 256
def bfs(dp, arr, i,  visited):
	q = []
	q.append(i)
	visited[i] = True
	while q:
		i = q.pop(0)
		visited[i] = True
		for j in arr[i]:
			if dp[j] == -1:
				dp[j] = dp[i] + 1
			elif dp[i] == dp[j]:
				return -1
			
			if visited[j] == False:
				visited[j] = True
				q.append(j)
	return 0

n=int(input())
i=0
arr=[]
degree = [0]*n
while i<n:
	s=input()
	a=[]
	for j,e in enumerate(s):
		if e=='1':
			a.append(j)
			degree[i]+=1
	arr.append(a)	
	i+=1

res = -1
ans = -1
for i in range(n):
	dp = [-1]*n
	visited=[False for x in range(n)]
	dp[i] = 1
	res=bfs(dp, arr, i, visited)
	if res  == 0:
		ans = max(ans , max(dp))

print(ans)

Measured memory_bytes: 40432
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <limits>

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

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

    if (n >= 10){
        cout << r << endl;
    }else{
        cout << r + 100 * (10 - n) << endl;
    }

}

Measured memory_bytes: 888
#辞書順で一番小さいとこからK個つくる

s = input()
k = int(input())

early = list(set(s))
early.sort()


kouho = {}

for i in early:
    for j in range(len(s)):
        if s[j]==i:
            for l in range(k):
                kouho[s[j:j+l+1]]=0
    if len(kouho)>k:
        break

ans=list(kouho)
ans.sort()
print(ans[k-1])


Measured memory_bytes: 67656
#include <bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin >> str;
  string result = "No";
  for (int i = 0; i < str.length() - 1; ++i) 
  {
    if (str[i] == 'A' && str[i+1] == 'C') result = "Yes";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
long long a[100001],k,cnt,now=2,max=2,min=2;
int main()
{
	scanf("%lld",&k);
	for(int i=1;i<=k;++i)scanf("%lld",a+i);
	for(int i=k;i>=1;--i){
		max=(max/a[i]+1)*a[i]-1;
		min=((min-1)/a[i]+1)*a[i];
		if(max<min){puts("-1");return 0;}
	}
	printf("%lld %lld\n",min,max);
	return 0;
}

Measured memory_bytes: 896
def main():
    _ = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    B_ = []
    B_accum = []
    ans = 0

    for b in B:
        num = binary_search(A, b) + 1
        B_.append((b, num))

    tmp_sum = 0
    for b_ in B_:
        tmp_sum += b_[1]
        B_accum.append(tmp_sum)

    for c in C:
        b_idx = binary_search_tuple(B_, c)
        if b_idx >= 0:
            ans += B_accum[b_idx]
    print(ans)


def binary_search(A, x):
    ok = -1
    ng = len(A)
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if A[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok


def binary_search_tuple(A, x):
    ok = -1
    ng = len(A)
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if A[mid][0] < x:
            ok = mid
        else:
            ng = mid
    return ok


if __name__ == '__main__':
    main()

Measured memory_bytes: 104152
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M  1000000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 255001;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
const long double TAU = 2*PI;

ll a[3];

signed main(){
    cin >> a[0] >> a[1] >> a[2];
    if(!((a[0]&1)&&(a[1]&1)&&(a[2]&1)))return puts("0"),0;
    sort(a,a+3);
    cout << a[0]*a[1] << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define MP make_pair
typedef pair<int, int> PAIR;
const int MAX = 150;

int main(){
	vector<pair<int,PAIR> > rects;
	for( int i = 1; i <= MAX; i++ ){
		for( int j = i+1; j <= MAX; j++ ){
			int diagonal = i*i + j*j;
			rects.push_back(MP(diagonal, MP(i,j)));
		}
	}
	sort(rects.begin(), rects.end());
	int h, w;
	while( cin >> h >> w, h || w ){
		for( int i = 0; i < rects.size(); i++ ){
			if( h != rects[i].second.first ) continue;
			for( int j = 0; j < rects.size(); j++ ){
				if( h != rects[i+j].second.first ) break;
				if( w == rects[i+j].second.second ){
					cout << rects[i+j+1].second.first << " " << rects[i+j+1].second.second << endl;
					goto end;
				}
			}
		}
		end:;
	}
}

Measured memory_bytes: 1332