akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  bool ans=false;
  if(A==7){
    if(B==5){
      if(C==5){
        ans=true;
      }
    }
  }
  if(A==5){
    if(B==5){
      if(C==7){
        ans=true;
      }
    }
    else if(B==7){
      if(C==5){
        ans=true;
      }
    }
  }
  if(ans){
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9;
const long double PI=acos(-1);

map<ll,int>mp;

ll po(ll x,int y){
    ll res=1;
    for(int i=0;i<y;i++){
        res*=x;
        res%=MOD;
    }
    return res;
}

void f(int x){
    map<ll,int>s;
    for(int i=2;i*i<=x;i++){
        int tmp=0;
        while(x%i==0){
            tmp++;
            x/=i;
        }
        if(tmp){
            s[i]=tmp;
        }
    }
    if(x>=2){
        s[x]++;
    }
    for(auto i : s){
        mp[i.fi]=max(i.se,mp[i.fi]);
    }
}

void solve(int T){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(x&1 && i&1)ans++;
    }
    cout<<ans<<"\n";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}

/*
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9;
const long double PI=acos(-1);

map<ll,int>mp;

ll po(ll x,int y){
    ll res=1;
    for(int i=0;i<y;i++){
        res*=x;
        res%=MOD;
    }
    return res;
}

void f(int x){
    map<ll,int>s;
    for(int i=2;i*i<=x;i++){
        int tmp=0;
        while(x%i==0){
            tmp++;
            x/=i;
        }
        if(tmp){
            s[i]=tmp;
        }
    }
    if(x>=2){
        s[x]++;
    }
    for(auto i : s){
        mp[i.fi]=max(i.se,mp[i.fi]);
    }
}

void solve(int T){
    int n;
    cin>>n;
    vector<int>a(n);
    cin>>a[0];
    ll x=a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        f(a[i]);
    }
    ll ans=1;
    for(auto i:mp){
        ans=((ans%MOD) * (po(i.fi,i.se)%MOD))%MOD;
    }
    ll final_ans=0;
    for(int i=0;i<n;i++){
        final_ans+=(ans/a[i]);
        final_ans%=MOD;
    }
    cout<<final_ans<<"\n";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}
*/


Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int b1,b2,b3;
	scanf("%d %d %d",&b1,&b2,&b3);
	if(b1==1 && b2==1 || b3==1) printf("Open\n");
	else printf("Close\n");
	return 0;
}

Measured memory_bytes: 2616
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <unordered_map>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 100000;

unsigned long long a[1 + MAXN], b[1 + MAXN];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    unsigned long long answer = 0, add = 0;
    for (int i = n; i >= 1; i--) {
        unsigned long long value = a[i] + add;
        if (value % b[i])
            add += (b[i] - value % b[i]);
    }
    cout << add << "\n";
    return 0;
}


Measured memory_bytes: 1792
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int n; cin>>n;
   string s;

   unordered_set<string> st;
   for(int i = 0; i < n; i++){
       cin>>s;
       st.insert(s);
   }

   cout<<st.size();

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 17748
#include <stdio.h>

int main(){
	int i,n,in5;
	while(1){
		in5 = 0;
		scanf("%d",&n);
		if(!n) break;
		while(1){
			if(n < 5) break;
			else in5 += n / 5;
			n /= 5;
		}
		printf("%d\n",in5);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    char old=0, c;
    int ans=-1;
    while(cin>>c){
        ans+=c!=old;
        old=c;
    }
    cout<<ans;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

typedef struct indexVal{
  int64 val;
  int index;
} node;

typedef struct deque{
  node *a;
  int front;
  int last;
  int len;
} deque;

deque* newDeque(int len){
  deque *d=(deque *)calloc(1,sizeof(deque));
  d->a=(node *)calloc(len,sizeof(node));
  d->front=d->last=0;
  d->len=len;
  return d;
}

void push_back(deque *d,node v){
  d->a[d->last++]=v;
  d->last%=d->len;
}

node pop_front(deque *d){
  node t=d->a[d->front++];
  d->front%=d->len;
  return t;
}

node pop_back(deque *d){
  d->last=(d->last+d->len-1)%d->len;
  return d->a[d->last];
}

node get_front(deque *d){
  return d->a[d->front];
}

node get_back(deque *d){
  return d->a[(d->last+d->len-1)%d->len];
}

int isEmpty(deque *d){
  return d->front==d->last;
}

#define POS(i,j) ((i)*(k+1)+(j))

void run(void){
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  int *a=(int *)calloc(n+1,sizeof(int));
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  deque **deq=(deque **)calloc(k,sizeof(deque *));
  for(i=0;i<k;i++) deq[i]=newDeque(m+1);
  push_back(deq[0],(node){0,n});
  int64 ans=0;
  for(i=1;i<=n;i++){
    for(int j=MIN(k,i);j>=1;j--){
      node t=get_front(deq[j-1]);
      while(t.index<i-m){
	pop_front(deq[j-1]);
	t=get_front(deq[j-1]);
      }
      int64 local=(int64)j*a[i]+t.val;
      if(j==k){
	ans=MAX(ans,local);
      } else {
	while(!isEmpty(deq[j])){
	  node t=get_back(deq[j]);
	  if(t.val>local) break;
	  pop_back(deq[j]);
	}
	push_back(deq[j],(node){local,i});
      }
    }
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 11776
#!/usr/bin/perl
#abc086_b.pl
#Sun Jan 21 21:02:04 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;

my @temps = split(" ",$temp);

my $num = join("",@temps);

my $n = 1;

my %ans;

while ($n < 320){
	$ans{$n*$n}=1;
	$n++;
}

if (exists($ans{$num})){
	print "Yes\n";
}else{
	print "No\n";
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[2000];
int main(){
	int n,m;cin>>n>>m;
	int cnt=0;
	rep(i,n){
		scanf("%d",&a[i]);
		cnt+=a[i];
	}
	int e=0;
	rep(i,n){
		if(a[i]*4*m>=cnt)e++;
	}
	if(e>=m)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int m,f,r;
  while(1){
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1)break;
    if(m == -1 || f == -1) {cout << "F"<< endl;
continue;}
    if(m + f >= 80){cout << "A" <<endl;
    continue;}
    if(m + f >= 65 && m + f < 80) {cout << "B" << endl;
    continue;}
    if(m + f >= 50 && m + f < 65){ cout << "C" << endl;
    continue;}
    if(m + f >= 30 && m + f < 50 && r  >= 50) {cout << "C"<<endl;
    continue;}
    if(m + f >= 30 && m + f < 50 && r  < 50 ){ cout << "D" << endl;
    continue;}
    if(m + f < 30)cout << "F" << endl;}
		  
		
}


Measured memory_bytes: 3088
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B = inputIL()

print(max(A+B,A-B,A*B))

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

int main()
{
  int X, Y;
  while (cin >> X >> Y) {
    if ((X|Y) == 0)
      break;

    int cnt = 0;
    if (X < Y)
      swap(X, Y);

    do {
      X = X % Y;
      swap(X, Y);
      ++cnt;
    } while (Y != 0);

    cout << X << " " << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 0
def main():
    from heapq import heapify, heappush, heappop
    from math import floor
    n, m = list(map(int, input().split(' ')))
    a = list(map(int, input().split(' ')))
    a = [x*(-1) for x in a]
    heapify(a)
    for _ in range(m):
        x = floor(-heappop(a)/2)*(-1)
        heappush(a, x)
     
    print(-sum(a))
main()

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

int main(){
    int X,N;
    cin >> X >> N;
    
    //存在するところは１に
    vector<int> suretu(101,0);
    rep(i,N){
        int x;
        cin >> x;
        suretu[x] = 1;
    }
    
    
    int ans_abs = 1000;
    int ans_num;
    for(int i=110; i>= -10; i--){
        //存在しないとき
        if(0<=i && i<=100){
            if(suretu[i]==0){
                int x = abs(i - X);
                if(x <= ans_abs){
                    ans_abs = x;
                    ans_num = i;
                }
            }
        }else{
            int x = abs(i - X);
            if(x <= ans_abs){
                ans_abs = x;
                ans_num = i;
            }
        }
    }
    
    cout << ans_num << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main()
{
   int N;
   cin >> N;
   
   set<int> d;
   int a = 0;
   int n = N;
   while(n--){
       cin >> a;
       d.insert(a);
   }
   
       cout<<d.size()<<endl;
   return 0;
}

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

int main() {
  int X, Y;
  cin>>X>>Y;
  
  int P = 100000 * (4 - X);
  
  int Q = 100000 * (4 - Y);
  
  if (X == 1 && Y == 1)
    cout<<P + Q + 400000<<endl;
  else if (X > 3 && Y <= 3)
    cout<<Q<<endl;
  else if (X <= 3 && Y > 3)
    cout<<P<<endl;
  else if (X > 3 && Y > 3)
    cout<<0<<endl;
  else
    cout<<P + Q<<endl;
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int k;
  cin >> k;
  
  ll num = 7;
  ll cnt = 1;
  int n_10 = 70;
  n_10 %= k;
  
  map<int, int> check;
  check[num] = 1;
  
  while(true){
    if(num % k == 0){
      cout << cnt << endl;
      break;
    }
    else{
      num += n_10;
      num%=k;
      n_10 = n_10*10%k;
      cnt++;
      if(check.count(num)){
        cout << -1 << endl;
        break;
      }
      else{
        check[num] = 1;
      }
    }
  }
  
  return 0;
  
}

Measured memory_bytes: 50468
Q, H, S, D = list(map(int, input().split()))
N = int(input())

H = min(H, 2 * Q)
S = min(S, 2 * H)
D = min(D, 2 * S)

Ans = (N // 2) * D + (N % 2) * S
print(Ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if ((s[0] == 'R') && (s[1] == 'R') && (s[2] == 'R')) {
        cout << "3";
    }
    else if (((s[0] == 'R') && (s[1] == 'R')) || ((s[1] == 'R') && (s[2] == 'R'))) {
        cout << "2";
    }
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
        cout << "1";
    }
    else
        cout << "0";

    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))

typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    int n,m;
    cin>>n>>m;
    vi a(n,-1);
    f(i,m)
    {
        int s,c;
        cin>>s>>c;
        s-=1;
        if(a[s]!=-1 and a[s]!=c)
        {
            cout<<-1<<endl;
            return 0;
        }
        a[s]=c;
    }
    if(a[0]==-1)
    {
        if(n==1)a[0]=0;
        else
        {
            a[0]=1;
        }
    }
    f(i,n)
    {
        if(a[i]==-1)a[i]=0;
    }
    if(a[0]==0 and n>1)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(auto x:a)cout<<x<<"";
    cout<<endl;
}

Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	in, _ := strconv.Atoi(nextLine())
	a,b := in/100, in%10
	if a == b{
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,n; cin>>h>>w>>n;
    map<pi,int> cnt;
    rep(i,n){
        int a,b; cin>>a>>b; a--; b--;
        FOR(j,-2,0)FOR(k,-2,0){
            int s=a+j, t=b+k;
            if (!(0<=s&&s<h-2&&0<=t&&t<w-2)) continue;
            cnt[mp(s,t)]++;
        }
    }
    vll ans(10);
    ans[0] = (ll)(h-2)*(w-2);
    for(auto c:cnt){
        ans[c.se]++;
        ans[0]--;
    }
    rep(i,10){
        cout<<ans[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 56576
from operator import mul
from functools import reduce

def cmb(n,r):
  if n < r:
    return 0
  else:
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

N, K = map(int, input().split())
ma = (N-1)*(N-2)/2

if ma < K:
  print('-1')
else:
  cmb_val = cmb(N-1,2)
  a =[(1, i) for i in range(2, N+1)]
  b = [(i, j) for i in range(2, N+1) for j in range(i+1, N+1)]
  a.extend(b[:cmb_val-K])
      
  print(len(a))
  for i in range(len(a)):
    print(a[i][0], a[i][1])
  
  

Measured memory_bytes: 4584
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint cnt(9);
    REP(i,N){
        int a; cin>>a;
        cnt[min(8LL,a/400)]++;
    }

    int c=0;
    REP(i,8) if(cnt[i]>0) c++;

    if(c==0) cout<<1<<' '<<N<<endl;
    else cout<<c<<' '<<c+cnt[8]<<endl;

}


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







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


	int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    
    sort(arr, arr + n);

    long long count = 0;

    for (int i = 0; i < k; i++)
        count += arr[i];

    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string a;
int d[10000000];
signed main(){
  int b,c,e,f=0;
  cin>>b>>c;
  for(int i=0;i<b;i++){
    cin>>e;
    if(e>=c){
      f++;
    }
  }
  cout<<f<<"\n";
  return(0);
}

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

int main(){
  int X;cin>>X;
  vector<bool> prime(101000,true);
  vector<int> P;
  for(int i=2;i<101000;i++){
    if(!prime.at(i)) continue;
    P.push_back(i);
    if(i>=X){
      cout<<i<<endl;
      break;
    }
    for(int j=i;j<101000;j+=i) prime.at(j)=false;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n;
#define nn 608
int v[nn][nn]; 
signed main()
{
	scanf("%d",&n);
	
	for(int k=0;k<10;k++){
		for(int i=0;i<n;i++) for(int j=0;j<n;j++){
			if(v[i][j]==0 and ((i^j)&(1<<k))) v[i][j]=k+1;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++) printf("%d ",v[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main(){
  char str[21];
  scanf("%s",str);
  int len =strlen(str);
  for(int i=len-1;i>=0;i--){
    printf("%c",str[i]);
  }
  cout<<endl;
}

Measured memory_bytes: 1140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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




int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i,N){
    cin >> a[i];
  }
  int l[N];
  int r[N];
  l[0] = a[0];
  r[N-1] = a[N-1];
  for(int i = 1; i < N; i++){
    l[i] = gcd(a[i],l[i-1]);
  }
  for(int i = N - 2; i >= 0; i--){
    r[i] = gcd(a[i],r[i+1]);
  }
  
  int ans = max(l[N-2], r[1]);
  for(int i = 1; i < N-1; i ++){
     ans = max(ans,gcd(l[i-1],r[i+1]));
  }
  // cout << l[0] << r[2] << endl;
  cout << ans << endl;
}




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

typedef long long ll;

const int maxn = 22, mod = 1e9 + 7;
int N, a[maxn][maxn], dp[maxn][1 << maxn];

int rec(int m, int w) {
    if (m == N) {
        if (w == 0) {
            return 1;
        }
        return 0;
    }
    int &ret = dp[m][w];
    if (ret != -1) {
        return ret;
    }
    ll tot = 0;
    for (int i = 0; i < N; i++) {
        int woman = 1 << i;
        bool available = false;
        if (woman & w) {
            available = true;
        }
        if (available && a[m][i] == 1) {
            tot = (tot + rec(m + 1, w ^ (woman))) % mod;
        }
    }
    ret = tot;
    return ret;
}

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

    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    int ans = rec(0, ((1 << N) - 1));
    cout << ans;

    return 0;
}

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

typedef long long ll;

const int Maxn = 100005;

int n;
ll m;
int a[Maxn];
ll S[Maxn];

ll Get(int x)
{
    ll res = 0;
    for (int i = 0; i < n; i++)
        res += a + n - upper_bound(a, a + n, x - a[i]);
    return res;
}

ll getSum(int x)
{
    ll res = 0;
    for (int i = 0; i < n; i++) {
        int ind = upper_bound(a, a + n, x - a[i]) - a;
        res += S[ind] + ll(n - ind) * a[i];
    }
    return res;
}

int main()
{
    scanf("%d %lld", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    for (int i = n - 1; i >= 0; i--)
        S[i] = S[i + 1] + a[i];
    int l = 0, r = 2 * Maxn;
    while (l <= r) {
        int mid = l + r >> 1;
        if (Get(mid) < m) r = mid - 1;
        else l = mid + 1;
    }
    int wh = r + 1;
    ll g = Get(wh);
    ll res = getSum(wh) + (m - g) * wh;
    cout << res << endl;
    return 0;
}


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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,K; cin>>n>>K;
	ll a[3]{}; forn(i,0,3) cin>>a[i];
	string s; cin>>s;
	
	bool skipped[n]{};
	
	ll ans=0;
	forn(i,0,n){
		if(s[i]=='r') ans+=a[2];
		if(s[i]=='s') ans+=a[0];
		if(s[i]=='p') ans+=a[1];
		if(i-K>=0 && s[i]==s[i-K] && !skipped[i-K]){
			if(s[i]=='r') ans-=a[2];
			if(s[i]=='s') ans-=a[0];
			if(s[i]=='p') ans-=a[1];
			skipped[i]=1;
		}
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


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

struct rectangle{
  int w,h,W,H;
  rectangle(){};
  rectangle(int w,int h):w(w),h(h){
    this->W=w*w;
    this->H=h*h;
      };
  bool operator<(const rectangle &a)const{
    if(this->W + this->H != a.W + a.H){
      return this->W + this->H < a.W + a.H;
    }else{
      return this->h < a.h;
    }
  }
};

int main(){
  int w,h;
  while(cin>>h>>w,h){
    rectangle r(w,h);
    rectangle min(150,150);
    for(int i=1;i<=150;i++){
      for(int j=i+1;j<=150;j++){
	rectangle tmp(j,i);
	if(r<tmp && tmp<min){
	  min=tmp;
	}
      }
    }
    cout << min.h << " " << min.w << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.begin()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  bool isOK[100] = {};
  vector<pci> card;
  for (int i = 1; i <= 52; ++i) {
    if( i <= 13 ) card.pb(pci('S', i));
    else if( i <= 26 ) card.pb(pci('H', i - 13));
    else if( i <= 39 ) card.pb(pci('C', i - 26));
    else if( i <= 52 ) card.pb(pci('D', i - 39));
    isOK[i] = true;
  }

  int n; cin >> n;
  char c; int cnum;

  rep(i, n) {
    cin >> c >> cnum;

    if( c == 'S' ) isOK[cnum] = false;
    else if( c == 'H' ) isOK[cnum+13] = false;
    else if( c == 'C' ) isOK[cnum+26] = false;
    else isOK[cnum+39] = false;
  }

  for (int i = 1; i <= 52; ++i) {
    if( isOK[i] ) cout << card[i-1].first << ' ' << card[i-1].second << endl;
  }

  return 0;
}



Measured memory_bytes: 3172
/* ex9_1
   tamayama */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 11

typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
}stack;

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

stack stk;

int main(void){
    char array[SIZE];
    int i=0;

    initialize_stack(&stk);
    scanf("%s",array);
    
    for(i=0;i<strlen(array);i++){    //0か1があればスタックに入れる
        if(array[i] == '0' || array[i] == '1'){
            push(&stk,array[i]);
        }else if(array[i] == 'B'){    //Bがあればスタックから数を取り出す
            pop(&stk);
        }
    }

    print_stack(&stk);
    return 0;
}

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

//スタックに入れる操作
void push(stack *stk,char x){
    if(stk->count >= stk->size){
        printf("Error: stack overflow. (x= %c)\n",x);
    }else{
        *(stk->top) = x;
        stk->top++;
        stk->count++;
    }
}

//スタックから取り出す操作
void pop(stack *stk){
    if(stk->count>=1){
        stk->top--;
        *(stk->top) = '\0';
        stk->count--;
    } 
}

//スタックの中身を見る
void print_stack(stack *stk){
    char *p;
    int i;
    p = stk->data;
    for(i=0;i<stk->count;i++){
        printf("%c",*p++);
    }
    printf("\n");
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
void solve(long long N){
  long long lz = 2;
  long long lw = 1;
  long long tmp;
  REPI(i, 1, N) {
    tmp = lw;
    lw += lz;
    lz = tmp;
  }

  cout << lw << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long long int a, b, c;
	scanf("%lld %lld.%lld", &a, &b, &c);
	//printf("%lld %lld %lld\n", a, b, c);
	printf("%lld\n", a * (b*100 + c) / 100);
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
template<class T> inline void read(T &x){
	x=0; register char c=getchar(); register bool f=0;
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar(); if(f)x=-x;
}
template<class T> inline void print(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10); putchar(x%10+'0');
}
template<class T> inline void print(T x,char c){print(x),putchar(c);}
const int N=2e5+10;
int n,m,ans,l[N],r[N];
std::pair<int,int> a[N];
struct node{
	int l,r,mid,max,res,tag;
}p[N<<2];
inline void maintain(int u){
	p[u].max=std::max(p[u<<1].max,p[u<<1|1].max);
	p[u].res=std::max(p[u<<1].res,p[u<<1|1].res);
}
inline void pushup(int u,int v){
	p[u].res+=v,p[u].max+=v,p[u].tag+=v;
}
inline void pushdown(int u){
	if(p[u].tag&&p[u].l!=p[u].r){
		pushup(u<<1,p[u].tag);
		pushup(u<<1|1,p[u].tag);
		p[u].tag=0;
	}
}
void build(int u,int l,int r){
	p[u].l=l,p[u].r=r,p[u].mid=(l+r)>>1;
	if(l==r){p[u].max=p[u].res=-1000000000;return;}
	build(u<<1,l,p[u].mid);
	build(u<<1|1,p[u].mid+1,r);
	maintain(u);
}
void modify(int u,int k,int v){
	pushdown(u);
	if(p[u].l==p[u].r){p[u].max=v,p[u].res=v-m+k-1;return;}
	modify(k<=p[u].mid?(u<<1):(u<<1|1),k,v);
	maintain(u);
}
void modify(int u,int l,int r,int x){
	pushdown(u);
	if(p[u].l==l&&p[u].r==r){pushup(u,x);return;}
	if(r<=p[u].mid)modify(u<<1,l,r,x);
	else if(l>p[u].mid)modify(u<<1|1,l,r,x);
	else modify(u<<1,l,p[u].mid,x),modify(u<<1|1,p[u].mid+1,r,x);
	maintain(u);
}
int query_max(int u,int l,int r){
	pushdown(u);
	if(p[u].l==l&&p[u].r==r)return p[u].max;
	if(r<=p[u].mid)return query_max(u<<1,l,r);
	if(l>p[u].mid)return query_max(u<<1|1,l,r);
	return std::max(query_max(u<<1,l,p[u].mid),query_max(u<<1|1,p[u].mid+1,r));
}
int query_res(int u,int l,int r){
	pushdown(u);
	if(p[u].l==l&&p[u].r==r)return p[u].res;
	if(r<=p[u].mid)return query_res(u<<1,l,r);
	if(l>p[u].mid)return query_res(u<<1|1,l,r);
	return std::max(query_res(u<<1,l,p[u].mid),query_res(u<<1|1,p[u].mid+1,r));
}
int main(){
#ifdef memset0
	freopen("1.in","r",stdin);
#endif
	read(n),read(m);
	for(int i=1;i<=n;i++)read(a[i].first),read(a[i].second);
	std::sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)l[i]=a[i].first,r[i]=a[i].second;
	build(1,0,m+1);
	for(int i=1;i<=n;i++){
		// printf("=== i = %d : %d %d ===\n",i,l[i],r[i]);
		ans=std::max(ans,1-l[i]-m+r[i]-1);
		ans=std::max(ans,query_max(1,0,l[i])+1-m);
		ans=std::max(ans,query_max(1,r[i],m+1)+1-l[i]-m+r[i]-1);
		// printf("> %d %d\n",query_max(1,0,l[i])+1-n,query_max(1,r[i],m+1)+1-l[i]-m+r[i]-1);
		if(r[i]-l[i]>1)ans=std::max(ans,query_res(1,l[i]+1,r[i]-1)-l[i]+1);
		modify(1,0,r[i]-1,1);
		modify(1,r[i],std::max(1,1+query_max(0,r[i],m+1)));
	}
	print(ans,'\n');
}

Measured memory_bytes: 18048
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int a, b, c, d;
bool bl;

int main(){
    scanf("%d%d%d%d", &a, &b, &c, &d);

    bl = false;

    if(abs(a - c) <= d){
        bl = true;
    } else if (abs(a - b) <= d && abs(b - c) <= d){
        bl = true;
    }

    if(bl) printf("Yes\n");
    else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 120000;

int was[MAXN];
vector<int> vv;
vector<int> eds[MAXN];
vector<int> reds[MAXN];
int n, m;
int cl[MAXN];

void dfs1(int v) {
	was[v] = 1;
	vv.push_back(v);
	for (int u: eds[v]) {
		if (!was[u])
			dfs1(u);
	}
	for (int u: reds[v]) {
		if (!was[u])
			dfs1(u);
	}
}

int dfs2(int v, int c) {
	cl[v] = c;
	for (int u: eds[v]) {
		if (cl[u] == -1) {
			if (dfs2(u, (c + 1) % 3))
				return 1;
		}
		else {
			if (cl[u] != (c + 1) % 3)
				return 1;
		}
	}
	for (int u: reds[v]) {
		if (cl[u] == -1) {
			if (dfs2(u, (c + 2) % 3))
				return 1;
		}
		else {
			if (cl[u] != (c + 2) % 3)
				return 1;
		}
	}
	return 0;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a, --b;
		eds[a].push_back(b);
		reds[b].push_back(a);
	}
	fill(cl, cl + n, -1);
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		if (was[i])
			continue;
		vv.clear();
		dfs1(i);
		int st = -1;
		for (int u: vv) {
			if (!reds[u].empty() && !eds[u].empty()) {
				st = u;
				break;
			}
		}
		if (st == -1) {
			for (int u: vv)
				ans += eds[u].size();
			continue;
		}
		if (dfs2(st, 0)) {
			ll sz = vv.size();
			ans += sz * sz;
			continue;
		}
		ll cc[3] = {};
		for (int u: vv)
			++cc[cl[u]];
		ans += cc[0] * cc[1] + cc[1] * cc[2] + cc[2] * cc[0];
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 18172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define MOD (ll)(1e9+7)
#define M(x) ((x+MOD)%MOD)
#define MAX 100010

vector<int> G[MAX];
int we[MAX], vis[MAX], K, N;

ll bfs(int k)
{
	ll res = K;
	deque<int> q;
	q.push_back(k);
	vis[k] = 1;
	while (!q.empty())
	{
		int cur = q.front();q.pop_front();
		for (int i = 0, j = 0;i < G[cur].size();++i)
			if (!vis[G[cur][i]])
			{
				res = M(res*(K - (j++) - (cur == 1 ? 1 : 2)));
				vis[G[cur][i]] = 1;
				q.push_back(G[cur][i]);
			}
	}
	return res;
}

int main()
{
	memset(vis, 0, sizeof(vis));
	int u, v;
	scanf("%d%d", &N, &K);
	for (int i = 1;i <= N - 1;++i)
	{
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	printf("%lld\n", bfs(1));
	return 0;
}

Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define rep(n) for(ll j=1;j<=n;j++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define loopne(i,a,b) for(ll i=a;i<b;i++)
ll a[303]={0};
 ll n=0;
long double dp[305][305][305];
 ll visited[305][305][305]={0};
long double ex(ll a,ll b,ll c)
{
  if(a==0&&b==0&&c==0)
    return 0;
    if(visited[a][b][c]==1)
    return(dp[a][b][c]);
    long double ansx=0;
    long double ansy=0;
    long double ansz=0;
    if(a>0)
    ansx=a*ex(a-1,b,c);
    if(b>0)
    ansy=b*ex(a+1,b-1,c);
    if(c>0)
    ansz=c*ex(a,b+1,c-1);
    dp[a][b][c]=(ansx+ansy+ansz+n)/(a+b+c);
    visited[a][b][c]=1;
    return(dp[a][b][c]);
}
int main()
{
    ll c1=0,c2=0,c3=0;
    flash
    cin>>n;
    rep(n)
    {
        ll x;
        cin>>x;
        a[j]=x;
        if(x==1)
        c1++;
        if(x==2)
        c2++;
        if(x==3)
        c3++;
    }
  
    cout<<fixed<<setprecision(9)<<ex(c1,c2,c3);
  return 0;
    
}

Measured memory_bytes: 657664
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,a,b,time=0;
    cin >> n;
    vpll v(n);
    rep(i,n){
        cin >> a >> b;
        v[i]=m_p(b,a);
    }
    sort(all(v));
    rep(i,n){
        time+=v[i].second;
        if(time>v[i].first){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

using namespace std;

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void milkshake() {
  int k;
  cin >> k;
  for(int i = 0; i < k; i++) {
    cout << "ACL";
  }
  cout << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt=1;
  //cin >> tt;
  while(tt--) milkshake();

  return 0;
}



Measured memory_bytes: 3616
S = input()
N = len(S)
K = int(input())

dp = [[[0] * 2 for _ in range(4)] for _ in range(N + 10)]
dp[0][0][0] = 1

for i, s in enumerate(S):
    nd = int(s)
    for j in range(K+1):
        for k in range(2):
            for d in range(10):
                ni = i + 1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if nk == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk += 1
                dp[ni][nj][nk] += dp[i][j][k]

print(dp[N][K][0]+dp[N][K][1])

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

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int X = sc.nextInt();
            if (X == 0) {
            	System.out.println("1");
            } else if (X == 1) {
            	System.out.println("0");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int count(vector<int> ls, int x) {
  const int n = ls.size();
  int left;
  int right;

  {{{ // search left
    if (ls[0] == x) {
      left = 0;
    } else {
      int l = 0;
      int r = n;
      // ls[l] < x <= ls[r]
      while (l < r) {
        if (l + 1 == r) {
          if (ls[l] == x) left = l;
          else if (ls[r] == x) left = r;
          else return 0;
          break;
        }
        int m = (l + r) / 2;
        if (ls[m] < x) {
          l = m;
        } else {
          r = m;
        }
      }
    }
  }}}

  {{{ // search right
    if (ls[n-1] == x) {
      right = n;
    } else {
      int l = 0;
      int r = n;
      // ls[l] <= x < ls[r]
      while (l < r) {
        if (l + 1 == r) {
          if (ls[l] == x) right = r;
          else if (ls[r] == x) right = r + 1;
          else return 0;
          break;
        }
        int m = (l + r) / 2;
        if (ls[m] <= x) {
          l = m;
        } else {
          r = m;
        }
      }
    }
  }}}

  return right - left;
}

int main() {

more:;
     int n, m; cin >> n >> m;
     if (!n && !m) return 0;

     vector<int> as = {0};
     vector<int> bs = {0};

     int a = 0;
     rep (i, n) {
       int h; cin >> h;
       a += h;
       as.push_back(a);
     }
     int b = 0;
     rep (i, m) {
       int h; cin >> h;
       b += h;
       bs.push_back(b);
     }

     map<int, int> ws;
     map<int, int> hs;

     rep (i, n) {
       range (j, i + 1, n + 1) {
         ws[as[j] - as[i]]++; } }

     rep (i, m) {
       range (j, i + 1, m + 1) {
         hs[bs[j] - bs[i]]++; } }

     int ans = 0;
     for (auto&pr : ws) {
       int w = car(pr);
       int c = cdr(pr);
       ans += hs[w] * c;
     }
     cout << ans << endl;
     goto more;

  return 0;
}

Measured memory_bytes: 32224
n = int(input())
l = [int(x) for x in input().split()]

ans = 100000000000
for i in range(1,n):
  ans1 = sum(l[:i])
  ans2 = sum(l[i:])
  diff = abs(ans1 - ans2)
  if diff < ans:
    ans = diff
    
print(ans)
  

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int N,x;
	cin >> N >> x;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	int A = 0;
	for(int i = 0;i < N;i++) {
		A += vec.at(i);
	}
	sort(vec.begin(),vec.end());
	if(A == x) {
		cout << N << endl;
	}
	else if(A < x) {
		cout << N - 1 << endl;
	}
	else if(A > x) {
		int B = 0;
		for(int i = 0;i < N;i++) {
			if(x - B < vec.at(i)) {
				cout << i << endl;
				break;
			}
			B += vec.at(i);
		}
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b,i,ans=1;
    int city[4];
  for(i=0;i<4;i++) city[i]=0;
    for(i=0;i<3;i++){
        cin >> a >> b;
        city[a-1]++;
        city[b-1]++;
    }
    for(i=0;i<4;i++){
        if(city[i]==3) ans=0;
    }
    if(ans) cout <<"YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



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

using namespace std;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<long long,long long>
#define fi first
#define se second

long long i,j,k,l,n,m;

long long dp[DIM][4],a[DIM],b[DIM],c[DIM];

int main()
{
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];

    for(i=2;i<=n;i++){
        dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);
    }

    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;

    return 0;
}


Measured memory_bytes: 7680
#include <iostream>

using namespace std;

int main() {
	string color1, color2, removed;
	int numA, numB;
	cin>>color1>>color2>>numA>>numB>>removed;
	
	if(color1 == removed)
		cout<<numA-1<<" "<<numB<<endl;
	else
		cout<<numA<<" "<<numB-1<<endl;
}

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

int score(int a,int b)
{
	int total=0;
	if (a==1)  total+=300000; 
	if (b==1)  total+=300000; 
	if (a==2)  total+=200000; 
	if (b==2)  total+=200000; 
	if (a==3)  total+=100000; 
	if (b==3)  total+=100000;
	if (a==1&&b==1)  total+=400000;
	return total; 
}

int main()
{
	int n,m;
	cin>>n>>m;
	cout<<score(n,m)<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s ;
        int n ,m;
        while(true){
            s=sc.next();
            if(s.equals("-"))break;
            n=sc.nextInt();
            for(int i=0;i<n;i++){
                m=sc.nextInt();
                s=s.substring(m)+s.substring(0,m);
            }
            System.out.println(s);
        }
    }
}


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

using namespace std;
#define int long long
int n, dp[5005][5005], m;

string s;

const int mod = 1e9 + 7;

int BinPow(int x, int k){
    if(k == 0)
        return 1;
    else if(k == 1)
        return x;
    else{
        int sum1 = BinPow(x, k/2) % mod;
        sum1 = (sum1 * sum1)%mod;
        if(k % 2 != 0){
            sum1 = (sum1 * x)%mod, sum1 %= mod;
        }
        return sum1;
    }
}

signed main(){
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    cin >> s;
    m = s.length();
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= n; j++){
            if(!dp[i][j]) continue;
            if(j == 0){
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
            }
            else{
                dp[i + 1][j - 1] += dp[i][j];
                dp[i + 1][j - 1] %= mod;
            }
            dp[i + 1][j + 1] += 2 * dp[i][j];
            dp[i + 1][j + 1] %= mod;
        }
    }
    int sum1 = BinPow(2, m);
    cout << (BinPow(sum1, mod - 2) * dp[n][m])%mod << "\n";
}


Measured memory_bytes: 194048
N = int(input())
S = [input() for i in range(N)] 
a = str(S.count('AC'))
b = str(S.count('WA'))
c = str(S.count('TLE'))
d = str(S.count('RE'))
print("AC"+" "+"x"+" "+a)
print("WA"+" "+"x"+" "+b)
print("TLE"+" "+"x"+" "+ c)
print("RE"+" "+"x"+" "+ d)

Measured memory_bytes: 16328
#include <iostream> 
#include <vector> 
using namespace std;
 
int main(){
    int N,ans;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256