akhauriyash/Code-Regression huggingface dataset:
S = list(input())
L = len(S)

ans = L
for m in range(2):
  t = 0
  for i in range(L):
    s = S[i]
    if i % 2 == m:
      if s == '0':
        t += 1
    else:
      if s == '1':
        t += 1
  ans = min(ans,t)
  
print(ans)

Measured memory_bytes: 9752
// Problem : String Formation
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc158_d
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//#define int ll

signed main() {
	fast_io;
	string s; cin>>s;
	vector<char> f,b;
	int n; cin>>n;
	int rev=0;
	lp(i,0,n){
		int c; cin>>c;
		if(c==1){
			rev=rev^1;
			swap(f,b);
		}else{
			int d;char ch; cin>>d>>ch;
			if(d==1) f.pb(ch);
			else b.pb(ch);
		}
	}
	if(rev) reverse(all(s));
	for(int i=f.size()-1;i>=0;i--) cout<<f[i];
	cout<<s;
	lp(i,0,b.size()) cout<<b[i];
}
// code!=think
// least efficient code to get ac


Measured memory_bytes: 3964
import collections
s=input()
n=len(s)
a=[]
x=0
p=1
for i in range(n):
	j = n-1-i
	c = int(s[j])
	p %= 2019
	x += (p*c)%2019
	p *= 10
	x %= 2019
	a.append(x)
c=collections.Counter(a)
ans = 0
for k,v in c.items():
	if k==0:
		ans += v
	ans += v*(v-1)//2
print(ans)

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

int main(int argc, char const *argv[])
{
    long n, k;
    cin >> n >> k;
    n %= k;
    long o;
    while (true)
    {
        o = min(n, abs(n - k));
        if (n == o)
        {
            break;
        }
        n = o;
        // cout << n << endl;
    }
    cout << o << endl;
    return 0;
}


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

using namespace std; 

int main()
{
    int a , b, c; 
    int k ;
    cin >> a >> b >> c; 
    cin >> k; 
    int cnt =0; 
    while( b <= a){
        b = b*2; 
        cnt++; 
    }
    while( c <= b){
        c = c*2; 
        cnt++; 
    }
    if( cnt <= k ) cout << "Yes"<<endl ; 
    else cout <<"No"<<endl; 
    return 0; 

}


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

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t,dp[li];
lo cev;
string s;
vector<lo> v;

int main(void){
	scanf("%lld %lld",&n,&k);
	FOR{
		scanf("%lld %lld",&b[i],&a[i]);
	}
	FOR{
		for(int j=k;j>=0;j--){
			if(j-b[i]<0)dp[j]=dp[j];
			else dp[j]=max(dp[j],dp[j-b[i]]+a[i]);
		}
	}
	lo mx=0;
	//~ cout<<dp[3][8]<<endl;
	for(int i=0;i<=k;i++)mx=max(mx,dp[i]);
	printf("%lld\n",mx);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

ll n, dp[maxN], x[maxN];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll e, t; cin >> n >> e >> t;
	for (int i = 1; i <= n; i++) cin >> x[i];
	dp[0] = 0;
	int it = 0;
	ll ans = INF;
	for (int i = 1; i <= n; i++){
		while (2 * x[it + 1] < 2 * x[i] - t){
			ans = min(ans, dp[it] - 2 * x[++it]);
		}
		dp[i] = min(ans + 2 * x[i], dp[it] + t);
	}
	cout << e + dp[n] << endl;
	return 0;
}
 



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++) 
#define E "\n"

int solve()
{
    int n;
    cin >> n;
    string s="ACL";

    while(n--) cout<<s;
    cout<<E;
    return 0;    
}


int32_t main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
     int t = 1;
     //cin >> t;
     while(t--)
     {
          solve();
     }
     return 0;
}

Measured memory_bytes: 3568
import math


def primes(x):
    if x < 2: return []
    primes = [i for i in range(x)]
    primes[1] = 0
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
    return [p for p in primes if p != 0]


N = int(input())
ans = 1
for p in primes(N+1):
    k = 0
    for n in range(1,N+1):
        while n%p==0:
            n /= p
            k += 1
    ans *= k+1
    ans %= 1000000007
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int H, W; cin >> H >> W;
  int h, w; cin >> h >> w;

  cout << ((H-h)*(W-w)) << endl;

}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC043-B.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 W PIC X(100).
       77 I PIC 9(3).
       77 CN PIC 9(2).
       01 WCC.
        03 CC OCCURS 26 PIC 9(3) VALUE ZERO.
       77 NFLG PIC 9(1) VALUE ZERO.

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
            ACCEPT W FROM SYSIN.
            PERFORM VARYING I FROM 1 BY 1
             UNTIL FUNCTION STORED-CHAR-LENGTH (W) < I
               COMPUTE CN = FUNCTION ORD (W(I:1))
                               - FUNCTION ORD ("`")
               ADD 1 TO CC(CN)
            END-PERFORM.
            PERFORM VARYING I FROM 1 BY 1 UNTIL 26 < I
               IF FUNCTION REM (CC(I),2) = 1 THEN
                   MOVE 1 TO NFLG
                   EXIT PERFORM
               END-IF
            END-PERFORM.
            IF NFLG = 1 THEN
               DISPLAY "No"
            ELSE
               DISPLAY "Yes"
            END-IF
            STOP RUN.
       END PROGRAM ABC043-B.


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;
int cnt1[2020];
int cnt2[2020];

int main(){
    ll n,k; cin >> n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(a[i]>a[j])cnt1[i]++;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j])cnt2[i]++;
        }
    }
    for(int i=0;i<n;i++){
        ll m=k; ll l=k+1; ll j=k-1;
        if(k%2==0){
            m/=2;
        }
        else{
            l/=2;
            j/=2;
        }
        (ans+=cnt2[i]%mod*m%mod*l%mod)%=mod;
        (ans+=cnt1[i]%mod*m%mod*j%mod)%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int n, m;
  cin >> n >> m;
  
  vector<string> vec(n);
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    
    vec.at(i) = s;
  }
  
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      
      if (vec.at(i).at(j) == '#'){
        cout << '#';
      } else {

        int c = 0;

        //上の行
        if (i != 0){
          for(int k=max(0,(j-1)); k<=min((m-1),(j+1)); k++){
            if (vec.at(i-1).at(k) == '#') c++;
          }
        }

        //両隣
        if (j != 0 && vec.at(i).at(j-1) == '#') c++; 
        if (j != m-1 && vec.at(i).at(j+1) == '#') c++;      

        //下の行
        if (i != n-1){
          for(int k=max(0,(j-1)); k<=min((m-1),(j+1)); k++){
            if (vec.at(i+1).at(k) == '#') c++;
          }
        } 

        cout << c;
      }
      
      
    }
    cout << endl;
  }

}

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

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

    vector<vector<long long>> A(K);

    set<int> s;

    for (int i = 0; i < K; i++)
    {
        long long d;
        scanf("%lld", &d);

        for (int j = 0; j < d; j++)
        {
            long long a;
            scanf("%lld", &a);
            s.insert(a);
        }
    }

    cout << N - s.size() << endl;

    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
ll fact[400005];

long modPow(long a, long x, long p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long modInverse(long a, long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return powmod(a, mod-2);
}
long nck(long n, long k) {
// calculates C(n,k) mod p (assuming p is prime)

    // numerator / denominator mod p.
    ll res=mul(fact[n],modInverse(mul(fact[k],fact[n-k]),mod));
    res=(res+mod)%mod;
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    fact[0]=1;
    for(int i=1;i<4e5;i++){
        fact[i]=fact[i-1]*i;
        fact[i]+=mod;
        fact[i]%=mod;
    }
    ll res=nck(2*n-1,n);
    for(int i=k+1;i<n;i++){
        res=(res+mod-nck(n,i)*nck(n-1,i)%mod)%mod;
    }
    cout<<res<<endl;
    return 0;
    }


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

using namespace std;

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

int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)cin >> a[i];
    int ans = 0;
    int highest = 0;
    for(int i = 0; i < n; i++){
        if(chmax(highest, a[i])){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from heapq import heappush, heappop


def dijkstra(graph: list, node: int, start: int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF] * node

    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0, start)]

    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)

        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))

    return dist


n = ni()
graph = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = li()
    u -= 1
    v -= 1

    graph[u].append((w, v))
    graph[v].append((w, u))

dist = dijkstra(graph, n, 0)

for di in dist:
    print(0 if di % 2 else 1)

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

struct Dice {
	vector<int> val;
	Dice(){ val.resize(6); }
	bool operator == (const Dice &t) const {
		return val == t.val;
	}
	bool operator != (const Dice &t) const {
		return val != t.val;
	}
	bool operator < (const Dice &t) const {
		return val < t.val;
	}
	void rotate_right(){
		int tmp = val[1];
		val[1] = val[2];
		val[2] = val[4];
		val[4] = val[3];
		val[3] = tmp;
	}
	void roll_front(){
		int tmp = val[0];
		val[0] = val[1];
		val[1] = val[5];
		val[5] = val[4];
		val[4] = tmp;
	}
	void roll_right(){
		int tmp = val[0];
		val[0] = val[3];
		val[3] = val[5];
		val[5] = val[2];
		val[2] = tmp;
	}
	vector<Dice> all_pattern(){
		vector<Dice> res;
		Dice d = *this;
		for (int i = 0; i < 6; i++){
			for (int j = 0; j < 4; j++){
				res.push_back(d);
				d.rotate_right();
			}
			if (i == 0) d.roll_front();
			else if (i < 5) d.roll_right();
			else d.roll_front();
		}
		return res;
	}
};

struct UnionFind {
	vector<int> parent;
	
	UnionFind(int n){
		parent.resize(n);
		for (int i = 0; i < n; i++){
			parent[i] = i;
		}
	}
	
	int find(int x){
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x == y) return false;
		parent[x] = y;
	}
};

map<string, int> ctoi;
int n;
vector<Dice> dices;

bool check(const vector<Dice> &A, const vector<Dice> &B)
{
	for (int i = 0; i < A.size(); i++){
		for (int j = 0; j < B.size(); j++){
			if (A[i] == B[j]) return true;
		}
	}
	return false;
}

void solve()
{
	vector<vector<Dice> > pats;
	UnionFind uf(n);
	
	for (int i = 0; i < n; i++){
		pats.push_back(dices[i].all_pattern());
	}
	
	int res = 0;
	
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			vector<Dice> &A = pats[i];
			vector<Dice> &B = pats[j];
			if (!uf.same(i, j)){
				if (check(A, B)){
					uf.unite(i, j);
					res++;
					continue;
				};
			}
		}
	}
	
	printf("%d\n", res);
}

int main()
{
	ctoi["Red"] = 0;
	ctoi["Yellow"] = 1;
	ctoi["Blue"] = 2;
	ctoi["Magenta"] = 3;
	ctoi["Green"] = 4;
	ctoi["Cyan"] = 5;
	
	while (scanf("%d", &n), n){
		dices.clear();
		for (int i = 0; i < n; i++){
			Dice d;
			for (int j = 0; j < 6; j++){
				string str;
				cin >> str;
				d.val[j] = ctoi[str];
			}
			dices.push_back(d);
		}
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1336
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int w,a,b;
    cin >> w >> a >> b;
    if(a+w < b) cout << b-a-w << endl;
    else if(b+w < a) cout << a-b-w << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N,sum,ans;
  
  cin >> N;
  int A[2][N];
  for(int i=0; i<N; i++) cin >> A[0][i];
  for(int i=0; i<N; i++) cin >> A[1][i];

  for(int i=1; i<N; i++){
    A[0][i] = A[0][i-1] + A[0][i];
  }
  for(int i=0; i<N; i++){
    sum = A[0][i];
    for(int j=i; j<N; j++){
      sum += A[1][j];
    }
    ans = max(ans,sum);
  }
  cout << ans << endl;
}

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


int main() {
	ll N,K;
	cin >> N >> K;
	ll ans = 0;
	for (ll i = K; i <= N + 1; i++) {
		ans += N*(N+1)/2-(N-i)*(N-i+1)/2-i*(i-1)/2 + 1;
		ans %= 1000000007;
	}
	cout << ans;
}





Measured memory_bytes: 3588
import sys

n,k=map(int,input().split())

p=list(map(int,input().split()))
c=list(map(int,input().split()))

check=[0 for i in range(n)]

if max(c)<0:
    print(max(c))
    sys.exit()

ans=0

for i in range(n):
    if check[i]==0:
        cnt=0
        check[i]=1
        li=[i]
        pc=p[i]-1
        while pc!=i:
            check[pc]=1
            li.append(pc)
            pc=p[pc]-1
        sumli=0
        for j in li:
            sumli+=c[j]
        add=0
        ki=k
        if k>len(li):
            if sumli>0:
                ki=(ki-1)%len(li)+1
                add=sumli*((k-ki)//len(li))
            else:
                ki=len(li)
        for w in range(1,ki+1):
            sumwmax=0
            sumw=0
            for j in range(w):
                sumw+=c[li[j]]
            for j in range(len(li)):
                sumw=sumw-c[li[j]]+c[li[(j+w)%len(li)]]
                sumwmax=max(sumw,sumwmax)
            cnt=max(cnt,sumwmax)
        ans=max(ans,cnt+add)

print(ans)

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int D,G;
    cin >> D >> G;
    vector<int> p(D),c(D);
    for (int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }
    ll ans = INT_MAX;
    for (int b = 0; b < (1<<D); b++){
        ll t_G = 0;
        ll t_Q = 0;
        int index = 0;
        for (int i = 0; i < D; i++){
            if (b & (1<<i)){
                t_G += c[i];
                t_G += p[i] * 100 * (i+1);
                t_Q += p[i];
            } else {
                index = i;
            }
        }
        if (t_G < G){
            for (int i = 1; i < p[index]; i++){
                t_G += 100*(index+1);
                t_Q++;
                if (t_G >= G){
                    break;
                }
            }
        }
        if (t_G >= G){
            ans = min(ans,t_Q);
        }
    }
    cout << ans << endl;







    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[] nums = new long[5];
        for(int i=0;i<5;i++){
            nums[i] = sc.nextInt();
        }
        nums[0] *= 8;
        nums[1] *= 4;
        nums[2] *= 2;
        long minl = nums[0];
        for(int i=1;i<4;i++){
            minl = Math.min(minl,nums[i]);
        }

        if(nums[4]%2==1&&minl==nums[3]){
            long sum = 0;
            sum = nums[4]/2*minl;
            minl=nums[0];
            for(int i=1;i<3;i++){
                minl = Math.min(minl,nums[i]);
            }
            sum += minl/2;
            System.out.println(sum);
        }else{
            System.out.println(minl*nums[4]/2);
        }
        return;


    }
}


Measured memory_bytes: 21972
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr, minimumBy)
import qualified Data.ByteString.Char8 as BS

main = do
  [n,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let xs = [l+i-1 | i <- [1..n]]
  print $ sum xs - minimumBy (\x y -> compare (abs x) (abs y)) xs


Measured memory_bytes: 508
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    int ans = 0;
    for(int i=1;i<361;i++){
      if( i*n % 360 == 0 ){
        ans = i;
        break;
      }
    }
    System.out.print(ans);
  }
}

Measured memory_bytes: 27024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
 
int main(){
    int n;
    long long total=0;
    cin>>n;
    vector<long long> a(3*n);
    rep(i,3*n) cin>>a[i];
    sort(ALL(a),greater<int>());
    
    for(float i=1; i<=2*n - 1; i +=2){
        total += a[i];
    }
    cout<<total<<endl;
    return 0;
}

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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    lld X;
    cin >> X;
    lld now = 100.0;
    lld cnt = 0;
    while(true) {
        if(now >= X) {
            cout << cnt << endl;
            exit(0);
        }
        now += now * 0.01;
        cnt++;
    }
}

Measured memory_bytes: 3676
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = -1
sub = float("INF")
for i in range(N):
  temp = T - H[i] * 0.006
  if sub > abs(temp-A):
    sub = abs(temp-A)
    ans = i + 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<double, double> pdd;
using namespace std;


#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull testcase;cin>>testcase;while(testcase--)
#define pb push_back
#define mp make_pair
#define nl cout<<"\n"
#define prime 1000000007
#define debug(x) cout<<(#x)<<" : "<<x,nl
#define debug2(x,y) cout<<(#x)<<" : "<<x<<" "<<(#y)<<" : "<<y,nl
#define debug3(x,y,z) cout<<(#x)<<" : "<<x<<" "<<(#y)<<" : "<<y<<" "<<(#z)<<" : "<<z,nl
#define f first
#define s second
#define oa(a,n) loop(i,0,n)cout<<a[i]<<" ";nl;
#define ov(a) loop(i,0,a.size()) cout<<a[i]<<" ";nl;
#define MOD(a) (((a%prime)+prime)%prime)


int main()
{


    ll a,p;

    cin >> a >>p;

    cout << (3*a+p)/2 << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type As [][]int

func (a As) Len() int {
	return len(a)
}

func (a As) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a As) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

func main() {
	var n int
	fmt.Scan(&n)
	ls := make(As, n)
	for i := range ls {
		var x, l int
		fmt.Scan(&x, &l)
		ls[i] = []int{x - l, x + l}
	}
	sort.Sort(ls)

	var cnt int
	pr := int(-1e9 - 1)
	for i := range ls {
		l, r := ls[i][0], ls[i][1]
		if l >= pr {
			cnt++
			pr = r
		}
	}

	fmt.Println(cnt)
}


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

int main()
{
  int N;
  cin >> N;
  vector<int64_t> A(N);
  int64_t total = 0;
  int64_t at = 0;
  int mod = 1000000007;
  
  for(int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  for(int i = N - 1; i > 0; i--)
  {
    at += A.at(i);
    at = at % mod;
    total += A.at(i - 1) * at % mod;
    total = total % mod;
  }
  cout << total << endl;
}

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

using namespace std;
int prime(int n) 
{ 
    if (n <= 1) 
        return 0; 
  
   
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return 0; 
  
    return 1; 
} 
int main()
{
   int n=0,x,a,b;
    cin>>x;
    

    for (int i = x;; i++) 
    {
       int d=prime(i);
        if(d)
        {
            cout<<i;
            break;
        }
    }
    
    
    return 0;
}



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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> x(N);
    rep(i, 0, N) cin >> x[i];
    ll ans = 0;
    rep(i, 0, N){
        ans += 2*min(x[i], K-x[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
char s[10] ;
int main()
{
	scanf("%s" , s) ;
	if(strcmp(s , "SAT") == 0)
	  printf("1\n") ;
	else if(strcmp(s , "SUN") == 0)
	  printf("7\n") ;
	else if(strcmp(s , "FRI") == 0)
	  printf("2\n") ;
	else if(strcmp(s , "TUE") == 0)
	  printf("5\n") ;
	else if(strcmp(s , "WED") == 0)
	  printf("4\n") ;
	else if(strcmp(s , "THU") == 0)
	  printf("3\n") ;
	else
	  printf("6\n") ;
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;
const LL MOD = 2019;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		string s;
		cin >> s;
		if (s.empty()) return 0;
		LL ans = 0, sum = 0;
		vector<LL> dp(MOD + 1);
		dp[0] = 1;
		LL d = 1, x = 0;
		// 桁DP
		for (auto it = s.rbegin(); it != s.rend(); ++it) {
			x = (x + d * (*it - '0')) % MOD;
			ans += dp[x];
			dp[x] += 1;
			d = (d * 10) % MOD;
		}
		cout << ans << endl;
	}
	return 0;
}


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

#define rep(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define pb push_back

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

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

  vi C;
  int now = 1, cnt = 0;
  rep(i, n){
    if(s[i] == (char)(now + '0')) cnt++;
    else{
      C.pb(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  C.pb(cnt);
  if(C.size()%2 == 0) C.pb(0);

  int m = C.size();
  vi S(m+1); rep(i, m) S[i+1] = S[i] + C[i];

  int ans = 0;
  for (int i = 0; i < m; i += 2) {
    //chmax(ans, S[i+2*k+1] - S[i]); これじゃダメ
    int left = i;
    int right = min(i+2*k+1,m);// ここ気を付ける
    chmax(ans, S[right] - S[left]);
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1272
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))
button = lis[0]
count = 1
if button == 2:
    ans = 1
else:
    while True:
        count += 1
        button = lis[button - 1]
        if button == 2:
            ans = count
            break
        if count > n:
            ans = -1
            break
print(ans)

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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

int main()
{
    ll x;
    cin >> x;
    Rep(i, -200, 200)
    {
        Rep(j, -200, 200)
        {
            if (pow(i, 5) - pow(j, 5) == x)
            {
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3988
#include<cstdio>
using namespace std;
int main(void)
{
	char c;
	while(~scanf("%c",&c))
	{
		getchar();
		if(c>='a'&&c<='z')
		puts("a");
		else //if(c>='A'&&c<)
		puts("A");
	}
	return 0;
 } 

Measured memory_bytes: 2992
#include <stdio.h>          // printf(), scanf(), fgets()
#include <stdbool.h>

#define H 100
#define W 100

int
main(int argc, char **argv)
{
	int h, w;
	char tiles[H][W + 2];
	bool used[H][W];
	int x, y;

	while (true)
	{
		scanf("%d %d\n", &h, &w);
		if (h == 0 && w == 0)
			break;

		for (y = 0; y < h; ++y)
			fgets(&tiles[y][0], W + 2, stdin);

		for (y = 0; y < h; ++y)
		{
			for (x = 0; x < w; ++x)
				used[y][x] = false;
		}

		x = 0, y = 0;
		while (tiles[y][x] != '.' && !used[y][x] && 0 <= x && x < w && 0 <= y && y < h)
		{
			used[y][x] = true;
			switch (tiles[y][x])
			{
			case '>':
				x++; break;

			case '<':
				x--; break;

			case '^':
				y--; break;

			case 'v':
				y++; break;
			}
		}

		if (used[y][x])
			printf("LOOP\n");

		else if (tiles[y][x] == '.')
			printf("%d %d\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
ll n,k;

int main(int argc,char const* argv[])
{
  cin >> n >> k;
  ll ans=0;
  for(int i=0;i<n-1;i++)
    {
      ans=k*(ans/(k-1))+ans%(k-1)+1;
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3116
N, W = map(int,input().split())
wn = [0]*N
vn = [0]*N
vnmax = pow(10,3)*N+1
dp = [10**9+1]*(vnmax)
dp[0] = 0

for n in range(N):
  wn, vn = map(int,input().split())
  for v in range(vnmax-1,vn-1,-1):
    dp[v] = min(dp[v],dp[v-vn]+wn)

num = 0
for v in range(1,vnmax):
  if dp[v] <= W: num = v
print(num)


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

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		boolean[] prime = new boolean[250000];
		
		Arrays.fill(prime,true);
		prime[0] = false;
		prime[1] = false;
		
		for(int i=2;i<250000;i++)
		{
			if(prime[i])
			{
				int j = i*2; 
				while(j<250000)
				{
					prime[j] = false;
					j = j + i;
				}
			}
		}
		
		while(true)
		{
			int n = stdIn.nextInt();
			
			if(n==0)
			{
				break;
			}
			
			int count = 0;
			
			for(int i=n+1;i<=n*2;i++)
			{
				if(prime[i])
				{
					count++;
				}
			}
			
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 20964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String result = "";
		for(int i = 0 ;  i<N ;i++){
			BigDecimal bd1 = new BigDecimal(br.readLine());
			BigDecimal bd2 = new BigDecimal(br.readLine());
			bd1 = bd1.add(bd2);
			if(bd1.toString().length() <= 80){
				result += bd1.toString()+"\n";
			}else{
				result += "overflow\n";
			}
		}
		System.out.print(result);
	}

}

Measured memory_bytes: 24516
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n,ac=0,tle=0,re=0,wa=0;
 string s;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     cin>>s;
     if(s[0]=='A')
        ac++;
     else if(s[0]=='W')
        wa++;
     else if(s[0]=='T')
        tle++;
     else
        re++;
 }

     cout<<"AC x "<<ac<<endl;
     cout<<"WA x "<<wa<<endl;
     cout<<"TLE x "<<tle<<endl;
     cout<<"RE x "<<re<<endl;
return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cmath>
#define ll long long
using namespace std;


ll mmin(ll a, ll b) {
    if (a< b) {
        return  a;
    }else {
        return b;
    }
}
int myPow(int x, int p)
{
    if (p == 0)
        return 1;
    if (p == 1)
        return x;

    int tmp = myPow(x, p / 2);
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return x * tmp * tmp;
}

int main() {
    ll n,m,x;
    cin >> n>>m>>x;
    int c[n];
    int a[n][m];
    for (int i=0;i < n;i++) {
        cin >> c[i];
        for (int j=0;j < m;j++) {
            cin >>a[i][j];
        }
    }
    ll temp = myPow(10,9);
    for (int i=0;i <  myPow(2, n);i++ ) {
        ll cost =0;
        int te[m] = {0};
        int part=1;
         for (int j=0;j < n;j++) {
            if ((i/ part)%2 ==1){
                cost += c[j];
                for (int k = 0; k < m; k++) {
                    te[k] += a[j][k];
                }
            } 
            //cout << (i / part) % 2  ;
            part =part*2;
        } 
        bool flag = true;
        for (int k=0;k < m;k++) {
            if (te[k]<x){
                flag =false;
            }
        }
        
        if (flag) {
            temp = mmin(temp,cost);
            //cout << "cost = " << cost << endl;
        }  
 
    }
    if (temp ==myPow(10,9)){
        cout << "-1";
    }else {
        cout << temp;
    }
}

Measured memory_bytes: 3588
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

int main(){

  int N;
  cin >> N;
  int a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int prefix[N+1];
  int suffix[N+1];
  prefix[0] = 0;
  for(int i=1; i< N+1; i++){
    prefix[i] = gcd(prefix[i-1], a[i-1]);
    // cout << prefix[i] << endl;
  }
  // cout << endl;
  suffix[N] = 0;
  for(int i=N-1; i >=0; i--){
    suffix[i] = gcd(suffix[i+1], a[i]);
  }

  int ans = 1;
  for(int i=0; i<N; i++){
    ans = max(ans, gcd(prefix[i], suffix[i+1]));
  }
  cout << ans << endl;

}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];

    VVL dp(h, VL(w));
    dp[0][0] = 1;
    REP(i,h) REP(j,w){
        if (i < h - 1 && s[i + 1][j] == '.'){
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
        }
        if (j < w - 1 && s[i][j + 1] == '.'){
            dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % mod;
        }
    }
    cout << dp[h-1][w-1] << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  if(N/10%111 ==0 || N%1000%111 ==0){
    cout << "Yes" << endl;}
  
  else{cout << "No" << endl;}
  
  }
  
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int board = 1;
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (board < K) board += board;
    else board += K;
  }
  cout << board << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

S = input()

yy = int(S[0:2])
mm = int(S[2:])

yymm = False
mmyy = False

if yy > 0 and yy < 13:
    mmyy = True
if mm > 0 and mm < 13:
    yymm = True

if yymm and mmyy :
    print("AMBIGUOUS")
elif yymm and not mmyy:
    print("YYMM")
elif not yymm and mmyy:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 9180
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
A = list(int(input()) for _ in range(M))

mod = 10**9+7

# 床が壊れてる階段を高速に判別できるように
B = [True]*(N+1)
for a in A:
    B[a] = False

# dp[i] : i番目の階段までの場合の数
dp = [0]*(N+1) 
dp[0] = 1
dp[1] = 1 if 1 not in A else 0 

for i in range(2,N+1):
    if B[i]:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod

print(dp[N])


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

int main(){
	list<int> yama;
	int tmp=0;
	while(yama.size()<10){
		cin>>tmp;
		yama.push_back(tmp);
	}
	yama.sort(greater<int>());
	list<int>::iterator it=yama.begin();
	for(int i=0;i<3;i++){
		cout<<*it<<endl;
		it++;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string.h>
#include <set>
#include <cstdlib>
#include <iostream>
#include <bits/stdc++.h>
#define sl(n) scanf("%lld",&n)
#define s(n) scanf("%d",&n)
#define f(n) for(int i=0;i<n;++i)
#define fo(n) for(int i=1;i<=n;++i)
#define ll long long
#define pb push_back
#define pf printf
#define F first
#define S second
using namespace std;
 typedef pair <int , int> l;
ll arr[150001];

bool comp(l a, l b){
	return a.first< b.first;
}

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s.size()>n){
		for(int i=0;i<n; i++)cout<<s[i];
		cout<<"...";
	}
	else cout<<s;
	


}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll l = lcm(c, d);
    ll e = (b / c - (a - 1) / c) + (b / d - (a - 1) / d);
    ll f = (b / l - (a - 1) / l);
    cout << (b - a + 1) - e + f << endl;

}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

double dp[3000][3000];

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	cout << fixed << setprecision(15);
	vector<double> arr(n+1);
	for(int i = 1; i <= n; i++)
		cin >> arr[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= i; j++) {
			dp[i][j] = dp[i-1][j]*arr[i];
			if(j)
				dp[i][j] += dp[i-1][j-1]*(1-arr[i]);
			//cout << i << ' ' << j << '\n' << dp[i][j] << '\n';
		}
	//cout << dp[n][0] << '\n';
	double ans = 0;
	for(int i = 0; i <= n/2; i++)
		ans += dp[n][i];
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 49992
// inputに入力データ全体が入る
function Main(input) {

  var inp = input.split(" ");
  var a = parseInt(inp[0]);
  var b = parseInt(inp[1]);
  var c = Math.ceil((a + b) / 2);
  console.log('%d', c);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 21952
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int a,b,c,d;
    while(cin>>a>>b>>c>>d)
    {
        if((a==1||a==3||a==5||a==7||a==8||a==10||a==12)&&b==31){cout<<1<<endl;continue;}
        if((a==4||a==6||a==9||a==11)&&b==30){cout<<1<<endl;continue;}
        if((a==2)&&b==28){cout<<1<<endl;continue;}
        cout<<0<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            int count = X / 100;
            int fraction = X % 100;
            Console.WriteLine(count * 5 < fraction ? 0 : 1);
        }
    }
}


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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	lli a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}

Measured memory_bytes: 3640
const main = (input) => {
    input = input.split('\n');
    const K = input[0];
    const tmp = input[1].split(' ');
    const A = parseInt(tmp[0]);
    const B = parseInt(tmp[1]);

    for (let i = A; i <= B; i++) {
        if (i % K === 0) {
            console.log('OK');
            return;
        }
    }

    console.log('NG');
};

// 標準入力
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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

    while (true) {
        ll N, M;
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        vector<ll> P(N + 1);
        P.at(0) = 0;
        for (int i = 1; i <= N; ++i) {
            cin >> P.at(i);
        }
        vector<ll> V;
        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j <= N; ++j) {
                V.push_back(P.at(i) + P.at(j));
            }
        }
        sort(V.begin(), V.end());

        ll ans = 0;
        for (int i = 0; i < V.size(); ++i) {
            auto itr = upper_bound(V.begin(), V.end(), M - V.at(i));
            if (itr == V.begin()) continue;
            ans = max(ans, V.at(i) + *(itr - 1));
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 18984
#include<bits/stdc++.h>
using namespace std;
long long solve(int n)
{
	long long sum = 0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
		{
			int g = __gcd(i,j);
			for(int h=1;h<=n;++h)
				sum += 1LL*__gcd(g,h);
		}
	return sum;	
}
int main()
{
	int n;
	cin>>n;
	cout<<solve(n);
	return 0;
}

Measured memory_bytes: 3632