akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
char a[1001][1001];
int wi[8]={1,1,0,-1,-1,-1,0,1},wj[8]={0,-1,-1,-1,0,1,1,1},n=0,m=0;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>a[i][j];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='#')cout<<'#';
            else
            {
                int num=0;
                for(int m=0;m<8;m++)
                {
                    if(a[i][j]!='.')continue;
                    if(a[i+wi[m]][j+wj[m]]=='#')num++;
                }
                cout<<num;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $keta_cnt = array_fill(0, 32, 0);
  for ($i=0; $i<$n; $i++) {
    $b[$i] = str_pad(decbin($a[$i]), 32, 0, STR_PAD_LEFT);
//    echo $b[$i].PHP_EOL;
    for ($j=0; $j<strlen($b[$i]); $j++){
      if($b[$i][$j] == '1'){
        $keta_cnt[$j]++;
      }
    }
  }

  $ans_all = [];
  for ($i=0; $i<$n; $i++) {
    $ans = [];
    for ($j=0; $j<strlen($b[$i]); $j++){
      if($b[$i][$j] == '0'){
        if($keta_cnt[$j] % 2 == 0){
          $ans[] = '0';
        }else{
          $ans[] = '1';
        }
      }else{
        if($keta_cnt[$j] % 2 == 0){
          $ans[] = '1';
        }else{
          $ans[] = '0';
        }
      }
    }
    $ans = implode("", $ans);
    $ans_all[] = bindec($ans);
  }
  echo implode(" ", $ans_all);


Measured memory_bytes: 61384
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    h, w = map(int, input().strip().split())
    c = [[0] * 10 for _ in range(10)]
    for i in range(10):
        c[i] = list(map(int, input().strip().split()))
    a = [[0] * w for _ in range(h)]
    for i in range(h):
        a[i] = list(map(int, input().strip().split()))

    ary = list(c)
    for k in range(10):
        for i in range(10):
            for j in range(10):
                ary[i][j] = min(ary[i][j], ary[i][k] + ary[k][j])
    ans = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] not in (-1, 1):
                # print(ary[i][j])
                ans += ary[a[i][j]][1]
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 40796
#include <bits/stdc++.h>
#include<algorithm>	
using namespace std;
#define ll long long 
vector<vector<int>> l(100001);
//int used[100001][100001];
int col[100001];
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];


int main() {
  int n;
  cin >> n;
  int a[n+1];
  
  for(int i= 1;i<n+1;i++){
    cin >> a[i];
  }
  int b = 0;
  int t = 1;
  for(int i= 1;i<n+1;i++){
      if(a[i] == t){
        t += 1;
      }else{
        b += 1;
      }
    
  }
  
  if(t == 1){
    cout << -1;
  }else{
    cout << b;
  }
  
  
}




Measured memory_bytes: 6352
N=int(input())

a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

total=0
d=a[0]
for i in a:
    total +=b[i-1]
    
    if i-d == 1:
        total +=c[i-2]
    
        
    d=i
    
        
print(total)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * Created by wild on 16/08/28.
 */
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int stayDay = scan.nextInt();
        int changePay = scan.nextInt();
        int first = scan.nextInt();
        int second = scan.nextInt();

        int result = 0;
        for (int i = 0; i < stayDay; i++){
            if (changePay <= i){
                result += second;
            }else {
                result += first;
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 9936
N = int(input())
H = list(map(int, input().split()))
 
for i in range(1, N):
    if H[i] < H[i - 1]:
        H[i] += 1

for i in range(1, N):
    if H[i] < H[i - 1]:
        print('No')
        exit(0)
print('Yes')

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

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


int main(){
    ll a,b;
    cin>>a>>b;

    ll min,el;
    if(a>b){
        min =b;
        el =a;
    }else{
        min =a;
        el =b;
    }

    ll g=1,gm=1;
    for(ll i=1;i<=min;i++){
        if(min%i==0&&el%i==0){
            g = i;
            if(gm<g){
                gm=g;
            }
        }
    }

    a /= gm;
    b /= gm;

    cout<<a*b*gm<<endl;


}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int K;cin>>K;
    cout<<(K/2)*((K+1)/2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
 
using namespace std;
using namespace __gnu_pbds;
 
// template<typename T>
using o_set=tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define M 1000010


int main(){
	IOS;
	ll n;cin>>n;
	vector<pii>v;
	rep(i,0,n){
		ll pos,len;cin>>pos>>len;
		v.pb({pos+len,pos-len});
	}
	sort(all(v));
	ll ans=0,j=1,i=0;
	while(i<n and j<n){
		ll l=v[i].se,r=v[i].fi;
		while(v[j].se<r and v[j].fi>=l){
			j++,ans++;
			if(j==n)break;
		}
		i=j,j++;
	}
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 3444
n = int(input())
A = [int(input()) for i in range(n)]
#print(A)

next_a = 1
count = 0
while(True):
    #print(next_a)
    tmp = A[next_a-1]
    A[next_a-1] = -1
    next_a = tmp
    count += 1
    if next_a == 2:
        print(count)
        break
    if A[next_a-1] == -1:
        print(-1)
        break


Measured memory_bytes: 7084
n = int(input())
h = list(map(int, input().split()))

cnt = 0
parts = [h]

while True:
    found = False
    new_parts = []
    for part in parts:
        min_v = min(part)
        cnt += min_v
        if part:
            new_part = []
            for v in part:
                if v > min_v:
                    new_part.append(v - min_v)
                elif new_part:
                    new_parts.append(new_part)
                    new_part = []
            if new_part:
                new_parts.append(new_part)
            found = True
    if not found:
        break
    parts = new_parts

print(cnt)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int n,k,target,x,a[105]={},ans=0;
    cin>>n>>k;
    while(k--){
        cin>>target;
        while(target--){
            cin>>x;
            a[x]++;
        }

    }
    for(int i=1;i<=n;i++){
        if(a[i]==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  char S, pre;
  cin >> S;
  if (S != 'h') {
  	cout << "No" << endl;
    return 0;
  }
  pre = S;
  cin >> S;
  while (1) {
    if ((pre == 'i' && S == 'h') || (pre == 'h' && S == 'i'))  {
      pre = S;
      cin >> S;
      continue;
    }
    if (cin.eof() && S == 'i') {
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <functional>

using namespace std;

int main(){
    string S;
    cin >> S;

    int N = S.length();

    vector<int> X(N);

    int e=0,o=0;
    for (size_t i = 0; i < N-1; i++)
    {
        if(S[i]=='L') continue;
        if((i+1)%2==0){
            e++;
        }else{
            o++;
        }
        if(S[i+1]=='L'){
            if((i+1)%2==0){
                X[i]+=e;
                X[i+1]+=o;
            }else{
                X[i]+=o;
                X[i+1]+=e;
            }
            e=0;
            o=0;
        }
    }

    for (size_t i = N-1; i > 0; i--)
    {
        if(S[i]=='R') continue;
        if((i+1)%2==0){
            e++;
        }else{
            o++;
        }
        if(S[i-1]=='R'){
            if((i+1)%2==0){
                X[i]+=e;
                X[i-1]+=o;
            }else{
                X[i]+=o;
                X[i-1]+=e;
            }
            e=0;
            o=0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << X[i] << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1024
open Printf
open Scanf

let id x = x
             
let solve x n =
  if n = 0 then x
  else let lp = List.init n @@ fun _ -> scanf "%d " id in
       let rec loop i =
         if not @@ List.mem (x - i) lp then (x - i)
         else if not @@ List.mem (x + i) lp then (x + i)
         else loop (i + 1) in
       loop 0

let () =
  scanf "%d %d " solve |> printf "%d\n"


Measured memory_bytes: 3796
import math
minutes = [int(input()) for _ in range(5)]
minutes = sorted(minutes,key = lambda x:-x%10)
cnt = 0
for i in minutes:
    cnt += math.ceil(i/10)*10

if minutes[-1] % 10 !=0:
    cnt -= 10 - minutes[-1] % 10
print(cnt)

Measured memory_bytes: 9180
N,M =map(int,input().split())
abc = [list(map(int,input().split())) for _ in range(M)]
abc = [(a-1,b-1,-c) for a,b,c in abc]

dist = [float('inf')] * N
dist[0] = 0

for _ in range(N-1):
    for a,b,c in abc:
        if dist[a] == float('inf'):
            continue
        if dist[b] > dist[a] + c:
            dist[b] = dist[a] + c

ans = dist[N-1]
negative = [False]*N

for _ in range(N):
    for a,b,c in abc:
        if dist[a] == float('inf'):
            continue
        if dist[b] > dist[a] + c:
            dist[b] = dist[a] + c
            negative[b] = True
        if negative[a]:
            negative[b] = True

if negative[N-1]:
    print('inf')
else:
    print(-ans)


Measured memory_bytes: 48600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

struct Edge{
    long long to,cost;
};
struct Bellman_Ford{
   vector<vector<Edge>> graph;
    ll roop = 0;
    int n;
    vector<bool> seen;

    Bellman_Ford (ll t){
        n = t;
        graph.resize(n);
        seen.resize(n,false);
    }


    bool Do (vector<long long>& d,const ll s = 0){
        d.resize(n,INF);
        d[s] = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                for(Edge p:graph[j]){
                    if(d[j] != INF && d[p.to] > d[j]+p.cost){
                        d[p.to] = d[j]+p.cost;
                        
                        if(i == n-1){
                            roop = p.to;
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

    
    vector<bool> Can_to(int a,int r = -1){
        if(seen[a]);
        else {
            seen[a] = true;
            for(Edge p:graph[a]){
                if(p.to == r) continue;
                Can_to(p.to,a);
            }
        }
        return seen;
    }
};

int main(){
    long long n,m;
    cin >> n >> m;
    Bellman_Ford mike(n);
    for(int i = 0; i < m; i++){
        long long a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        Edge e = {b,-c};
        mike.graph[a].push_back(e);
    }
    vector<ll> ans;
    bool roop = mike.Do(ans);
    vector<bool> flag = mike.Can_to(mike.roop);
    if(!roop) cout << -ans[n-1] << endl;
    else if(flag[n-1]) cout << "inf" << endl;
    else cout << -ans[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3836
n,m=map(int,input().split())
 
A=[input() for i in range(n)]
B=[input() for i in range(m)]
 
ans=0        
for i in range(n-m+1):
    for j in range(n-m+1):
        if [a[j:j+m] for a in A[i:i+m]] == B:
            ans=1
        
        
if ans == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;


namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                if(n==0){break;}
                List<int> inlis = new List<int>();
                int sum = 0;
                for (int i = 0; i < n; i++) {
                    int this_score = int.Parse(Console.ReadLine());
                    sum += this_score;
                    inlis.Add(this_score);
                }
                inlis.Sort();
                sum -= inlis.ElementAt(n-1);
                sum -= inlis.ElementAt(0);
                Console.WriteLine(sum/(n-2));
            }   
        }   
    }
}

Measured memory_bytes: 5904
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#define ll long long
using namespace std;
int main(){
    long long i=100;
    long long x;cin>>x;
    int count=0;
    long long n;
    while(true){
        n=i/100;
        i+=n;
        count++;
        if(i>=x)break;
    }
    cout<<count<<endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long K)
{
  lli ret = 0;
  for (int i = 1; i <= K; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      for (int l = 1; l <= K; l++)
      {
        ret += __gcd(l, __gcd(i, j));
      }
    }
  }
  cout << ret << endl;
}

signed main()
{
  long long K;
  scanf("%lld", &K);
  solve(K);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,t,k,ans,x,dp[200001],B,a[200001],Min1,Min2;
int main () {
    cin>>n;
    cin>>k;
    for (i=1;i<=n;i++) {
        cin>>a[i];
    }
    B=1e16;
    for (i=2;i<=n;i++) {
        dp[i]=B;
    }
    for (i=2;i<=n;i++) {
        Min1=B;
        for (j=1;j<=k;j++) {
            if(i-j<=0) continue;
            Min1=min(Min1,dp[i-j]+abs(a[i]-a[i-j]));
        }
        dp[i]=Min1;
    }
    ans=dp[n];
    if (ans==B) cout<<"0"<<endl;
    else
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None

def f(k):
    if k % 2 == 0:
        return k // 2
    else:
        return 3 * k + 1

def main():
    s = int(input())

    L = [s]

    for i in range(2, 10**10):
        s = f(s)

        if s in L:
            print(i)
            return
        
        L.append(s)



main()


Measured memory_bytes: 5204
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
string A, B;
int count=0;
cin >> A >> B;
for(int i=0;i<A.size();i++){
    if(A.at(i)!=B.at(i))count++;
}
cout << count << endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

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

    ll sq = sqrt(n) + 1;

    ll mx;

    for (ll i = 1; i <= sq; i++) {
        if (n % i == 0) {
            mx = i;
        }
    }

    ll p = n / mx;

    cout << (int)(log10(p) + 1) << endl;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N=nextInt();
		int M=nextInt();
		int[][] A = new int[N][];
		int[] G = new int[M+1];
		Arrays.fill(G, 0);

		for(int i=0;i<N;i++){
			A[i]=nextInts();
			for(int k=1;k<A[i].length;k++){
				G[A[i][k]]++;
			}
		}

//		for(int i=0;i<M;i++){
//			G[i+1]+=G[i];
//		}

		int ans = 0;
		for(int i=0;i<G.length;i++){
			if(G[i]==N){
				ans++;
			}
		}

		System.out.println(ans);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 24532
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n];
    int numbers = 0;
    int[] count = new int[200001];
    HashSet<Integer> set = new HashSet<>();
    for(int i = 0; i < n; i++) {
      int num = sc.nextInt();
      a[i] = num;
      count[num]++;
      set.add(num);
    }
    Arrays.sort(count);
    int ans = 0;
    int index = 0;
    int size = set.size();
    while(count[index] == 0) index++;
    while(size > k) {
      ans += count[index];
      index++;
      size--;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 98788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d",&n);

	vector<int> a(n);
	rep(i,n) scanf("%d",&a.at(i));
  
    int mn=1000000000;
    int l=0,r=100,hp=0;
  
  	for(int p=l; p<=r; p++){
      hp=0;
      rep(i,n) hp += pow( (a.at(i)-p), 2);
      mn = min(mn,hp);
    }

	printf("%d\n",mn);
}


Measured memory_bytes: 256
INF = 1010101010

def main():
    N,Ma,Mb = map(int,input().split())

    a = [0 for _ in range(N)]
    b = [0 for _ in range(N)]
    c = [0 for _ in range(N)]

    for i in range(N):
        a[i],b[i],c[i] = map(int,input().split())

    dp = [[[INF for k in range(401)] for j in range(401)] for i in range(41)]
    dp[0][0][0] = 0

    for i in range(N):
        for A in range(401):
            for B in range(401):
                dp[i+1][A][B] = min(dp[i+1][A][B], dp[i][A][B])
                if A+a[i]<=400 and B+b[i]<=400:
                    dp[i+1][A+a[i]][B+b[i]] = min(dp[i+1][A+a[i]][B+b[i]], dp[i][A][B]+c[i])

    ans = INF
    for A in range(1,401):
        for B in range(1,401):
            if Ma*B == Mb*A:
                ans = min(ans, dp[N][A][B])

    return -1 if ans == INF else ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 96988
import java.io.*;
import java.util.*;
import java.lang.*;


public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();

        long[] A = new long[N];
        for(int n=0; n<N; n++) A[n]=sc.nextLong();

        long damage = 0;
        for(int n=0; n<N; n++) damage += A[n];
        if(H<=damage) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 56436
n=int(input())
ans=[0 for i in range(4)]
for i in range(n):
    k=input()
    if k=="AC":
        ans[0]+=1
    if k=="WA":
        ans[1]+=1
    if k=="TLE":
        ans[2]+=1
    if k=="RE":
        ans[3]+=1
print("AC x",ans[0])
print("WA x",ans[1])
print("TLE x",ans[2])
print("RE x",ans[3])

Measured memory_bytes: 9216
from functools import reduce
from operator import add
input()
w = list(map(int,input().split(" ")))
S1 = w[0]
S2 = reduce(add,w[1:])
diffMin = abs(S1 - S2)
for i in w[1:]:
    S1 += i
    S2 -= i
    diff = abs(S1 - S2)
    if diff < diffMin:
        diffMin = diff
print(diffMin)

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String command;
		int query = sc.nextInt();
		int a,b;
		for(int i = 0; i < query; i++){
			command = sc.next();
			a = sc.nextInt();
			b = sc.nextInt();
			if(command.compareTo("print") == 0){
				System.out.println(str.substring(a,b+1));
			}else if(command.compareTo("reverse") == 0){
				StringBuffer sb = new StringBuffer(str.substring(a,b+1));
				str = str.substring(0,a) + sb.reverse().toString() + str.substring(b+ 1,str.length());
			}else if(command.compareTo("replace") == 0){
				String work = sc.next();
				str = str.substring(0,a) + work + str.substring(b + 1,str.length());
			}
		}
	}
}

Measured memory_bytes: 29744
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;

	cout<<s.substr(0,4)<<" "<<s.substr(4)<<endl;

	return 0;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int x = 0;
  for(char c : s) x += c - '0';
  cout << (x % 9 == 0 ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],key[m];
    for(int i=0;i<m;i++){
        int b;
        cin>>a[i]>>b;
        int num=0;
        for(int i=0;i<b;i++){
            int c;
            cin>>c;
            num+=1<<(c-1);
        }
        key[i]=num;
    }
    int dp[1<<n];
    fill(dp,dp+(1<<n),INF);
    dp[0]=0;
    for(int i=0;i<(1<<n)-1;i++){
        for(int j=0;j<m;j++){
            dp[i|key[j]]=min(dp[i|key[j]],dp[i]+a[j]);
        }
    }
    if(dp[(1<<n)-1]==INF)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
}

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



int main()
{

	int N, K;
	int ans = 0;
	int buf;
	scanf("%d%d", &N, &K);

	for (int a = 0; a < N; ++a)
	{
		scanf("%d", &buf);

		if (buf < std::max(K - buf, buf - K))
		{
			ans += buf * 2;
		}
		else
		{
			ans += std::max(K - buf, buf - K) * 2;
		}

	}

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const ll MOD = 1e9 + 7;


int main(void) {
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    ll ans = 0;
    ll now = 1;

    if (s1[0] == s2[0]) ans = 3;
    else {
        ans = 6;
        now++;
    }

    for (int i = now; i < n; i++) {
        if (s1[i] == s2[i]) {
            if (s1[i - 1] == s2[i - 1]) {
                ans *= 2;
                ans %= MOD;
            }
        }
        else {
            if (s1[i - 1] == s2[i - 1]) {
                ans *= 2;
                ans %= MOD;
                i++;
            }
            else {
                ans *= 3;
                ans %= MOD;
                i++;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n + 1], b[n];
    REP(i,n + 1){
        cin >> a[i];
    }
    REP(i,n){
        cin >> b[i];
    }
    ll ans = 0;
    REP(i,n){
        if(a[i] < b[i]){
            ans += a[i];
            if(a[i + 1] >= b[i] - a[i]){
                a[i + 1] -= b[i] - a[i];
                ans += b[i] - a[i];
            }else{
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }else{
            ans += b[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define sc(x) scanf("%lld",&x);
#define fi first
#define se second
#define endl '\n'
#define P pair<int,int>

signed main()
{
    int a,b,c;
    sc(a)sc(b)sc(c)
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;

int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,d;
  cin>>n>>d;
  ll x[n],y[n];
  ll i;
  for(i=0;i<n;i++){
  	cin>>x[i]>>y[i];
  }
  
  ll count=0;
  dd dist;
  for(i=0;i<n;i++){
  	dist=pow(x[i],2)+pow(y[i],2);
  	dist=pow(dist,0.5);
  	if(dist<=d){
  		count++;
	  }
  }
  
  cout<<count<<endl;
 
  return 0;
}

Measured memory_bytes: 7436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
//ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
//ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){

  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i,0,n)ans+=i;
  cout << ans << endl;

}


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

using namespace std;

long int MAX_N = 200000;
long int MAX_X = 1000000000;


int main(int argc, char const *argv[]) {
  long int N;
  long int x[MAX_N];

  cin >> N;
  vector<pair<long int, long int>> v(N);

  for (long int i = 0; i < N; i++) {
    cin >> x[i];
    v[i] = make_pair(x[i], i);
  }

  int l = N/2;

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

  long int idx[MAX_N];

  for (int i = 0; i < N; i++) idx[v[i].second] = i;

  for (long int i = 0; i < N; i++){
    if (v[idx[i]].first < v[l-1].first) cout << v[l].first << endl;
    else if (v[idx[i]].first == v[l-1].first) cout << v[l].first << endl;
    else cout << v[l-1].first << endl;
  }

  return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int x, t;
  cin >> x >> t;
  cout << max (x-t, 0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	char b,a;
	scanf("%c", &b);
	if(b=='A')
		a='T';
	else if(b=='T')
		a='A';
	else if(b=='C')
		a='G';
	else if(b=='G')
		a='C';
	printf("%c\n", a);
	return 0;
}


Measured memory_bytes: 128
# AOJ 0016 Treasure Hunt

x = y = 0
angle = 90

while line = gets
  r, d_angle = line.split(",").map {|v| v.to_i}
  break if r.zero? && d_angle.zero?

  rad = angle * Math::PI / 180
  x += r * Math.cos(rad)
  y += r * Math.sin(rad)

  angle -= d_angle
  angle += 360 if angle < 0
  angle = angle % 360
end

puts x.to_i
puts y.to_i

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

using namespace std;
const int INF = 1<<29;

int main(){
  int D,G; cin >> D >> G;
  vector<int> p(D),c(D),d;
  int min = INF, sum = 0;
  for(int i = 0; i < D; ++i){
    cin >> p[i] >> c[i];
    sum += p[i];
  }

  for(int bit = 0,t = -1; bit < pow(2,D); ++bit){
    int tmp = G,count = 0;
    d.clear();
    for(int k = 0; k < D && tmp > 0; ++k){
      if(bit >> k & 1){
        tmp -= 100*(k+1)*p[k]+c[k];
        count += p[k];
      }
      else d.push_back(k);
    }
    for(int i = d.size()-1; i >= 0; --i){
      if(tmp <= 0) break;
      for(int j = 0; j < p[d[i]] && tmp > 0; ++j){
        count++;
        tmp -= (d[i]+1)*100;
      }
    }
    if(tmp <= 0 && min > count) min = count;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  if(s[0]=='S') cout << "Cloudy" << endl;
  else if(s[0]=='C') cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
from math import pi,sin,cos
_x=_y=a=0
while 1:
    x,y=map(int,input().split(','))
    if x==y==0:break
    r=a*pi/180
    _x+=x*sin(r)
    _y+=x*cos(r)
    a+=y
print(*map(int,[_x,_y]),sep='\n')

Measured memory_bytes: 7832
e1,e2,e3,e4 = map(int,input().split())
if e1==e2 and e3==e4:
    print('yes')
elif e1==e3 and e2==e4:
    print('yes')
elif e1==e4 and e2==e3:
    print('yes')
elif e1==e2==e3==e4:
    print('yes')
else:
    print('no')


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int n;
cin >> n;
vector<double>a(n);
for(int i=0;i<n;i++){
    cin>> a.at(i);
}
sort(a.begin(),a.end());
double ans = (a.at(0)+a.at(1))/2;
for(int i=2;i<n;i++){
    ans = (ans+a.at(i))/2;
}
cout << ans << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,e=0;;
  cin>>a;
  vector<int> b(a),c(a),d(a-1);
  fo(i,a)
    cin>>b[i];
  fo(i,a)
    cin>>c[i];
  fo(i,a-1)
    cin>>d[i];
  fo(i,a)
    e+=c[i];
  fo(i,a-1){
    if(b[i]==b[i+1]-1)
      e+=d[b[i]-1];
  }
  cout<<e<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
static const int INFTY = 2147483647;
ll mod = 1000000007;

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

	cout << 24 - M + 24 << endl;

	return 0;
}

Measured memory_bytes: 768
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long int;
const ll INF = 1LL << 60;

template <typename Tp>
void chmax(Tp &A, Tp B) { A = max(A, B); }

template <typename Tp>
void chmin(Tp &A, Tp B) { A = min(A, B); }

ll rec[1010][1 << 12][2];

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, 1, -1};
const string pat = "UDRL";

int solve_testcase() {
  ll HP_init, HP_max; cin >> HP_init >> HP_max;
  if(HP_init == 0 and HP_max == 0) return 1;

  int H, W; cin >> H >> W;
  vector<string> board(H);
  for(int i=0; i<H; i++) cin >> board[i];

  int T; cin >> T;
  vector<ll> damage(26);
  for(int i=0; i<T; i++) {
    char c; cin >> c;
    ll d; cin >> d;
    chmax(damage[c - 'A'], d);
  }

  int S; cin >> S;
  int N = 0;
  vector<int> op;
  for(int i=0; i<S; i++) {
    char c; cin >> c;
    int n; cin >> n;
    N += n;
    int id = pat.find(c);
    for(int j=0; j<n; j++) op.emplace_back(id); 
  }

  int P; cin >> P;
  vector<ll> p(P);
  for(int i=0; i<P; i++) cin >> p[i];

  fill(rec[0][0], rec[N+1][0], -INF);
  rec[0][0][0] = HP_init;

  // init
  for(int bit=0; bit<(1<<P); bit++) {
    for(int i=0; i<P; i++) {
      if(bit >> i & 1) continue;
      int nbit = bit | (1 << i);
      chmax(rec[0][nbit][0], min(rec[0][bit][0] + p[i], HP_max));
    }
  }

  int x = 0, y = 0;
  for(int i=0; i<N; i++) {
    // move
    x += dx[ op[i] ], y += dy[ op[i] ];
    ll dam = damage[ board[x][y] - 'A' ];
    for(int bit=0; bit<(1<<P); bit++) {
      // 0 -> 1
      {
        chmax(rec[i][bit][1], min(HP_max - dam, rec[i][bit][0] - dam));
      }
      // 1 -> 1
      {
        for(int k=0; k<P; k++) {
          if(bit >> k & 1) continue;
          int nbit = bit | (1 << k);
          chmax(rec[i][nbit][1], min(HP_max - dam, rec[i][bit][1] + p[k]));
        }
      }
      // 1 -> next 0
      if(rec[i][bit][1] > 0) {
        chmax(rec[i+1][bit][0], rec[i][bit][1]);
      }
      // fprintf(stderr, "rec[%d][%d][%d] = %lld\n", i, bit, 0, rec[i][bit][0]);
      // fprintf(stderr, "rec[%d][%d][%d] = %lld\n", i, bit, 1, rec[i][bit][1]);
    }
  }

  bool ok = false;
  for(int bit=0; bit<(1<<P); bit++) {
    ok |= (rec[N][bit][0] > 0);
    ok |= (rec[N][bit][1] > 0);
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}

int main() {
  while(!solve_testcase());
  return 0;
}



Measured memory_bytes: 67256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a+b;
  int r = c + d;
  if (l>r){
    cout << "Left" << endl;
  }
  else if (l<r){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

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

int main() {
	int N,M,D;
	cin >> N >> M >> D;
	vector<vector<int>> R(N, vector<int>(M));
	rep(n, N) {
		rep(m, M) {
			char c;
			cin >> c;
			if (c == '.') {
				R.at(n).at(m) = 1;
			} else {
				R.at(n).at(m) = 0;
			}
		}
	}
	vector<int> v;
	int c = 0;
	rep(n, N) {
		rep(m, M) {
			c += R.at(n).at(m);
			if (R.at(n).at(m) == 0) {
				if (c >= D)	v.push_back(c);
				c = 0;
			}
		}
		if (c >= D)	v.push_back(c);
		c = 0;
	}
	rep(m, M) {
		rep(n, N) {
			c += R.at(n).at(m);
			if (R.at(n).at(m) == 0) {
				if (c >= D)	v.push_back(c);
				c = 0;
			}
		}
		if (c >= D)	v.push_back(c);
		c = 0;
	}
	int ret = 0;
	rep(i, v.size()) {
		ret += v.at(i) - (D - 1);
	}
	cout  << ret << endl;
	return 0;
}




Measured memory_bytes: 3168
#include<stdio.h>
int main(void)
{
    int k,i,j,s;
    scanf("%d",&k);
    for(j=2,s=0;j<=k;j++)
    {
        for(i=1;i<=j;i++)
        {
            if((i%2!=0 && j%2==0) || (i%2==0 && j%2!=0))
            {
                s++;
            }
        }
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(x,n) for(int x = 0; x < n; x++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  
  ll a = 0, b = 0;
  FOR(x,N) {
    ll S, T; cin >> S >> T;
    if(S*(b/T+(b%T!=0)) >= a)
      a = S*(b/T+(b%T!=0)), b = (b/T+(b%T!=0))*T;
    else
      a = (a/S+(a%S!=0))*S, b = T*(a/S);
    if(x == 0) a = S, b = T;
  }
  
  cout << a + b << "\n";
}


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

int main() {
  int n;
  cin >>n;
  int a[1000001];
  for(int i=1;i<=n;i++) {
    cin >> a[i];
  }
  int now=1;
  int sum=0;
  for(;;) {
    sum +=1;
    if(a[now]==2) {
      cout << sum <<endl;break;
    }
    else if(sum > n) {
      cout << -1 <<endl; break;
    }
    else if(a[now]==now) {
      cout << -1 <<endl;break;
    }
    else {
      now=a[now]; continue;
    }
  }
}

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

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数

int main()
{
	int k,x;
	cin >> k >> x;
	bool f = false;

	FOR(i, -1000000, 1000001) {
		if ((i < x && i+k>x) || (i>x&&i-k<x) || i==x) {
			//cout << i << endl;
			cout << (f ? " " : "") << i ;
			f = true;
		}
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define repn(i,j,n) for (int i = j; i <= n; ++i)
const int mod=1e9+7;
using namespace std;

int a[101],dp[101][100001],sum[100001];

int32_t main() 
{
    int n,k;
    cin>>n>>k;
    repn(i,1,n){
        dp[i][0]=1;
        cin>>a[i];
    }
    dp[0][0]=1;
    repn(i,1,n){
        sum[0]=dp[i-1][0];
        repn(j,1,k){
            sum[j]=(sum[j-1]+dp[i-1][j])%mod;
        }
        repn(j,0,k){
            if(j<a[i])
                dp[i][j]=sum[j];
            else
                dp[i][j]=(sum[j]-sum[j-a[i]-1]+mod)%mod;
        }
    }
    cout<<dp[n][k]<<endl;
}

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

int main(void) {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll mm;
    for(int i=0; i<N; i++) {
        cin >> mm;
        A[i] = (mm-1-i);
    }
    sort(A.begin(), A.end());
    ll b;
    if(A.size() % 2 == 0) b = (A[N/2] + A[N/2-1]) / 2;
    else b = A[N/2];
    ll sm = 0;
    for(int i=0; i<N; i++) sm += abs(A[i] - b);
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 1792