akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    ll N;
    cin >> N;
    ll w;
    for (ll h = 1; h <= 3500; h++)
    {
        for (ll n = 1; n <= 3500; n++)
        {
            if ((4 * h * n - N * n - N * h) > 0 && (N * n * h) % (4 * h * n - N * n - N * h) == 0)
            {
                w = (N * n * h) / (4 * h * n - N * n - N * h);
                cout << h << ' ' << n << ' ' << w << endl;
                return 0;
            }
        }
    }
}


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

int main(void){
    int n, m;
    int max=0;
    map<string,int> s, t;
    string tmp;
    cin>>n;for(int i=0;i<n;i++){cin>>tmp;s[tmp]++;}
    cin>>m;for(int i=0;i<m;i++){cin>>tmp;t[tmp]++;}
    int score=0;
    for( auto i = s.begin(); i != s.end() ; ++i ){
        score=i->second-t[i->first];
        if(max<score)max=score;
    }

    cout<<max<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int H,W;
		
		Scanner scan = new Scanner(System.in);
		while(true)
		{
			H=scan.nextInt();
			W=scan.nextInt();
			if(H==0&&W==0)
				break;
			
			for(int i=0;i<H;i++) {
				
				for(int j=0;j<W;j++) {
					if((i+j)%2==0)
						System.out.printf("#");
					else
						System.out.printf(".");
				}
				
				System.out.printf("\n");
				
			}
			System.out.printf("\n");
			
		}

	}

}

Measured memory_bytes: 62796
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a,const void *b){
   return (*((int *)b))-(*((int *)a));
}

int main(){
   int k,t;
   int a[100];
   int i,ans;

   scanf("%d %d",&k,&t);

   for(i=0;i<t;++i){
      scanf("%d",a+i);
   }

   qsort(a,t,sizeof(int),cmp);
   for(i=1;i<t;++i){
      a[0]-=a[i];
   }
   ans=(((a[0])>0)?(a[0]-1):(0));

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

   return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<bool> red(N, false);
    red[0] = true;
    vector<ll> cnts(N, 1);
    rep(i, M) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        if (red[x]) {
            cnts[x]--;
            cnts[y]++;
            red[y] = true;
            if (cnts[x] == 0) red[x] = false;
        } else {
            cnts[x]--;
            cnts[y]++;
            if (cnts[x] == 0) red[x] = false;
        }
    }
    ll ans = 0;
    rep(i, N) if (red[i]) ans++;
    print(ans);
    return 0;
}

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

using namespace std;

int main()
{
    string s ;
    cin>>s ;
    long long cnt = 0 ;
    long long ans = 0 ;
    for(int i = 0 ; i < s.size() ; ++i)
    {
        if(s[i] == 'B')
            cnt++;
        else
            ans += cnt ;
    }
    return cout<<ans , 0 ;
}


Measured memory_bytes: 640
/* 
 * Project: AtCoder Beginners Contest 135 B - 0 or 1 Swap
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/09/10
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
using namespace std;

int32_t n;
vector<int32_t> p;

void solve() {

    vector<int32_t> sorted_p(n);
    copy(p.begin(), p.end(), sorted_p.begin());
    sort(sorted_p.begin(), sorted_p.end());
    uint32_t cnt = 0;
    for (int i=0;i<n;i++) {
        if (p[i] != sorted_p[i])
            cnt++;
    }
    if (cnt <= 2) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

}

int main() {

    scanf("%d", &n);
    p.resize(n);
    for (int i=0;i<n;i++) {
        scanf("%d", &p[i]);
    }

    solve();

}


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

int main()
{
    int n,i,max1,max2,mx=0;
    cin>>n;
    int a[n];
    cin>>a[0];
    max1=a[0];max2=0;
    for(i=1;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>max1)
            max1=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(max1==a[i])
            mx++;
        if(a[i]>max2 && a[i]<max1)
            max2=a[i];
    }

    if(max2==0)
        max2=max1;
    if(mx==1)
    for(i=0;i<n;i++)
    {
        if(a[i]==max1)
            cout<<max2<<"\n";
        else
            cout<<max1<<"\n";
    }
    else
    for(i=0;i<n;i++)
    {
        cout<<max1<<"\n";
    }
	return 0;
}


Measured memory_bytes: 2432
def prime_fact(n):
    ret = []
    if n == 1:
        return [1]
    for d in [2] + list(range(3, int(n ** 0.5) + 1, 2)):
        while n % d == 0:
            ret.append(d)
            n //= d
    if n != 1:
        ret.append(n)
    return ret

n = int(input())
print("{}: ".format(n), end = "")
print(*prime_fact(n))


Measured memory_bytes: 6264
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_M = 200005;
const int MAX_N = 505;
int sumL[MAX_N],ans[MAX_N][MAX_N],sum[MAX_N][MAX_N];

int main()
{
	int N,M,Q;
	cin >> N >> M >> Q;
	rep(i,M)
	{
		int l,r;
		cin >> l >> r;
		sum[l][r]++;
		sumL[l]++;
	}

	ans[N][N] = sumL[N];
	for (int i = N-1; i >= 1; --i)
	{
		sumL[i] += sumL[i+1];
		ans[i][N] = sumL[i];
	}
	for (int j = 1; j <= N; ++j)
	{
		for (int i = N-1; i >= 1; --i)
		{
			sum[i][j] += sum[i+1][j];
		}
	}
	for (int i = 1; i <= N; ++i)
	{
		for (int j = N-1; j >= 1; --j)
		{
			ans[i][j] = ans[i][j+1] - sum[i][j+1];
		}
	}

	rep(i,Q)
	{
		int p,q;
		cin >> p >> q;
		cout << ans[p][q] << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main()
{
	int A,B;
	scanf("%d%d",&A,&B);
	
	if (A+B<=16)
	{
		if (A<=8 && B<=8)
		printf("Yay!\n");
		else
		printf(":(\n");
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        b[a-1] = i;
    }
    set<int> ar;
    ar.insert(-1);
    ar.insert(N);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll t = b[i];
        auto it1 = ar.lower_bound(t);
        auto it2 = it1;
        it1--;
        ans += (ll)(t-(*it1)) * ((*it2)-t) * (i+1);
        ar.insert(t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i=0;
  int a=1;
  int N,K;
  cin>>N>>K;
  for (i; i < N; i++) {
    a*=2;
    if(a>K){
      break;
    }
  }
  int b=a;
  for (int j=0;j<N-i-1;j++){
    b+=K;
  }
  cout<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int H, W, N;
    cin >> H >> W >> N;
    int temp;
    queue<int> que;
    for(int i = 0; i < N; i++){
        cin >> temp;
        for(int j = 0; j < temp; j++){
            que.push(i+1);
        }
    }

    int res[100][100];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            res[i][j] = que.front();
            que.pop();
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W;j++){
            if(i%2){
                cout << res[i][j];
            }else{
                cout << res[i][W-j-1];
            }
            if(j != W-1) cout << ' ';
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, k;
vector<lli> e[2001];

lli dfs(lli u, lli p, lli d) {
  lli res = d > k/2 ? 1 : 0;
  for (lli v : e[u]) {
    if (v != p) res += dfs(v, u, d + 1);
  }
  return res;
}

int main() {
  cin >> n >> k;
  for (lli i=0; i<n-1; ++i) {
    lli u, v; cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }

  lli ans = 1e10;
  if (k % 2 == 1) {
    for (lli i=1; i<=n; ++i) {
      for (lli v : e[i]) {
        if (v > i) ans = min(ans, dfs(i, v, 0) + dfs(v, i, 0));
      }
    }
  } else {
    for (lli i=1; i<=n; ++i) {
      ans = min(ans, dfs(i, -1, 0));
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
typedef pair<ll,pair<ll,ll> >P;
priority_queue<P>Q;
ll n,m,k,a,b,c,t,s[3010];

ll Bad_Station(ll x,ll lim){
  if(t-x<0)return 0;
  return min(lim,(t-x)/a+1);
}

void Qpush(ll x,ll lim){
  ll tmp=Bad_Station(x,lim);
  Q.push(make_pair(tmp,make_pair(x,lim)));
}

int main(){
  cin>>n>>m>>k>>a>>b>>c>>t;
  lol(i,m){cin>>s[i];s[i]--;}
  s[m]=n;
  ll ans=0;
  lol(i,m){
    ll nes=Bad_Station(s[i]*b,s[i+1]-s[i]);
    ans+=nes;
    ll x=s[i]*b+nes*c;
    ll lim=s[i+1]-s[i]-nes;
    Qpush(x,lim);
  }
  lol(i,k-m){
    if(Q.empty())break;
    ll nes=Q.top().first;
    ll x=Q.top().second.first;
    ll lim=Q.top().second.second;
    Q.pop();
    ans+=nes;
    x+=nes*c;
    lim-=nes;
    Qpush(x,lim);
  }
  cout<<ans-1<<endl;
  return 0;
}



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

int main() {
    uint64_t s,p=-1;
    cin>>s;
    uint64_t ts=s;
    while(ts){
        ts/=10;
        ++p;
    }
    uint64_t sum=0;
    bitset<9>b;
    for(int i=0,k;i<(1<<p);++i){
        b=i;
        ts=s;
        k=10;
        for(int j=0;j<p;++j){
            if(b.test(j)){
                sum+=ts%k;
                ts/=k;
                k=1;
            }
            k*=10;
        }
        sum+=ts;
    }
    cout<<sum<<"\n"s;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

loop{

  a, op, b = STDIN.gets.split
  a = a.to_i
  b = b.to_i

  case op
  when '+' then
    puts a+b
  when '-' then
    puts a-b
  when '*' then
    puts a*b
  when '/' then
    puts a/b
  else
    break
  end
}

Measured memory_bytes: 8684
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
const int M = 1000005;
int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> cnt(M);
    for (int x : a) {
        if (cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x) {
            cnt[i]++;
        }
    }
    int ans = 0;
    for (int x : a) {
        if (cnt[x] == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7996
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	S := next()
	if S[len(S)-1] == 's' {
		fmt.Println(S + "es")
	} else {
		fmt.Println(S + "s")
	}
}


Measured memory_bytes: 1812
N,L = map(int,input().rstrip().split(' '))
apple_pie = 0
ex = abs(L * N)
apple = []
for i in range(N):
    a = L + i 
    apple.append(a)
    apple_pie += a
for i in range(len(apple)):
    if abs(ex) > abs(apple[i]):
        ex = apple[i]
apple_pie-= ex
print(apple_pie)

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

int main() {
	string s,t;
	cin>>s;
	cin>>t;
	bool flag = false;
	for(int i=0;i<s.size();i++)
    {
       if(s==t)
           {
            flag=true;
            break;}
            s =s.back()+s.substr(0,s.size()-1);
    }
	if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

X, N = map(int, input().split())
A = []
if N != 0:
    A = set(map(int, input().split()))

ans = 0
d = 1 << 28
for i in range(200):
    if i not in A and abs(X - i) < d:
        ans = i
        d = abs(X - i)

print(ans)

Measured memory_bytes: 9636
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<Int> A;
    vector<int> two(N), five(N);
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        int dot = -1;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == '.') {
                dot = j;
                break;
            }
        }
        string pre, post;
        if (dot == -1) {
            pre = s;
            post = "";
        } else {
            pre = s.substr(0, dot);
            post = s.substr(dot + 1, string::npos);
        }
        while (post.size() < 9) {
            post.push_back('0');
        }
        Int val = stoll(pre) * 1000000000 + stoll(post);
        A.push_back(val);
    }
    for (int i = 0; i < N; i++) {
        Int a = A[i];
        while (a % 2 == 0) {
            a /= 2;
            two[i]++;
        }
        while (a % 5 == 0) {
            a /= 5;
            five[i]++;
        }
        two[i] = min(two[i], 18);
        five[i] = min(five[i], 18);
    }
    int cnts[19][19] = {};
    Int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        ans += cnts[18 - two[i]][18 - five[i]];
        for (int t = 0; t <= two[i]; t++) {
            for (int f = 0; f <= five[i]; f++) {
                cnts[t][f]++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


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

#define int long long

#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##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
int cntp[11000][1100]={};
int cntq[11000][1100]={};
signed main(){
	int n;
	cin>>n;
	set<int> memo;
	int a[110000];
	rep(i,n)cin>>a[i];
	int g=gcd(a[0],a[1]);
	if(n>1){
		rep(i,2,n)g=gcd(g,a[i]);
	}else{
		g=1;
	}
	rep(i,n)a[i]/=g;
	rep(i,n){
		rep(j,2,(int)sqrt((a[i]+1))+1){
			while(a[i]%j==0){
				a[i]/=j;
				cntp[i][j]++;
			}
		}
		if(a[i]<1100){
			cntp[i][a[i]]++;
			cntp[i][0]=1;
		}else{
			cntp[i][0]=a[i];
			memo.insert(a[i]);
		}
	}
	int sum[1100]={};
	rep(j,1,1100){
		rep(i,n){
			sum[j]+=cntp[i][j];
		}
	}
	rep(j,1,1100){
		rep(i,n){
			cntq[i][j]=sum[j]-cntp[i][j];
		}
	}
	int ma[1100];
	rep(i,1,1100)ma[i]=INF;
	rep(j,1,1100){
		rep(i,n){
			chmin(ma[j],cntq[i][j]);
		}
	}
	rep(j,1,1100){
		rep(i,n){
			cntq[i][j]-=ma[j];
		}
	}
	int kake=1;
	for(int k:memo){
		kake*=k;
		kake%=MOD;
	}
	
	int ans=0;
	rep(i,n){
		int c=1;
		rep(j,1100){
			rep(k,cntq[i][j]){
				c*=j;
				c%=MOD;
			}
		}
		c*=kake*modinv(cntp[i][0],MOD)%MOD;
		c%=MOD;
		ans+=c;
		ans%=MOD;
	}
	cout<<ans%MOD<<endl;
}

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

typedef long long ll;

int dp[31];
ll f(int n){
    int & ans = dp[n];
    if(ans!=0) return ans;
    else {
        if(n==1) ans = 1;
        else if(n==2) ans = 1 + f(n-1);
        else if(n==3) ans = 1 + f(n-1) + f(n-2);
        else ans = f(n-1) + f(n-2) + f(n-3);

        return ans;
    }
}

int main(){
    memset(dp,0,sizeof(dp));
    int n;
    while(cin>>n,n){
        cout << f(n)/10/365 + 1 << endl;
    }
}

Measured memory_bytes: 1156
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define mCalc(a, s, b) (a)=((a)s(b))%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, x;
    cin >> N >> x;
    ll i;
    ll ans=0;
    ll a[111];
    ll s=0;
    for(i=0; i<N; i++) {
        cin >> a[i];
        s+=a[i];
    }
    sort(a, a+N);
    
    if(s<x) ans--;
    
    for(i=0; i<N; i++) {
        if(x-a[i]<0) {
            pt(ans);
            return 0;
        }
        
        x-=a[i];
        ans++;
        
    }
    
    pt(ans);
}




Measured memory_bytes: 256
k=int(input())
li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[k-1])

Measured memory_bytes: 3060
'use strict';

function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const n = Number(input[0].split(' ')[0]);
  const k = Number(input[0].split(' ')[1]);
  const h = input[1].split(' ').map(Number);
  const dp = Array(n).fill(1e10);
  dp[0] = 0;

  for (let i = 0; i < n; i++) {
    for (let diff = 1; diff <= k; diff++){
      if (i + diff >= n) continue;
      dp[i + diff] = Math.min(dp[i + diff], dp[i] + Math.abs(h[i] - h[i + diff]));
    }
  }
  console.log(dp[n - 1]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 27744
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
cin >> S;
if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
    cout << "Bad" << endl;
} else cout << "Good" << endl;


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    string ans = (s[0] == s[2])? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

long long countAD(long long y, int m, int d)
{
    int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
        ++ days[2];

    long long ret = (y-1) * 365LL + (y-1) / 4 - (y-1) / 100 + (y-1) / 400;
    for(int i=1; i<m; ++i)
        ret += days[i];
    ret += d - 1;

    return ret;
}

void addAD(long long y, int m, int d, long long& y2, int& m2, int& d2, long long x)
{
    int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    x += countAD(y, m, d);
    
    y2 = 0;
    y2 += x / (365 * 400 + 97) * 400;
    x -= (365 * 400 + 97) * (y2 / 400);
    y2 += min(300LL, x / (365 * 100 + 24) * 100);
    x -= (365 * 100 + 24) * (y2 % 400 / 100);
    y2 += x / (365 * 4 + 1) * 4;
    x -= (365 * 4 + 1) * (y2 % 100 / 4);
    y2 += min(3LL, x / 365);
    x -= 365 * (y2 % 4);
    ++ y2;

    if((y2 % 4 == 0 && y2 % 100 != 0) || y2 % 400 == 0)
        ++ days[2];
    m2 = 1;
    while(x >= days[m2]){
        x -= days[m2];
        ++ m2;
    }

    d2 = (int)x + 1;
}

int main()
{
    int x[] = {13, 20, 20, 18, 20};

    for(;;){
        string s;
        cin >> s;
        if(s == "#")
            return 0;
        istringstream iss(s);

        if(count(s.begin(), s.end(), '.') == 2){
            long long y;
            int m, d;
            char c;
            iss >> y >> c >> m >> c >> d;

            long long a = countAD(y, m, d) - countAD(2012, 12, 21);

            vector<int> ret(5);
            for(int i=4; i>=0; --i){
                ret[i] = a % x[i];
                a /= x[i];
            }
            for(int i=0; i<4; ++i)
                cout << ret[i] << '.';
            cout << ret[4] << endl;
        }else{
            long long a = 0;
            for(int i=0; i<5; ++i){
                int b;
                char c;
                iss >> b >> c;
                a *= x[i];
                a += b;
            }

            long long y;
            int m, d;
            addAD(2012, 12, 21, y, m, d, a);

            cout << y << '.' << m << '.' << d << endl;
        }
    }
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(void)
{
	int n, k;
	int i;

	scanf("%d %d", &n, &k);
	for (i = 0; i < k; i++){
		int xi, yi;
		int xmin, ymin;
		int min;
		scanf("%d %d", &xi, &yi);

		xmin = fmin(xi, n + 1 - xi);
		ymin = fmin(yi, n + 1 - yi);
		min = fmin(xmin, ymin);

		printf("%d\n", min % 3 ?: 3);
	}

	return (0);
}

Measured memory_bytes: 600
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int c = 0;
    int res = 0;
    for (int i = 0; i <= n; i++) {
        if (i == n || a[i] != a[i - 1]) {
            res += c / 2;
            c = 1;
        } else {
            c++;
        }
    }
    cout << res << "\n";

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;

ll n,m,q,T;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    int c1,c2,c3,c4,c5;
    ll a,b,c,d;
    ll x,y;

    cin >> n;

    vector<ll> X;
    vector<ll> SP;
    vector<ll> PL;

    ll prev = 0;
    ll sum = 0;

    ll ans = 1;

    ll curr = 1;
    ll plm = 1;

    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        sum += a-prev-1;
        ans *= c1-plm+2;
       // cout << plm << " " << curr << "\n";
        if(a < curr){
            plm++;
            //curr = a;
        }
        else{
            curr += 2;
        }
        ans %= big;

    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
'use strict'

function main(s) {

  const str = s.split('\n')[0].split('');
  const first_char = str[0];
  const mid_length = str.slice(1, -1).length;
  const last_char = str[str.length - 1];
  const ans = first_char + mid_length + last_char;
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = st[0];
            int B = st[1];
            int C = st[2];

            var modList = new List<int>();

            int index = 1;
            int new_num;

            while (true) {
                new_num = A * index % B;
                if (!modList.Contains(new_num)) {
                    modList.Add(new_num);
                    index++;
                } else {
                    break;
                }
            }
            //Console.WriteLine(string.Join(" ", modList));

            Console.WriteLine(modList.Contains(C)? "YES" : "NO");

        }
    }
}


Measured memory_bytes: 13280
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> flg(n, false);
    flg[0] = true;
    vector<int> cnt(n, 1);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        if (flg[x]) {
            flg[y] = true;
        }
        --cnt[x];
        if (cnt[x] == 0) {
            flg[x] = false; 
        }
        ++cnt[y];
    }
    int ans = 0;
    rep(i, n) {
        if (flg[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){

  int a, b;
  cin >> a >> b;

  int s;
  s = a * b;

  cout << s - (a + b - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 1000000007
#define MAXN 100005
bool sortby1column(vector<ll> &v1,vector<ll> &v2){
 return v1[0]<v2[0];
}


int main(){
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	int t=1;
	//cin>>t;
	while(t--){
	    int n,x,y;
	    cin>>n>>x>>y;
	    int kam = y-x-1;
	    int ans[n]={0};
	    for(int i=1;i<=n;i++){
	        for(int j=i+1;j<=n;j++){
	            int temp = j-i;
	            temp = min(temp,abs(x-i)+1+abs(j-y));
	            ans[temp]++;
	        }
	    }
	    for(int i=1;i<n;i++)
	        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

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

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int64 a, b, c;
    cin >> a >> b >> c;
    if (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}



Measured memory_bytes: 256
import numpy as np

H,W,K=map(int,input().strip().split())
c=[]
for n in range(H):
    c.append(list(input()))
for h in range(H):
    for w in range(W):
        if c[h][w]==".":
            c[h][w]=0
        else:
            c[h][w]=1
c=np.array(c)

cnt=0
def rec(l,H,W,K):
    global cnt
    if len(l)==H+W:
        t=c.copy()
        for i in range(len(l)):
            if i<=H-1:
                if l[i]==1:
                    t[i,:]=0
            else:
                if l[i]==1:
                    t[:,i-H]=0
        if np.sum(t)==K:
            cnt+=1
    else:
        for n in range(2):
            l.append(n)
            rec(l,H,W,K)
            l.pop()

rec([],H,W,K)
print(cnt)

Measured memory_bytes: 27224
#include <iostream>
#include <chrono>

using namespace std;

int main() {
    int n, y;
    cin >> n >> y;

    auto start = chrono::system_clock::now();

    long ans = 0;
    bool breakFlag = false;
    int mn = n;
    int gn = 0;
    int sn = 0;
    for (int mi = n; mi >= 0; --mi) {
        int diff = n - mi;
        for (int gi = 0; gi <= diff; ++gi) {
            ans = mi * 10000 + gi * 5000 + (diff - gi) * 1000;
            if (ans == y) {
                mn = mi;
                gn = gi;
                sn = n - mn - gn;
                breakFlag = true;
                break;
            }
        }

        if (breakFlag) {
            break;
        }

        mn = -1;
        gn = -1;
        sn = -1;
    }

    cout << mn << " " << gn << " " << sn << endl;

    auto end = chrono::system_clock::now();
    auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
//    cout << msec << " milli sec" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll x, y;
	cin >> x >> y;
	ll ans = 0;
	if (x == 0 || y == 0) {
		if (x <= y) ans = y - x;
		else ans = x - y + 1;
	}
	else  if (x * y > 0) {
		if (x <= y) ans = y - x;
		else ans = x - y + 2;
	}
	else {
		if (x >= y) ans = abs(abs(y) - x) + 1;
		else ans = abs(y - abs(x)) + 1;
	}
	cout << ans << endl;
}


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

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

void logic()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();++i)
    {
        ans=ans+(s[i]=='+'?1:-1);
    }
    cout<<ans;
    cout<<"\n";
    //incase of wrong answer...stress test your code...do not stress test yourself
    //overflow,bounds,size,constraints
    //sample tests,corner case/special case(n==0 or n==1 or negative numbers...),some hand written tests
    //read statement carefully
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
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,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    vector<ll> t(n);
    REP(i, n) cin >> t[i];
    ll sum = 0;
    REP(i, n) sum += t[i];
    ll m; cin >> m;
    REP(i, m){
        ll p, x; cin >> p >> x;
        cout << sum - t[p-1] + x << endl;
    }
}

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

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void)
{	
	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k)print(s);
	else {
		string result = s.substr(0, k);
		result += "...";
		print(result);
	}
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main {
	
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int N=Integer.parseInt(br.readLine());
		if(N%1000==0)
			System.out.println(0);
		else
			System.out.println(1000-(N%1000));
	}
}


Measured memory_bytes: 32576
step = input()

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

f = True
for i in range(len(step)):
    if (i + 1) % 2 == 1 and step[i] not in odd:
        f = False
        break
    elif (i + 1) % 2 == 0 and step[i] not in even:
        f = False
        break
if f == False:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




typedef long long ll;
int N;  ll L[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;

    L[0] = 2;
    L[1] = 1;

    rep(i, 2, N + 1) L[i] = L[i - 1] + L[i - 2];

    cout << L[N] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

int res(int x, int y){
  return x<y?x:y;
}
void enqueue(P x){
  Q[tail]=x;
  tail = (tail+1)%LEN;

}

P dequeue(){
  P x=Q[head];
  head = (head+1)%LEN;
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n+1;

  while(head != tail){
    u= dequeue();
    c= res(q,u.t);
    u.t -=c;
    elaps +=c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}
    



Measured memory_bytes: 11984
N_x, M_y, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

judge = 'War'
border_x = max(X, max(xs))
border_y = min(Y, min(ys))

if (border_x < border_y):
    judge = 'No War'

print(judge)

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

int main() 
{
   int n,m,l;
   cin >> n >> m >>l;
   vector<vector<long> > a(n, vector<long>(m));
   vector<vector<long> > b(m, vector<long>(l));
   vector<vector<long> > ans(n, vector<long>(l));

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

   for (int i = 0; i < m; i++){
       for (int j = 0; j < l; j++){
           cin >> b[i][j];
       }
   }

   for (int i = 0; i < n; i++){
       for (int j = 0; j < l; j++){
           for (int h = 0; h < m; h++){
               ans[i][j] += a[i][h] * b[h][j];
           }
           if (j != l-1 ){
               cout << ans[i][j] << " ";
           }
           else {
               cout << ans[i][j];
           }
       }
       cout << endl;
   }
  
   return(0);

}




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

def main():
  n,m,k = map(int, input().split())
  a = list(map(int, input().split()))
  b = list(map(int, input().split()))
  sa = [0] * (n+1)
  sb = [0] * (m+1)
  for i in range(n):
    sa[i+1] = sa[i] + a[i]
  for i in range(m):
    sb[i+1] = sb[i] + b[i]
  rx = 0
  rb = m
  for ra in range(0,n+1): 
    while (sb[rb] + sa[ra]) > k and rb>0 :
      rb-=1
    if (sb[rb] + sa[ra]) <= k:
      rx = max(rx,ra+rb)
  print(rx)

if __name__ == '__main__':
    main()

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

typedef pair<double,string> P;

int main(){
	int n;
	while( cin >> n , n ){
		vector<P> vc;
		for(int i=0 ; i < n ; i++ ){
			int p,a,b,c,d,e,f,s,m;
			string l;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			double E = -(double)( f*s*m - p ) / ( (a+b+c) + (d+e)*m );
			P p_( E , l );
			vc.push_back( p_ );
		}
		sort( vc.begin() , vc.end() );
		for(int i=0 ; i < vc.size() ; i++ ){
			cout << vc[i].second << endl;
		}
		cout << "#" << endl;
	}
}

Measured memory_bytes: 0
n=int(input())
t=tuple([0]+list(map(int,input().split()))+[0])
a=tuple([0]+list(map(int,input().split()))+[0])
if n==1 and t[1]!=a[1]:
    print(0)
    exit()
c=1
m=10**9+7
for i in range(1,n):
    if t[i]>t[i-1]:
        if a[i]>a[i+1]and a[i]!=t[i]or a[i]==a[i+1]and a[i]<t[i]:
            print(0)
            exit()
    else:
        if a[i]>a[i+1]and a[i]>t[i]:
            print(0)
            exit()
        if a[i]==a[i+1]:
            c=min(t[i],a[i])*c%m
print(c)

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

int main(){
    int a, b, c;
    vector<int> V(10);
    string S, S1, S2, S3;
    cin >> S;
    S1 = "Sunny", S2 = "Cloudy", S3 = "Rainy";
    if(S == S1) cout << S2 << endl;
    else if(S == S2) cout << S3 << endl;
    else cout  << S1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
uintmax_t combination(unsigned int n, unsigned int r){    //組み合わせ
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

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

    cout << pow(n, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    vector<ll> v(n);
    ll ans=1,maxi = (ll)pow(10,18);
    ll f=0;
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
        if(v[i]==0) f=1;
    }
  
    if(f)
    {
      cout<<0<<endl;
      return 0;
    }
    
    for(ll i=0;i<n;i++)
    {
        if(v[i]>maxi/ans)
        {
            ans = -1;
            break;
        }
        ans *= v[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3960
#include<stdio.h>
int x[2000000],n;
void max(int a){
  int left,right,m,temp;
  left=2*a;
  right=2*a+1;
  if(left<=n && x[left]>x[a]){
    m=left;
  }
  else{
    m=a;
  }
  if(right<=n&&x[right]>x[m])m=right;
  if(m!=a){
    temp=x[a];
    x[a]=x[m];
    x[m]=temp;
    max(m);
  }
} 
int main(){
  int i;
  scanf("%d",&n);
     
  for(i=1;i<=n;++i){
    scanf("%d",&x[i]);
  }
  for(i=n/2;i>=1;--i){
    max(i);
  }  
  for(i=1;i<=n;++i){
    printf(" %d",x[i]);
  }
  printf("\n");
     
  return 0;
}




Measured memory_bytes: 3668