akhauriyash/Code-Regression huggingface dataset:
using System;

namespace _126B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            bool YYMM = false;
            bool MMYY = false;

            int F = N / 100;
            int B = (N % 100);

            if (B >= 1 && B <= 12)
            {
                YYMM = true;
            }
            if (F >= 1 && F <= 12)
            {
                MMYY = true;
            }

            if (YYMM == true && MMYY == true)
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (YYMM == true)
            {
                Console.WriteLine("YYMM");
            }
            else if(MMYY == true)
            {
                Console.WriteLine("MMYY");
            }
            else
            {
                Console.WriteLine("NA");
            }




        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int n,m,i,x,y,ans[200005],dfn[N],low[N],xb,st[N],w,bel[N],scnt;
vector<pair<int,int>>e[N],tmp,tmp2;
bool b[N];
void dfs(int x){
	dfn[x]=low[x]=++xb;st[++w]=x;
	for(auto u:e[x])if(!dfn[u.first]){
		dfs(u.first);low[x]=min(low[x],low[u.first]);
	}else if(!bel[u.first])low[x]=min(low[x],low[u.first]);
	if(dfn[x]==low[x])for(++scnt;;){
		bel[st[w]]=scnt;
		for(auto u:e[st[w]])if(bel[u.first] && bel[u.first]!=scnt)ans[u.second]=1;
		if(st[w--]==x)break;
	}
}
void dfs2(int x){b[x]=1;for(auto u:e[x])if(!b[u.first])dfs2(u.first);}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(i=1;i<=m;++i)cin>>x>>y,e[x].push_back(make_pair(y,i));
	for(i=1;i<=n;++i)if(!dfn[i])dfs(i);
	for(i=1;i<=n;++i){
		memset(b+1,0,n);b[i]=1;tmp.clear();tmp2.clear();
		for(auto u:e[i])if(!b[u.first])tmp.push_back(u),dfs2(u.first);
			else tmp2.push_back(u);
		memset(b+1,0,n);b[i]=1;reverse(tmp.begin(),tmp.end());
		for(auto u:tmp2)dfs2(u.first);
		for(auto u:tmp)if(!b[u.first])ans[u.second]^=1,dfs2(u.first);
	}
	for(i=1;i<=m;++i)cout<<(ans[i]?"diff\n":"same\n");
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,cnt=0;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	rep(i,n){
	    while(a[i]%2==0){
	        cnt++;
	        a[i]/=2;
	    }
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,a,b;
    string s;
    cin>>k;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0&&k<=i){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    }


Measured memory_bytes: 3628
<?php
  list($h,$w) = explode(" ", trim(fgets(STDIN)));
  $s=[];
  for($i=0;$i<$h;$i++){
    list($tmp) = explode(" ", trim(fgets(STDIN)));
    $s[] = str_split($tmp);
  }

  for($i=0;$i<$h;$i++){
    for($j=0;$j<$w;$j++){
      if($s[$i][$j]=="#"){
        if(isset($s[$i][$j+1])){
          if($s[$i][$j+1]=="#"){
            continue;
          }
        }
        if(isset($s[$i][$j-1])){
          if($s[$i][$j-1]=="#"){
            continue;
          }
        }
        if(isset($s[$i+1][$j])){
          if($s[$i+1][$j]=="#"){
            continue;
          }
        }
        if(isset($s[$i-1][$j])){
          if($s[$i-1][$j]=="#"){
            continue;
          }
        }
        echo "No";
        exit;
      }
    }
  }

  echo "Yes";

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

bool check(const char *p, int n){

    char buf[128];
    char cbuf[128];
    memset(cbuf, 0, sizeof(cbuf));
    strcpy(buf, p);
    int len = strlen(buf);

    int m = 0;
    int idx = 0;
    int lastnum = 0;

    for(int i = len - 1; i >= -1; i--){
        int nn = n;

        if(i < 0 || buf[i] == '=' || buf[i] == '+'){
            if(idx > 1 && lastnum == 0) return false;
            if(i < 0) continue;
        }

        if(buf[i] == '=' || buf[i] == '+'){
            m = 1; idx = 0;
            continue;
        }

        if(buf[i] != 'X') nn = buf[i] - '0';
        lastnum = nn;

        if(m == 0){
            cbuf[idx++] = nn;
            continue;
        }
        for(int j = idx; j < sizeof(cbuf) && nn > 0; j++){
            cbuf[j] -= nn; nn = 0;
            if(cbuf[j] < 0){
                cbuf[j] += 10;
                nn = 1;
            }
        }
        if(nn) return false;
        idx++;
    }
    for(int i = 0; i < sizeof(cbuf); i++){
        if(cbuf[i] != 0) return false;
    }
    return true;
}

int main(void){

    char buf[128];
    while(fgets(buf, sizeof(buf), stdin)){
        if(buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;

        int i;
        for(i = 0; i < 10; i++){
            if(check(buf, i)){
                printf("%d\n", i);
                break;
            }
        }
        if(i == 10){
            printf("NA\n");
        }
    }
    return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(L):
    M = Mod(10**9 + 7)
    dp = [[0] * (len(L)+1) for _ in range(2)]
    dp[0][0] = 1

    for i, l in enumerate(map(int, L)):
        if l == 1:
            dp[0][i+1] = M.mul(dp[0][i], 2)
            dp[1][i+1] = M.add(dp[0][i], M.mul(dp[1][i], 3))
        else:
            dp[0][i+1] = dp[0][i]
            dp[1][i+1] = M.mul(dp[1][i], 3)
    return M.add(dp[0][len(L)], dp[1][len(L)])


def main():
    L = read_str()
    print(slv(L))


if __name__ == '__main__':
    main()


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

int main(void) {
    int a, b, c, d;
    string ret = "";

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        ret = "Left";
    } else if (a + b < c + d) {
        ret = "Right";
    } else {
        ret = "Balanced";
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	string s;
	cin >> s;
	string t = "ACTG";
	for(int i = 0; i < s.size(); ++i){
		for(int j = 0; j < t.size(); ++j){
			if(s[i] == t[j]){
				s[i] = t[(j + 2) % sz(t)];
				break;
			}
		}
	}
	cout << s;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct data {
    int w, s, v;
    bool operator<(const data& rhs) const {
        return w + s < rhs.w + rhs.s;
    }
};
int main()
{
    int N; cin >> N;
    vector<struct data> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].w >> A[i].s >> A[i].v;
    }
    sort(begin(A), end(A));
    vector<long long> value(20001);
    for (int i = 0; i < N; i++) {
        for (int j = A[i].s; j >= 0; j--) {
            value[j + A[i].w] = max(value[j + A[i].w], value[j] + A[i].v);
        }
    }
    cout << *max_element(begin(value), end(value)) << endl;
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r[n+1],g[n+1],b[n+1],rn=0,gn=0,bn=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			rn++;
			r[rn]=i;
		}
		if(s[i]=='G'){
			gn++;
			g[gn]=i;
		}
		if(s[i]=='B'){
			bn++;
			b[bn]=i;
		}
	}
	long long ans=0;
	for(int i=1;i<=rn;i++){
		for(int j=1;j<=bn;j++){
			int xx=gn;
			if(min(r[i],b[j])-abs(r[i]-b[j])>=0){
				if(binary_search(g+1,g+gn+1,min(r[i],b[j])-abs(r[i]-b[j]))){
					xx--;
				}
			}
			if(max(r[i],b[j])+abs(r[i]-b[j])<n){
				if(binary_search(g+1,g+gn+1,max(r[i],b[j])+abs(r[i]-b[j]))){
					xx--;
				}
			}
			if(abs(r[i]-b[j])%2==0){
				if(binary_search(g+1,g+gn+1,abs(r[i]-b[j])/2+min(r[i],b[j]))){
					xx--;
				}
			}
			//cout<<r[i]<<" "<<b[j]<<" "<<xx<<" "<<max(r[i],b[j])+abs(r[i]-b[j])<<endl;
			ans+=xx;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>

double round_d(double x) {
    if ( x >= 0.0 ) {
        return floor(x + 0.5);
    } else {
        return -1.0 * floor(fabs(x) + 0.5);
    }
}

int main(){
double num1[10000],num2[10000],num3[10000],num4[10000],num5[10000],num6[10000],x=0.0,y=0.0;
int i,count=0;
for(i=0;i<10000;i++){
if(scanf("%lf %lf %lf %lf %lf %lf",&num1[i],&num2[i],&num3[i],&num4[i],&num5[i],&num6[i])==EOF)break;
count++;
}
for(i=0;i<count;i++){
if((num1[i]==0.0&&num4[i]==0.0)==1||(num2[i]==0.0&&num5[i]==0.0)==1||(num1[i]==0.0&&num2[i]==0.0)==1||(num4[i]==0.0&&num5[i]==0.0)==1||(num2[i]*num4[i]-num1[i]*num5[i])==0.0){}
else{
if(num1[i]==0.0){y=num3[i]/num2[i];x=num6[i]/num4[i]-num3[i]*num5[i]/(num2[i]*num4[i]);}
else if(num2[i]==0.0){x=num3[i]/num1[i];y=num6[i]/num5[i]-num3[i]*num4[i]/(num1[i]*num5[i]);}
else if(num4[i]==0.0){y=num6[i]/num5[i];x=num3[i]/num1[i]-num2[i]*num6[i]/(num1[i]*num5[i]);}
else if(num5[i]==0.0){x=num6[i]/num4[i];y=num3[i]/num2[i]-num1[i]*num6[i]/(num2[i]*num4[i]);}
else{
x=(num2[i]*num6[i]-num3[i]*num5[i])/(num2[i]*num4[i]-num1[i]*num5[i]);
x=round_d(x*1000.0)/1000.0;
y=(num1[i]*num6[i]-num3[i]*num4[i])/(num1[i]*num5[i]-num2[i]*num4[i]);
y=round_d(y*1000.0)/1000.0;
}
printf("%.3f %.3f\n",x,y);
}
}
return 0;
}

Measured memory_bytes: 684
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
int main(){
	double x1, x2, x3, y1, y2, y3;
	int n;
	cin >> n;
	rep(i, n){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
		double b = sqrt(pow(x3-x1,2)+pow(y3-y1,2));
		double c = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
		double A = a*a;
		double B = b*b;
		double C = c*c;
		
		double px= (A*(B+C-A)*x1+B*(C+A-B)*x2+C*(A+B-C)*x3)/(A*(B+C-A)+B*(C+A-B)+C*(A+B-C));
		double py= (A*(B+C-A)*y1+B*(C+A-B)*y2+C*(A+B-C)*y3)/(A*(B+C-A)+B*(C+A-B)+C*(A+B-C));
		double r= a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
	return 0;
}

Measured memory_bytes: 1244
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    
    cout << 10*a[0] + a[1] + a[2] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
constexpr i64 mod = 1000000007;

long long *fact, *inv;

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

int main() {
    i64 n, x;
    std::cin >> n >> x;
    std::vector<int> s(n);
    for (auto &el : s) std::cin >> el;
    std::sort(s.begin(), s.end(), std::greater<>());
    std::vector<i64> vv(n + 1);
    for (i64 i = 1; i <= n; i++) vv[i] = inverse(i, mod);
    std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(x + 1));
    dp[0][x] = 1;
    for (int i = 1; i <= n; i++) for (int j = 0; j <= x; j++) {
        dp[i][j % s[i - 1]] = (dp[i][j % s[i - 1]] + dp[i - 1][j] * vv[n + 1 - i] % mod) % mod;
        dp[i][j] = (dp[i][j] + dp[i - 1][j] * vv[n + 1 - i] % mod * (n - i) % mod) % mod;
    }
    i64 ret = 0;
    for (i64 i = 0; i <= x; i++) ret = (ret + i * dp[n][i]) % mod;
    for (i64 i = 2; i <= n; i++) ret = ret * i % mod;
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 158592
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back


int main(){
    int N;
    cin >> N;
    bool ok = true;
    rep(i,N){
        int a; cin >> a;
        if(a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) ok = false;
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

class SegmentTreeSum
{
private:
    int m_n;
    vector<int> m_dat;
    
public:
    void init(int n) {
        m_n = 1;
        while (m_n < n) m_n *= 2;

        m_dat.resize(2 * m_n - 1, 0);
    }

    // k????????????a?????????
    void update(int k, int a) {
        k += m_n - 1;
        m_dat[k] += a;

        while (k > 0) {
            k = (k - 1) / 2;
            m_dat[k] = m_dat[k * 2 + 1] + m_dat[k * 2 + 2];
        }

        // cout << "m_n: " << m_n << endl;
        // cout << "m_data:";
        // REP(i, 2 * m_n - 1) cout << m_dat[i] << ",";
        // cout << endl;
    }

    // [a, b)???????????§????¨??????????
    int query(int a, int b) {
        return queryInternal(a, b, 0, 0, m_n);
    }

private:
    int queryInternal(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return 0;
        }
        if (a <= l && r <= b) return m_dat[k];
        else {
            int vl = queryInternal(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = queryInternal(a, b, k * 2 + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }
};

// DSL_2_A??¨?????°?????????
// 1-origin???????????¨???
int main(){
    int N, Q;
    cin >> N >> Q;
    
    SegmentTreeSum st;
    st.init(N+1); // 1-origin??????
    
    REP(q, Q) {
        int com, x, y;
        cin >> com >> x >> y;
        
        if (com == 0) {
            st.update(x, y);
        }
        else {
            auto res = st.query(x, y+1);
            cout << res << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        int A, B, C, K;
        cin >> A >> B >> C >> K;
            if(A >= B && A >= C){
                //cout << 2*K*A+B+C << endl;
                    //return 0;
                for(int i = 0; i < K; i++){
                    A = 2*A;
                }
                        cout << A + B + C;
                return 0;
            }else if(B >= A && B >= C){
                //cout << A+2*K*B+C << endl;
                    //return 0;
                for(int i = 0; i < K; i++){
                    B = 2*B;
                }
                        cout << A + B + C;
                return 0;
            }else if(C >= A && C >= B){
                //cout << A+B+2*K*C << endl;
                    //return 0;
                for(int i = 0; i < K; i++){
                    C = 2*C;
                }
                        cout << A + B + C;
                return 0;
            }else{}
    return 0;}


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

int main(){
    long N; cin>>N;
    ll power = 1;
    rep(i, N){
        power *= i+1;
        power %= 1000000007;
    }

    cout << power << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  lint H[N];
  REP(i,N)cin>>H[i];
  sort(H,H+N);
  lint ans=0;
  REP(i,N-K)ans+=H[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>

using namespace std;

//////////////////////////////////////////////////////////////////////////
/* Custom function starts here */

/* Custom function ends here: */
//////////////////////////////////////////////////////////////////////////////

int main() {


  /* MAIN Code STARTS here: */
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
  /* MAIN Code ENDS here: */
 
}

Measured memory_bytes: 3128
def mapt(fn, *args):
    return list(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    a, b = Input()
    if a >= 13:
        print(b)
    elif 6 <= a <= 12:
        print(b//2)
    else:
        print(0)

main()

Measured memory_bytes: 9084
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
	vector<int> prime_num{ 2, 3 };
	int n;

	while (cin >> n){
		int result;
		if (n <= 1) {
			result = 0;
		}
		else if (n == 2){
			result = 1;
		}
		else if (n < prime_num.back()){
			result = count_if(prime_num.begin(), prime_num.end(), [n](int a){return a <= n; });
		}
		else {
			for (int i = prime_num.back() + 2; i <= n; i += 2) {
				int temp = static_cast<int>( sqrt(i));
				auto it = find_if(prime_num.begin(), prime_num.end(), [temp](int a){return a > temp; });
				if (all_of(prime_num.begin(), it, [i](int a){return (i % a) != 0; })) {
					prime_num.push_back(i);
				}
			}
			result = prime_num.size();
		}

		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1728
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <iomanip>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
typedef long long int ll;
#define INF 1000000000

using namespace std;
int main() {

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


	ll ans = 0;
	//cout << ans << endl;
	for (int i = 0; i < n; i++) {
		ans += b[a[i] - 1];
		if (a[i] >= 1 && a[i] == a[i - 1] + 1) {
			ans += c[a[i] - 2];
		}
		//cout << ans << endl;
	}
	cout << ans << endl;

	return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<pii> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i].second >> a[i].first;
    }
    sort(begin(a), end(a));
    int now = 0;
    for(int i = 0; i < n; ++i){
        if(a[i].first - now < a[i].second){
            cout << "No\n";
            return 0;
        }

        now += a[i].second;
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 1792
N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = Array.new(N+1, "!")
dp[0] = ""
(2..N).each do |i|
    as.each do |a|
        next if i-num[a] < 0 || dp[i-num[a]] == "!"
        d2 = dp[i-num[a]] + a.to_s
        if d2.size > dp[i].size || (d2.size == dp[i].size && d2 > dp[i])
            dp[i] = d2
        end
    end
end

puts dp[N]

Measured memory_bytes: 61692
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) {
		
		int [][] array = new int [100][2];
		
		int counter = 0;
		
		Scanner input = new Scanner (System.in);
		
		while (input.hasNext()) {
			int a = input.nextInt();
			boolean found = false;
			
			for (int i = 0; i < counter; i++) {
				if (array[i][0] == a) {
					array[i][1]++;
					found = true;
					
				}
			}
			
			if (!found) {
				array[counter][0] = a;
				array [counter][1] = 1;
				counter++;
			}
		}
		
		ArrayList<Integer> mode = new ArrayList<>();
		
		int max = array[0][1];
		
		for (int i = 1; i < counter; i++) {
			if (array[i][1] > max)
				max = array[i][1];
		}
		
		for (int i = 0; i < counter; i++) {
			if (array[i][1] == max)
				mode.add(array[i][0]);
		}
		
		Collections.sort(mode);
		
		for (int i = 0; i < mode.size(); i++) {
			System.out.println(mode.get(i));
		}

	}

}

Measured memory_bytes: 26204
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, x, y;std::cin >> n;
  ll e = 0;
  vvl d = vv(100000, 2, 0, ll);
  std::vector<ll> num(n);
  ll o = 0;

  for(int j=0;j<n;j++){
    std::cin >> num[j];
    for(int m=0;m<num[j];m++){
      std::cin >> x >> y;
      d[o+m][0] = x, d[o+m][1] = y;
    }
    o += num[j];
  }

  for(int i=0;i<(1<<n);i++){
    o = 0;
    bool flag = true;
    std::vector<bool> t(n, false);
    ll tmp = i;
    ll c = 0;
    ll ans = 0;
    while(tmp>0){
      if(tmp%2==1) t[c] = true, ans++;
      tmp/=2;
      c++;
    }
    for(int j=0;j<n;j++){
      ll a = num[j];
      for(int k=0;k<a;k++){
        x = d[o+k][0], y = d[o+k][1];
        if(t[j]==true&&t[x-1]==false&&y==1) flag = false;
        if(t[j]==true&&t[x-1]==true&&y==0) flag = false;
      }
      o += a;
    }
    //std::cout << e << '\n';
    if(flag) e = max(e, ans);
  }
  std::cout << e << '\n';
  return 0;
}


Measured memory_bytes: 6264
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [b, c] <- map strToInt . words <$> getLine
    if b `mod` c == 0 then putStrLn "-1"
        else putStrLn . show $ head [b * i | i <- [1..], b*i `mod` c /= 0]


Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    string S;
    cin >> S;
    if(S == "AAA" || S == "BBB" ) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)
using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif

int main(void) {
  string str;
  cin >> str;
  int sCount = 0, popCount = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'S') {
      sCount++;
    } else {
      if (sCount > 0) {
        sCount--; popCount++;
      }
    }
  }
  cout << (str.size() - popCount * 2) << endl;
  return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, count = 32;
	
	cin >> N;
	
	for (int i = 0; i < N; i++) {
		int A;
		
		cin >> A;
		
		int c = 0;
		
		while (A % 2 == 0) {
			A /= 2;
			c++;
		}
		
		count = min(count, c);
	}
	
	cout << count << endl;
}


Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
void init_comb(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll comb(ll n, ll r){
    if(n<r || n<0 || r<0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}




//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    init_comb();
    int ans;
    for(int i=1;i<=K;i++){
        ans = (comb(N-K+1, i) * comb(K-1, i-1)) % MOD;
        cout << ans << endl;
    }



}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	
	ll n;
	cin >> n;

	ll p = 26, sz = 1, tot = 26;
	while(n > tot){

		// cerr << n << " " << tot << " " << sz << endl;

		sz++;
		p *= 26;
		tot += p;
	}

	// cerr << p << " " << sz << endl;

	for(ll i = 1, cnt = 26; i < sz; i++){
		n -= cnt;
		cnt *= 26;
	}

	string ans = "";

	for(ll i = 0; i < sz; i++){
		ll tmp = p / 26;
		char last = '*';
		for(char c = 'a'; c <= 'z'; c++){
			if(n - tmp <= 0){
				last = c;
				break;
			}
			else n -= tmp;
		}
		ans += last; 
		p /= 26;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    if i == N-1:
        if x == a[i]:
            ans += 1
    elif x >= a[i]:
        x -= a[i]
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline


def read():
    N, M = map(int, input().strip().split())
    AB = []
    for i in range(M):
        a, b = map(int, input().strip().split())
        AB.append((a, b))
    return N, M, AB


def solve(N, M, AB):
    is_ok = True
    mid_b = set()
    mid_a = set()
    for a, b in AB:
        if a == 1:
            mid_b.add(b)
        elif b == N:
            mid_a.add(a)
    is_ok = len(mid_a.intersection(mid_b)) > 0
    return "POSSIBLE" if is_ok else "IMPOSSIBLE"


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  bool c = false;
  int d = 0;
  int result;
  while (!c) {
    if (count(p.begin(), p.end(), (X - d)) == 0) {
      result = X - d;
      c = true;
    }
    if (count(p.begin(), p.end(), (X + d)) == 0 && !c) {
      result = X + d;
      c = true;
    }
    if (!c) d++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

long long xx(long long a) {
	if (a == 0) return 0;
	if (a % 2 == 1) {
		if (a % 4 == 1) return 1;
		return 0;
	}
	return a + xx(a - 1);
}

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

	long long a, b, aa, bb, ans;
	cin >> a >> b;
	if (a >= 1) aa = xx(a - 1);
	else aa = 0;
	if (b >= 1) bb = xx(b);
	else bb = 0;
	ans = aa ^ bb;
	cout << ans << "\n";


	return 0;
}

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

int main() {
	vector<int> v(10);
	int n, j = 0;
	while (cin >> n) {
		if (n) {
			v.at(j) = n;
			j++;
		}
		else {
			j--;
			cout << v.at(j) << endl;
			v.at(j) = 0;
		}
	}
}


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(){
	string sentence;
	bool flag;
	string answer;
	vector<int> kakko; //1: mkakkko 2: kkakkko
	int leng = -1;


	while(1){
		answer = "yes";
		getline(cin,sentence);

		if(sentence == "."){
			break;
		}
		for(int i = 0 ; i < leng+1;i++){
			kakko.pop_back();
		}
		leng = -1;

		for(int i = 0; i < sentence.length();i++){
			if(sentence[i] == '('){
				kakko.push_back(1);
				leng++;
				//cout << " testcase 1 " << endl;
			}else if(sentence[i] == '['){
				kakko.push_back(2);
				leng++;
				//cout << " testcase 2" << endl;
			}else if(sentence[i] == ')'){
				if(leng == -1){
					answer = "no";
					break;
				}else{
					if(kakko[leng] == 1){
						kakko.pop_back();
						leng--;
					}else{
						answer = "no";
						break;
					}
				}
				//cout << " testcase 3" << endl;
			}else if(sentence[i] == ']'){
				if(leng == -1){
					answer = "no";
					break;
				}else{
					if(kakko[leng] == 2){
						kakko.pop_back();
						leng--;
					}else{
						answer = "no";
						break;
					}
				}
				//cout << " testcase 4" << endl;

			}else{}
		}
		if(leng > -1){
			answer = "no";
		}
			
		cout << answer << endl;

	}

}

Measured memory_bytes: 3020
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
const int N = 100005;
const int mod = 1e9 + 7;
int n;
int a[N];
int main(){
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if(x > n){
            
        }
        else{
            a[x]++;
        }
    }
    for(int i = 0; i <= n; ++i){
        if(a[i] >= i){
            ans += i;
        }
    }
    cout << n - ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	int A[n];
	int B[n];
	rep(i, n) cin >> A[i];
	rep(i, n) cin >> B[i];

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

Measured memory_bytes: 256
// AOJ Volume 0 Problem 0079

#include <stdio.h>
#include <math.h>

double point[20][2];

double len(int i, int j)
{
	return (
		    sqrt(
		       (point[i][0] - point[j][0]) * (point[i][0] - point[j][0]) +
		       (point[i][1] - point[j][1]) * (point[i][1] - point[j][1])
			)
			);
}

int main(void)
{
    double s, z;
	int n;
	int i;
	double a, b, c;
    
	n = 0;
    while (scanf("%lf,%lf", &point[n][0], &point[n][1]) != EOF){
		n++;
    }

	s = 0;
	

	for (i = 1; i < n - 1; i++){
		a = len(0, i);
		b = len(i, i + 1);
		c = len(i + 1, 0);

		z = (a + b + c) / 2;
	
//		printf("<%d : %lf>", i, sqrt(z * (z - a) * (z - b) * (z - c)));
		s += sqrt(z * (z - a) * (z - b) * (z - c));
	}
	
	printf("%lf\n", s);
	
    
    return (0);
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

#define mp make_pair

int main() {
    int n, m;
    cin >> n >> m;
    cout << ((n == m) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };

template<typename T>
struct Dice {
  T var[6]; int id[6];
  Dice() {
    id[0] = TOP, id[1] = FRONT, id[2] = LEFT;
    id[3] = RIGHT, id[4] = BACK, id[5] = BOTTOM;
  }
  T& operator[] (FACE f) { return var[id[f]]; }
  const T& operator[] (FACE f) const { return var[id[f]]; }
  bool operator ==(const Dice<T>& b) const {
    const Dice<T>& a = *this;
    if(a[TOP] != b[TOP]) return false;
    if(a[BOTTOM] != b[BOTTOM]) return false;
    if(a[FRONT] != b[FRONT]) return false;
    if(a[BACK] != b[BACK]) return false;
    if(a[LEFT] != b[LEFT]) return false;
    if(a[RIGHT] != b[RIGHT]) return false;
    return true;
  }
  // a -> b, b -> c, c -> d, d -> a
  void roll(FACE a, FACE b, FACE c, FACE d) {
    int value = id[d];
    id[d] = id[c], id[c] = id[b], id[b] = id[a], id[a] = value;
  }
  // FRONT???RIGHT????§??????????
  void roll_r() { roll(FRONT, RIGHT, BACK, LEFT); }
  // FRONT???TOP????§??????????
  void roll_u() { roll(FRONT, TOP, BACK, BOTTOM); }
  // TOP, RIGHT, BOTTOM, LEFT???????¨???????????§??????????
  void roll_c() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  // roll_r??¨roll_u????????????????????????????????????roll_c???4?????????
  bool eq(const Dice& d) {
    for(int k = 0; k < 6; k++) {
      for(int i = 0; i < 4; i++) {
        if(*this == d) return true;
        roll_c();
      }
      if(k % 2 == 0) roll_r();
      else roll_u();
    }
    return false;
  }
};

int main() {
  Dice<int> dice;
  cin >> dice[TOP];
  cin >> dice[FRONT];
  cin >> dice[RIGHT];
  cin >> dice[LEFT];
  cin >> dice[BACK];
  cin >> dice[BOTTOM];
  Dice<int> dice2;
  cin >> dice2[TOP];
  cin >> dice2[FRONT];
  cin >> dice2[RIGHT];
  cin >> dice2[LEFT];
  cin >> dice2[BACK];
  cin >> dice2[BOTTOM];
  cout << (dice.eq(dice2) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1156
def main():
    n, k = (int(z) for z in input().split())
    xs = [0] * k
    for i in range(k - 1):
        xs[i] += 1
        n -= 1
    xs[-1] += n
    print(max(xs) - min(xs))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#define MAXSIZE 1000

int main(void){
    int n, t, a, h[MAXSIZE];
    scanf("%d %d %d", &n, &t, &a);
    double meantemp[MAXSIZE], diff, mindiff = 707.7;
    int ans = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
        meantemp[i] = (double)t - h[i] * 0.006;
        diff = fabs((double)a - meantemp[i]);
        if(diff < mindiff){
            mindiff = diff;
            ans = i;
        }
    }
    printf("%d\n", ans + 1);
    return 0;
}

Measured memory_bytes: 128
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=0; i < n; i++) {
      ans += sc.nextInt() - 1;
    }

    System.out.println(ans);
  }
}


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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const int MAXN = 100010;

struct UFS {
	int fa[MAXN];

	inline void init(int n) { for(int i = 1; i <= n; i++) fa[i] = i; }
	inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
	inline int Merge(int u, int v) {
		int fu = find(u), fv = find(v);
		if(fu == fv) return 0;
		return fa[fu] = fv, 1;
	}
}ufs;

int tot;
int fi[MAXN];
int to[MAXN << 1];
int ne[MAXN << 1];

inline void Link(int u, int v) {
	tot++;
	to[tot] = v;
	ne[tot] = fi[u];
	fi[u] = tot;
}

int N;
int st[MAXN];
int col[MAXN];
int fa[MAXN];

inline ll Dfs(int x, int la, int d) {
	ll res = 0; col[x] = d, fa[x] = la;
	for(int i = fi[x]; i; i = ne[i]) {
		int u = to[i];
		if(u == la) continue;
		res += Dfs(u, x, -d), col[x] += col[u];
	} return !la && col[x] ? -1 : res + abs(col[x]);
}

int main() {
	int n = ri, m = ri, rt = 1, rem = -1;

	ufs.init(n);
	for(int i = 1; i <= m; i++) {
		int u = ri, v = ri;
		if(ufs.Merge(u, v)) Link(u, v), Link(v, u);
		else rt = u, rem = v;
	}

	Dfs(rt, 0, 1);

	if(~rem) {
		for(int i = rem; i; i = fa[i]) st[++N] = col[i];
		if(N & 1) {
			if(abs(col[rt]) & 1) return puts("-1"), 0;
			for(int i = rem; i; i = fa[i]) col[i] -= col[rt] >> 1;
		} else {
			if(col[rt]) return puts("-1"), 0;
			sort(st + 1, st + 1 + N);
			for(int i = rem; i; i = fa[i]) col[i] -= st[N >> 1];
		}
	} else if(col[rt]) return puts("-1"), 0;
	ll res = 0;
	for(int i = 1; i <= n; i++) res += abs(col[i]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      long mod = 1000000007;
      int N = int.Parse(Console.ReadLine());

      long[] ns = new long[2001];
      for(int i = 3; i <= N; i++)
      {
        long x = 1;
        for(int j = 3; j <= i - 3; j++)
        {
          x += ns[j];
          x %= mod;
        }
        ns[i] = x;
      }

      Console.WriteLine(ns[N]);
      Console.ReadLine();
    }
    
  }
}

Measured memory_bytes: 27480
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    result = 1
    if 0 in A:
        print(0)
        return
    for n in range(N):
        result *= A[n]
        if result > (10 ** 18):
            print('-1')
            return
    print(result)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24440
A,B,C=[list(input())for j in range(3)]
res=A.pop(0)
flag=True
while flag==True:
    if res=="a" and len(A)==0:
        print("A")
        flag=False
    if res=="b" and len(B)==0:
        print("B")
        flag=False
    if res=="c" and len(C)==0:
        print("C")
        flag=False
    if res=="a":
        if len(A)>0:
            res=A.pop(0)
    elif res=="b":
        if len(B)>0:
            res=B.pop(0)
    else:
        if len(C)>0:
            res=C.pop(0)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val s = readLine()!!
    for ((i, c) in s.withIndex()) {
        val idx = i + 1
        if (idx % 2 == 1) {
            if (c == 'R' || c == 'U' || c == 'D') {
            } else {
                println("No")
                return
            }
        } else {
            if (c == 'L' || c == 'U' || c == 'D') {
            } else {
                println("No")
                return
            }
        }
    }
    println("Yes")
}


Measured memory_bytes: 33912
import sys

def call(n):
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print(' ', i, sep='', end='')
        else:
            while x:
                if x % 10 == 3:
                    print(' ', i, sep='', end='')
                    break

                x //= 10
            
        i += 1
        
    print('')
    
if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    call(n)

Measured memory_bytes: 8260
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        
        int[] i = new int[N];
        
        for(int j = 0; j < N; j++){
            i[j] = Integer.parseInt(sc.next());
        }
        
        long ans = gcd(i[0],i[1]);
        
        for(int j = 2; j < N; j++){
            ans = gcd(ans,i[j]);
        }
        
        System.out.println(ans);
    }
    
    public static long gcd(long a, long b){
        if(b == 0) return a;
        return gcd(b,a%b);
        
        
    }
}


Measured memory_bytes: 50396
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;

int main() {
	int n, m;
	vector<int> a(100000);
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> a[i];

	vector<int> up_way(100000);
	up_way[0] = 1;
	up_way[1] = 1;
	int num = 0;
	// first broken
	if (!a.empty() && a[0] == 1) {
		up_way[1] = 0;
		num++;
	}

	for (int i = 2; i <= n; i++) {
		up_way[i] = (up_way[i - 1] + up_way[i - 2]) % MOD;
		if (!a.empty() && i == a[num]) {
			up_way[i] = 0;
			num++;
		}
	}

	cout << up_way[n] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int NMAX = 16;
main(){
  int N, T[NMAX][NMAX+1], dp[(1<<NMAX)];
  while( cin >> N, N){
    rep(i, N) REP(j, 0, N+1) cin >> T[i][j];
    rep(i, (1<<N)) dp[i] = (1<<25);
    dp[0] = 0;
    rep(s, (1<<N)){
      rep(i, N){
	int next = s | (1<<i);
	if ( next >= (1<<N) ) continue;
	int cost = T[i][0];
	REP(j,1, N+1){
	  if ( s&(1<<(j-1)) ) cost = min(cost, T[i][j]);
	}
	dp[next] = min(dp[next], dp[s] + cost);      
      }
    }
    cout << dp[(1<<N)-1] << endl;
  }
}

Measured memory_bytes: 1416
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int v[101], w[101];
int dp[101][10010];
int const MOD = 1e9 + 7;
int main(void)
{
    int N, W;
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
        cin >> v[i] >> w[i];

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j <= W; ++j)
        {
            if (j - w[i] >= 0)
            {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7008
import Control.Monad (replicateM)

main :: IO ()
main = do
  [n,x] <- map read . words <$> getLine :: IO [Int]
  ms    <- replicateM n readLn :: IO [Int]
  print $ f n x ms

f :: Int -> Int -> [Int] -> Int
f n x ms = n + (x - sum ms) `div` (minimum ms)


Measured memory_bytes: 1020
/*
 * main.c
 *
 *  Created on: 2019/05/11
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int R = 0, G = 0, B = 0, N = 0;
    int r,g,b, ans = 0;
    scanf("%d %d %d %d", &R, &G, &B, &N);
    for(r = 0; r <= N; r++) {
        for(g = 0; g <= N; g++) {
            int temp = (N - (r*R) - (g*G));
            b = temp/B;
            if(((temp - b*B) == 0) && (b >= 0)) {
                //printf("N=%d,r=%d,g=%d,b=%d\n",N,r*R,g*G,b*B);
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
int N;
  cin >>N;
  N=N%10;
switch(N){
  case 0:
  case 1:
  case 6:
  case 8:
   cout<<"pon";
  break;
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout<<"hon";
  break;
  case 3:
    cout<<"bon";
  break;
}
}

Measured memory_bytes: 3128