akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
char x[1000005];
int a=0,b=0,c=0,d=0,e,f,i,j,k,maxi=0;
int main(){
	fill(x,x+1000005,'A');
	scanf("%s",x);
int leng=strlen(x);
while(1){
if(a==leng){break;}
if(x[a]!='J'){
a++;
}else{
  while(1){
    if(x[a]=='J'){
      b++;
      a++;
    }else{
       break;
}}
while(1){
if(x[a]=='O'){
c++;
a++;
}else{
break;
}}
while(1){
if(x[a]=='I'){
d++;
a++;
}else{
break;
}}
if(b>=c && c<=d){
maxi=max(maxi,c);
}
b=0;
c=0;
d=0;
}
}
printf("%d\n",maxi);scanf("%d",&a);
return 0;
}

Measured memory_bytes: 1956
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    X = int(input())
    check = [i ** 5 for i in range(-5 * (10 ** 2), 5 * (10 ** 2))]
    for i in range(len(check) - 1):
        for j in range(i + 1, len(check)):
            if check[j] - check[i] == X:
                print(j - 500, i - 500)
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 9140
S = input()
M = 2019
dp = [0] * M
dp[0] = 1
t = 0
for i, s in enumerate(S[::-1]):
    t = (t + int(s) * (pow(10, i, M))) % M
    dp[t] += 1

r = 0
for d in dp:
    r += d * (d - 1) // 2

print(r)


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

using namespace std;

typedef pair<int, int> P;

#define MAX 1000000

int main()
{
	bool is_prime[MAX] = {false};
	for(int i = 3; i < MAX; i += 2) {
		is_prime[i] = true;
	}
	is_prime[2] = true;
	for(int i = 3; i * i < MAX; i += 2) {
		if(!is_prime[i]) continue;
		for(int j = i * 2; j < MAX; j += i) {
			is_prime[j] = false;
		}
	}

	while(1) {
		int N, P;
		multiset<int> set_sum_p;
		int first_p;
		int ans;

		scanf("%d %d", &N, &P);
		if(N == -1 && P == -1) break;

		for(int i = N + 1; i < MAX; i++) {
			if(!is_prime[i]) continue;
			first_p = i;
			break;
		}
		int a = first_p, b = first_p;
		while(a < MAX) {
			if(!is_prime[a]) {
				a++;
				continue;
			}
			if(set_sum_p.size() >= P) {
				multiset<int>::iterator it = set_sum_p.begin();
				for(int i = 1; i < P; i++) {
					it++;
				}
				if(a + first_p > *it) {
					ans = *it;
					break;
				}
			}
			b = first_p;
			while(b <= a) {
				if(!is_prime[b]) {
					b++;
					continue;
				}
				set_sum_p.insert(a + b);
				b++;
			}
			a++;
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 2184
#include <iostream>
#define llint long long
#define mod 998244353

using namespace std;

llint fact[300005], fact_i[300005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 300005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 300005; i++){
		fact_i[i] = pow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_i[k], ret %= mod;
	ret *= fact_i[n-k], ret %= mod;
	return ret;
}

llint N, A, B, K;

int main(void)
{
	make_fact();
	cin >> N >> A >> B >> K;
	
	llint ans = 0;
	for(int y = 0; y <= N; y++){
		if(K - B*y < 0 || (K - B*y) % A) continue;
		llint x = (K - B*y) / A;
		if(x < 0 || x > N) continue;
		//cout << x << " " << y << endl;
		llint tmp = comb(N, x);
		tmp *= comb(N, y);
		tmp %= mod;
		ans += tmp, ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(1000000)

N=int(input())

B=[[]for i in range(N+1)]

F=[10**10 for i in range(N+1)]
F[1]=0
S=[10**10 for i in range(N+1)]
S[N]=0

for i in range(N-1):
    a,b=map(int,input().split())
    B[a].append(b)
    B[b].append(a)
    
#print(B)
def dfsF(f):
    for i in B[f]:
        if F[i]==10**10:
            F[i]=F[f]+1
            dfsF(i)
dfsF(1)

def dfsS(s):
    for i in B[s]:
        if S[i]==10**10:
            S[i]=S[s]+1
            dfsS(i)
dfsS(N)
#print(F)
#print(S)
Fennec=0
Snuke=0
for i in range(1,N+1):
    if F[i]<=S[i]:
        Fennec+=1
    else:
        Snuke+=1
if Fennec>Snuke:
    print("Fennec")
else:
    print("Snuke")


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll a, b;

ll calc(ll x) {
    return floor((double) a * x / b) - a * floor((double) x / b);
}

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

    ll n; cin >> a >> b >> n;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll x = min(n, b - 1);
    ll ans = 0;
    chmax(ans, calc(x));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin >> n >> k;
	vl p(n + 1), c(n + 1);
	for (ll i = 1; i <= n; i++)
		cin >> p[i];
	for (ll i = 1; i <= n; i++)
		cin >> c[i];
	ll ans = -2e13;
	for (ll i = 1; i <= n; i++) {
		ll cur = p[i];
		ll cvalue, csize;
		cvalue = csize = 0;
		ll j = i;
		do {
			j = p[j];
			cvalue += c[j];
			csize++;
		} while (j != i);
		//cout << cvalue << "\n";
		ll rem, cbest, rem1, cbest1;
		rem = rem1 = k;
		cbest = cbest1 = 0;
		if (cvalue > 0 && k >= csize) {
			rem = k;
			cbest = 0;
			cbest += (k / csize) * cvalue;
			rem %= csize;
			rem1 = k;
			cbest1 = 0;
			cbest1 += (k / csize - 1) * cvalue;
			rem1 %= csize;
			rem1 += csize;
		}
		ll ma = -2e13;
		ll ma1 = -2e13;
		if (rem == 0)
			ma = 0;
		if (rem1 == 0)
			ma1 = 0;
		ll t = 0;
		j = i;
		ll curr = 0;
		do {
			j = p[j];
			curr += c[j];
			t++;
			if (t <= rem)
				ma = max(ma, curr);
			if (t <= rem1)
				ma1 = max(ma1, curr);
		} while (j != i);
		cbest += ma;
		cbest1 += ma1;
		//cout << cbest << " " << cbest1 << "\n";
		ans = max(ans, cbest);
		ans = max(ans, cbest1);
		//cout << cbest << " " << cbest1 << "\n";
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <unordered_set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 H, W;
  cin >> H >> W;
  vvi D(H, vi(W));
  i64 r, c;
  REP(0, H, r) {
    REP(0, W, c) {
      cin >> D[r][c];
    }
  }
  REP(0, H, r) {
    REP(0, W, c) {
      i64 b;
      cin >> b;
      D[r][c] -= b;
      if(D[r][c] < 0)
	D[r][c] *= -1;
    }
  }

  //  using us = unordered_set<i64>;
  //vector<vector<us>> S(H, vector<us>(W));
  vector<vector<vector<int>>> F(H, vector<vector<int>>(W));

  //i64 L = (H + W) / 2;

  i64 LIM = 161*81, d;
  F[0][0].resize(LIM, 0);
  F[0][0][D[0][0]] = 1;
  //cout << D[0][0] << endl;
  
  // S[0][0].insert(D[0][0]);
  REP(0, H, r) {
    REP(0, W, c) {
      /*
      if(r + c > L) {
	continue;
      }
      */

      if(r != 0 || c != 0) {
	F[r][c].resize(LIM, 0);
      }
      
      //i64 ct = 0;
      //cout << r << " " << c << endl;
      if(c > 0) {
	REP(0, LIM, d) {	  
	  if(F[r][c-1][d] == 1) {
	    i64 d0 = abs(d + D[r][c]), d1 = abs(d - D[r][c]);
	    F[r][c][d0] = 1;
	    F[r][c][d1] = 1;
	    //++ct;
	  }
	}
      }
      if(r > 0) {
	REP(0, LIM, d) {
	  if(F[r-1][c][d] == 1) {
	    i64 d0 = abs(d + D[r][c]), d1 = abs(d - D[r][c]);
	    F[r][c][d0] = 1;
	    F[r][c][d1] = 1;
	    //++ct;
	  }
	}
      }
      //cout << ct << endl;
      //cout << r << " " << c << " " << sz(S[r][c]) << endl;
    }
    //cout << "line " << r << endl;
  }

  REP(0, LIM, d) {
    if(F[H-1][W-1][d] != 0) {
      cout << d << endl;
      return 0;
    }
  }
  
  return 0;
}


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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 100000 + 5;

LL queries[MAXN], t[MAXN], answer[MAXN];

int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  static LL stack[MAXN];
  int top = 0;
  stack[++ top] = n;
  For(i, 1, q) {
    scanf("%lld", &queries[i]);
    while (top && stack[top] >= queries[i]) {
      -- top;
    }
    stack[++ top] = queries[i];
  }
  LL all = 0;
  t[top] = 1;
  Rep(i, top, 1) {
    LL cur = stack[i];
    int pos = i - 1;
    while (pos) {
      int x = std::upper_bound(stack + 1, stack + pos + 1, cur) - 1 - stack;
      if (!x) {
        break;
      }
      t[x] += cur / stack[x] * t[i];
      cur %= stack[x];
      pos = x - 1;
    }
    answer[1] += t[i], answer[cur + 1] -= t[i];
  }
  For(i, 1, n) {
    printf("%lld\n", all + (answer[i] += answer[i - 1]));
  }
  return 0;
}

Measured memory_bytes: 4864
res = 10**30
a,b,c,x,y = map(int,input().split())
for i in range(0,max(x,y)+1):
    # ABを2*iまい買う
    tmp = 2 * i * c
    xx,yy = x - i, y - i
    tmp += max(0,xx) * a
    tmp += max(0,yy) * b
    res = min(res, tmp)
print(res)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    int K; //ケーキの種類
    int c[10000];
    while(true){
        cin >> K;
        if(K == 0) break;

        int cnt = 0; //ケーキの販売数
        for(int i = 0; i < (K * (K - 1) / 2); i++){
            cin >> c[i];
            cnt += c[i];
        }
        cout << cnt / (K - 1) << endl;
    }
}



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


int main(){
    int a[3], ans = 0;
    cin >> a[0] >> a[1] >> a[2];
    int par = (a[0]&1) + (a[1]&1) + (a[2]&1);

    if(par == 1)
    {
        rep(i,3) if(a[i]%2 == 0) a[i]++;
        ans++;
    }
    else if(par == 2)
    {
        rep(i,3) if(a[i]&1) a[i]++;
        ans++;
    }

    int maxi = max({a[0], a[1], a[2]});
    rep(i,3){
        ans += (maxi - a[i])/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,base=0,cou=0,out=0;
    char ive[10];
    cin>>n;
    for(int i=0;i<n;i++){
        cou=0,out=0,base=0;
        for(;;){
            cin>>ive;
            if(ive[0]=='H'&&ive[1]=='I')base++;
            if(ive[0]=='H'&&ive[1]=='O'){
                cou+=base+1;
                base=0;
            }
            if(ive[0]=='O')out++;
            if(base==4){
                base=3;
                cou++;
            }
            if(out==3)break;
        }
        cout<<cou<<endl;
    }
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 3002;
const int mo = 998244353;

int n, m, ans = 0;
long long f[maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n >> m;

    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;

        f[0] = i+1;
        if (v <= m) {
            ans = (ans + f[m-v] * (n-i) % mo) % mo;
            for (int j = m; j >= v; --j)
                f[j] = (f[j] + f[j-v]) % mo;
        }
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import           Data.Array (Array, (!))
import qualified Data.Array as Array

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  if n == 0 then return ()
  else do
  arr <- Array.listArray (0, n-1) <$> replicateM n readInt
  k <- readInt
  print $ solve arr k 0 0 (n-1)
  main

solve :: Array Int Int -> Int -> Int -> Int -> Int -> Int
solve arr target count l r
  | l > r             = count
  | arr ! m == target = count+1
  | arr ! m <  target = solve arr target (count+1) (m+1) r
  | otherwise         = solve arr target (count+1) l (m-1)
  where m = (l + r) `div` 2

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"

Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a;
  string b;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    if(b=="Y"){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
}


  
    
  
    

Measured memory_bytes: 256
#include<stdio.h>

#define N 10000
#define INF 1000000000

int d[N], color[N], m[500000][3];
int  snm = 0, nm;

void dijkstra(int s){
    int i;
    color[s] = 1;

    while(color[s] != 0){
        color[s] = 0;
        for(i = 0; i < snm; i++){
            if(d[m[i][1]] > d[m[i][0]] + m[i][2]){
                d[m[i][1]] = d[m[i][0]] + m[i][2];
                color[s] = 1;
            }
        }
    }

    for(i = 0; i < nm; i++) printf("%d %d\n",i,d[i]);
}

int main(){
    int i, j, k, u;

    scanf("%d", &nm);

    for(i = 0; i < nm; i++){
        d[i] = INF;
        scanf("%d %d", &u, &k);
        for(j = 0;j < k; j++){
            m[snm][0] = u;
            scanf("%d %d", &m[snm][1], &m[snm][2]);
            snm++;
        }
    }

    d[0] = 0;

    dijkstra(u);

    return 0;
}




Measured memory_bytes: 7576
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	int K;
	cin >> K;
	string s;
	cin >> s;
	if((int)s.size() > K){
		s = s.substr(0,K);
		s += "...";
	}
	out(s);
}

Measured memory_bytes: 3632
#include <stdio.h>
 
int main() {
  int L, R, d, s = 0;
  scanf("%d %d %d", &L, &R, &d);
 
  for(int i = L; i <= R; i++) {
    if(i % d == 0) {
      s++;
    }
  }
  printf("%d", s);
  return 0;
}

Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
string s, t;
	
int main(){
	IOS
	cin >> s >> t;
	bool sama=1;
	int c=s.length(), d=t.length();
	for(int i=0;i<min(c, d);i++){
		if(s[i]!=t[i]){
			sama=0;
			break;
		}
	}
	if(sama){
		if(s.length()<t.length()){
			cout << "Yes" << '\n';
		}
		else{
			cout << "No" << '\n';
		}
		return 0;
	}
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if(s[0]<t[0]){
		cout << "Yes" << '\n';
	}
	else{
		cout << "No" << '\n';
	}
}


Measured memory_bytes: 3628
N,Q = map(int,input().split())
str = input()
ac_list = [0]
for i in range(1,N):
  if str[i-1:i+1] == "AC":
    ac_list.append(ac_list[-1]+1)
  else:
    ac_list.append(ac_list[-1])
    
for i in range(Q):
  l,r = map(int,input().split())
  print(ac_list[r-1]-ac_list[l-1])

Measured memory_bytes: 6180
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,M = two_int()

temp = N/M

if temp.is_integer():
    print(int(temp))
else:
    print(int(temp)+1)

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

int used[20] = {};

double ans = 0.0;

void func(int now, int last, int n, int m, vector<vector<double> >& table){

    if(now == m){

        /*for(int i = 0; i < n; i++){
            cout << used[i] << " ";
        }cout << endl;
        */

        vector<int> array;
        for(int i = 0; i < n; i++){
            if(used[i] == 1) array.push_back(i);
        }

        /*for(int i = 0; i < m; i++){
            cout << array[i] << " ";
        }cout << endl;
        */

        double temp = 0.0;
        for(int i = 0; i < m-1; i++){
            for(int j = i+1; j < m; j++){
                temp += table[array[i]][array[j]];
            }
        }
        //cout << temp << endl;

        if(ans < temp) ans = temp; 
    }

    for(int i = last + 1; i < n; i++){
        used[i] = 1;
        func(now + 1, i, n, m, table);
        used[i] = 0;
    }
}

int main(void){

    int n, m; cin >> n >> m;
    double l[30];
    double a[30];
    double b[30];

    for(int i = 0; i < n; i++){
        cin >> l[i] >> a[i] >> b[i];
    }
     
    vector<vector<double> > table(22, vector<double>(22, 0.0));


    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            table[i][j] = (a[i] - a[j])*(a[i] - a[j]) + (l[i] - l[j])*(l[i] - l[j]) + (b[i] - b[j])*(b[i] - b[j]);
        }
    }

    /*for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout << table[i][j] << " ";
        }cout << endl;
    }*/

    func(0, -1, n, m, table);

    cout << fixed;
    cout << setprecision(10);
    cout << ans << endl;
    
}

Measured memory_bytes: 3284
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;




	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = max({a*c,a*d,b*c,b*d});
  cout << ans << endl;
}


Measured memory_bytes: 3632
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n, k; cin >> n >> k;
  vector <int> have(n + 1, 0);
  for(int i = 0; i < k; i++) {
    int d; cin >> d;
    while(d--) {
      int x; cin >> x;
      have[x] = 1;
    }
  }
  cout << count(have.begin(), have.end(), 0) - 1 << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 3632
from functools import reduce
from math import gcd

N, *A = map(int, open(0).read().split())

C = [0] * (10 ** 6 + 10)
for a in A:
    C[a] += 1

if reduce(gcd, A) != 1:
    print("not coprime")

elif all(sum(C[i::i]) <= 1 for i in range(2, len(C))):
    print("pairwise coprime")

else:
    print("setwise coprime")

Measured memory_bytes: 121888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  int x,a; cin >> x >> a;
  cout << ((x<a ) ? 0 : 10) << endl;
  return 0;
}



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


int main() {
  int R ; 
  cin >> R ; 
  
  if(R >=2800){
    cout << "AGC" << endl ; 
  }
  else if(R >=1200 && R < 2800){
    cout << "ARC" << endl ;  
  }
  else {
    cout << "ABC" << endl ; 
  }
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <iostream>
#define ll long long
using namespace std;
char s[105];
int main() {
	scanf("%s", &s);
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (i % 2 == 0 && s[i] == 'L') {
			printf("No\n");
			return 0;
		}
		if (i % 2 == 1 && s[i] == 'R') {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

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

#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> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e9 + 9;
const ll SIZE = 5e5 + 5;
const ll MOD  = 1e9 + 7;


int main() { speedhack()

	char c;
	cin >> c;
	if (c > 96)
		cout << 'a';
	else
		cout << 'A';

	return 0;
}

Measured memory_bytes: 3620
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

const ll MOD = 1000000007;

int main(){
    ll n,k; cin >> n >> k;
    ll ans = 0;
    ll ma = 0, mi = 0;
    rip(i,n+1,0){
        ma += n-i;
        mi += i;
        if(i < k-1) continue;
        ans += ma-mi+1;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
    ArrayList<Integer> arr = new ArrayList<>() ;
    for(int i = 0 ; i < 3 ; i++){
      arr.add(scan.nextInt());
    }
 
    System.out.println(Collections.max(arr,null) -Collections.min(arr, null));
    
  }
}


Measured memory_bytes: 22484
use std::io::Read;
use std::cmp;

fn main() {
    const INF: i64 = 1 << 60;

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();

    let mut h: Vec<i64> = Vec::with_capacity(n + 1);
    h.push(0);
    for _ in 0..n {
        h.push(iter.next().unwrap().parse().unwrap());
    }

    let mut dp: Vec<Vec<i64>> = vec![vec![INF; n + 1]; n + 1];
    dp[0][0] = 0;

    for i in 1..(n + 1) {
        for j in 0..i {
            for k in 0..(j + 1) {
                let d: i64 = dp[j][k] + cmp::max(0, h[i] - h[j]);
                dp[i][k + 1] = cmp::min(dp[i][k + 1], d);
            }
        }
    }

    let mut ans: i64 = INF;
    for i in 0..(n + 1) {
        ans = cmp::min(ans, dp[i][n - k]);
    }

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

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

int main() {
    int X;
    cin >> X;
    int maxValue = 1;
    for (int i = 1; i <= X; i++) {  // O(N^2) -> 1000 * 1000 = 10^6
        for (int j = 2; j <= X; j++) {
            if (pow(i, j) <= X) {
                maxValue = max(maxValue, (int)pow(i, j));
            }
        }
    }

    cout << maxValue << endl;

    return 0;
}


Measured memory_bytes: 4160
#include <iostream>
#include <algorithm>
#define maxn 3000000
using namespace std;
int n,m=0,e,ans=maxn;
char s[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>s;
	for(int i=0;i<n;i++)
		e+=s[i]=='E';
	ans=e-(m=s[0]=='E');
	for(int i=1;i<n;i++){
		m+=s[i]=='E';
		ans=min(ans,i+1+e-2*m);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
//A smoothe sea never made a skilled sailor.
//KEEP IT SIMPLE STUPID
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<n;i++)
#define FORr(a,b) for(ll i=a;i<=b;i++)

int main()
{
    ll k,n;
  cin>>k>>n;
  vll v(n);
  FOR(n)
    cin>>v[i];
  
  vll len(n);
  for(ll i=1,t=0;i<n;i++,t++)
  {
      len[t]=v[i]-v[i-1];
  }
  
  len[n-1]=(k-v[n-1]+v[0]);
  //print(len);
  //cout<<"\n";
  sort(len.begin(),len.end());
  ll sum=0;
  for(ll i=0;i<n-1;i++)
  {
      sum+=len[i];
  }
  cout<<sum;
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,i,j,sum,a,b,f=0;
    cin>>x>>y;
    for(i=0;i<=x;i++)
    {
        a=i;
        b=x-i;
        sum=2*a+4*b;
        if(sum==y)
        {

            f=1;
           break;

        }

    }
    if(f==1)
         cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);
  if(A>B){
    printf("%d", 2*A-1);
  }
  else if(A==B){
    printf("%d", 2*A);
  }
  else{
    printf("%d", 2*B-1);
  }
  return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int main()
{
    ll y,n;
    scanf("%lld%lld",&n,&y);
    for(ll i=0;i*10000<=y;i++)
    {
        for(ll j=0;(i*10000+j*5000)<=y;j++)
        {
            ll k=y-(i*10000+j*5000);
            if(k%1000==0&&(i+j+k/1000)==n){
                printf("%lld %lld %lld\n",i,j,k/1000);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
// binary search tree 2
// input command "insert", "print", "find" or "delete", print is output in-order tree walk and pre-order tree walk, find is output "yes" or "no"#include<stdio.h>
#include<iostream>
#include<string>
typedef struct node{
  struct node *left, *right, *parent;
  int key;
}node;
node *T;
void Insert(int);
void Inorder(node*);
void Preorder(node*);
int Find(int);
void Delete(int);
node* Successor(node*);
node* Minimum(node*);
node* Maximum(node*);
void Free(node*);
int main(){
  int n, i, key;
  std::string func, ins="insert", pri="print", fin="find", del="delete";
  T = new node;
  T->parent = T->left = T->right = NULL, T->key = -1;
  std::cin >> n;
  for(i=0; i<n; i++){
    std::cin >> func;
    if(func == ins){
      std::cin >> key;
      Insert(key);
    }
    else if(func == pri){
      Inorder(T); std::cout << "\n";
      Preorder(T); std::cout << "\n";
    }
    else if(func == fin){
      std::cin >> key;
      std::cout << (Find(key) ? "yes\n" : "no\n");
    }
    else if(func == del){
      std::cin >> key;
      Delete(key);
    }
  }
  Free(T);
  return 0;
}
void Inorder(node* x){
  if(x != NULL){
    Inorder(x->left);
    std::cout << " " << x->key;
    Inorder(x->right);
  }
}
void Preorder(node* x){
  if(x != NULL){
    std::cout << " " << x->key;
    Preorder(x->left);
    Preorder(x->right);
  }
}
void Free(node* x){
  if(x != NULL){
    Free(x->left);
    Free(x->right);
    delete x;
  }
}
void Insert(int key){
  node *x, *y, *R;
  if(T->key == -1){
    T->key = key;
    return;
  }
  R = new node;
  R->key = key;
  R->parent = R->left = R->right = NULL;
  x = T;
  while(x != NULL){
    y = x;
    if(key < x->key) x = x->left;
    else x = x->right;
  }
  R->parent = y;
  if(R->key < y->key) y->left = R;
  else y->right = R;
}
int Find(int key){
  node *x;
  for(x=T; x != NULL;){
    if(x->key > key) x = x->left;
    else if(x->key < key) x = x->right;
    else return 1;
  }
  return 0;
}
void Delete(int key){
  node *x, *y, *z;
  for(x=T; x != NULL;){
    if(x->key > key) x = x->left;
    else if(x->key < key) x = x->right;
    else break;
  }
  z = x;
  if(z->left == NULL || z->right == NULL) y = z;
  else y = Successor(z);
  if(y->left != NULL) x = y->left;
  else x = y->right;
  if(x != NULL) x->parent = y->parent;
  if(y->parent == NULL) T = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
}
node* Successor(node* x){
  node *y;
  if(x->right != NULL) return Minimum(x->right);
  y = x->parent;
  while(y != NULL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
node* Minimum(node* x){
  while(x->left != NULL) x = x->left;
  return x;
}
node* Maximum(node* x){
  while(x->right != NULL) x = x->right;
  return x;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};






int main(){
  
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a+1 > 2*c){
    for(int i = a;i < a+c;i++)cout << i << endl;
    for(int i = b-c+1;i <= b;i++)cout << i << endl;
  }else{
    for(int i = a;i <= b;i++)cout << i << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 55
using namespace std;
int n,m,q,st=maxn,ed=0,sum;
int a[maxn],b[maxn],c[maxn],d[maxn],p[15];
void dfs(int step){
	int i,j;
	if(step==ed+1){
		int t=0;
		for(j=1;j<=q;j++)
			if(p[b[j]]-p[a[j]]==c[j])t+=d[j];
		sum=max(sum,t);
		return;
	}
	for(i=p[step-1];i<=m;i++){
		p[step]=i;
		dfs(step+1);
	}
}
int main(){
	int i;
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=q;i++)scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]),st=min(st,a[i]),ed=max(ed,b[i]);
	ed=ed-st+1,st=1,p[0]=1;
	dfs(1);
	printf("%d\n",sum);
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n+m==0) {
				break;
			}
			int[] a = new int[n];
			int[] b = new int[m];
			int sum_a = 0;
			int sum_b = 0;
			for(int i=0;i<n;i++) {
				a[i] = sc.nextInt();
				sum_a += a[i];
			}
			for(int i=0;i<m;i++) {
				b[i] = sc.nextInt();
				sum_b += b[i];
			}
			if ((sum_b-sum_a+100)%2 == 1) {
				System.out.println(-1);
				continue;
			}
			Arrays.sort(a);
			Arrays.sort(b);
			int i=0,j=0;
			boolean flag = false;
			while(i < n && j < m) {
				//System.out.println(a[i] + "," + b[j] + "," + (sum_b-sum_a));
				int diff1 = a[i] - b[j];
				int diff2 = (sum_a-sum_b)/2;
				if (diff1 == diff2) {
					flag = true;
					break;
				}else if(diff1 < diff2) {
					i++;
				}else{
					j++;
				}
			}
			if (flag) {
				System.out.println(a[i] + " " + b[j]);
			}else{
				System.out.println(-1);
			}
		}
	}

}

Measured memory_bytes: 21032
import itertools


def distance(Y, Z):
    result = 0
    for y, z in zip(Y, Z):
        result += (int(y) - int(z)) ** 2
    result = result ** 0.5
    return result


N, _ = [int(i) for i in input().split()]
X = [input().split() for _ in range(N)]


ans = 0
for Y, Z in itertools.combinations(X, 2):
    if distance(Y, Z).is_integer():
        ans += 1

print(ans)


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

#define M 1000001
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5; //????????°??¨?????????
  }
  return sum;
}

int h1(long long key){
  int h1;
  h1 = key % M;
  //if(h1<0)printf("h1 = %d\n",h1);
  return h1;
}
int h2(long long key){
  int h2;
  h2 = 1 + key % (M - 1);
  //if(h2<0)printf("h2 = %d\n",h2);
  return h2;
}

int find(char str[]){
  int i=0,j;
  long long k;
  
  k = getKey(str);
  while(1){
    j = (h1(k) + i * h2(k))%M;
    if (strcmp(H[j],str)==0) return j;
    else if(H[j][0] == '\0' || i >= M) return 0;
    else i++;
  }
}

int insert(char str[]){
  long long i=0,j;
  long long k;
  
  k = getKey(str);
  while(1){
    j = (h1(k) + i * h2(k))%M;
    
    //printf("str=%s k=%lld %lld %s\n",str,k,j,H[j]);

    if(H[j][0]=='\0'){
      strcpy(H[j],str);
      return j;
    }
    else i++;
  }
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    }
    
    else {
      if (find(str)){
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }
    
  }
  return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	string s; cin >> s;
	int sum = 700;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o')sum += 100;
	}
	cout << sum;

	cout << endl;
	return 0;
}

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


using namespace std;



int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a,b,c;
    cin>>a>>b>>c;
    
    if((a==b && b!=c) || (b==c && c!=a) || (a==c && c!=b))
    {
    	cout<<"Yes"<<endl;
	}
	else 
	cout<<"No"<<endl;
    

    	
	return 0;

}

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

int main(){
    int n,a;
    int ma =0;
    int ma_2=0;
    cin >> n;
    vector <int> vec(n);
    rep(i,n) cin >> vec[i];
    vector <int> vec2(n);
    vec2=vec;
    sort(vec2.begin(),vec2.end());
    reverse(vec2.begin(),vec2.end());
    int ma1=vec2[0];
    int ma2=vec2[1];
    rep(i,n){
        if(vec[i]==ma1) cout << ma2 << endl;
        else cout << ma1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
a, b, x = map(int, input().split())

import math

if x/a >= a*b/2:
    h = 2*(a*b - x/a)/a
    print(math.degrees(math.atan(h/a)))
else:
    h = 2*(x/a)/b
    print(math.degrees(math.atan(b/h)))

Measured memory_bytes: 38256
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int n, cnt, mcnt = 0;
	scanf("%d", &n);
	int* a = calloc(n, sizeof(int));
	for (size_t i = 0; i < n; i++)
	{
		scanf("%d", a + i);
	}

	cnt = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (a[i] == cnt+1)
		{
			cnt++;
		}
	}
	if (cnt)
	{
		printf("%d", n - cnt);
	}
	else
	{
		printf("-1");
	}

}




Measured memory_bytes: 896
N,A,B=map(int,input().split());M=998244353;P=N+1;f=1;F=[1]*P;I=[1]*P;z=0;R=range
for n in R(1,P):F[n]=f=f*n%M
I[N]=i=pow(f,M-2,M)
for n in R(N,1,-1):I[n-1]=i=i*n%M
for k in R(min(A+1,N-B)if N-B-A else A+1):Q=N-B-k-1;z+=(B-k)*F[B+k-1]*I[B]*I[k]*F[Q+A-k]*I[Q]*I[A-k]
print(z%M if B else 1)

Measured memory_bytes: 190616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
	public static HashSet<Integer> r= new HashSet<Integer>();;
	public static void main(String[] args) throws IOException {
		FastScanner in= new FastScanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		
		String s= in.next();
		if(s.length()<=3) {
			System.out.println("No");
			return;
		}
		if(s.substring(0, 4).equals("YAKI")) System.out.println("Yes");
		else System.out.println("No");
			
		
	}
	static class p implements Comparable<p>{
		int x;
		int y;
		public p(int a, int b) {
			x=a;
			y=b;
		}
		public int compareTo(p o) {
			return this.x-o.x;
		}
	}
	static class FenwickTree {
		long[] ft;
		public FenwickTree(int n) {
			ft = new long[n + 1];
		}

		int rsq(int b) {
			int sum = 0;
			for (; b > 0; b -= (b & (-b)))
				sum += ft[b];
			return sum;
		}

		int rsq(int a, int b) {
			return rsq(b) - (a == 1 ? 0 : rsq(a - 1));
		}

		void update(int k, int v) {
			for (; k < ft.length; k += (k & (-k)))
				ft[k] += v;
		}
	}
	public static long gcd(long a, long b) {
		return b==0 ? a: gcd(b, a%b);
	}
	public static long lcm(long a, long b) {
		return a*b/ gcd(a,b);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define SIZE 2010
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, x, y;

int main() {
	io(); cin >> n >> x >> y;
	vector<int> ans(n);
	//ans[1]++;
	rep(i, 1, n) {
		rep(j, (i + 1), n) {
			if (i <= x && j <= x) ans[j - i]++;
			else if (i >= y && j >= y) ans[j - i]++;
			else if (i <= x && j <= y) ans[min(j - i, y - j + 1 + x - i)]++;
			else if (i <= x && j > y) ans[j - i + x - y + 1]++;
			else if (i <= y && j > y) ans[min(j - i, i - x + 1 + j - y)]++;
			else ans[min(j - i, i - x + 1 + y - j)]++;
		}
	}
	rep(i, 1, (n - 1)) cout << ans[i] << '\n';
}

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

using namespace std;

int main() {
    string str;
    int ans = 0;

    cin >> str;

    for (int i=0; i<4; i++) {
        if (str[i] == '2') {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {

	long long A, B, K;

	cin >> A >> B >> K;

	if (K >= A) {
		if (K - A >= B) {
			A = 0;
			B = 0;
		}
		else {
			B -= K - A;
			A = 0;
			
		}
	}
	else {
		A -= K;
	}

	cout << A << ' ' << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL A, B, C, X, Y;

int main(void)
{
	cin >> A >> B >> C >> X >> Y;
	LL ans = LLONG_MAX;
	for (int i = 0; i <= max(X, Y); ++i) {
		ans = min(ans, C * 2 * i + A*max(0LL, X - i) + B*max(0LL, Y - i));
		//++i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256