akhauriyash/Code-Regression huggingface dataset:
l,r=map(int,input().split())
m= 2019
lmod = l%m
rmod = r%m
ans = 0
if r-l >=2018:
    ans = 0
else:
    if r//m - l//m >0:
        ans = 0
    else:
        ans = 10**9
        for i in range(lmod ,rmod +1):
            for j in range(lmod ,i):
                tmp = (i*j)%m
                ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 41068
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		doIt();
		//test();
	}
	public static void test(){
		double x = 1.234567890;
		double y = 9.876543210;
		//小数点代4位を四捨五入
		System.out.println(x + " " + y);
		y *= 1000;
		y = (double)Math.round(y) / 1000;
		x *= 1000;
		x = (double)Math.round(x) / 1000;
		System.out.println(x + " " + y);
	}
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		//a0 1b 2c 3d 4e 5f
		double[] v = new double[6];
		double x = 0;
		double y = 0;
		while(sc.hasNextDouble()){
			//boolean bAns = false;
			//System.out.println("ts");
			//Math.round
			for(int i = 0; i < 6; i++){
				v[i] = sc.nextDouble();
				//System.out.println(i + " " + v[i]);
			}
			//sc.nextInt();
			if(v[0] == 0){
				y = v[2] / v[1];
				x = v[5] - v[4]*y;
				x /= v[3];
			}
			else if(v[1] == 0){
				x = v[2] / v[0];
				y = v[5] - v[3]*x;
				y/= v[4];
			}
			else if(v[3] == 0){
				y = v[5] / v[4];
				x = v[2] - v[1]*y;
				x /= v[0];
			}
			else if(v[4] == 0){
				x = v[5] / v[3];
				y = v[2] - v[0]*x;
				y/= v[1];
			}
			else{
				double tmp1 = v[1] * v[3] - v[0] * v[4];
				double tmp2 = v[3] * v[2] - v[0] * v[5];
				y = tmp2 / tmp1;

				x = v[2] - v[1]*y;
				x /= v[0];

			}
			//小数点代4位を四捨五入
			y *= 1000;
			y = (double)Math.round(y) / 1000;
			x *= 1000;
			x = (double)Math.round(x) / 1000;
			//System.out.println(x + " " + y);
			System.out.printf("%.3f %.3f\n", x,y);
		}
		sc.close();
	}

}

Measured memory_bytes: 12000
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

struct Point {
    double x, y;
    Point opBinary(alias op)(in Point p) {
        if (op == "+") return Point(x + p.x, y + p.y);
        if (op == "-") return Point(x - p.x, y - p.y);
    }
    Point opBinary(alias op)(double k) {
        if (op == "*") return Point(x * k, y * k);
    }
}
double dot(in Point a, in Point b) {
    return a.x * b.x + a.y * b.y;
}
double cross(in Point a, in Point b) {
    return a.x * b.y - a.y * b.x;
}
double norm(in Point p) {
    return sqrt(p.x * p.x + p.y * p.y);
}

const EPS = 1e-8;

bool EQ(double a, double b) {
    return abs(a - b) < EPS;
}

double D;
Point P, V;

bool input() {
    scanf("%lf\n", &D);
    if (D == 0) return false;
    double x, y;
    scanf("%lf %lf", &x, &y);
    P = Point(x, y);
    scanf("%lf %lf", &x, &y);
    V = Point(x, y);
    return true;
}

void solve() {
    if (EQ(P.dot(V), -P.norm * V.norm)) {
        double ans = norm(P);
        if (ans >= D) {
            writeln("impossible");
        } else {
            writefln("%.8f", ans);
        }
    } else if (EQ(P.dot(V), P.norm * V.norm)) {
        double ans = 2.0 - norm(P);
        if (ans >= D) {
            writeln("impossible");
        } else {
            writefln("%.8f", ans);
        }
    } else {
        writeln("impossible");
    }
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 1148
N = int(input())
P = list(map(int, input().split()))

E = list(range(1,N+1))

d = [0 if p == e else 1 for p, e in zip(P, E)]

if sum(d) == 0 or sum(d) == 2:
    print('YES')
else:
    print('NO')

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

using namespace std;
using ll = long long;

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

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

  ll sum = 0;
  map<int, int> mp;
  rep(i, n) {
    int a;
    cin >> a;
    sum += a;
    ++mp[a];
  }

  int q;
  cin >> q;
  rep(nq, q) {
    int b, c;
    cin >> b >> c;
    sum += (c - b) * mp[b];
    printf("%lld\n", sum);
    mp[c] += mp[b];
    mp[b] = 0;
  }

  return 0;
}


Measured memory_bytes: 8072
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		StringBuilder s2 = new StringBuilder();
		for(int i = 0; i < s1.length(); i++){
			if(s1.charAt(i) == '0'){
				s2.append('0');
			}
			if(s1.charAt(i) == '1'){
				s2.append('1');
			}
			if(s1.charAt(i) == 'B'){
				if(0 < s2.length()) s2.deleteCharAt( s2.length()-1 );
			}
		}
		System.out.println(s2);
	}
}

Measured memory_bytes: 23380
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

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

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl as(N, 0); REP(i, N) cin >> as[i];
    ll ret = LINF;
    FOR(i, -100, 101){
        ll tmp = 0;
        REP(j, N) tmp += (as[j] - i) * (as[j] - i);
        ret = min(tmp, ret);
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
<?php
$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$y = (int)$input[1];

for ($i=0; $i <= $n; $i++) { 
	for ($j=0; $j <=$n-$i ; $j++) { 
		$sum = 10000*$i + 5000*$j + 1000*($n-$i-$j);
		if ($sum === $y) {
			echo $i . ' ' . $j . ' ' . ($n-$i-$j);
			exit();
		}
	}
}
echo '-1 -1 -1';

Measured memory_bytes: 4856
import itertools

n = int(input())
P = input().split()
numbers = list(itertools.permutations(P))
P = ''.join(P)
Q = input()
Q = Q.replace(' ', '')

numbers_str = []
for num in numbers:
    numbers_str.append(''.join(num))
numbers_str.sort()
print(abs(numbers_str.index(P)-numbers_str.index(Q)))


Measured memory_bytes: 10868
N = int(input())
n = list(map(int, input().split()))

n4 = len(list(filter(lambda x: x % 4 == 0, n)))
no = len(list(filter(lambda x: x % 2 == 1, n)))
if n4 + no < N:
    no += 1

if no <= n4 + 1:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 14252
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
 
  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
//   typedef string str;
//   typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;
  
 

  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 ll a,b,n;
 cin>>a>>b>>n;
 ll v = min(b-1, n);
 // cout<<v<<endl;
 cout<<a*v/b<<"\n";

}
  

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
    int n;
    cin >> n;
    
    int table[100001] = {0};
    
    rep(i, n) {
        int a;
        cin >> a;
        table[a] += 1;
    }
    
    int flg = 0;
    if (n % 2 != 0) {
        if (table[0] != 1) flg = 1;
        for (int i = 2; i <= 2 * (n / 2); i += 2) {
            if (table[i] != 2) flg = 1;
        }
    } else {
        for (int i = 1; i <= n / 2 - 1; i += 2) {
            if (table[i] != 2) flg = 1;
        }
    }
    
    if (flg == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1;
    rep(i, n / 2) {
        (ans *= 2) %= inf;
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

string ans;
int main(){
    string s;
    cin >> s;
    for(size_t i = 0; i < s.size(); i++)
    {
        if((i+1)%2!=0) ans+=s[i]; 
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  sort(d.begin(),d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() << endl;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int H, W;
  cin >> H >> W;
  int h, w;
  cin >> h >> w;
  cout << (H - h) * (W - w) << endl;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		String S = nextString();

		long ans = 0;
		long tmp=0;
		for(int i=0;i<S.length();i++){
			char c= S.charAt(i);
			if(c=='A' || c=='C' || c=='G' || c=='T'){
				tmp++;
			}else{
				ans = Math.max(ans, tmp);
				tmp=0;
			}
		}
		ans = Math.max(ans, tmp);
		System.out.println(ans);
	}

	public static boolean isExpN(long a,int base){
		int x=1;
		while((int)Math.pow(x, 2) <= a){
			if((int)Math.pow(x, 2) == a){
				return true;
			}
			x*=base;
		}
		return false;
	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int x,a,b; cin >> x >> a >> b;
    cout << (x-a)%b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	for(int i = 1; i<=9; i++)
	{
		for (int n = 1; n<= 9;n++)
		{
			cout<<i<<'x'<<n<<'='<<i*n<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;


int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;

	vector<int> w(n + 10, 0), b(n + 10, 0);

	for (int i = 0; i < n; i++)
	{
		if (s[i] == '#')
		{
			b[i+1] = 1;
		}
		else
		{
			w[i+1] = 1;
		}
	}

	for (int i = 0; i <= n; i++)
	{
		w[i + 1] += w[i];
		b[i + 1] += b[i];
	}

	int ans = INF;
	for (int i = 0; i <= n; i++)
	{
		//i番目までを白にする
		ans = min(ans, b[i] + w[n] - w[i]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 2180
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getList()
A = Counter(A)

one = 0
two = 0
for i in A.items():
    a, b = i
    if b % 2 == 0:
        two += 1
    else:
        one += 1
ans = 0
if two % 2 == 0:
    print(one + two)
else:
    print(one + two - 1)

Measured memory_bytes: 104060
/*input
5
100 1 2 3 14 15 58 58 58 29
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[maxn];
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n+n) cin>>a[i];
	sort(a,a+n+n);
	int ans=0;
	REP(i,n) ans+=a[i+i];
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
a, b, c, k = map(int, input().split())

ans = 0

if a < k:
    ans += a
    k -= a
    if b < k:
        ans += 0
        k -= b
        if c < k:
            ans -= c
        else:
            ans -= k
    else:
        ans += 0
else:
    ans += k

print(ans)


Measured memory_bytes: 9120
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int a, b, c, d, e, f, g;
	cin >> a >> b >> c >> d;
	e = c - a;
	f = b - a;
	g = c - b;
	while(1){
		if(e < 0){
			e *= -1;
		}
		if(f < 0){
			f *= -1;
		}
		if(g < 0){
			g *= -1;
		}
		if(e <= d){
			cout << "Yes" << endl;
			break;
		}
		if(f <= d && g <= d){
			cout << "Yes" << endl;
			break;
		}
		if(f > d || g > d){
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    int ans=0;
    for(int i=1;i<n-1;i++){
        if(p.at(i) < max(p.at(i-1), p.at(i+1)) and min(p.at(i-1), p.at(i+1)) < p.at(i)) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep (i, s.size()) cout << 'x'; cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include <ctype.h>
int main()
{
    char s1[10],s2[10],s3[10],s[3];
    scanf("%s",s1);
    scanf("%s",s2);
    scanf("%s",s3);

     printf("%c%c%c",toupper(s1[0]),toupper(s2[0]),toupper(s3[0]));
}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    A = ['#' * (W + 2)] + ['#' + input() + '#' for _ in range(H)] + ['#' * (W + 2)]
    for i in range(H + 2):
        print(A[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 62440
# -*- coding: utf-8 -*-
import sys
import os

n,m = [int(p) for p in input().split()]
h = [int(p) for p in input().split()]

ab = []
for i in range(m):
    a,b = [int(p) for p in input().split()]
    ab.append([a,b])

#print(h)
#print(ab)

tenbo = [[] for i in range(n)]

#1つの展望台から行ける展望台を全部書く
for j in range(m):
    a,b = ab[j]

    tenbo[a-1].append(h[b-1])
    tenbo[b-1].append(h[a-1])

#print(tenbo)

#各展望台を検索
kazu = 0
for i in range(n):
    
    if len(tenbo[i]) == 0:
        kazu += 1
        #print("Y", h[i], tenbo[i], 0)
    elif h[i] > max(tenbo[i]):
        kazu += 1
        #print("Y", h[i], tenbo[i], max(tenbo[i]))

print(kazu)

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<n-1;i++){
        ans+=v[i+1]-v[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

bool isAllEven(vector<int> numbers) {
  for (int x: numbers) {
    if (x % 2 != 0) return false;
  }
  return true;
}

void divideByTwo(vector<int>& numbers) {
  for (int i = 0; i < numbers.size(); i++) {
    numbers.at(i) = numbers.at(i) / 2;
  }
}

int main() {
  int N;
  cin >> N;
  
  vector<int> numbers(N, 0);
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> numbers.at(i);
  }
    
  while (isAllEven(numbers)) {
      count++;
      divideByTwo(numbers);
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int p, q, r; cin >> p >> q >> r;
    int d = p+q;
    d =min(d, p+r);
    d =min(d, q+r);
    cout << d << endl;
    return 0;
}




Measured memory_bytes: 3608
a = [list(map(int, input().split())) for _ in range(3)]
card = [[False, False, False], [False, False, False], [False, False, False]]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                card[i][j] = True
ans = 'No'
for i in range(3):
    if card[i][0] and card[i][1] and card[i][2]:
        ans = 'Yes'
        break
    if card[0][i] and card[1][i] and card[2][i]:
        ans = 'Yes'
        break
if card[0][0] and card[1][1] and card[2][2]:
    ans = 'Yes'
elif card[0][2] and card[1][1] and card[2][0]:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (pp(ll) p1, pp(ll) p2){
        return p1.ff >= p2.ff;
    }
};


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


Measured memory_bytes: 3620
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

l = 0
while l <= len(A[0]) - len(B[0]):
	for i in range(N - M + 1):
		s = A[i][l:]
		if not B[0] in s:
			continue
		if 0 == s.index(B[0]):
			for m in range(1, M):
				if not B[m] in A[i + m][l:]:
					break
				if 0 != A[i + m][l:].index(B[m]):
					break
			else:
				print("Yes")
				exit()
	l += 1
print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

bool table[8][8];
int f(vector<bool>check,int n,int v){
    bool allcheck=true;
    for(int i=0;i<n;i++){
        if(!check[i]) allcheck=false;
    }
    if(allcheck) return 1;
 
    int res=0;
    for(int i=0;i<n;i++){
        if(table[v][i]==false) continue;
        if(check[i]) continue;
        check[i]=true;
        res+=f(check,n,i);
        check[i]=false;
    }
    return res;
}
 
int main(){
    ios::sync_with_stdio(false);
    int m,n;
    cin>>n>>m;
 
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        table[a-1][b-1]=true;
        table[b-1][a-1]=true;
    }
    vector<bool> check(n);
    //bool check[8];
    for(int i=0;i<n;i++){
        check[i]=false;
    }
    check[0]=true;
 
    cout<<f(check,n,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main(){
    string s; cin >> s;
    if(s.size() % 2 == 1){
        cout << "No" << endl;
        return 0;
    }else{
        for(int i = 0; i < s.size(); i+=2){
            if(s[i] == 'h' && s[i+1] == 'i'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int r; cin >> r;
    cout << 3 * r * r << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

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

  repi(i, 0, 101) repi(j, 0, 101)
  {
    if (2 * i + 4 * j == y && i + j == x)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  if(K > (N-1)*(N-2)/2){
    cout << -1 << endl;
    return 0;
  }
  int D = (N-1)*(N-2)/2 - K;
  vector<pair<int,int>> E;
  for(int i = 1; i < N; ++i){
    E.emplace_back(0,i);
  }
  while(D){
    for(int i = 1; i < N; ++i){
      for(int j = i+1; j < N; ++j){
        E.emplace_back(i,j);
        --D;
        if(not D) break;
      }
      if(not D) break;
    }
  }
  cout << E.size() << endl;
  for(auto e : E){
    cout << e.first+1 << " " << e.second+1 << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    int a, b, c, tmp;
    cin >> a >> b >> c;
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    if (a > c) {
        tmp = a;
        a = c;
        c = tmp;
    }
    if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_N = 1000;
const ll DIV = 1000000000 + 7;
int N;
map<int, int> prime_map;
set<int> primes;

ll solve() {
    primes.insert(2);
    for(int i=2; i<=N; i++){
        int target = i;
        for(auto prime : primes){
            while(target % prime == 0){
                if(prime_map[prime] == 0) prime_map[prime] = 1;
                else prime_map[prime] += 1;
                target /= prime;
                eprintf("target: %d, prime: %d\n", i, prime);
            }
        }
        if(target != 1 && primes.find(target) == primes.end()){
            primes.insert(target);
            prime_map[target] = 1;
        }
    }
    ll ans = 1;
    for(auto pair : prime_map){
        eprintf("prime: %d, count: %d\n",pair.first ,pair.second);
        ans *= pair.second + 1;
        ans %= DIV;
        eprintf("%d\n",ans);
    }
    return ans;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    cout << solve() << "\n";
    return 0;
}



Measured memory_bytes: 256
K,A,B = map(int,input().split())
if K+1<=A:
    print(K+1)
else:
    if A+2>=B:
        print(K+1)
    else:
        #A+2枚→B枚
        #この状態になると叩くよりも交換した方が得
        #2回でB-A枚増えていく
        #奇数偶数で場合わけ
        if (K-A-1)%2==0:
            print(A+(B-A)*((K-A+1)//2))
        else:
            print(A+1+(B-A)*((K-A+1)//2))

Measured memory_bytes: 61800
import sys
input = lambda: sys.stdin.readline().rstrip()

def find_parent(x):
    y=parent[x]
    if y<0:
        return x
    parent[x]=find_parent(y)
    return parent[x]

def connect(a,b):
    c=find_parent(a)
    d=find_parent(b)
    if c==d:
        return
    if parent[c]<parent[d]:
        parent[c]+=parent[d]
        parent[d]=c
    else:
        parent[d]+=parent[c]
        parent[c]=d
    return

N=int(input())
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    X.append([x,i])
    Y.append([y,i])

X.sort()
Y.sort()
edge=[]
for i in range(1,N):
    edge.append([X[i][0]-X[i-1][0],X[i-1][1],X[i][1]])
    edge.append([Y[i][0]-Y[i-1][0],Y[i-1][1],Y[i][1]])
edge.sort()
parent=[-1]*N

ans=0
for l,a,b in edge:
    if find_parent(a)==find_parent(b):
        continue
    else:
        ans+=l
        connect(a,b)

print(ans)


Measured memory_bytes: 125788
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)



int main() {
	string S[100];
	string T[100];
	map<string, int> R;
	int N, M;
	cin >> N;

	rep(i, 0, N) {
		cin >> S[i];
		R[S[i]] += 1;
	}
	cin >> M;
	rep(i, 0, M) {
		cin >> T[i];
		R[T[i]] -= 1;
	}

	int ans = -1000;
	for (auto itr = R.begin(); itr != R.end();itr++) {
		if (ans < itr->second)ans = itr->second;

	}
	if (ans < 0) ans = 0;
	cout << ans;
		   
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    readline = sys.stdin.readline

    n = int(readline())

    dp = [[0] * 3 for _ in range(n + 1)]

    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed
        a, b, c = map(int, readline().split())
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c

    print(max(dp[n]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 53996
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long
ll dp[100010][2];

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    dp[0][1] = 1;
    rep(i,n+1){
        if(i==0)continue;
        if(s[i-1]=='1'){
            dp[i][0] = (dp[i-1][1]+dp[i-1][0]*3)%mod;
            dp[i][1] = (dp[i-1][1]*2)%mod;
        }else{
            dp[i][0] = (dp[i-1][0]*3)%mod;
            dp[i][1] = (dp[i-1][1])%mod;
        }
        
    } 
    cout << (dp[n][0]+dp[n][1])%mod << endl;
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll M=1e2+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll l,r;
	cin>>l>>r;
	if(r-l+1>=2019){
		cout<<0<<endl;
		return 0;
	}
	
	ll p=INT_MAX;
	for(ll i=l;i<=r;i++){
		for(ll j=i+1;j<=r;j++){
			ll ans=(i*j);
			ans=ans%2019;
			p=min(p,ans);
		}
	}
	
	cout<<p<<endl;
	
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	type pair struct{ v, fa int }

	n, m := r(), r()
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		v, w := r(), r()
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	ans := make([]int, n+1)
	vis := make([]bool, n+1)
	q := []pair{{1, 0}}
	vis[1] = true
	cnt := 1
	for len(q) > 0 {
		p := q[0]
		q = q[1:]
		v := p.v
		for _, w := range g[v] {
			if w != p.fa && !vis[w] {
				vis[w] = true
				cnt++
				ans[w] = v
				q = append(q, pair{w, v})
			}
		}
	}
	if cnt < n {
		Fprint(out, "No")
		return
	}
	Fprintln(out, "Yes")
	for _, v := range ans[2:] {
		Fprintln(out, v)
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 22452
#include <bits/stdc++.h>
using namespace std;   
int main()
{
    int N;
    cin >> N;
    int a[N], b[N], c[N-1];
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++) cin >> b[i];
    for(int i=0;i<N-1;i++) cin >> c[i];
   	int basic_point=0;
    	for(int i=0;i<N;i++){
        	basic_point += b[i];
    	}
    	int add_point=0;
    	for(int i=0;i<N-1;i++){
        	if(a[i+1] == a[i]+1){
        		add_point += c[a[i]-1];
      	  	}else add_point +=0;
    	}
	int point = basic_point + add_point;
    cout << point << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

def main(N):
    if N == 0:
        return 0, 0
    if N >= 1:
        for i in range(0, 32, 2):
            if N <= (2**(i+2)-1)//3:
                return N - 2**i, 10**i
    if N <= -1:
        for i in range(1, 34, 2):
            if (-2)*(2**(i+1)-1)//3 <= N:
                return N - (-2)**i, 10**i
    assert False, 'Never reached: N = {}'.format(N)

base2 = 0
while N != 0:
    N, bit = main(N)
    base2 += bit
print(base2)

Measured memory_bytes: 3064
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=0
for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(sum(b)+ans)        

Measured memory_bytes: 38384
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        l: usize,
        r: usize,
        d: usize,
    }
    println!("{}", (r / d) - (l - 1) / d);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int a, b, c, d, e, A[n];
    rep(i, n) {
      cin >> a >> b >> c >> d >> e;
      A[i] = a + b + c + e + d;
    }
    sort(A, A + n);
    cout << A[n - 1] << ' ' << A[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long           ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}

ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
void yes_or_no(ll x) {
    if (x) cout << "YES\n"; else cout << "NO\n";
}

void solve_test() {
    ll ans = 0;
    ll n, s;
    cin >> s;
    ll mod = 1e9 + 7;
    vector<ll> dp(s + 1, 0);
    dp[0] = 1;
    for (int i = 3; i <= s; i++) {
        for (int j = i; j >= 3; j--) {
            dp[i] = (dp[i] + dp[i - j]) % mod;

        }
        // trace(i, dp[i]);

    }
    ans = dp[s];
    cout << ans << "\n";
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;

    solve_test();

    return 0;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int N=cin.nextInt();
        char[] s=cin.next().ToCharArray();
        for(int i=0;i<s.Length;i++)
        {
            int n=s[i]+N;
            if(n>=91)n=65+(n-91);
            Console.Write((char)n);
        }
        Console.WriteLine();
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

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

using namespace std;
using ll = long long;

int main() {
	int N, L;
	cin >> N >> L;

	int sum = 0;
	for (int i = 1; i <= N; ++i) {
		sum += (L + i - 1);
	}

	int res = -1e8;
	for (int i = 1; i <= N; ++i) {
		int tmp = 0;
		for (int j = 1; j <= N; ++j) {
			if (j == i) { continue; }
			tmp += (L + j - 1);
		}
		if (abs(sum - res) > abs(sum - tmp)) { res = tmp; }
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
 
int main(){
	string x[7]={
	"SUN","MON","TUE","WED","THU","FRI","SAT"
	};
	string s; cin >> s;;
	int ans;
	rep(i,7){
		if(x[i] == s) ans = i;
	}
	cout << 7-ans << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}


ll cul(vector<ll> &A){
    ll ret=0;
    ll cnt0=0;
    for(ll i=(int)A.size()-1;i>=0;i--){
        if(A[i]==0){cnt0++;}
        else{ret+=cnt0;}
    }
    return ret;
}

int main(){
    string s;
    cin>>s;
    vector<vector<ll>> A(1);
    for(ll i=0;i<s.size();i++){
        if(s[i]=='A'){A.back().push_back(1);}
        else if(i+1<s.size() && s[i]=='B' && s[i+1]=='C'){
            A.back().push_back(0);
            i++;
        }
        else if(!A.back().empty()){
            A.push_back({});
        }
    }
    ll ans=0;
    for(auto &I:A){
        ans+=cul(I);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

int main() {
int N;
cin >> N;
  int a,b,j;
	vector<vector<int>> num(10,vector<int>(10));
  for(int i = 1; i <= N; i++){
    j = i;
  	while(j > 0){
    	a = j;
      	j /= 10;
    }
    b = i%10;
    num[a][b]++;
  }
  int ans = 0;
  for(int i= 0; i < 10; i++){
  	for(int j = 0; j < 10; j++){
    	ans = ans + num[i][j]* num[j][i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256