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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long X) {
  ll yen = 100;
  ll ret = 0;
  while(yen<X){
    yen += yen / 100LL;
    ret++;
  }
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long X;
  std::cin >> X;
  solve(X);
  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
	int n, a, b;
	int flag = 0;
	scanf("%d", &n);
	
	scanf("%d %d", &a, &b);
	
	for(int i = a; i <= b; i++){
		if(i % n == 0){
			flag = 1;
		}
	}
	if(flag == 1){
		printf("OK\n");
	}else{
		printf("NG\n");
	}
}

Measured memory_bytes: 1604
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int N;
  C(N);

  cout << "ABC" << N << endl;
  ret 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0094
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] num = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            double a = num[0];
            double b = num[1];

            double S = (a * b) / 3.305785;

            Console.WriteLine(S);
        }
    }
}



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

const int N = 100005;

int main() {
  int n;
  scanf("%d", &n);
  int maxs = 0;
  int cur = 0;
  int h, prv;
  scanf("%d", &prv);
  
  for (int i = 1; i < n; ++i) {
    scanf("%d", &h);
    if (h > prv) {
      cur = 0;
    } else maxs = max(maxs, ++cur);
    
    prv = h;
  }
  
  printf("%d\n", maxs);
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n+1);
  rep(i,m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }
  vector<int> dp(n+2);
  const int mod = 1000000007;
  dp[n] = 1;
  for (int i = n-1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % mod;
  }
  cout << dp[0] << endl;
  return 0;
}    


Measured memory_bytes: 1024
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
 
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
 
int compare(const void *a, const void *b){
  return (*(ll int *)a)- (*(ll int *)b);
} 
 
int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  ll int s[n],ans=1e9;
  for(ll int i=0;i<n;i++) scanf("%lld",&s[i]);
  qsort(s,n,sizeof(ll int),compare);
  for(int i=0;i<=n-k;i++){
    if(ans>s[i+k-1]-s[i]){
      ans=s[i+k-1]-s[i];
    }
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < 4; i++) {
    if (S.at(i) == '+') { count++; }
    else { count--; }
  }
  cout << count << endl;
}

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

int main() {
	int64_t N,D;
	int count = 0;
	cin >> N >> D;
	vector<int64_t>pointx(N);
	vector<int64_t>pointy(N);
	for(int64_t i=0;i<N;i++){
		cin >> pointx.at(i) >> pointy.at(i);
	}
	for(int64_t i=0;i<N;i++){
		int64_t p = pointx.at(i);
		int64_t q = pointy.at(i);
		if(p*p+(q*q) <= D*D){
			count++;
		}
	}
	cout << count << endl;
}
	

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin >> str;
	int x = 65;
	int ans = 0;
	for(int i = 0; i < str.size(); i++)
	{
		if(str[i] <= x)
			ans++;
		x = str[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3208
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
    for (vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
    for (T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define per(i,b,a) for (int i = b; i > a; i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 998244353;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int n, s;
    cin >> n >> s;
    vi v(n);
    cin >> v;
    vvl dp(n+1, vl(s+1));
    ll ans = 0;
    rep(i,0,n)
    {
        dp[i+1] = dp[i];
        if(v[i] <= s)
            (dp[i+1][v[i]] += i + 1) %= h;
        rep(j,0,s+1)
            if(j + v[i] <= s)
                (dp[i+1][j + v[i]] += dp[i][j]) %= h;
        (ans += dp[i+1][s]) %= h;
    }
    cout << ans;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long t=0,i=0,j=0,N,R;
  int ans;
  
  cin >> N >> R;

  if (N>=10)
  {
    ans=R;
  }else
  {
    ans=R+100*(10-N);
  }
  
  
  cout << ans <<endl;
  return 0;
}

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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
using ll=long long;
using ii=pair<int,int>;
using pll=pair<ll,ll>;

const int mxN = 2e5+5;

const int P = 103;
const int P2 = 1009;
const int P3 = 401;
const int P4 = 709;
const int Q = 1e9+11;
const int Q2 = 1e9+7;

int N;
string S[mxN];
unordered_map<ll,unordered_map<ll,array<int,26>>> um;
int haschar[26];
pll lst[mxN];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> N;
    FOR(i,1,N){
		cin >> S[i];
		reverse(ALL(S[i]));
	}
	
	FOR(i,1,N){
		int roll = 0, roll2 = 0, roll3 = 0, roll4 = 0;
		int ft[26] = {0};
		RFOR(j,SZ(S[i])-1,0) ft[S[i][j]-'a']++;
		FOR(k,0,25) if (ft[k]) ++haschar[k];
		if (SZ(S[i]) > 1) {
			FOR(j,0,SZ(S[i])-1){
				ft[S[i][j]-'a']--;
				roll = (ll) roll * P % Q;
				roll = (roll + (S[i][j]-'a'+1)) % Q;
				
				roll2 = (ll) roll2 * P2 % Q;
				roll2 = (roll2 + (S[i][j]-'a'+1)) % Q;
				
				roll3 = (ll) roll3 * P3 % Q2;
				roll3 = (roll3 + (S[i][j]-'a'+1)) % Q2;
				
				roll4 = (ll) roll4 * P4 % Q2;
				roll4 = (roll4 + (S[i][j]-'a'+1)) % Q2;
				
				ll comb1 = (ll)roll*1000000000+roll2;
				ll comb2 = (ll)roll3*1000000000+roll4;
				FOR(k,0,25) if (ft[k]) ++um[comb1][comb2][k];
				if (j == SZ(S[i])-2) lst[i] = pll(comb1,comb2);
				//~ TRACE(S[i] _ i _ j _ roll);
			}
		}
	}
	ll ans = 0;
	FOR(i,1,N){
		if (SZ(S[i]) == 1) ans += haschar[S[i][0]-'a']-1;
		else ans += um[lst[i].first][lst[i].second][S[i].back()-'a']-1;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 252744
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    string a;
    cin>>a;
    int n,i,j;
    n=a.size();
    i=0;
    j=n/2;
    for(i=0;i<n/2;i++)
    {
        if(a[i]==a[n-i-1])
        j--;
        
    }
    
    //j=j-i;
    cout<<j;

    return 0;
}


Measured memory_bytes: 256
n = int(input()); arr = [list(map(int,input().split())) for _ in range(n-1)]

graph = [[] for _ in range(n)]
for a,b in arr:
    graph[a-1].append(b-1); graph[b-1].append(a-1)

parents = [-1]*n
children = [[] for _ in range(n)]
orders = []
stack = [0]
flags = [True] * n; flags[0] = False
while stack:
    tmp = stack.pop()
    orders.append(tmp)
    for node in graph[tmp]:
        if flags[node]:
            flags[node] = False
            children[tmp].append(node)
            stack.append(node)
            parents[node] = tmp

mod = 10**9+7
fac = [1]*(n+1)
inv = [1]*(n+1)
ifac = [1]*(n+1)
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    inv[i] = (- (mod//i)*inv[(mod%i)]) % mod
    ifac[i] = ifac[i-1] * inv[i] % mod

size = [1] * n;dp = [1] * n
for parent in orders[::-1]:
    for child in children[parent]:
        size[parent] += size[child]
        dp[parent] = dp[parent] * dp[child] * ifac[size[child]] % mod
    dp[parent] = dp[parent] * fac[size[parent]-1] % mod

size2 = [n-i+1 for i in size];dp2 = [1] * n; dp2[0] = dp[0]
for parent in orders[1:]:
    child = parents[parent]
    dp2[parent] = dp2[parent] * size[parent] * dp2[child] * inv[size2[parent]-1] % mod
    
for i in range(n):
    print(dp2[i])

Measured memory_bytes: 151980
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w = LI()
    a = [[c == '#' for c in S()] for _ in range(h)]
    b = [[None] * w for _ in range(h)]

    def f(i,j,k):
        if b[i][j] or a[i][j] != k:
            return (0,0)
        b[i][j] = 1
        r = [1,0]
        for di,dj in dd:
            ni = i + di
            nj = j + dj
            if ni < 0 or ni >= h or nj < 0 or nj >= w:
                continue
            res = f(ni,nj,not k)
            r[0] += res[1]
            r[1] += res[0]
        return r

    r = 0
    for i in range(h):
        for j in range(w):
            t = f(i,j,a[i][j])
            r += t[0] * t[1]

    return r



print(main())




Measured memory_bytes: 208060
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{
    int h, w;
    while(1)
    {
        scanf("%d %d", &h, &w);
        if((h==0) && (w==0)) break;
        for(int i=0; i<h; i++)
        {
            string str;
            for(int j=0; j<w; j++)
            {
                if((i==0) || (i==h-1) || (j==0) || (j==w-1)) str.push_back('#');
                else str.push_back('.');
            }
            printf("%s\n", str.c_str());
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2744
#include<iostream>
using namespace std;
int n = 40;
long double calc(long double p, long double q) {
	return (p - q) - (p - q) / (q + 1.0l);
}
int main() {
	cout << n << endl;
	long double maxn = 0; int maxid = 0;
	for (int i = 1; i <= n-1; i++) {
		long double c = calc(n, i);
		if (c > maxn) { maxn = c; maxid = i; }
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j && (i < maxid || j < maxid))cout << "Y";
			else cout << "N";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    ll N,K,S;cin>>N>>K>>S;
    ll a[100010];
    if(S!=1000000000){
        rep(i,0,K){
            a[i]=S;
        }
        rep(i,K,N){
            a[i]=1000000000;
        }
    }
    else{
        rep(i,0,K-1){
            a[i]=S;
        }
        rep(i,K-1,N){
            a[i]=S/(N-K+1);
        }
        a[N-1]+=S%(N-K+1);
    }
    
    
    rep(i,0,N){
        cout<<a[i];
        if(i!=N-1)cout<<" ";
    }
    cout<<endl;
}






Measured memory_bytes: 2048
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;

    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if (i + j <= s && i + j + k >= s)
                ans++;
        }
    }
     
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main{
	public static void main(String args []){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), max = 0;
		if(a+b > a-b){
			max = a+b;
		}else{
			max = a-b;
		}
		if(max > a*b){
			max = max;
		}else{
			max = a*b;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=3010,Mo=1000000007;
int n,m;
char s[N];
int f[N][N],w[N],r[N],id[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    cin>>n>>m;
    scanf("%s",s+1);
    for(int i=1;i<=n;i++) w[i]=w[i-1]+s[i]-'0',r[i]=i;
    for(int i=1;i<=m;i++) {
	int x=gi(),y=gi();
	for(int j=x;j<=y;j++) r[j]=max(r[j],y);
    }
    f[0][0]=1;
    for(int i=1;i<=n;i++)
	for(int j=max(0,i-r[i]+w[r[i]]);j<=w[r[i]];j++)
	    f[i][j]=(f[i-1][j]+f[i-1][j-1])%Mo;
    cout<<f[n][w[n]];
    return 0;
}

Measured memory_bytes: 33920
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n,p;
    bool prime[200001] = {1,1,0};
    vector<int> PrimeNumber;
    vector<int> number;
    vector<int>::iterator it;
    vector<int>::iterator cpit;

    rep(i,200000){
        if(!prime[i]){
            for(int j = i + i; j < 200000; j+=i){
                prime[j] = 1;
            }
        }
    }
    rep(i,200000) if(!prime[i]) PrimeNumber.pb(i);

    while(cin >> n >> p, n != -1 || p != -1){
        for(it = PrimeNumber.begin(); it != PrimeNumber.end(); it++){
            if(*it > n) break;
        }
        //rep(i,15) cout << *(it + i) << endl;
        for(int i = 0; i < 30; i++){
            cpit = it;
            for(int j = i; j < 30; j++){
                number.pb(*it + *cpit);
                cpit++;
            }
            it++;
        }
        sort(all(number));
        //rep(i,101) cout << number[i] << endl;
        //debug(number.size());
        cout << number[p - 1] << endl;
        number.clear();
    }
}

Measured memory_bytes: 1544
#include <stdio.h>

int		hit(int n, int *b)
{
	int i;
	i = 0;
	while (b[i])
	{
		if (n == b[i])
			return (1);
		i++;
	}
	return (0);
}

int		main(void)
{
	int A[3][3];
	int i = 0;
	int j;
	while (i < 3)
	{
		j = 0;
		while (j < 3)
			scanf("%d", &A[i][j++]);
		i++;
	}
	int N;
	scanf("%d", &N);
	int b[N];
	i = 0;
	while (i < N)
		scanf("%d", &b[i++]);
	i = 0;
	while (i < 3)
	{
		if (hit(A[i][0], b) && hit(A[i][1], b) && hit(A[i][2], b))
		{
			printf("Yes");
			return 0;
		}
		i++;
	}
	j = 0;
	while (j < 3)
	{
		if (hit(A[0][j], b) && hit(A[1][j], b) && hit(A[2][j], b))
		{
			printf("Yes");
			return 0;
		}
		j++;
	}
	if (hit(A[0][0], b) && hit(A[1][1], b) && hit(A[2][2], b)
	 || hit(A[0][2], b) && hit(A[1][1], b) && hit(A[2][0], b))
	{
		printf("Yes");
		return 0;
	}
	printf("No");
	return (0);
}


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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int w,h,n;
	cin >> w >> h >> n;
	int x,y,a;
	int lx = 0,dy = 0;
	for(int i = 0; i < n; i++){
		cin >> x >> y >> a;
		if(!(a - 1)){
			lx = max(lx,x);
		}
		if(!(a - 3)){
			dy = max(dy,y);
		}
		if(!(a - 2)){
			w = min(w,x);
		}
		if(!(a - 4)){
			h = min(h,y);
		}
	}
	if(h < dy || w < lx){
		cout << 0 << endl;
	}
	else{
		cout << (h - dy) * (w - lx) << endl;
	}
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

signed main(){
    int a, b;
    cin >> a >> b;
    
    int heikin = (a + b) / 2;
    
    if(((a%2==0)&&(b%2==0)) || ((a%2==1)&&(b%2==1))) cout << heikin <<endl;
    else cout << heikin + 1 << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        for(int i=0;i<N;i++){
            int a = sc.nextInt();
            if(a%2 == 1){
                System.out.println("first");
                return;
            }
        }

        System.out.println("second");
        return;
    }
}

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

int main(){
    int N,t,t1 = 0,t2,x1 = 0,y1 = 0,x2,y2,x,y,xn = 0,yn = 0,min,minN;
    int flag = 0,ng = 0;
    cin >> N;
    int a[4][2],b[4];

    for(int i = 0;i<N;i++){
        xn = 0;
        yn = 0;
        cin >> t2 >> x2 >> y2;
        t = t2 - t1;
        x = x2 - x1;
        y = y2 - y1;
        t1 = t2;
        x1 = x2;
        y1 = y2;
        //cout << "t" << t << "x" << x << "y" << y << endl;
        for(int j = 1;j <= t;j++){
            a[0][0] = xn;
            a[0][1] = yn + 1;
            a[1][0] = xn;
            a[1][1] = yn - 1;
            a[2][0] = xn + 1;
            a[2][1] = yn;
            a[3][0] = xn - 1;
            a[3][1] = yn;
            if(x > a[0][0]){
                if(y > a[0][1])min = x - a[0][0] + y - a[0][1];
                else min = x - a[0][0] + a[0][1] - y;
            }else{
                if(y > a[0][1])min = a[0][0] - x + y - a[0][1];
                else min = a[0][0] - x + a[0][1] - y;
                }
            minN = 0;
            for(int k = 0;k<4;k++){
                if(x > a[k][0]){
                    if(y > a[k][1])b[k] = x - a[k][0] + y - a[k][1];
                    else b[k] = x - a[k][0] + a[k][1] - y;
                }else{
                    if(y > a[k][1])b[k] = a[k][0] - x + y - a[k][1];
                    else b[k] = a[k][0] - x + a[k][1] - y;
                }
                if(b[k] == 0 && (t - j) % 2 == 0)flag = 1;
                //cout << k << " " << b[k] << endl;
                if(b[k] < min){
                    min = b[k];
                    minN = k;
                }
            }
            xn = a[minN][0];
            yn = a[minN][1];
            //cout  << xn << " " << yn <<endl;
            if(flag == 1)break;
        }
        if(flag == 1)flag = 0;
        else ng = 1;
        //cout << ng << endl;
    }
    if(ng == 1)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    ll ans = 0;
    for (int bit = 0; bit < (1 << s.size() - 1); bit++) {
        ll num = s[0] - '0';
        for (int i = 0; i < s.size() - 1; i++) {
            if (bit & (1 << i)) {
                ans += num;
                num = 0;
            }
            num = num * 10 + s[i+1] - '0';
        }
        ans += num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >>n;
  cin.ignore();
  while(n--){
    string word;
    getline(cin,word);
    string::size_type index;
    for(;;){
      index = word.find("Hoshino");
      if(index == string::npos){break;}
      word[index+6] = 'a';
    }
    cout <<word<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()
A,B,C,D = map(int,list(S))
numlis = [B,C,D]

for bitlines in range(0,1<<3):
    ans = [A]
    num = A
    for target in range(3):
        if bitlines>>target & 1:
            num += numlis[target]
            ans = ans+["+",numlis[target]]
        else:
            num -= numlis[target]
            ans = ans+["-",numlis[target]]
    if num ==7:
        ans.append("=7")
        print(*ans,sep="")
        exit()

# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

struct tourist{
	int stationNo;
	int time;
};


int main()
{
	int n;
	cin>>n;
	int *c = new int[n-1];
	int *s = new int[n-1];
	int *f = new int[n-1];
	for(int i = 0; i < n-1; i++){
		cin>>c[i]>>s[i]>>f[i];
	}
	for(int i = 0; i <= n-1; i++){
		struct tourist t1;
		t1.stationNo = i;
		t1.time = 0;
		while(t1.stationNo != n-1){
			int index = t1.stationNo;
			if( t1.time < s[index]){
				t1.time = s[index] + c[index];
				t1.stationNo++;
			}else if( t1.time == s[index]){
				t1.time += c[index];
				t1.stationNo++;
			}else if( t1.time % f[index] == 0){
				t1.time += c[index];
				t1.stationNo++;
			}else{
				t1.time = t1.time - (t1.time % f[index]) + f[index] + c[index];
				t1.stationNo++;
			}
		}
		cout<<t1.time<<endl;
	};
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define vi vector<int>
#define int int64_t
#define ALL(a) (a).begin(),(a).end()
signed main(){
  int N;
  cin>>N;
  vi A(5);
  rep(i,0,N){
    string S;
    cin>>S;
    if(S[0]=='M')
      A[0]++;
    else if(S[0]=='A')
      A[1]++;
    else if(S[0]=='R')
      A[2]++;
    else if(S[0]=='C')
      A[3]++;
    else if(S[0]=='H')
      A[4]++;
    }
  int ans=0;
  rep(i,0,3){
    rep(j,i+1,4){
      rep(k,j+1,5)
        ans+=A[i]*A[j]*A[k];
      }
    }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
N = int(input())
M = int(input())
A = list(map(int, input().split()))
S = [0 for i in range(N)]

for i in range(M) :
    B = list(map(int, input().split()))
    for j in range(N) :
        if(B[j] == A[i]) :
            S[j] += 1
        else :
            pass
    S[A[i] - 1] += N - B.count(A[i])

for i in range(N) :
    print(S[i])
        


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

int main(){
  string N;
  cin >> N;
  int A, B, C, D;
  A=N.at(0)-'0';
  B=N.at(1)-'0';
  C=N.at(2)-'0';
  D=N.at(3)-'0';
  vector<char> vec;
  
  if (A+B+C+D==7) vec = {'+', '+', '+' };
  else if (A-B+C+D==7) vec = {'-', '+', '+' };
  else if (A+B-C+D==7) vec = {'+', '-', '+' };
  else if (A+B+C-D==7) vec = {'+', '+', '-' };
  else if (A-B-C+D==7) vec = {'-', '-', '+' };
  else if (A+B-C-D==7) vec = {'+', '-', '-' };
  else if (A-B+C-D==7) vec = {'-', '+', '-' };
  else if (A-B-C-D==7) vec = {'-', '-', '-' };
  else vec = {'+', '+', '+' };

  cout << A << vec.at(0) << B << vec.at(1) << C << vec.at(2) << D << "=7" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] blue = new String[N];
        for(int i = 0;i < N;i++){
            blue[i] = sc.next();
        }
        int M = sc.nextInt();
        String[] red= new String[M];
        for(int i = 0;i < M;i++){
            red[i] = sc.next();
        }
        int max = 0;
        for(int i = 0;i < N;i++){
            int num = 1;
            for(int j = i+1;j < N;j++){
                if(blue[i].equals(blue[j])){
                    num++;
                }
            }
            for(int j = 0;j < M;j++){
                if(blue[i].equals(red[j])){
                    num--;
                }
            }
            if(max <= num){
                max = num;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0 && a==b && b==c) cout<<-1<<endl;
    else{
        ll cnt=0;
        while(1){
            if(a%2==1||b%2==1||c%2==1){
                cout<<cnt<<endl;
                break;
            }
            cnt++;
            ll tmpa=(b+c)/2,tmpb=(a+c)/2,tmpc=(a+b)/2;
            a=tmpa;
            b=tmpb;
            c=tmpc;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  string s;
  while (N > 0) {
    N--;
    s.push_back('a' + N%26);
    N /= 26;
  }

  reverse(s.begin(), s.end());
  cout << s << endl;;
}

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


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}

ll gcd(ll x, ll y)
{
    if (x % y == 0)
        return y;
    return gcd(y, x % y);
}

int dp[3005][3005], a[3005], b[3005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m, i, j, k, x, y;
    cin >> n >> m;
    for (i = 1; i <= n; i++)
        cin >> a[i];
    dp[0][0] = 1;
    for (i = 1; i <= n; i++)
    {
        for (j = 0; j <= m; j++)
        {
            dp[i][j] = dp[i - 1][j] * 2 % mod;
            if (j >= a[i])
                dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % mod;
        }
    }
    cout << dp[n][m] << "\n";
    return 0;
}


Measured memory_bytes: 38736
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n,m,k,ans=0; char a[6][6];

void solve()
{
    cin >> n >> m >> k;
    for (int i=0; i<n; i++) for (int j=0; j<m; j++) cin >> a[i][j];

    for (int I=0; I<(1<<n); I++) {
        for (int J=0; J<(1<<m); J++) {
            int cnt=0;
            for (int i=0; i<n; i++) {
                for (int j=0; j<m; j++) {
                    if ((I&(1<<i)) || (J&(1<<j))) continue;
                    if (a[i][j]=='#') cnt++;
                }
            }ans += (cnt==k) ? 1 : 0;
        }
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	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 COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if( m==0 || n==m){
		return 1;
	}
	if(n<m || n<=0 || m<0){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


//


////////////////////////////////////////////////////////////////////




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

ll d[n+2];
for(ll i=1;i<=n;i++){
    char l=s[i-1];
    d[i]=(ll)(l-'0');
}

for(int i=1;i<=n;i++){
    d[i]%=p;
}

ll ans=0;


if(p==2){
    for(ll i=1;i<=n;i++){
        if(d[i]%2==0){
ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

if(p==5){
    for(ll i=1;i<=n;i++){
        if(d[i]%5==0){
ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


ll now=1;
for(ll i=1;i<=n;i++){
if(i>=2){
    now*=10;
    now%=p;
}
d[n+1-i]*=now;
d[n+1-i]%=p;
}

d[n+1]=0;
for(ll i=n;i>=1;i--){
    d[i]=d[i]+d[i+1];
    d[i]%=p;
}

ll rem[p];

for(int i=0;i<p;i++){
    rem[i]=0;
}

for(int i=1;i<=n+1;i++){
    rem[d[i]]++;
}

ans=0;

for(int i=0;i<p;i++){
if(rem[i]<=1){continue;}
ll val=rem[i]*(rem[i]-1)/2;
ans+=val;
}

cout<<ans<<endl;
return 0;



}



Measured memory_bytes: 2180
m=[31,28,31,30,31,30,31,31,30,31,30,31]
a,b=map(int,input().split())
ans=0
for month in range(a):
  for day in range(m[month]):
    if month==a-1 and day+1>b:
      break
    if month==day:
      ans+=1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    ll x;
    cin>>x;
    ll ans=0;
    if(x>=500){
        ans+=1000*(x/500);
        x=x%500;
        ans+=5*(x/5);
        cout<<ans<<endl;
    }
    else{
        ans+=5*(x/5);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>

typedef std::pair<int, int> P;

P data[30];

int main(){
	int n;

	while (std::cin >> n, n){
		memset(data, 0, sizeof(data));

		for (int i = 0; i < n; i++){
			std::cin >> data[i].second >> data[i].first;
		}

		std::sort(data, data + n);

		int res = 0;
		for (int i = 0; i < n; i++){
			res += data[i].second;
			if (res>data[i].first){
				std::cout << "No" << std::endl;
				break;
			}
			if (i == n - 1)std::cout << "Yes" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#C - Traveling
num = int( input())
check = 0
step_b = 0
x_b = 0
y_b = 0
for i in range(num):
    step ,x ,y = map(int,input().split())
    if ((x-x_b)+(y-y_b) - (step-step_b)  > 0) or (((x-x_b)+(y-y_b) - (step - step_b))%2 == 1) :
        check = 1
        break
    x_b = x
    y_b = y
    step_b = step
if check == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n, m, c = gets.chomp.split(" ").map(&:to_i)
bs = gets.chomp.split(" ").map(&:to_i)
res = 0

n.times do |i|
  is = gets.chomp.split(" ").map(&:to_i)
  res += 1 if is.zip(bs).map{|a,b| a*b}.reduce(&:+) + c > 0
end

puts res


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

using namespace std;

int main(){
    int a, b, k;
    cin>>a>>b;
    if((a+b)%2==0){
        k=(a+b)/2;
        cout<<k<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N=int(raw_input())
ans=0
A=[]
for i in range(N):
    A.append(int(raw_input()))
Ar=list(reversed(A))
tmp=Ar[0]
for i in range(0, N-1):
    if (Ar[i] - Ar[i+1]) > 1:
        ans = -1
        break
    elif (Ar[i] - Ar[i+1]) != 1:
        if i+Ar[i] >= N:
            ans = -1
            break
        ans += tmp
        tmp =Ar[i+1]
if Ar[N-1]!=0:
    ans = -1
if ans != -1 and Ar[N-1]==0 and Ar[N-2]==1:
    ans+=tmp

print ans


Measured memory_bytes: 18920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
# define M_PI  3.14159265358979323846

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int x;
	cin >> x;
	if (x == 0) {
		cout << "1";
	} else if (x == 1) {
		cout << "0";
	}
	cout << "\n";
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll INF = TEN(18);
const int maxn = 200010;

int N;
int A[maxn], B[maxn];

bool check(int p) {
	int l = p-1;
	if (l < 0) l += N;
	int r = p+1;
	if (r >= N) r -= N;
	return A[p] != B[p] && B[p] >= B[l] + B[r];
}

int main() {
	cin >> N;
	queue<int> que;

	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	ll ans = 0;
	rep(i, N) {
		if (check(i)) {
			que.push(i);
		}
	}

	while (!que.empty()) {
		int i = que.front(); que.pop();
		if (!check(i)) continue;

		int l = i-1;
		if (l < 0) l += N;
		int r = i+1;
		if (r >= N) r -= N;


		ll dec = B[l] + B[r];
		ll num = INF;
		if (A[i] >= dec) {
			if ((B[i] - A[i]) % dec != 0) {
				puts("-1");
				return 0;
			} else {
				num = (B[i] - A[i]) / dec;
				B[i] -= num * dec;
			}
		} else {
			num = (B[i] - dec) / dec;
			B[i] -= num * dec;
			if (B[i] > dec) {
				++num;
				B[i] -= dec;
			}
		}
		ans += num;
		if (check(l)) {
			que.push(l);
		}
		if (check(r)) {
			que.push(r);
		}
	}

	bool ok = 1;
	rep(i, N) if (A[i] != B[i]) {
		ok = 0;
	}

	if (ok) {
		cout << ans << endl;
	} else {
		puts("-1");
	}

	return 0;
}

Measured memory_bytes: 2176
n,x,m=map(int,input().split())
p=[x]
A=set([x])
f=0
for i in range(n-1):
	p.append(p[-1]**2%m)
	if p[-1] in A:
		f=1
		break
	else:
		A.add(p[-1])
if f==0:
	print(sum(p))
else:
	for i in range(len(p)):
		if p[i]==p[-1]:
			loop=len(p)-i-1
			break
	SUM=sum(p[i:-1])
	ans=sum(p)-p[-1]
	n-=len(p)-1
	ans+=SUM*(n//loop)+sum(p[i:i+n%loop])
	print(ans)

Measured memory_bytes: 77380
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
using namespace std;
//#define int long

signed main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int>x(N), y(M);
	for (int i = 0; i < N; i++)cin >> x[i];
	for (int i = 0; i < M; i++)cin >> y[i];
	int max_x=-100, min_y=100;
	for (int i = 0; i < N; i++)if (max_x < x[i])max_x = x[i];
	for (int i = 0; i < M; i++)if (min_y > y[i])min_y = y[i];
	if (Y - X >= 1 && min_y - max_x >= 1 && min_y - X >= 1 && Y - max_x >= 1)cout << "No War";
	else cout << "War";
}

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

////////////////////////////
// 拡張ユークリッドの互除法 //
////////////////////////////

// x, yは非負整数
// ret[0] * x + ret[1] * y == ret[2] == gcd(x, y) となるようなretを返す
std::array<int64_t, 3> extendedEuclidean(const int64_t x, const int64_t y)
{
	if (y == 0) return {1, 0, x};
	auto next{extendedEuclidean(y, x % y)};
	return {next[1], next[0] - (x / y) * next[1], next[2]};
}
// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_E
int main()
{
	int64_t a, b;
	scanf("%lld%lld", &a, &b);
	auto ext{extendedEuclidean(a, b)};
	// 条件を満たすことの証明はコーナーケースを除いてext[0] <= b / 2, ext[1] <= a / 2であることから帰納的になされる
	// https://teratail.com/questions/176282
	std::cout << ext[0] << ' ' << ext[1] << std::endl;

	return 0;
}


Measured memory_bytes: 3248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(),c=sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[101];
		//String s=sc.next(),t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			array[sc.nextInt()]++;
		}
		for(int i=0;i<101;i++) {
			if(array[i]>=1)count++;;
		}
		System.out.println(count);



	}
	public static int sample(int n) {
		return n;
	}

}


Measured memory_bytes: 23636
def word_break(s, words):
    ok = [True]
    word_length = max(len(word) for word in words)
    for i in range(1, len(s)+1):
        ok += any(ok[j] and s[j:i] in words for j in range(max(0, i - word_length), i)),
    return ok[-1]
 
 
s = input()
words = ["eraser", "erase", "dreamer", "dream"]
print("YES" if word_break(s, words) else "NO")

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

#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()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  cout << (k >= e-a ? "Yay!" : ":(") << endl;

}



Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    O = list(_ for _ in input())
    E = list(_ for _ in input())
    ans = []
    for i in range(len(E)):
        ans.append(O[i])
        ans.append(E[i])
    if(len(O)>len(E)):
        ans.append(O[-1])
    print(''.join(ans))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h> 
using namespace std; 
long long arr[105][2] , dp[105][100005];
int main(){
	int n , cp;
	cin>>n>>cp;
	for(int i =0 ;i  < n ; i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	// we gonna memoize weight and num
	for(int i = 0; i <= n ; i++){
		for(int j = 0; j <= cp ; j++){
			if(i == 0 || j==0)
				dp[i][j] = 0;
			else if(arr[i-1][0] <= j){
				dp[i][j] = max(arr[i-1][1] + dp[i-1][j-arr[i-1][0]] , dp[i-1][j]);
				
			}else 
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout<<dp[n][cp];
	return 0;
}  


Measured memory_bytes: 80128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		int i = 0;
		while (i == 0) {
			String line = sc.nextLine();
			String[] x = line.split(" ");
			int a = Integer.parseInt(x[0]);
			int b = Integer.parseInt(x[2]);
			String op = x[1];
			if (op.equals("+")) {
				list.add(a + b);
			}
			if (op.equals("-")) {
				list.add(a - b);
			}
			if (op.equals("*")) {
				list.add(a * b);
			}
			if (op.equals("/")) {
				list.add(a / b);
			}
			if (op.equals("?")) {
				break;
			}
		}
		for (Integer integer : list) {
			System.out.println(integer);
		}
	}
}

Measured memory_bytes: 26080
using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int main()
{
	int n;
	while(cin>>n&&n){
		int pm,pe,pj;
		while(n--){
			char ans='C';
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100||
				pm+pe>=180||pm+pe+pj>=240)ans='A';
			else if(pm+pe+pj>=210||
				(pm+pe+pj>=150&&(pm>=80||pe>=80)))ans='B';
			cout<<ans<<endl;
		}

	}
    return 0;
}

Measured memory_bytes: 1152