akhauriyash/Code-Regression huggingface dataset:
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    # QUERYS = [input().split() for _ in range(Q)]
    A, V = [int(a) for a in input().split()]
    B, W = [int(a) for a in input().split()]
    T = int(input())
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]

    dd = abs(A - B)
    if V <= W:
        print('NO')
        return
    vv = V - W
    if vv * T >= dd:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()


Measured memory_bytes: 74468
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    def enum_divisors(n):
        # 約数列挙

        divisors = []

        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        return divisors

    ans = 0
    for i in range(1, N + 1, 2):
        divs = enum_divisors(i)
        if len(divs) == 8:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62008
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}


int main() {
    bool z = true;
    ll n, y, ma = 0;
    cin>>n>>y;
    vector<ll> x(n);
    rep(i, n) cin>>x[i];
    
    vector<ll> num;
    
    
    num = enum_div(abs(y-x[0]));
    num.push_back(abs(y-x[0]));
    
    
    for(int i=1; i<num.size();i++){
        z = true;
        rep(j, n){
            if(abs(y-x[j]) % num[i] != 0){
                z = false;
                break;
            }
        }
        if(z==true) ma = max(ma, num[i]);
        
    }
    if(ma == 0) ma = 1;
    
    if(n == 1) ma = abs(x[0]-y);
    
    cout<<ma<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int A[52];
int N, P;

ll memo[52][3];
bool visited[52][3];

ll dfs(int pos, int mod){
    if(pos == N){
        if(mod == P) return 1;
        else return 0;
    }
    if(visited[pos][mod]) return memo[pos][mod];
    visited[pos][mod] = true;
    return memo[pos][mod] = dfs(pos+1, mod) + dfs(pos+1, (mod + A[pos]) % 2);
}

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

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

    memset(visited, 0, sizeof(visited));
    cout << dfs(0, 0) << endl;

    return 0;
}

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

int main(void){
    int n,q;
    cin >> n >> q;
    queue<int> Q[n]; // n個のqueue

    for(int i=0; i<q; i++){
        int cmd;
        cin >> cmd;

        if(cmd==0){
            int t,x;
            cin >> t >> x;
            Q[t].push(x);
        }
        else if(cmd==1){
            int t;
            cin >> t;
            if(!Q[t].empty()){
                cout << Q[t].front() << "\n";
            }
        }
        else if(cmd==2){
            int t;
            cin >> t;
            if(!Q[t].empty()){
                Q[t].pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4384
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL A, B, K;

int main()
{
	in >> A >> B >> K;
	rep(i, K)
	{
		if (i % 2 == 0)
		{
			A = A / 2 * 2;
			LL halfA = A / 2;
			A -= halfA;
			B += halfA;
		}
		else
		{
			B = B / 2 * 2;
			LL halfB = B / 2;
			B -= halfB;
			A += halfB;
		}
	}
	out << A << " " << B << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    sc.close();

    String s = String.valueOf(N);
    boolean ans = s.contains("7");
    System.out.println(ans ? "Yes" : "No");
  }
}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
mt19937 rd(time(0)); // i = rd%n
signed main() 
{
    fastio();

    int n;
    string s;
    cin>>n>>s;
    map<char,vector<int> >mp;
    mp['R'] = mp['G'] = mp['B'] = vector<int>(n+1,0);
    for(int i = n-1;i>=0;i--)
    {
        for(auto j:mp)
        {
            mp[j.first][i] = mp[j.first][i+1];
            if(j.first == s[i])
                mp[j.first][i]++;
        }
    }
    int ans = 0;
    for(int i= 0;i<n;i++)
    {
        for(int j = i+1;j<n;j++)
        {
            if(s[i]!=s[j])
            {
                int ch = 'R' + 'G' + 'B' -s[i] - s[j];
                ans+=mp[ch][j+1];
                if(j + (j-i)<n && s[2*j-i]==ch)
                    ans--;
            }
        }
    }
    cout<<ans;


    return 0;
}


Measured memory_bytes: 3728
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    job_list = defaultdict(list)
    for _ in range(N):
        a, b = map(int, input().split())
        job_list[a].append(-b)

    pool = []
    ans = 0
    for i in range(1, M+1):
        for reward in job_list[i]:
            heappush(pool, reward)
        if 0 < len(pool):
            ans -= heappop(pool)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27680
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/


ll N;
vector<ll> D;
int main(){
  ll N;
  cin >> N;
  vector<ll> D(N);
  rep(i, N) cin >> D[i];
  sort(D.begin(), D.end());
  vector<ll> used(24, 0);
  used[0] = 1;
  bool next = 1;
  ll ans = 24;
  rep(i, N){
    if(next){
      if(used[D[i]]) ans = 0;
      used[D[i]] = 1;
      next = 0;
    }else{
      if(used[24-D[i]]) ans = 0;
      used[24-D[i]] = 1;
      next = 1;
    }
  }

  rep(i, 24){
    if(used[i] == 0) continue;
    for(ll j = i+1;;j++){
      if(used[j] == 0) continue;
      ans = min(ans, j-i);
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
solve :: Int -> Int
solve n = foldl (+) 0 $ filter (\x -> x > 0 && n `div` x == n `mod` x) [ n `div` c - 1 | c <- (takeWhile (\x -> x * x <= n) [1..]), n `mod` c == 0 ]

main :: IO ()
main = do
  n <- readLn :: IO Int
  print $ solve n


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

using namespace std;

int main(){
        long long int N,T;
        long long int t[200010];
        int ans=0;

        cin>>N>>T;
        for(int i=0; i<N; ++i) cin>>t[i];

        for(int i=1; i<N; ++i){
                if((t[i]-t[i-1])>T) ans+=t[i]-t[i-1]-T;
        }

        cout<<t[N-1]-ans+T<<endl;

        return 0;
}


Measured memory_bytes: 1792
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, n = mput()
    p = lput()
    ans = []
    for i in range(x, x-n-1, -1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    for i in range(x, x+n+1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    if abs(x-ans[0]) <= abs(x-ans[1]):
        print(ans[0])
    else:
        print(ans[1])
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9180
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Apr  4 21:00:24 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

const Int N = 10;
signed main() {
    Int K;
    std::cin >> K;
    K--;
    auto dp = make_vec<Int>(N, 10, 0);
    REP(j, 10) dp[0][j] = 1;
    Int curi = -1;
    std::string ans;
    bool done = false;
    REP(i, N) {
        REP(j, 10) {
            if (i) {
                REP(dif, -1, 2) {
                    Int j2 = j + dif;
                    if (j2 < 0 || j2 >= 10) continue;
                    dp[i][j] += dp[i - 1][j2];
                }
            }
            if (j) K -= dp[i][j];
            if (K < 0) {
                curi = i;
                ans.push_back('0' + j);
                K += dp[i][j];
                done = true;
                break;
            }
        }
        if (done) break;
    }
    for (Int i = curi - 1; i >= 0; i--) {
        REP(j, 10) {
            if (std::abs((Int)(ans.back() - '0') - j) >= 2) continue;
            K -= dp[i][j];
            if (K < 0) {
                ans.push_back('0' + j);
                K += dp[i][j];
                break;
            }
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
a = list(map(int, input().split()))
a.sort()
first, second, third = a[2], a[1], a[0]

x, y = first - second, first - third

res = 0
res += min(x, y) + abs(x - y) // 2

if abs(x - y) % 2 == 0:
    print(res)
else:
    print(res + 2)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int n, t, d[101], f[101];
vector< vector<int> >m(101);


void dfs(int u){
    d[u] = ++t;
    int v;
    for(int i=0; i<m[u].size(); i++){
        v = m[u][i];
        if(d[v]==-1){
            dfs(v);
        }
    }
    f[u] = ++t;
    return;
}

int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        int id, d, to;
        scanf("%d %d", &id, &d);
        for(int j=0; j<d; j++){
            scanf("%d", &to);
            m[id].push_back(to);
        }
    }
    memset(d, 255, sizeof(d));
    t = -0;

    for(int i=1; i<=n; i++){
        if(d[i]==-1)
            dfs(i);
    }
    for(int i=1; i<=n; i++){
        printf("%d %d %d\n", i, d[i], f[i]);
    }
    return 0;
}


Measured memory_bytes: 2752
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll N;cin>>N;
    ll H[N];REP(i,N)cin>>H[i];
    
	// 解法
    bool ans = true;
    REP(i,N-1){
        ll H1 = H[N-2-i];
        ll H2 = H[N-1-i];
        if (H1==H2+1) H[N-2-i]--;
        else if (H1>H2+1){
            // printf("%lld %lld\n", H1, H2);
            ans = false;
            break;
        }
    }

	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 1024
k=int(input())
n=50
a=[0 for _ in range(n)]
for i in range(n):
  if i < (k%n):
    a[i]=n
  else:
    a[i]=n-1-k%n
for i in range(n):
  a[i]+=(k//n)
print(n)
for i in range(n):
  if i==n-1:
    print(a[i])
  else:
    print(a[i],end=" ")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] highest = new int[n + 1];
		for (int i = 0;i < n;i++)
			highest[i + 1] = Max(highest[i],h[i]);
		int ans = 0;
		for (int i = 0;i < n;i++)
			if (highest[i] <= h[i])
				ans++;
		Console.WriteLine(ans);
	}
}

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

# D - Not Divisible
n = int(input())
a = list(map(int, input().split()))
dic = dict()

for ai in a:
	dic.setdefault(ai, 0)
	dic[ai] += 1

multiples = set()
upper = 10 ** 6

for k in dic.keys():
  i = 2
  
  while True:
    if k * i <= upper:
      multiples.add(k * i)
      i += 1
    else:
      break

ans = 0

for k, v in dic.items():
  if v == 1:
    if not k in multiples:
      ans += 1

print(ans)

Measured memory_bytes: 218104
import java.util.*; 
import java.math.BigDecimal;

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        BigDecimal n=new BigDecimal(sc.nextDouble());
  		BigDecimal b=new BigDecimal(3);
        BigDecimal a=n.divide(b,8,BigDecimal.ROUND_HALF_UP);
		BigDecimal ans=a.multiply(a);
  		ans=ans.multiply(a);

    	System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import sys
N = int(input())

ans = []
if N % 2:
    print(N*(N-1)//2 - N//2)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if i + j != N:
                ans.append("%d %d\n" % (i, j))
else:
    print(N*(N-1)//2 - N//2)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if i + j != N+1:
                ans.append("%d %d\n" % (i, j))
sys.stdout.writelines(ans)

Measured memory_bytes: 39152
#include<cmath>
#include<cstdio>
#include<algorithm>
#define MN 500001
#define lp (p<<1)
#define rp ((p<<1)|1)
#define eps 0
#define double long double
#define ll long long
using namespace std;

struct na{double x,y;na(double _x=0,double _y=0):x(_x),y(_y){}};
na operator + (na a,na b){return na(a.x+b.x,a.y+b.y);}
na operator - (na a,na b){return na(a.x-b.x,a.y-b.y);}
na operator * (na a,na b){return na(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}
na operator / (na a,na b){return na((a.x*b.x+a.y*b.y)/(b.x*b.x+b.y*b.y),(a.y*b.x-a.x*b.y)/(b.x*b.x+b.y*b.y));}
const double pi=4.0*atan(1.0);
ll T,n,m,l,r,id,N,a[MN],b[MN];
ll read_p,read_ca;
inline ll read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int main(){
	register ll i;
	n=read();m=N=0;
	for (i=1;i<=n;i++) a[i]=read(),b[i]=read();
	for (i=n;i;i--) a[i]+=N,N+=a[i]%b[i]==0?0:(b[i]-a[i]%b[i]);
	printf("%lld\n",N);
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(a>0 || c>0){
        c-=b;
        if(c<=0){
            break;
        }
        a-=d;
    }
    if(a>0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2088
#include <stdio.h>
#include <stdlib.h>

int main(){
        int N;
        scanf("%d",&N);
        int t[N],x[N],y[N];
        t[0]=0,x[0]=0,y[0]=0;
        for (int i=1;i<=N;i++){
                scanf("%d %d %d",&t[i],&x[i],&y[i]);
        }
        int countX=0,countY=0,sum=0;
        for (int i=1;i<=N;i++){
                countX=x[i]-x[i-1];
                countY=y[i]-y[i-1];
                sum=countX+countY;
                if(sum>t[i]){
                        printf("No");
                        exit(0);
                }
                if((t[i]-t[i-1])%2==0){
                        if(sum%2==1){
                                printf("No");
                                exit(0);
                        }
                }else{
                        if(sum%2==0){
                                printf("No");
                                exit(0);
                        }
                }
        }
        printf("Yes");
        return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(void)
{
	int tsum=0,hsum=0;
	int h1[100],h2[100],h3[100],i=0;
	
	while (scanf("%d,%d,%d", &h1[i], &h2[i], &h3[i]) != EOF){
		if ((h1[i]*h1[i]+h2[i]*h2[i]==h3[i]*h3[i])&&(h1[i]+h2[i]!=h2[i]+h3[i])){
			tsum++;
		}
		if (h1[i]==h2[i]){
			hsum++;
		}
	}
	
	printf("%d\n%d\n", tsum, hsum);
	
	return 0;
}

Measured memory_bytes: 596
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        a: [chars; n],
        b: [chars; m],
    }
    for i in 0..n - m + 1 {
        'inner: for j in 0..n - m + 1 {
            for row in 0..m {
                for col in 0..m {
                    if a[i + row][j + col] != b[row][col] {
                        continue 'inner;
                    }
                }
            }
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
n = int(input())

xy = []
a_list = []

for i in range(n):
    a = int(input())
    a_list.append(a)
    for j in range(a):
        x,y = map(int,input().split())
        xy.append([x,y])
        
#print(xy)
#print(a_list)

num = 2**n
hito = []
flag = True

for i in reversed(range(num)):
    #print(i)
    hito = []
    tmp = i
    while tmp != 0:
        if tmp % 2 == 1:
            hito.append(1)
        else:
            hito.append(0)
        tmp //= 2
    """
    if len(hito) == 2:
        hito.append(0)
    elif len(hito) == 1:
        hito.append(0)
        hito.append(0)
    elif len(hito) == 0:
        hito.append(0)
        hito.append(0)
        hito.append(0)
    """
    if len(hito) != n:
        for j in range(n-len(hito)):
            hito.append(0)
    
    hito = hito[::-1]
    #print(hito)
    
    number = 0
    flag = True
    #print(hito)
    
    for j in range(n):
        #print(j)
        for k in range(a_list[j]):
            #正しいことを言う人
            if hito[j] == 1:
                #print(number,hito[xy[number][0]] , xy[number][1])
                if hito[xy[number][0]-1] != xy[number][1]:
                    flag = False
            number += 1
    if flag == True:
        print(sum(hito))
        exit()
        
print(0)
exit()

Measured memory_bytes: 3064
import sys

def main():
    num = int(input())
    data = list(map(int, input().split()))

    dp = [0 for i in range(num - 1)]
    dp[0] = abs(data[1] - data[0])

    if num > 2:
        dp[1] = min(dp[0] + abs(data[2] - data[1]), abs(data[2] - data[0]))

        for i in range(2, num - 1):
            dp[i] = min(dp[i - 1] + abs(data[i + 1] - data[i]), dp[i - 2] + abs(data[i + 1] - data[i - 1]))

        # print(dp)

    print(dp[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 52720
import sys
import heapq
import operator as op
from itertools import accumulate

inf = float("inf")

def dijkstra(graph, start):
    dist = [inf for _ in range(len(graph))]
    dist[start] = 0
    prev = [None for _ in range(len(graph))]
    q = [(0, start)]
    rem = len(graph) - 1

    while q != [] and rem > 0:
        du, u = heapq.heappop(q)
        if dist[u] < du:
            continue
        rem -= 1

        for v, d in graph[u].items():
            if dist[v] > du + d:
                dist[v] = du + d
                prev[v] = u
                heapq.heappush(q, (dist[v], v))

    return dist, prev

n, m, s, t = map(int, next(sys.stdin).split(" "))

yen_graph = [dict() for _ in range(n)]
snuke_graph = [dict() for _ in range(n)]

for line in sys.stdin.readlines():
    u, v, a, b = map(int, line.strip().split(" "))
    yen_graph[u-1][v-1] = yen_graph[v-1][u-1] = a
    snuke_graph[u-1][v-1] = snuke_graph[v-1][u-1] = b

yen, _ = dijkstra(yen_graph, s-1)
snuke, _ = dijkstra(snuke_graph, t-1)
result = list(accumulate([y+s for y, s in zip(yen, snuke)][::-1], min))

for i in range(n-1, -1, -1):
    print(10**15 - result[i])


Measured memory_bytes: 101412
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=2e5+5;
ll n,k,tot;
ll lowbit(ll x)
{
	return x&-x;
}
ll a[N],b[N],c[N];
struct node{
	ll num,in;
}s[N];
ll sum(ll x)
{
	ll ans=0;
	while(x>0)
	{
		ans+=c[x];
		x-=lowbit(x);
	}
	return ans;
}
void add(ll x,ll y)
{
	while(x<=tot)
	{
		c[x]+=y;
		x+=lowbit(x);
	}
}
bool cmp1(node x,node y)
{
	return x.num<y.num;
}
bool cmp2(node x,node y)
{
	return x.in<y.in;
}
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	cin>>n>>k;
	s[0].in=0;
	s[0].num=0;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]-=k;
		s[i].num=s[i-1].num+a[i];
		s[i].in=i;
	}
	
	sort(s,s+n+1,cmp1);
	

	for(i=0;i<=n;i++)
	{
		if(i==0||s[i].num!=s[i-1].num)
		{
			b[i]=++tot;
		}
		else 
			b[i]=b[i-1];
	}
	
	for(i=0;i<=n;i++)
		s[i].num=b[i];
		
	sort(s,s+n+1,cmp2);
//	for(i=0;i<=n;i++)
//		cout<<s[i].num<<" ";
//	cout<<endl;
	ll ans=0;
	for(i=0;i<=n;i++)
	{
		ans+=sum(s[i].num);
		add(s[i].num,1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8064
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1
print(z+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M

Measured memory_bytes: 157800
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
const int maxn=200005;
typedef long long LL;
int n,m,a[maxn];
map<LL,int> M;
LL ans,sum[maxn];
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]), sum[i]=sum[i-1]+a[i];
  M[0]++; for(int i=1;i<=n;i++) ans+=M[sum[i]], M[sum[i]]++;
  printf("%lld\n",ans);
  return 0;
}  

Measured memory_bytes: 15104
main :: IO ()
main = do
  n <- readLn :: IO Int
  let bnds = (floor $ 0.5 + (sqrt $ (fromIntegral n) + 0.25))
  print $ sum $ [(n-r) `div` r | r <- [1..bnds], r < (n-r) `div` r , (n-r) `mod` r == 0]


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

#define int long long
#define ll unsigned long long
#define pb push_back
#define mp make_pair
#define veci vector<int>
#define pii pair<int,int>
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define repi(i,a,b) for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define fi first 
#define se second
#define all(v) v.begin(),v.end()

int mod=1e9+7;

int powerm(int x,int y, int M){ int res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
int  power(int x,int y){ int res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
    T=1;
//    cin>>T;
while(T--){
    int n;
    cin>>n;
    int a[n];
    int zero=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==0) zero++;
    }
    if(zero){
        cout<<0;
        continue;
    }
    int prod=1;
    bool flag=true;
    rep(i,n){
        if(a[i]<=1000000000000000000/prod) prod*=a[i];
        else{
            flag=false;
            cout<<-1;
            break;
        }
    }
    if(flag) cout<<prod;
}
    
    return 0;
}


Measured memory_bytes: 4408
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # グループのサイズ
        return -self.parents[self.find(x)]

    def roots(self):  # 根のリスト
        return [self.size(i) for i, x in enumerate(self.parents) if x < 0]


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = Unionfind(n)
for ai, bi in ab:
    uf.union(ai - 1, bi - 1)
print(max(uf.roots()))


Measured memory_bytes: 106700
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
  	ci(s);
  co("ABC"+s)
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			@SuppressWarnings("unused")
			int n = scanner.nextInt(), m = scanner.nextInt();
			int[] l = new int[m], r = new int[m];
			int lMax = IntStream.range(0, m).map(i -> {
				l[i] = scanner.nextInt();
				r[i] = scanner.nextInt();
				return l[i];
			}).max().getAsInt();
			int rMin = Arrays.stream(r).min().getAsInt();
			System.out.println((rMin >= lMax) ? rMin - lMax + 1 : 0);
		}
	}
}


Measured memory_bytes: 60392
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 200 + 10;
const int Mod = 998244353;
int N;
int stk[MAXN], top;
bool vis[MAXN][MAXN];
int fc[MAXN];
int ans;
#define x first
#define y second
pair<int, int> A[MAXN];

inline bool check(int i, int j, int k) {
	return (A[i].y - A[j].y) * (A[i].x - A[k].x) == (A[i].y - A[k].y) * (A[i].x - A[j].x);
}

int main() {
	register int i, j, k;
	scanf("%d", &N);
	for(i = 1; i <= N; ++i)
		scanf("%d%d", &A[i].x, &A[i].y);
	for(*fc = i = 1; i <= N; ++i)
		fc[i] = 1ll * fc[i - 1] * 2 % Mod;
	ans = fc[N] - N - 1;
	for(i = 1; i <= N; ++i)
		for(j = i + 1; j <= N; ++j) {
			int res = 0;
			for(k = j + 1; k <= N; ++k)
				res += check(i, j, k);
			ans = (ans - fc[res] + Mod) % Mod;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
        int n,k;
        std::cin >> n >> k;

        std::vector<int> ord(n+1,0);
        for(int i=0;i<k;i++)
        {
                int d;
                std::cin >> d;

                for(int j=0;j<d;j++)
                {
                        int num;
                        std::cin >> num;
                        ord[num]++;
                }
        }

        int count=0;
        for(int i=1;i<n+1;i++)
                if(ord[i] == 0)
                        count++;

        std::cout << count << std::endl;

}

Measured memory_bytes: 3568
#include<string>
   #include<stdio.h>
   #include<iostream>
   #include<utility>
   #include<algorithm>
   using namespace std;
   int main(){
   int n;
   string s;
   cin >> s;
   cin >> n;
   for(int i=0;i<n;i++){
   string command;
   cin >> command;
   if(command == "print"){
      int first,second;
      cin >> first >> second;
   for(int i=first;i<=second;i++)cout << s[i];
   cout << endl;
   }
   else if(command == "reverse"){
   string temp;
   int first,second;
   cin >> first >> second;
   temp = s.substr(first,second - first + 1);
   //cout << temp << endl;
   reverse(temp.begin(),temp.end());
   //cout << temp << endl;
   int cnt;
   cnt =0;
   for(int i=first;i<=second;i++){
      char c = temp[cnt];
      s[i] = c;
      cnt++;
   }
   //cout << s << endl;
   }
   else if(command == "replace"){
   string temp;
   int first,second;
   cin >> first >> second >> temp;
   s.replace(first,second - first + 1,temp);
   //cout << s << endl;
   }


   }

   return 0;
   }







Measured memory_bytes: 3204
from math import ceil
def C(x):
  cnt = 0
  for i in range(n):
    cnt += ceil(a[i] / x) - 1
  if cnt > k:
    return False
  else:
    return True
  
n, k = map(int, input().split())
a = list(map(int, input().split()))
lb = 0
ub = 1000000000
while ub - lb > 1:
  mid = (lb + ub) // 2
  if C(mid):
    ub = mid
  else:
    lb = mid
print(ub)

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	ll n;
	cin >> n;
	vector<ll> a(n/2);
	vector<ll> b(n/2);
	rep(i,n){
		ll t; cin >> t;
		if(i%2==0){
			a[i/2] = t;
		}else b[i/2] = t;
	}
	SORT(a);
	SORT(b);
	//CAUTION : a と b の要素が同じ	
	//pair (何個あるか、数は何か）
	ll cnt = 0;
	vector<pair<ll,ll>> A;
	rep(i,a.size()){
		ll c = a[i];
		while(c == a[i] && i < a.size()){
				i++;
				cnt++;
		}
		i--;
		A.emplace_back(cnt,c);
		cnt = 0;
	}
	vector<pair<ll,ll>> B;
	rep(i,b.size()){
		ll c = b[i];
		while(c == b[i] && i < b.size()){
				i++;
				cnt++;
		}
		i--;
		B.emplace_back(cnt,c);
		cnt = 0;
	}
	SORT(A);
	SORT(B);
	rSORT(A);
	rSORT(B);


	//要素が何個あるか、要素は何か。これは多分同じ数は出てこない
//	for(auto x:A){
//		cout <<x.first<<": "<<x.second<<"/";
//	}
//	cout << endl;
//	for(auto x:B){
//		cout <<x.first<<": "<<x.second<<"/";
//	}
//	cout << endl;

	ll ans ;
	if(A[0].second == B[0].second){
		//A[0]とB[1]を使うときと、その逆のパターンのうち操作回数が最小となるほうを採用する

		ll minus = max(A[0].first+B[1].first , A[1].first + B[0].first);
		cout << n - minus << endl;
	}else{
		cout << n - A[0].first -B[0].first <<endl;
	}

}


Measured memory_bytes: 3316
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
mod = 10**9+7
A.sort()

fact = np.zeros(N+1, np.int64)
inv = np.zeros(N+1, np.int64)

fact[0], fact[1] = 1, 1
inv[0], inv[1] = 1, 1

for i in range(2,N+1):
	fact[i] = fact[i-1] * i
	fact[i] %= mod
	inv[i] = inv[i-1] * pow(i, mod-2, mod)
	inv[i] %= mod

ans = 0
lim = N - K + 1
for ind, a in enumerate(A,1):
	if ind < K:
		tmp_max = 0
	else:
		r_cnt = ind - 1
		r_comb = fact[r_cnt]
		r_comb *= inv[K - 1]
		r_comb %= mod
		r_comb *= inv[r_cnt - K + 1]
		r_comb %= mod

		tmp_max= r_comb * a % mod

	if ind > lim:
		tmp_min = 0
	else:
		l_cnt = N - ind
		l_comb = fact[l_cnt]
		l_comb *= inv[K - 1]
		l_comb %= mod
		l_comb *= inv[l_cnt - K + 1]
		l_comb %= mod

		tmp_min = l_comb * a % mod

	ans += (tmp_max - tmp_min) % mod
	ans %= mod

ans %= mod
print(ans)


	

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int a[100];
    for(int i = 0; i < N; ++i) cin >> a[i];
    sort(a, a+N);
    cout << a[N-1] - a[0] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <vector>
#include <array>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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


int main(void) {

	int i, j, k, tmp, n, ans = 0, prev = 0, b = 0;
	vector<int> B;

	scanf("%d", &n);
	rep(i, n - 1) {
		scanf("%d", &tmp);
		B.push_back(tmp);
	}
	ans = B.at(0);
	b = ans;
	for (i = 1; i < n - 1; i++) {
		ans += min(B.at(i), b);
		b = B.at(i);
	}
	ans += B.at(n - 2);
	printf("%d", ans);


	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

bool solve(lli h, lli w, vector<lli> cnt) {
    lli r1 = (h%2)*(w%2);
    lli r2 = (h%2)*(w/2)+(w%2)*(h/2);
    assert  ((h * w - 2 * r2 - r1) % 4 == 0);
    lli r4 = (h*w-2*r2-r1) / 4;
    rep(i, 26){
        if(cnt[i] < 4) continue;
        while(r4 > 0 && cnt[i] >= 4) cnt[i]-=4, r4--;
    }
    if(r4 > 0) return false;
    for (int c = 0; r2--; ) {
        while (c < 26 && cnt[c] < 2) c++;
        if (c == 26) return false;
        cnt[c] -= 2;
    }
    return true;
}

int main() {
    lli h, w;
    cin >> h >> w;
    vector<lli> cnt(26);
    rep(i, h) rep(j, w){
        char c;
        cin >> c;
        cnt[c - 'a']++;
    }
    // solve
    bool result = solve(h, w, cnt);
    // output
    printf("%s\n", result ? "Yes" : "No");
    return 0;
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int N, R;
    cin >> N >> R;
    if(N >= 10)
        cout << R << endl;
    else
        cout << R + 100 * (10 - N) << endl;
    return 0;
    
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>

using namespace std;

const int Max = 1e9 + 7;
typedef long long ll;
ll ans;

int main(){
	int a, b, w, ans, A, B;
	while(~scanf("%d %d %d", &w, &a, &b)){
		A = a + w, B = b + w;
		if(A <= b)  ans = b - A;
		if(A > b && A <= B)  ans = 0;
		if(A > B){
			if(a < B) ans = 0;
			else ans = a - B;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	for( int &i : v ){
		cin >> i;
	}
	cout << accumulate(v.begin(), v.end(), 0) - n << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
ans = 'Yes'
for i in range(n - 1, 0, -1):
    d = h[i - 1] - h[i]
    if d >= 2:
        ans = 'No'
        break
    elif d == 1:
        h[i - 1] -= 1
print(ans)

Measured memory_bytes: 20496
#include <stdio.h>

int solve(int, int);
int a[20], n;

int main () {
  int q, m[200], i, j;

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

  i = 0;
  
  scanf("%d", &q);
  for(j = 0 ; j < q ; j++) {
    scanf("%d", &m[j]);
    if(solve(i,m[j])) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i, int m){
  
  if(m == 0) return 1;
  if(i >= n) return 0;

  if(solve(i+1,m) || solve(i+1,m-a[i])) return 1;
}

Measured memory_bytes: 580
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int A, B, C;
  while (cin >> A >> B >> C) {
    int pA = A % 2, pB = B % 2, pC = C % 2;
    int res = 0;
    if (pA != pB || pA != pC) {
      ++res;
      if (pA == pB) {
        ++A;
        ++B;
      } else if (pA == pC) {
        ++A;
        ++C;
      } else if (pB == pC) {
        ++B;
        ++C;
      }
    }
    res += (3 * max({A, B, C}) - A - B - C) / 2;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int main() {
	int N, M, X;
	std::cin >> N >> M >> X;

	int grid[101]{};

	for (int i{}; i < M; ++i) {
		int ai;
		std::cin >> ai;
		grid[ai] = 1;
	}


	auto left = std::count(std::begin(grid), std::begin(grid) + X, 1);
	std::cout << std::min(left, M - left) << "\n";
	return 0;
}

Measured memory_bytes: 504
class binaryTreeNode:
    def __init__(self, x):
        self.val = x
        self.right = None
        self.left = None

n = int(input())
hashMap = {}
rootL = list(range(n))
index = 0
while index < n:
    inputL = list(map(int, input().split()))
    if not inputL[0] in hashMap:
        hashMap[inputL[0]] = binaryTreeNode(inputL[0])
    parent = hashMap[inputL[0]]
    if inputL[1] != -1:
        rootL.remove(inputL[1])
        if inputL[1] in hashMap:
            leftN = hashMap[inputL[1]]
            parent.left = leftN
        else:
            leftN = binaryTreeNode(inputL[1])
            hashMap[inputL[1]] = leftN
            parent.left = leftN
    if inputL[2] != -1:
        rootL.remove(inputL[2])
        if inputL[2] in hashMap:
            rightN = hashMap[inputL[2]]
            parent.right = rightN
        else:
            rightN = binaryTreeNode(inputL[2])
            hashMap[inputL[2]] = rightN
            parent.right = rightN
    index+=1

answerL = ['']*n
root = hashMap[rootL[0]]
def lookNode(parentV, node, sibling, depth):
    if node != None:
        answer = ''
        answer+='node '+str(node.val)+': '
        answer+='parent = '+str(parentV)+', '
        if sibling != None:
            answer+='sibling = '+str(sibling.val)+', '
        else:
            answer+='sibling = '+str(-1)+', '
        if node.right != None and node.left != None:
            answer+='degree = '+str(2)+', '
        elif node.right == None and node.left == None:
            answer+='degree = '+str(0)+', '
        else:
            answer+='degree = '+str(1)+', '
        answer+='depth = '+str(depth)+', '
        height = 0
        if node.right == None and node.left == None:
            height = 0
        else:
            height = max(lookNode(node.val, node.left, node.right, depth+1), lookNode(node.val, node.right, node.left, depth+1))+1
        answer+='height = ' +str(height)+', '
        if parentV == -1:
            answer+='root'
        elif node.right == None and node.left == None:
            answer+='leaf'
        else:
            answer+='internal node'
        answerL[node.val] = answer
        return height
    else:
        return 0
lookNode(-1, root, None, 0)
for ans in answerL:
    print(ans)



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }
 
int n, cap, cur, w[105], v[105];
ll dp[2][100005];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    cin >> n >> cap;
 
    for (int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
 
    for (int i = 1; i <= n; i++) {
        cur = i&1;
        for (int j = 0; j <= cap; j++) {
            if (j < w[i]) dp[cur][j] = dp[1-cur][j];
            else dp[cur][j] = max(dp[1-cur][j], dp[1-cur][j-w[i]] + v[i]);
        }
    }
 
    cout << dp[cur][cap] << '\n';
 
    return 0;
}

Measured memory_bytes: 1792
'use strict'

const main = arg => {
    var input = arg.trim().split("\n");
    const finalIndex = input.indexOf("-");
    input = input.slice(0, finalIndex);
    const mojiIndex = [];
    input.forEach((obj,i) => {
        if(obj.match(/[A-Za-z]/g)){
            mojiIndex.push(i);
        }
    });
    const loopNo = mojiIndex.length;
    const result = [];
    var firstIndex = 0;

    for(var i=0;i<loopNo;i++){
        var deck = input[firstIndex];
        const count = parseInt(input[firstIndex+1], 10);
        var shuffle = input.slice(firstIndex+2, firstIndex+2+count);
        firstIndex = firstIndex+2+count;

        shuffle.forEach(j => {
            const takeout = deck.slice(0, j);
            deck = deck.slice(j) + takeout;
        });
        result.push(deck);
    }

    console.log(result.join("\n"));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15840
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int N,M;
const int MAX_N=1e5,MAX_M=1e5;
char A[MAX_N+1],B[MAX_N+1],C[MAX_M+1],D[MAX_M+1];
const ll MOD=998244353;
int psmup[MAX_M+1],psmdown[MAX_M+1],lftmn,rigmn;
ll lpnt[MAX_M],rpnt[MAX_M],fact[MAX_N*3+1],ifact[MAX_N*3+1];
ll mpw(ll n,ll m){
	ll ret=1;
	while(m){
		if(m&1){
			ret*=n;
			ret%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return ret;
}
ll cmb(int n,int m){
	return fact[n]*ifact[m]%MOD*ifact[n-m]%MOD;
}
int main(){
	scanf("%d %d %s %s %s %s",&N,&M,A,B,C,D);
	fact[0]=1;
	REP(i,MAX_N*3){
		fact[i+1]=(i+1)*fact[i]%MOD;
	}
	ifact[MAX_N*3]=mpw(fact[MAX_N*3],MOD-2);
	for(int i=MAX_N*3-1;i>=0;i--){
		ifact[i]=(i+1)*ifact[i+1]%MOD;
	}
	ll ans=0;
	REP(q,2){
		REP(i,M){
			psmup[i+1]=psmup[i]+(C[i]=='1');
			psmdown[i+1]=psmdown[i]+(D[i]=='1');
		}
		lftmn=rigmn=0;
		REP(i,N){
			lftmn+=(A[i]=='1');
			rigmn+=(B[i]=='1');
		}
		if(lftmn==0 && rigmn==0 && psmup[M]==0 && psmdown[M]==0){
			ans=1;
			break;
		}
		if(psmup[M]>0 || psmdown[M]>0){
			REP(i,M){
				if(C[i]=='1' || D[i]=='1'){
					if(lftmn==0){
						if(psmup[i]==0 && psmdown[i]==0){
							lpnt[i]=1;
						}else{
							lpnt[i]=0;
						}
					}else{
						lpnt[i]=cmb(lftmn+psmup[i]+psmdown[i]-1,lftmn-1);
					}
					if(rigmn==0){
						if(psmup[M]-psmup[i+1]==0 && psmdown[M]-psmdown[i+1]==0){
							rpnt[i]=1;
						}else{
							rpnt[i]=0;
						}
					}else{
						rpnt[i]=cmb(rigmn+psmup[M]-psmup[i+1]+psmdown[M]-psmdown[i+1]-1,rigmn-1);
					}
				}
			}
			ll tmp=0,p2=1,inv2=mpw(2,MOD-2);
			REP(i,M){
				if(C[i]=='1' || D[i]=='1'){
					if(C[i]=='1' && D[i]=='1'){
						p2<<=1;
						p2%=MOD;
					}
					tmp+=p2*rpnt[i]%MOD;
					tmp%=MOD;
				}
			}
			REP(i,M){
				if(C[i]=='1' || D[i]=='1'){
					ans+=tmp*lpnt[i]%MOD;
					ans%=MOD;
					if(C[i]=='1' && D[i]=='1'){
						tmp*=inv2;
						tmp%=MOD;
					}
					tmp+=MOD-rpnt[i];
					tmp%=MOD;
				}
			}
		}
		swap(A,C);
		swap(B,D);
		swap(N,M);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n;
    cin >> n;
    int ans=inf;
    rep(i,50005){
        if(i*108/100==n) ans=i;
    }
    if (ans==inf) cout << ":(" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256