akhauriyash/Code-Regression huggingface dataset:
n = int(input())

import sys
sys.setrecursionlimit(999999999)
from functools import lru_cache
@lru_cache(maxsize=32)
def solve(cnt,nokori):
    if nokori<6:
        return cnt+nokori

    for six in range(10,-1,-1):
        if 6**six <= nokori:
            break
    for nine in range(10,-1,-1):
        if 9**nine <= nokori:
            break

    res1 = solve(cnt+1,nokori-6**six)
    if nine != 0:
        res2 = solve(cnt+1,nokori-9**nine)
    else:
        res2=10**9

    return min([res1,res2])

print(solve(0,n))

Measured memory_bytes: 58456
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	char s[100000],k;
	cin>>s;
	int i,j,l,d;
	l=strlen(s);
	for (i=97;i<=122;i++)
	{
		d=0;
		k=i;
		for (j=0;j<l;j++)
		{
			if (s[j]==k)
			{
				d=1;
			}
		}
		if (d==0)
		{
			cout<<k<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
} 


Measured memory_bytes: 888
G = []
cnt = 0

def insertionSort(A, n, g):
  for i in range(g, n):
    v = A[i]
    j = i - g
    while j >= 0 and A[j] > v:
      global cnt
      cnt += 1
      A[j+g] = A[j]
      j -= g
    A[j+g] = v

def shellSort(n, A):
  m = 1
  while m <= n / 9:
    m = m * 3 + 1
  while 0 < m:
    global G
    G.append(m)
    insertionSort(A, n, m)
    m = int(m / 3)

A = []
n = int(input())

for i in range(n):
  A.append(int(input()))

shellSort(n, A)

print(len(G))
print(*G)
print(cnt)

for i in range(n):
  print(A[i])



Measured memory_bytes: 45508
day = input()

if day == 'SUN' :
    print(7)
elif day == 'MON' :
    print(6)
elif day == 'TUE' :
    print(5)
elif day == 'WED' :
    print(4)
elif day == 'THU' :
    print(3)
elif day == 'FRI' :
    print(2)
elif day == 'SAT' :
    print(1)

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

int main(void){
   int N;
   cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end(),greater<int>());
   int sum_A=0;
   int sum_B=0;
   for(int i=0;i<N;i++){
      if(i%2==0) sum_A+=a[i];
      else sum_B+=a[i];
   }
   cout<<sum_A-sum_B<<endl;
   return 0;
}



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


int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  sort(a.begin(), a.end());
  
  ll ans = 0, same;
  ll i = 0;
  while(i < n){
    same = 0;
    ll k = 1;
    while(i + k < n && a.at(i+k) - a.at(i) == 0){
      same++;
      k++;
    }
    if (same%2 == 0){
      ans++;
    } 

    
    
    i += k;
    
  }
  cout << ans << endl;

}


Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    vector<char> result;
    while(1){
        int mid,fin,makeup;
        cin >> mid >> fin >> makeup;
        if(mid == -1 && fin == -1 && makeup == -1)break;
        if(mid == -1 || fin == -1){
            result.pb('F');
            continue;
        }
        int sum = mid + fin;
        if(sum >= 80){
            result.pb('A');
            continue;
        }else if(sum >= 65){
            result.pb('B');
            continue;
        }else if(sum >= 50){
            result.pb('C');
            continue;
        }else if(sum >= 30){
            if(makeup >= 50){
                result.pb('C');
                continue;
            }else{
                result.pb('D');
                continue;
            }
        }else{
            result.pb('F');
        }
    }
    F(i, 0, result.size()){
        cout << result[i] << endl;
    }
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define show(x) cout << x << '\n'
#define showh(x) cout << x << ' '
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
auto t1 = chrono::high_resolution_clock::now();
bool prime[100001];
ll expo(ll a, ll b)
{
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 1;
    if (b % 2)
        return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
    return expo((a * a) % mod, b >> 1) % mod;
}
ll mul(ll a, ll b)
{
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 0;
    if (b % 2)
        return ((a % mod) + (mul((a + a) % mod, b / 2) % mod)) % mod;
    return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
    return x && !(x & (x - 1));
}
ll xorcal(ll n)
{
    if (n % 4 == 0)
        return n;
    if (n % 4 == 1)
        return 1;
    if (n % 4 == 2)
        return n + 1;
    if (n % 4 == 3)
        return 0;
}
void sieve(ll n)
{
    memset(prime, true, sizeof(prime));
    prime[0] = false;
    prime[1] = false;
    for (ll i = 2; i * i <= n; i++)
    {
        if (prime[i] == true)
        {
            for (ll j = i * i; j <= n; j += i)
                prime[j] = false;
        }
    }
}
bool isprime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 or n % 3 == 0)
        return false;

    for (ll i = 5; i * i <= n; i += 6)
    {
        if (n % i == 0 or n % (i + 2) == 0)
            return false;
    }
    return true;
}

ll modinverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m;
        a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return (b % a, a);
}
bool ispalindrome(string s)
{
    string t = s;
    reverse(t.begin(), t.end());
    if (t == s)
        return true;
    return false;
}
void binary(ll a[], ll n)
{
    gor(i, 0, 64)
    {
        ll k = n >> i;
        a[i] = k & (ll)1;
    }
}
ll countBits(ll n)
{
    if (n == 0)
        return 0;
    return 1 + countBits(n & (n - 1));
}
bool palin(string s)
{
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    ll n = s.size();
    string s1 = "", s2 = "";
    go(i, 0, (n - 1) / 2) s1 += s[i];
    go(i, (n + 1) / 2, n) s2 += s[i];
    if (palin(s) and palin(s1) and palin(s2))
        show("Yes");
    else
        show("No");
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}

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

using namespace std;

int evaluateHsh(int n) {
	int ret = 0;

	while (n > 0) {
		ret += n % 10;
		n /= 10;
	}

	return ret;
}

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

	int hshNum = evaluateHsh(argN);
	if (argN % hshNum == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define MAXN 100005
#define MOD 2019
#define LL long long
int n;
LL a[MAXN],x[MAXN]; 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(i%2) x[1]+=2*a[i];
		else x[1]-=2*a[i];
	}
	x[1]/=2;
	for(int i=2;i<=n;i++)
		x[i]=2*a[i-1]-x[i-1];
	for(int i=1;i<n;i++)
		printf("%lld ",x[i]);
	printf("%lld\n",x[n]);
	return 0;
}
//LL不开毁前程 

Measured memory_bytes: 2816
from fractions import gcd
 
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
a, b, c, d = map(int, input().split())
 
yaku_b = b - (b // c + b // d - b // lcm(c,d))
yaku_a = a-1 - ((a-1) // c + (a-1) // d - (a-1) // lcm(c,d))
print(yaku_b - yaku_a)

Measured memory_bytes: 5332
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000
#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>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()


typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG 
#define VALUE(x)
#define debug(...)
#endif
/*
inline string IntToString(ll a) {
	char x[100];
	sprintf_s(x, "%lld", a); string s = x;
	return s;
}

inline ll StringToInt(string a) {
	char x[100]; ll res;
	strcpy_s(x, a.c_str()); sscanf_s(x, "%lld", &res);
	return res;
}
*/

inline string uppercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
	return s;
}

inline string lowercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
	return s;
}
int n;
ll d[100005];
ll solve() {
	ll nans = 0;
	ll nowsum = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			if (nowsum + d[i] <= 0) {
				nans += llabs(nowsum + d[i] - 1);
				nowsum = 1;
			}
			else {
				nowsum += d[i];
			}
		}
		else {
			if (nowsum + d[i] >= 0){
				nans += llabs(nowsum + d[i] - (-1));
				nowsum = -1;
			}
			else
				nowsum += d[i];
		}
		//cout << nans << endl;
	}
	return nans;
}

int main()
{
	
	cin >> n;
	rep(i, n) {
		cin >> d[i];
	}
	ll ans = solve();
	rep(i, n) d[i] *= -1;
	ans = MIN(ans, solve());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll long long
#define endl '\n'
#define pi 3.14159265
ll n;
vector<ll> v(600001);
ll dp[500001];
ll f(ll i)
{
    if(i>=n)
        return 1e16;
    if(i==n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll ans=abs(v[i+1]-v[i])+f(i+1);
    if(i+2<n)
    {
        ans=min(ans,f(i+2)+abs(v[i+2]-v[i]));
    }
    return dp[i]=ans;
}
int main()
{
    IOS;
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>v[i];
    memset(dp,-1,sizeof(dp));
    cout<<f(0);
}

Measured memory_bytes: 12032
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int pre = -999;
  rep(i, n) {
    if(pre <= h[i] - 1) {
      pre = h[i] - 1;
    } else if(pre <= h[i]) {
      pre = h[i];
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 317847191;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 10000005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
ll arr[MAXN];
ll b[MAXN];
char S[MAXN];
char T[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            sum += (ll)j;
        }
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3832
N=int(input())
B=list(map(int,input().split()))
A=[B[0]]
for i in range(N-2):
    if B[i]<=B[i+1]:
        A.append(B[i])
    else:
        A.append(B[i+1])
A.append(B[-1])
print(sum(A))

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

void ioThings() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
}

using   ll        = long long;
#define debug(x)    cerr << #x << ": <" << x << ">\n"
#define dotc()      int tcs; if (cin >> tcs) for (int tc = 0; tc < tcs; tc++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second
#define mod         1000000007

int main() {
    ioThings();

    string a; cin >> a;
    int i = a.size();
    while (i--)
        cout << 'x';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		String s=in.next();
		if(n<3200)
			System.out.println("red");
		else
			System.out.println(s);
	}
}
	

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

int main() {
	
	int a,b;
	cin>>a>>b;
	string res = "";
	if(a>=b) {
		for(int i =0;i< a;i++) {
			res = res + to_string(b); 
		}
	}
	else {
		for(int i =0;i< b;i++) {
			res = res + to_string(a); 
		}
	}
	cout<<res;
	return 0;
}

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

using namespace std;

char katu(char oppornent) {
  switch (oppornent) {
  case 'r':
    return 'p';
  case 's':
    return 'r';
  case 'p':
    return 's';
  }
  return '?';
}

int main(int argc, char const *argv[]) {
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  int ret = 0;
  vector<char> prev(k, ' ');

  for (int i = 0; i < n; i++) {
    if (prev[i % k] != katu(t[i])) {
      prev[i % k] = katu(t[i]);
      switch (katu(t[i])) {
      case 'r':
        ret += r;
        break;
      case 's':
        ret += s;
        break;
      case 'p':
        ret += p;
        break;
      }
    } else {
      prev[i % k] = ' ';
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 512
N = int(input())
S = {}
for _ in range(N):
    s = input()
    if s in S.keys():
        S[s] += 1
    else:
        S[s] = 1
S = sorted(S.items(), key=lambda x:x[1])
maxi = S[-1][1]
ans = []
for s in reversed(S):
    if s[1] == maxi:
        ans.append(s[0])
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 43228
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
const double EPS=1e-5;
bool EQ(double a,double b){
  return abs(a-b)<EPS;
}
typedef vector<double> vec;
typedef vector<vec> mat;


void fastStream(){
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
int N;
double VS[10];

vec gauss_jordan(const mat&A,const vec &b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      B[i][j]=A[i][j];
  for(int i=0;i<n;i++)
    B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int piv=-1;
    double val=-1;
    for(int j=i;j<n;j++){
      if(val<abs(B[j][i])){
        piv=j;
        val=abs(B[j][i]);
      }
    }
    if(piv==-1||val<EPS)return vec();
    swap(B[piv],B[i]);
    double divNum=B[i][i];
    for(int j=i;j<=n;j++)
      B[i][j]/=divNum;
    for(int j=0;j<n;j++){
      if(i==j)continue;
      double mulNum=B[j][i];
      for(int k=i;k<=n;k++)
        B[j][k]-=mulNum*B[i][k];
    }
  }
  vec res(n);
  for(int i=0;i<n;i++)
    res[i]=B[i][n];
  return res;
}

int solve(int d){
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      mat m(d+1,vec(d+1,0));
      vector<int> v;
      for(int k=0;k<N;k++){
        if((k==i||k==j))continue;
        v.push_back(k);
      }
      for(int k=0;k<(int)v.size();k++){
        int pos=v[k];
        double co=1;
        for(int l=0;l<d+1;l++){
          m[k][d-l]=co;
          co*=pos;
        }
      }
      vec vv(d+1,0);
      for(int k=0;k<d+1;k++){
        int pos=v[k];
        vv[k]=VS[pos];
      }
      vec ans=gauss_jordan(m,vv);
      if(ans.size()>0){
        int cnt=0;
        int ary[]={i,j};
        set<int> s;
        s.insert(i);
        s.insert(j);
        for(int k=0;k<2;k++){
          double x=1;
          double y=0;
          for(int l=0;l<d+1;l++){
            y+=ans[d-l]*x;
            x*=ary[k];
          }
          //cout<<i<<" "<<j<<" "<<k<<" "<<y<<" "<<VS[ary[k]]<<endl;
          //printf("%.10f\n",abs(y-VS[ary[k]]));
          if(EQ(y,VS[ary[k]])){
            cnt++;
            s.erase(ary[k]);
          }
        }
        // cout<<i<<" "<<j<<" "<<cnt<<endl;
        if(cnt==1){
          return *s.begin();
        }
      }
    }
  }
  return -1;
}

int main(){
  int d;
  while(cin>>d&&d){
    N=d+3;
    for(int i=0;i<N;i++)
      cin>>VS[i];
    cout<<solve(d)<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const int INF = 1e9 + 10;

struct Search {
  int y, x, cost;
  Search(int y, int x, int cost): y(y), x(x), cost(cost) { }
};

int main() {
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w + h == 0) {
      break;
    }
    vector<vector<bool>> b(2 * h + 1);
    vector<vector<int>> cost(h);
    for (int i = 0; i < 2 * h + 1; i++) {
      b[i] = vector<bool>(2 * w + 1);
    }
    for (int i = 0; i < h; i++) {
      cost[i] = vector<int>(w, INF);
    }

    for (int i = 0; i < 2 * h + 1; i++) {
      b[i][0] = true;
      b[i][2 * w] = true;
    }
    for (int i = 0; i < 2 * w + 1; i++) {
      b[0][i] = true;
      b[2 * h][i] = true;
    }
    
    for (int i = 0; i < 2 * h - 1; i++) {
      if (i % 2 == 0) {
        for (int j = 0; j < w - 1; j++) {
          int t;
          cin >> t;
          if (t == 1) {
            b[i + 1][2 * (j + 1)] = true;
          }
        }
      } else {
        for (int j = 0; j < w; j++) {
          int t;
          cin >> t;
          if (t == 1) {
            b[i + 1][2 * j + 1] = true;
          }
        }
      }
    }

    cost[0][0] = 0;
    queue<Search> que;
    que.push(Search(0, 0, 0));

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

    while (!que.empty()) {
      Search s = que.front(); que.pop();
      for (int i = 0; i < 4; i++) {
        int ny = s.y + dy[i];
        int nx = s.x + dx[i];
        if (ny < 0 || ny >= h) {
          continue;
        }
        if (nx < 0 || nx >= w) {
          continue;
        }
        if (i == 0 && b[2 * s.y][2 * s.x + 1]) {
          continue;
        }
        if (i == 1 && b[2 * s.y + 1][(s.x + 1) * 2]) {
          continue;
        }
        if (i == 2 && b[(s.y + 1) * 2][2 * nx + 1]) {
          continue;
        }
        if (i == 3 && b[2 * ny + 1][s.x * 2]) {
          continue;
        }

        if (s.cost + 1 < cost[ny][nx]) {
          cost[ny][nx] = s.cost + 1;
          que.push(Search(ny, nx, s.cost + 1));
        }
      }
    }

    if (cost[h - 1][w - 1] == INF) {
      cout << 0 << endl;
    } else {
      cout << cost[h - 1][w - 1] + 1 << endl;
    }
  } 

  return 0;
}

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

int main() {
  int d, n;
  cin >> d >> n;
  
  int tmp = 1;
  
  for(int i = 0; i < d; i++) {
    tmp *= 100;
  }
  
  if(n < 100) {
    cout << tmp * n << endl;
  }
  else {
    cout << tmp * 101 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX_N=10e5;
#define INF 10e9
int a[MAX_N],b[MAX_N],c[MAX_N];
	int N;
int dp[MAX_N+1][3];
int main(void){
		cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i] >> c[i];
		for(int j=0;j<3;j++)
			dp[i][j]=0;
	}
	dp[1][0]=a[0];
	dp[1][1]=b[0];
	dp[1][2]=c[0];
	
	if(N>1){
	for(int i=2;i<=N;i++){
		for(int j=0;j<3;j++){
			if(j==0)
				dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i-1];
			else if(j==1)
				dp[i][j]=max(dp[i-1][2],dp[i-1][0])+b[i-1];
			else
				dp[i][j]=max(dp[i-1][0],dp[i-1][1])+c[i-1];
		}
	}
	}
	cout << max(dp[N][0],max(dp[N][1],dp[N][2])) << endl;
	
	return 0;
}

Measured memory_bytes: 7552
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>
#include<vector>
#include<algorithm> //sort とかにいる

#define ll long long
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=a;i<=b;i++){
    if(i<a+k||b-k<i){
      cout<<i<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int w = 0, b = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '#') {
      b++;
    }
    else {
      w++; 
    }
  }
  int answer = min(N - b, N - w);
  int B = b, W = w;
  vector<int> white(N - 1);//左側の白
  vector<int> black(N - 1);//右側の黒
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) == '#') {
      b--;
    }
    else{
      w--; 
    }
    black.at(i) = B - b;
    white.at(i) = w;
    //cout << i << "   " << black.at(i) << " " << white.at(i) << endl;
    answer = min(answer, black.at(i) + white.at(i));
  }
  cout << answer << endl;
}

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

int main() {
	//declare the variables//
	int N, K, X, Y;
	
	//scan each variable//
	scanf("%d", &N);
	scanf("%d", &K);
	scanf("%d", &X);
	scanf("%d", &Y);

	//calculate the charge//
	if (N <= K) {
		printf("%d\n", N*X);
	}

	else {
		printf("%d\n", K*X + (N - K)*Y);
	}

	return(0);
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    int arr[1000000];
    cin >> n;
    map<int, int> dict;
    for(int i=0; i<n; i++){
        cin >>arr[i];
        dict[arr[i]] += 1;
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        int num = arr[i];
        if(dict[num] >= 2){
            continue;
        }
        if(num != 1 && dict[1] > 0){
            continue;
        }
        else{
            bool found = false;
            for(int j=2; j*j <= num; j++){
                if(num % j == 0){
                    int factor1 = j;
                    int factor2 = num/j;
                    if(dict[factor1] || dict[factor2]){
                        found = true;
                        break;
                    }
                }
            }
            if(!found){
                ans++;
                //cout << num << '\n';
            }
        }
    }
    cout << ans << '\n';    
    return 0;
}


Measured memory_bytes: 33316
N, M = map(int, input().split())

x = list(map(int, input().split()))

#print(N)
#print(M)
#print(x)

def hantei(number_1, list_1):
    for a in range(101):
        a_plus = number_1 + a
        a_minus = number_1 - a

        if a_minus not in list_1:
            return a_minus
            break
        elif a_plus not in list_1:
            return a_plus
            break
    
print(hantei(N,x))





Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin >> s >> t;
    int x=0;
    for (int i=0;i<(int)s.size(); i++) {
        if (s[i]!=t[i]) x++;
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>

using namespace std;

int main()
{

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

	int ans = 0;
	int renketsu = 1;
	for(int i=0; i<N-1; ++i){
		if(a[i] == a[i+1])
			++renketsu;
		else{
			ans += renketsu/2;
			renketsu = 1;
		}
	}
	ans += renketsu/2;

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
a, b, c = [C[i] for i in range(3, 0, -1)]

DP = [[[0] * (a + b + c - i - j + 1) for j in range(a + b - i + 1)] for i in range(a + 1)]

for i in range(a + 1):
    for j in range(a + b - i + 1):
        for k in range(a + b + c - i - j + 1):
            if i == j == k == 0:
                continue
            DP[i][j][k] = 1
            if i > 0: DP[i][j][k] += i / n * DP[i - 1][j + 1][k]
            if j > 0: DP[i][j][k] += j / n * DP[i][j - 1][k + 1]
            if k > 0: DP[i][j][k] += k / n * DP[i][j][k - 1]
            DP[i][j][k] *= n / (i + j + k)

print(DP[a][b][c])

Measured memory_bytes: 159112
#include <stdio.h>
int main(void)
{
        int H, W, i, j;
        
        while (1) {
                scanf("%d%d", &H, &W);
                if (H == 0 && W == 0) break;
                for (i = 0; i < H; i++) {
                        for (j = 0; j < W; j++) putchar('#');
                        putchar('\n');
                }
                putchar('\n');
        }
        return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

int main() {
        ios_base::sync_with_stdio( false );
        cin.tie( nullptr );
        int n;
        cin >> n;
        set< string > kinds;
        for ( int i = 0; i < n; ++i ) {
                string s;
                cin >> s;
                kinds.insert( s );
        }
        cout << ( int ) kinds.size() << "\n";
        return 0;
}


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int length = s.size();
	for (int i = 0; i < length; i++) {
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N , l , r ;
int x = 0 ;
//xは合計人数
cin >> N ;

for (int i =0 ; i < N ; i++){
    cin >> l >> r ;
x = x + ( r - l +1) ;

}

cout << x ;


}

Measured memory_bytes: 384
from itertools import accumulate
INF = float('inf')


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False
    # 素数のみ返す
    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


N = 10 ** 5
P = set(prime_numbers(N))
# これが素数
#print(P)
P = [n for n in P if (n + 1) // 2 in P]
# 自身 + 1 //2 も素数であるもののみに絞る
#print(P)
a = [0] * (N + 1)
for n in P:
    # likenumberは1にする
    a[n] = 1
# 累積和に変換
a = list(accumulate(a))


Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(a[r] - a[l - 1])


Measured memory_bytes: 13704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/
int n, k;
int a[101];
int dp[100001];

int recur(int k) {
	if (k < 0)
		return 1;
	if (k == 0)
		return 0;
	if (dp[k] != -1)
		return dp[k];
	dp[k] = 0;
	for (int i = 0; i < n; i++) {
		int x = recur(k-a[i]);
		if (x == 0) {
			dp[k] = 1;
			break;
		}
	}
	return dp[k];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<=1e5;i++)
        dp[i]=-1;
    if(recur(k)){
        cout<<"First"<<endl;
    }
    else
        cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 8696
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);		
		Long result = 0l;
		Integer n = in.nextInt();
		Integer[] a = new Integer[3*n];
		for (int i = 0; i < a.length; i++) {
			a[i] = in.nextInt();
		}		
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 1; i < 2 * n; i += 2) {
			result += a[i];
		}
		System.out.println(result);
	}
}

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

int main(){
  string S; cin >> S;
  int N=S.size();
  
  int turn1=0, turn2=0;
  
  for(int i=0; i<N; i++){
    if(i%2==0){
      if(S[i]=='0') turn1++;
    }else{
      if(S[i]=='1') turn1++;
    }
  }
  
  for(int i=0; i<N; i++){
    if(i%2==0){
      if(S[i]=='1') turn2++;
    }else{
      if(S[i]=='0') turn2++;
    }
  }
  
  cout << ((turn1>turn2)?turn2:turn1) << endl;
}

Measured memory_bytes: 512
N = gets.to_i
A = gets.split.map(&:to_i)

cost = 0

([0] + A + [0]).each_cons(2) do |from, to|
  cost += (from - to).abs
end

def f(skip, from, to)
  if from <= skip && skip <= to
    return 0
  elsif to <= skip && skip <= from
    return 0
  elsif from <= skip && to <= skip
    return (from - skip).abs + (to - skip).abs - (from - to).abs
  elsif skip <= from && skip <= to
    return (from - skip).abs + (to - skip).abs - (from - to).abs
  end
end

A.each_with_index do |a, i|
  if i == 0
    puts cost - f(a, 0, A[i + 1])
  elsif i == N - 1
    puts cost - f(a, A[i - 1], 0)
  else
    puts cost - f(a, A[i - 1], A[i + 1])
  end
end


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

string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int n;
    cin >> n;
    vector<int> leaves(n+1), suf_leaves(n+2);
    for(int i = 0; i <= n; i++) cin >> leaves[i];

    for(int i = n; i >= 0; i--) {
        suf_leaves[i] = suf_leaves[i+1] + leaves[i];
    }
    int ans = 0, nodes = 1;

    for(int d = 0; d <= n; d++) {
        if(nodes < leaves[d]) {
            cout << -1 << '\n';
            return;
        }
        ans += nodes;

        // for next level
        nodes -= leaves[d];
        nodes *= 2;
        nodes = min(nodes, suf_leaves[d+1]);    // at some level, all subtree leaf nodes will have a single chain in order to maximise nodes
    }
    cout << ans << '\n';
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 4784
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] s = sc.next().split("");
        
        Map<String, Integer> map = new HashMap<String, Integer>();
        
        for(int i=0; i<s.length; i++){
            if(map.get(s[i]) != null){
                System.out.println("no");
                return;
            }else{
                map.put(s[i], 0);
            }
        }
        
        System.out.println("yes");
    }
}

Measured memory_bytes: 23124
N, M = map(int, input().split())

students = []
for i in range(N):
    students.append(input().split())

checkpoints = []
for i in range(M):
    checkpoints.append(input().split())

for x1, y1 in students:
    result = 99999999999
    index = 1
    for x2, y2 in checkpoints:
        val = abs(int(x1) - int(x2)) + abs(int(y1) - int(y2))
        if result > val:
            ans = index
            result = val
        index += 1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};

signed main()
{
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin>>s;
    string g="keyence";
    
    rep(i,siz(s)+1)repi(j,i,siz(s)+1){
        string now=s.substr(0,i)+s.substr(j,siz(s)-j);
        //cout<<s.substr(0,i)<<" "<<s.substr(j,siz(s)-j)<<endl;
        if(now==g){
            cout<<"YES"<<endl;
            return 0;
        }
    }

    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())
F=map(int, sys.stdin.readline().split())
A.sort(reverse=True)
F.sort()

max_ans=A[0]*F[-1]

def check(temp_ans):
    if temp_ans<0:
        return False
    k=0
    for a,f in zip(A,F):
        if a*f<=temp_ans: continue
        aa=temp_ans/f
        k+=(a-aa)
        if K<k:
            return False
    else:
        return True

h=max_ans
l=-1

while h-l!=1:
    m=(h+l)/2
    if check(m):
        h=m
    else:
        l=m

print h

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

/**
 *    author:  knshnb
 *    created: Thu Mar 12 18:38:52 JST 2020
 **/

signed main() {
    Int n, m;
    cin >> n >> m;
    vector<int> num(n);
    Int ac = 0, wa = 0;
    REP(_, m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            if (num[p] != -1) {
                ac++;
                wa += num[p];
            }
            num[p] = -1;
        } else {
            if (num[p] != -1) num[p]++;
        }
    }
    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 640
N,K=gets.split.map &:to_i
as=gets.split.map &:to_i

class Integer
    def divisor_list
        return [1] if self == 1
        (1..Math.sqrt(self).to_i).select do |i|
            self%i == 0
        end.map {|e| [e, self/e]}.flatten.uniq.sort
    end
end

cand=as.inject(:+).divisor_list
cand.reverse.each do |m|
    as_mod=as.map{|i|m-i%m}.sort.reverse
    as_mod.delete(0)
    if as_mod.nil?
        puts m
        exit 0
    end
    rcnt=as_mod.inject(:+)
    lcnt=0
    for i in 0..as_mod.size-2
        rcnt+=-as_mod[i]
        lcnt+=-(m-as_mod[i])
        if rcnt % m == -lcnt % m && [rcnt,-lcnt].max <= K
            puts m
            exit 0
        end
    end
end


Measured memory_bytes: 1916
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//
# include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;

using namespace std;
using ll = long long;

int main(){
    int R; cin >> R;
    cout << (R<1200 ?"ABC": ( R<2800 ? "ARC": "AGC"));
    
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int h,a,n;
    scanf("%d %d",&h,&a);
    if(a>=h)
        printf("1");
    else if(h>=a&&h%a==0)
        printf("%d",h/a);
    else
        printf("%d",(h/a)+1);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>

#include <vector>

using namespace std;


const int N = 12, M = 1e3 + 10;

const int INF = 2e9;


vector <int> c[M];
int a[M];
int n, m;


int f[(1 << 12) + 10];

int sta[M];


int main()
{
	cin >> n >> m;
	
	for (int i = 1; i <= m; i++)
	{
		scanf("%d", &a[i]);
		int b;
		scanf("%d", &b);
		for (int j = 1; j <= b; j++)
		{
			int x;
			scanf("%d", &x);
			c[i].push_back(x - 1);
		}
	}
	
	for (int i = 1; i <= m; i++)
		for (int x : c[i])
			sta[i] |= (1 << x);
	
	for (int st = 0; st < (1 << n); st++)
		f[st] = INF;
	
	f[0] = 0;
	for (int st = 0; st < (1 << n); st++)
		for (int i = 1; i <= m; i++)
			f[st | sta[i]] = min(f[st | sta[i]], f[st] + a[i]);
	
	if (f[(1 << n) - 1] == INF) puts("-1");
	else printf("%d\n", f[(1 << n) - 1]);
	
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = f(n) - 1 - choose(n, a) - choose(n, b);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 3592
//B - Echo
#include <stdio.h>

int main(void){
    int n, i;
    char s[100];
    scanf("%d", &n);
    if(n%2==1){
        puts("No");
        return 0;    
    }
    scanf("%s", s);
    for(i=0; i<n/2; i++){
        if(s[i] != s[(n/2)+i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <float.h>
#include <math.h>

int main()
{
	double ans = 0;
	double a;
	int n;
	char str[5];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf %s", &a, str);

		if (strcmp(str, "JPY") == 0) {
			ans = ans + a;
		} else {
			ans = ans + a * 380000;
		}
	}

	printf("%.*lf\n", DBL_DIG, ans);

	return 0;
}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int ans=Integer.MAX_VALUE;
        int s1=n/6,s2=n/9;
        int[] TS=new int[n+1];
        int[] TN=new int[n+1];
        for (int i = 0; i <= n; i++) {
            int temp=i;
            while (temp/6>0){
                TS[i]+=temp%6;
                temp/=6;
            }
            TS[i]+=temp;
            temp=i;
            while (temp/9>0){
                TN[i]+=temp%9;
                temp/=9;
            }
            TN[i]+=temp;
        }
        for (int i = 0; i <= s1; i++) {
            for (int j = 0; j <= s2; j++) {
                int six=6*i;
                int nine=9*j;
                if(i*6+j*9<=n){
                    ans=min(ans,TS[i*6]+TN[j*9]+n-6*i-9*j);
                }
            }
        }
        out.println(ans);
    }
}

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

int main(){
    int n;
    cin >> n;
    ll a[n];
    ll MIN = 1e9;
    rep(i, n){
        cin >> a[i];
        MIN = min(MIN, abs(a[i]));
    }

    int cnt = 0;
    rep(i, n){
        if(a[i]<0){
            cnt++;
        }
    }

    ll sum = 0;
    if(cnt%2==0){
        rep(i, n){
            sum += abs(a[i]);
        }
    }else{
        rep(i, n){
            sum += abs(a[i]);
        }
        sum -= MIN*2;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <set>
#include <utility>
using namespace std;
string s[1000010];
int a[1000010],b[1000100];
multiset<pair<int,int>> s1,s2,s3;
int main(){
    int i,j,n;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> s[i];
        int cnt = 0;
        b[i] = 0;
        for(j=0;j<s[i].size();j++){
            if(s[i][j]=='(') cnt++;
            else cnt--;
            b[i] = min(b[i],cnt);
        }
        a[i] = cnt;
    }
    int sum = 0;
    for(i=0;i<n;i++){
        sum += a[i];
    }
    if(sum!=0){
        cout << "No" << endl;
        return 0;
    }
    for(i=0;i<n;i++){
        if(a[i]>=0){
            s1.insert({-b[i],a[i]});
        }
        if(a[i]==0){
            s2.insert({b[i],a[i]});
        }
        if(a[i]<0){
            s3.insert({-(b[i] - a[i]),-a[i]});
        }
    }
    sum = 0;
    while(s1.size()){
        auto it = s1.begin();
        pair<int,int> p = *it;
        if(sum - p.first<0){
            cout << "No" << endl;
            return 0;
        }
        s1.erase(it);
        sum += p.second;
    }
    while(s2.size()){
        auto it = s2.begin();
        pair<int,int> p = *it;
        if(sum + p.first<0){
            cout << "No" << endl;
            return 0;
        }
        s2.erase(it);
    }
    sum = 0;
    while(s3.size()){
        auto it = s3.begin();
        pair<int,int> p = *it;
        if(sum - p.first<0){
            cout << "No" << endl;
            return 0;
        }
        s3.erase(it);
        sum += p.second;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 89364
import java.util.Scanner;

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

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        if (a*b % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 22612