akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        String s = scanner.nextToken();
        if (s.charAt(s.length() - 1) == 's')
            s = s + "es";
        else
            s = s + "s";
        System.out.println(s);
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(nextToken());
    }

    long nextLong() {
        return Long.parseLong(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 36272
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  for(i<-1 to readInt) {
    val Array(x1,y1,x2,y2,x3,y3,x4,y4) = readLine.split(" ") map { _.toDouble }
    val p = (x2-x1)*(y4-y3) - (x4-x3)*(y2-y1)
    if(p< 1e-10 && p > -(1e-10)) println("YES") else println("NO")
  }
}

Measured memory_bytes: 44360
import java.util.Scanner;

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

        String s = sc.next();
        int max = 0;
        int count = 0;
        for(int i=0; i<3; i++){
            if(s.charAt(i) == 'S'){
                count = 0;
            }
            else if(s.charAt(i) == 'R'){
                count++;
                if(max < count){
                    max = count;
                }
            }
        }
        System.out.println(max);
    }
}

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

using namespace std;
const int INF=1000000007;

int N,K;
int D[15];

bool Iroha(int x){
    stringstream s; s<<x;
    string ss=s.str();
    for(int j=0; j<K; j++){
        for(int i=0; i<ss.size(); i++){
            int m=ss[i]-'0';
            if(m==D[j]){
                return 0;
            }
        }
    }
    return 1;
}

int main(){

cin>>N>>K;

for(int i=0; i<K; i++) scanf("%d",&D[i]);

int n=N; 

while(1){
    if(Iroha(n)){
        cout<<n<<endl; break;
    }
    n++;
}

return 0;
 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j=0,l=0,k=0;
    scanf("%d",&n);
    char a[n],b[n],ans[n+n];
    scanf("%s%s", a,b);
    for(i=0;i<n+n;i++)
    {
        if(i%2==0)
        {
            ans[k]=a[j];
            j++;
        }
        else
        {
            ans[k]=b[l];
            l++;
        }
        k++;
    }
    ans[i]='\0';
    printf("%s\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(void) {
    int i, n = 1;

    for( i = 'a'; i < 'z'; ++i ) ++n;
    int ch, sum[n];
    for( i = 0; i < n; ++i ) sum[i] = 0;
    while( ch = getchar(), ch != EOF ){
        if( isalpha(ch) ){
            ch = tolower(ch);
            sum[ch-'a'] += 1;
        }
    }

    for( i = 0; i < n; ++i )
        printf("%c : %d\n", 'a'+i, sum[i]);

    return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K; cin >> N >> K;
	string S; cin >> S;
	S[K - 1] = 'a' + S[K - 1] - 'A';
	print(S);
}

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

using namespace std;

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

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int a = N / 100;
        int x = 100 * a + 10 * a + a;
        if(N <= x)
        {
            Console.WriteLine(x);
        }
        else
        {
            Console.WriteLine(x + 111);
        }
    }
}

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

#define ll long long
#define vi vector<int>
  
using namespace std;                           

int h, a;

int main (){
	cin >> h >> a;
	if(h % a == 0){
		cout << h / a;
	}
	else {
		cout << h / a + 1;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
maze = []
maze.append('#' * (w+2))
for i in range(h):
    maze.append('#' + input() + '#')
cnt = 0
for i in maze:
    cnt += i.count('.')
maze.append('#' * (w+2))
i, j = 1, 1
seen = {(1, 1)}
d = 0
stack = deque([[(i, j), d]])
while stack:
    pos, d = stack.popleft()
    i, j = pos
    for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        if (i+di, j+dj) not in seen and maze[i + di][j + dj] == '.':
            if (i + di, j + dj) == (h, w):
                print(cnt - d -2)
                exit()
            stack.append([(i + di, j + dj), d + 1])
            seen.add((i + di, j + dj))
print(-1)

Measured memory_bytes: 3572
import java.util.*;
import java.io.*;

public class Main {
	
	static long[][]memo;
	static char[][] dots;
	static int h;
	static int w;

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		
		h=sc.nextInt();
		w=sc.nextInt();
		
		memo=new long[h][w];
		
		dots=new char[h][w];
		
		for(int i=0;i<h;i++) {
				String x=sc.next();
				dots[i]=x.toCharArray();
		}
		
		for(long[] x:memo) {
			Arrays.fill(x, -1);
		}
		
		long out=dp(0,0);
		
		System.out.println(out);
		
		
		
		}
	
	public static long dp(int i,int j) {
		
		if(i==h|j==w) {
			return 0;
		}
		
		if(memo[i][j]!=-1) {
			return memo[i][j];
		}
		
		
		if(dots[i][j]=='.'&i==h-1&&j==w-1) {
			return 1;
		}
		
		
		long x=0;
		long y=0;
		
		if(dots[i][j]=='.') {
			x=dp(i+1,j);
			y=dp(i,1+j);
			return memo[i][j]=(x+y)%((long)1e9+7);
		}else {
			return memo[i][j]=0;
		}
		
	}
	
}



Measured memory_bytes: 56828
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005


ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


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



int main(){
    int n,m;cin>>n>>m;
    int a[n];rep(i,0,n-1)a[i]=1;
    bool f[n];rep(i,0,n-1)f[i]=false;f[0]=true;
    while(m--){
        int c,d;cin>>c>>d;c--;d--;
        f[d]|=f[c];
        a[c]--;a[d]++;
        if(a[c]==0)f[c]=false;
    }
    int ans=0;
    rep(i,0,n-1)if(f[i])ans++;
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 768
#include <cstdio>

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int min = n / k;
    int max;
    if(n % k >= 1){
        max = min + 1;
    }else{
        max = min;
    }
    printf("%d\n",max - min);

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  map<string,int> mp;
  rep(i,N) {
    string s;
    cin >> s;
    sort(rng(s));
    mp[s]++;
  }
  ll ans = 0;
  for(auto x:mp) {
    ll c = x.second;
    ans += c*(c-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<queue>

using namespace std;

struct S{
  int x,p,v;
  double t;
  bool operator<(S s)const{
    return t>s.t;
  }
};

int main(){
  for(int n,m;cin>>n>>m,n;){
    int s,g;
    cin>>s>>g;
    int d[31][31];
    int l[31][31]={};
    for(int i=0;i<m;i++){
      int x,y,di,c;
      cin>>x>>y>>di>>c;
      d[x][y]=d[y][x]=di;
      l[x][y]=l[y][x]=c;
    }
    bool p[31][31][31]={};
    priority_queue<S> que;
    que.push({s,0,0,0});
    while(!que.empty()){
      S cs=que.top();
      if(cs.x==g&&cs.v==1)break;
      que.pop();
      if(p[cs.x][cs.p][cs.v]++)continue;
      for(int i=0;i<=n;i++){
	if(cs.p==i)continue;
	for(int j=-1;j<=1;j++){
	  int nv=cs.v+j;
	  if(nv<=0||l[cs.x][i]<nv)continue;
	  que.push({i,cs.x,nv,cs.t+d[cs.x][i]*1./nv});
	}
      }
    }
    if(que.empty()){
      cout<<"unreachable"<<endl;
    }else{
      cout<<fixed<<que.top().t<<endl;
    }
  }
}

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

int
main(int argc, char** argv)
{
	int dn[3] = {5, 9, 13};
	int dx[3][13] = {{-1, 0, 0, 1, 0}, {-1,-1,-1, 0, 0, 0, 1, 1, 1}, {-2,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 2}}; /*x*/
	int dy[3][13] = {{ 0,-1, 0, 0, 1}, {-1, 0, 1,-1, 0, 1,-1, 0, 1}, { 0,-1, 0, 1,-2,-1, 0, 1, 2,-1, 0, 1, 0}}; /*x*/

	int c[10][10];
	int x, y, t;
	int i, j;

	for (i = 0; i < 10; ++i)
	{
		for (j = 0; j < 10; ++j)
			c[i][j] = 0;
	}

	while (scanf("%d,%d,%d", &x, &y, &t) != EOF)
	{
		t--;
		for (i = 0; i < dn[t]; ++i)
		{
			int nx = x + dx[t][i], ny = y + dy[t][i];
			if (0 <= nx && nx < 10 && 0 <= ny && ny < 10)
				c[nx][ny]++;
		}
	}

	int count = 0;
	int max = 0;
	for (i = 0; i < 10; ++i)
	{
		for (j = 0; j < 10; ++j)
		{
			if (c[i][j] == 0)
				count++;

			if (c[i][j] > max)
				max = c[i][j];
		}
	}

	printf("%d\n", count);
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
using namespace std;
const int MAXN=1e5+9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	bool flag=false;
	while(k--)
	{
		if(flag)
		{
			break;
		}
		flag=true;
		int b[n+1];
		memset(b,0,sizeof(b));
		for(int i=1;i<=n;i++)
		{
			int lft=max(1,i-a[i]);
			int rgt=min(n+1,i+a[i]+1);
			b[lft]++;
			if(rgt<=n)
			{
				b[rgt]--;
			}
		}
		for(int i=1;i<=n;i++)
		{
			b[i]+=b[i-1];
		}
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=b[i])
			{
				flag=false;
			}
			a[i]=b[i];
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define rep(i,n,m) for(ll i = (n); i <(m); i++)
#define rrep(i,n,m) for(ll i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];

    priority_queue<pii> b_index_que;
    vector<ll> b(n);
    rep(i, 0, n)
    {
        ll bb;
        cin >> bb;
        b_index_que.push(make_pair(bb, i));
        b[i] = bb;
    }

    rep(i, 0, n)
    if (b[i] < a[i])
    {
        cout << -1 << endl;
        return 0;
    }

    ll cnt = 0;
    while (b_index_que.size() > 0)
    {
        // cout << "*********" << endl;
        pii b_i;
        b_i = b_index_que.top();
        b_index_que.pop();

        ll i = b_i.second;

        if (b[i] == a[i]) continue;

        ll next, prev;
        next = (i + 1 == n)? 0: i + 1;
        prev = (i - 1 == -1)? n - 1: i - 1;
        // cout << "**************" << endl;
        // cout << b[prev] << ' ' << b[i] << ' ' << b[next] << endl;

        ll b_target = a[i];
        if (b[next] > a[next] and b[prev] > a[prev])
            b_target = max(b[next], b[prev]);
        else if (b[next] > a[next])
            b_target = b[next];
        else if (b[prev] > a[prev])
            b_target = b[prev];

        if (b_target != -1)
        {
            ll num, add;
            add = b[next] + b[prev];
            num = (b[i] - b_target + add - 1) / add;
            num = max(0LL, num);
            b[i] -= num * add;
            cnt += num;
            // cout << "num " << num << ' ' << b_target << ' ' << add << endl;
        }
        // cout << b[prev] << ' ' << b[i] << ' ' << b[next] << ':' << a[i] << endl;
        // cout << (a[prev] == b[prev]) << ' ' << (b[i] == a[i]) << ' ' << (b[next] == a[next]) << endl;
        
        // cout << b[i] << ' ' << a[i] << endl;
        if (b[i] < a[i])
        {
            // cout << "here" << endl;
            // rep(i, 0, n)
            //     cout << b[i] << endl;
            cout << -1 << endl;
            return 0;
        }
        else
            b_index_que.push(make_pair(b[i], i));
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 9584
import java.util.*;

class Main {

	static int MAX_N = 1 << 17;
	static int INT_MAX = 2147483647;

	static int n;
	static int[] dat = new int[2*MAX_N-1];
	// static int[] dat = new int[100];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		init(N);
		for (int i=0;i<q;i++) {
			int c = Integer.parseInt(sc.next());
			int x = Integer.parseInt(sc.next());
			int y = Integer.parseInt(sc.next());
			if (c==0) {
				update(x, y);
			} else {
				System.out.println(query(x, y+1, 0, 0, n));
			}
		}
		// System.out.println(dat.length);
		// System.out.println(Arrays.toString(dat));
	}

	public static void init(int n_) {
		n = 1;
		while (n < n_) {
			n*=2;
		}
		for (int i=0;i<2*n-1;i++) {
			dat[i] = INT_MAX;
		}
	}

	public static void update(int k, int a) {
		k+=n-1;
		dat[k]=a;
		while (k>0) {
			k = (k-1)/2;
			dat[k] = Math.min(dat[k*2+1], dat[k*2+2]);
		}
	}

	public static int query(int a, int b, int k, int l, int r) {
		if (r<=a || b<=l) {
			return INT_MAX;
		}
		if (a<=l && r<=b) {
			return dat[k];
		} else {
			int vl = query(a, b, k*2+1, l, (l+r)/2);
			int vr = query(a, b, k*2+2, (l+r)/2, r);
			return Math.min(vl, vr);
		}
	}
}


Measured memory_bytes: 74796
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
using namespace std;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p)
{
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

typedef long long ll;

ll match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[11000];
const string INF = "-";

void comparison(string &a, string b)
{
    if (a == INF)
    {
        a = b;
    }
    else if (a.size() < b.size())
    {
        a = b;
    }
    else if (a.size() == b.size())
    {
        if (a < b)
        {
            a = b;
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < 11000; i++)
    {
        dp[i] = INF;
    }

    dp[0] = "";

    for (int i = 0; i <= n; i++)
    {
        if (dp[i] == INF)
        {
            continue;
        }

        for (auto aa : a)
        {
            comparison(dp[i + match[aa - 1]], dp[i] + (char)('0' + aa));
        }
    }

    // for (int i = 0; i < 100; i++)
    // {
    //     cout << dp[i] << endl;
    // }
    cout << dp[n] << endl;
}

Measured memory_bytes: 43776
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	int d[3];
	rep(i,3) d[i]=0;
	rep(i,n) {
		int a; cin>>a;
		if(a%4==0) d[2]++;
		else if(a%2==0) d[1]++;
		else d[0]++;
	}
	bool ans = false;
	if (d[2]>=d[0]+d[1]-1) ans=true;
	else if (d[1]!=0 && d[2]>=d[0]) ans=true;
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			map = new boolean[h][w];
			for (int i = 0; i < h; i++) {
				char[] c = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (c[j] == '@') {
						sy = i;
						sx = j;
					} else if (c[j] == '#')
						map[i][j] = true;
				}
			}
			ans = 0;
			dfs(sy, sx);
			System.out.println(ans);

		}
	}

	private void dfs(int y, int x) {
		map[y][x] = true;
		ans++;
		for (int[] m : move) {
			int ny = y + m[0];
			int nx = x + m[1];
			if (!isOK(ny, nx))
				continue;
			if (map[ny][nx])
				continue;
			dfs(ny, nx);
		}
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int w, h, sy, sx, ans;
	boolean[][] map;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

}

Measured memory_bytes: 25408
#input
char_list = raw_input().split()

#calculation
stack = []
for x in char_list:
    if x == "+":
        a = stack.pop()
        b = stack.pop()
        stack.append(a+b)
    elif x=="-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
    elif x=="*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(x))

#output
print stack[0]

Measured memory_bytes: 4216
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int total=0;
    for (int i=0;i<3;i++) {
      int a=sc.nextInt();
      total=total+a;
    }

    if (total>=22) {
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
ll a[300000];
ll b[300000];
ll c[300000];
ll d[300000];

bool check(ll k) {
	ll m = 1 << (k + 1);

	REP(i,n) {
		c[i] = a[i] % m;
		d[i] = b[i] % m;
	}

	sort(d,d + n);

	ll T = 1 << k;

	ll cou = 0;
	REP(i,n) {
		cou += lower_bound(d,d + n,2 * T - c[i]) - lower_bound(d,d + n,T - c[i]);
		cou += lower_bound(d,d + n,4 * T - c[i]) - lower_bound(d,d + n,3 * T - c[i]);
	}
	return cou % 2;
}

int main(){
	cin >> n;
	REP(i,n)
		cin >> a[i];
	REP(i,n) 
		cin >> b[i];

	ll ans = 0;
	REP(i,30) {
		ans += (check(i) << i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	if (abs(n - m) >= 2){
		cout << 0 << endl; return 0;
	}
	if (abs(n - m) == 1) {
		int ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= i; ans %= MOD;
		}
		int ans2 = 1;
		for (int i = 1; i <= m; i++) {
			ans2 *= i; ans2 %= MOD;
		}
		cout << (ans*ans2) % MOD << endl;
	}
	else {
		int ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= i; ans %= MOD;
		}
		int ans2 = 1;
		for (int i = 1; i <= m; i++) {
			ans2 *= i; ans2 %= MOD;
		}
		cout << (2*ans*ans2) % MOD << endl;
	}
	return 0;
}

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

a = 0
b = 0
for i in range(n):
  aw , bw = input().split()
  
  if aw > bw:
    a += 3
  elif aw < bw :
    b += 3
  else :
    a += 1
    b += 1

print(a,b)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

struct edge { ll to, from, cost; };
edge es[MAX_M];
ll d[MAX_M];
ll V, E;
bool bellmanford(int s) {
	repe(i, 1, V)d[i] = INF;
	d[s] = 0;
	ll k = 0;
	rep(k, 0, 2 * V) {
		bool update = false;
		repe(i, 1, E) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if (k > V && e.to == V) {
					return true;
				}
			}
		}
	}

	return false;
}

int main() {
	cin >> V >> E;
	repe(i, 1, E) {
		ll a, b, c; cin >> a >> b >> c;
		edge e;
		e.from = a;
		e.to = b;
		e.cost = -c;
		es[i] = e;
	}
	if (!bellmanford(1)) {
		cout << -d[V] << endl;
	}
	else {
		cout << "inf" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long A[200000];
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A, A + N);
  reverse(A, A + N);
  int left = N - 2;
  long long ans = A[0];
  for(int i = 1; i < N; i++){
    if(left <= 0){
      break;
    }
    if(left == 1){
      ans += A[i];
      break;
    } 
    ans += A[i] * 2;
    left -= 2;
  }
  cout << ans << endl;
  return 0;
}


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

int Max(int &a,int b){return a=max(a,b);}

int dp[101][30010];
int main(){
  int n,W;
  cin>>n>>W;
  int v[101],w[101];
  for(int i=0;i<n;i++) cin>>v[i]>>w[i];
  
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=W;j++){
      Max(dp[i+1][j],dp[i][j]);
      Max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
    }
  }

  int ans = 0;
  for(int i=0;i<=W;i++) Max(ans,dp[n][i]);
  cout<<ans<<endl;

  return 0;
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long

int main(){
	int a,b;
	cin>>a>>b;
	if(!(a%3)||!(b%3)||!((a+b)%3))
		cout<<"Possible"<<endl;
	else
		cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
aa = [input() for _ in range(n)]
bb = [input() for _ in range(m)]

def template_matching():
  for y in range(n-m+1):   
    for x in range(n-m+1):
      flag = True
      for yi in range(m):
        if aa[y+yi].find(bb[yi],x)-x != 0:          
          flag = False
      if flag :
        return True
  return False

if template_matching():
  print('Yes')
else:  
  print('No')

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

using namespace std;

#define M_DEBUG if (1)
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
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; }


/******************************************************************************
	typedef
******************************************************************************/
using lint = long long;
typedef unsigned long long int ullint;

/******************************************************************************
	Main
******************************************************************************/
int main()
{
    int n = -1, m = -1;
    cin >> n >> m;
    assert(n >= 0 && n <= 100);
    assert(m >= 0 && m <= 100);
    assert(n + m >= 2);

    // nC2 + mC2
	cout << n * (n-1) / 2 + m * (m-1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a, b;
	cin >> a >> b;
	if(a == 1 && a != b) cout << "Alice" << endl;
	else if(b == 1 && a != b) cout << "Bob" << endl;
	else if(a > b) cout << "Alice" << endl;
	else if(a < b) cout << "Bob" << endl;
	else if(a == b) cout << "Draw" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	vector<LL> A(N);
	rep(i,N) cin >> A[i];
	LL ans=0;
	rep(i,N-1){
		if(A[i]>A[i+1]){
			ans+=A[i]-A[i+1];
			A[i+1]=A[i];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
//#define int long long
using namespace std;
const int K = 1<<26;
int INF = 1e9;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int XOR = 0;
    vector<int> dp(K);
    fill(dp.begin(), dp.end(), INF);
    dp[0] = 0;
    int answer = INF;
    for (int i=0; i < s.size(); i++){
        answer = INF;
        XOR ^= 1 << (s[i] - 'a');
        answer = min(answer, dp[XOR] + 1);
        for (int j=0; j < 26; j++){
            answer = min(answer, dp[XOR ^ (1 << j)] + 1);
        }
        dp[XOR] = min(dp[XOR], answer);
    }
    cout << answer << endl;
    return 0;
}



Measured memory_bytes: 262804
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

//5時間かけて理解に努めたが理解不能
/*int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> a(N);

    rep(i, M){
        cin >> k;

        rep(j, k){
            cin >> s;
            s--;
            a(s) |= 1 << i;
        }
    }

    int p = 0;
    rep(i, M){
        cin >> x;
        p |= x << i;
    }

    for(int s = 0; s < (1 << N); s++){
        t = 0;
        rep(i, N){
            if(s >> i & 1){
                t ^= a[i];
            }
        }

        if(t == p){
            ans++;
        }
    }

    cout << ans << endl;
}
*/

int main()
{
    int N,M,end = 0;
    cin >> N >> M;
    vector<vector<int>> s(M); 
    vector<int> p(M);
    vector<int> ans(M);

    rep(i, M){
        int k;
        cin >> k;
        rep(j, k){
            int c;
            cin >> c;
            s[i].push_back(--c);
        }
    }

    rep(i, M){
        cin >> p[i];
    }

    for(int bit = 0; bit < (1 << N); bit++){

        rep(i, M){
            ans[i] = 0;
        }

        rep(i, N){
            if(bit & (1 << i)){
                rep(j, M){
                    int S = s[j].size();
                    rep(k, S){
                        if(s[j][k] == i){
                            ans[j]++;
                        }
                    }
                }
            }
        }

        bool flag = true;
        rep(i, M){
            if(ans[i] % 2 != p[i]){
                flag = false;
                break;
            }
        }

        if(flag){
            end++;
        }
    }

    cout << end << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int r = sc.nextInt();

        int result = r;

        if (n < 10) {
            result = r + 100 * (10 - n);
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main (void){
  char abc[7];
  
  scanf("%s",abc);
  
  if(abc[2]==abc[3]){
    if(abc[4]==abc[5]){
      printf("Yes");
    }
    else
      printf("No");
  }
  else
    printf("No");
  return 0;
  
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
		{
		ar[i]=scan.nextInt();
		}
		int score[]=new int[n];
		score[n-1]=0;
		for(int i=n-2;i>=0;i--)
		{
			if(ar[i]>=ar[i+1])
			{
				score[i]+=score[i+1]+1;
			}
		}
		int max=0;
		for(int i=0;i<n;i++)
		{
			max=Math.max(max, score[i]);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 50792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int count = 0;
		
		for(int i=0;i<N;i++) {
			int h = sc.nextInt();
			if(h>=K)count++;
		}
		
		System.out.println(count);
		
		sc.close();	
	}
}

Measured memory_bytes: 45384
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0]*(2501) for i in range(51)] for j in range(51)]
#dp[i][j][k]は、i番目まででj枚とって総数kとなる取り方
for i in range(n+1):
    dp[i][0][0]=1
for i in range(n):
    for j in range(1,i+2):
        for k in range(1,2501):
            if k-x[i]>=0:
                dp[i+1][j][k]=dp[i][j-1][k-x[i]]+dp[i][j][k]
            else:
                dp[i+1][j][k] = dp[i][j][k]
ans=0
for j in range(1,n+1):
    ans+=dp[n][j][a*j]
print(ans)

Measured memory_bytes: 117740
n, k = map(int, input().split())
ns = list(map(int, input().split()))
min_num = float('inf')
for i in range(n - k+1):
    l = ns[i]
    r = ns[i+k-1]
    min_num = min(min_num, abs(l) + abs(r-l), abs(r) + abs(l-r))
print(min_num)

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

int main (void)
{
	// variables for main process
	unsigned int maxloc_1st;
	unsigned int maxval_1st;
	unsigned int maxval_2nd;
	unsigned int len_sequence;
	unsigned int val_sequence;

	// support variables for main process
	register signed int rtvl;

	// STEP.01
	// read out the given data
	// (the length of the given sequence)
	rtvl = scanf("%d", &len_sequence);

	// STEP.02
	// initialize the variables to calculate the answer of this task
	maxval_1st = 0U;
	maxval_2nd = 0U;

	// STEP.03
	// calculate & output the answer of this task
	for (register unsigned int itr = 0; itr < len_sequence; itr++)
	{
		// STEP.03.01
		// read out the value of the given sequence
		rtvl = scanf("%d", &val_sequence);

		// STEP.03.02
		// update the maximum values of the given sequence
		if (maxval_1st < val_sequence)
		{
			maxval_2nd = maxval_1st;
			maxval_1st = val_sequence;
			maxloc_1st = itr;
		}
		else if (maxval_2nd < val_sequence)
		{ maxval_2nd = val_sequence; }
		else
		{ continue; }
	}

	// STEP.04
	// output the answer of this task
	for (register unsigned int itr = 0; itr < len_sequence; itr++)
	{
		if (itr == maxloc_1st) { printf("%d\n", maxval_2nd); }
		else                   { printf("%d\n", maxval_1st); }
	}

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <set>
#include <string>

using namespace std;

int main()
{
    uint32_t x;
    cin >> x;
    
    uint32_t gohyaku = x / 500;
    uint32_t go = (x%500) / 5;

    uint32_t ans = gohyaku * 1000 + go*5;

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll x=a[0],y=a[1];
    vector<ll> vx,vy;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            vx.pb(i);
            vx.pb(x/i);
        }
    }
    for(int i=1;i*i<=y;i++){
        if(y%i==0){
            vy.pb(i);
            vy.pb(y/i);
        }
    }
    /*sort(be(vx));
    sort(be(vy));
    era(vx);
    era(vy);*/
    ll ans=0;
    bool maki;
    for(int i=0;i<vx.size();i++){
        maki=false;
        for(int j=0;j<n;j++){
            if(a[j]%vx[i]){
                if(maki){
                    break;
                }
                else{
                    maki=true;
                }
            }
            if(j==n-1){
                ans=max(ans,vx[i]);
            }
        }
    }
    for(int i=0;i<vy.size();i++){
        maki=false;
        for(int j=0;j<n;j++){
            if(a[j]%vy[i]){
                if(maki){
                    j=n;
                }
                else{
                    maki=true;
                }
            }
            if(j==n-1){
                ans=max(ans,vy[i]);
            }
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long powmod(long long px, long long py, long long pmod){
	if(py == 0) return 1;
	if(py % 2 == 0) return powmod((px * px) % pmod, py / 2, pmod);
	else return (px * powmod(px, py - 1, pmod)) % pmod;
} 
int main() {
	// your code goes here
    long long n,i,d[100005],e,s=1,ans=1,mo=1;
    long long mod = (long long)998244353;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> d[i];
        if(i==0&&d[i]!=0){
            cout << "0" << endl;
            return 0;
        }
        if(i!=0&&d[i]==0){
            cout << "0" << endl;
            return 0;
        }
    }
    sort(d,d+n);
    d[n]=1000000;
    for(i=1;i<n+1;i++){
        if(d[i-1]!=d[i]){
            if(i!=n&&d[i-1]+1!=d[i]){
                cout << "0" << endl;
                return 0; 
            }
            if(i==1) s=1;
            else {
                ans=ans*powmod(mo,s,mod)%mod;
                mo=s;
                s=1;
            }
        } else s++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a, b;
  cin >> a >> b;
  
  if(a < 1 || a > 10000)
  {
    cout << "a(first input) must be between 1 and 10000" << endl;
  	exit(1);
  }
  
  if(b < 1 || b > 10000)
  {
    cout << "b(second input) must be between 1 and 10000" << endl;
  	exit(1);
  }
  
  if(a * b % 2 != 0)
  {
  	cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;

    auto check = [&](int a) {
        ll sum  = 0;
        int ret = a;
        while (a != 0) {
            sum += a % 10;
            a /= 10;
        }
        if (A <= sum && sum <= B)
            return ret;
        else
            return -1;
    };
    FOR(i, 1, N + 1) {
        int x = check(i);
        if (x != -1)
            ans += x;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector

#define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve() {
	int s; cin >> s;
	int dp[s+1] = {} ;
	for(int i = 3 ; i <= s ;++i) {
		dp[i] = 1; 
		for(int j = 3 ; i-j >= 3 ; ++j) dp[i] = (dp[i] + dp[j]) % mod ;
	}

	cout << dp[s]; 
}

int32_t main() {

#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif

    fast;

	// int t; cin >> t; while(t--)
		solve() ;

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


Measured memory_bytes: 3664
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var k = inputs[1];

            // ひとつずつ配って余りを１人に配れば最大（１人だけは例外）
            var diff = k == 1 ? 0 : n - k;

            // 解答の出力
            Console.WriteLine(diff);
        }
    }
}


Measured memory_bytes: 13396
import random as ra
import copy
import time

start_time = time.time()

D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]

### 得点計算用
#t = [int(input()) for i in range(D)]
def cal_point(t):
    score = 0
    last = [0]*26
    for d in range(D):
        score += s[d][t[d]-1]
        last[t[d]-1] = d+1
        for i in range(26):
            score -= c[i]*(d+1-last[i])
    #print(score)
    return score


t = []
last = [0]*26
for i in range(D):
    opt1 = s[i].index(max(s[i]))
    opt2 = last.index(min(last))
    if ra.random()<0.5:
        t.append(opt1+1)
        last[opt1] = i+1
    else:
        t.append(opt2+1)
        last[opt2] = i+1


#t = [ra.randint(1,26) for i in range(D)]
max_score = 0
optimal_t = copy.deepcopy(t)
#M = 10**5
while (time.time()-start_time)<1.95:
#for i in range(M):
    d = ra.randint(1,D)
    q = ra.randint(1,26)
    td = t[d-1]
    t[d-1] = q
    now = cal_point(t)
    if now > max_score:
        optimal_t = copy.deepcopy(t)
        max_score = now
    else:
        t[d-1] = td

print(*optimal_t,sep='\n')


Measured memory_bytes: 9912
N = int(input())
A = input().split()

result = True
for a in A:
    aint = int(a)
    if aint % 2 == 0:
        if aint % 3 != 0 and aint % 5 != 0:
            result = False

if result:
    print('APPROVED')
else:
    print('DENIED')



Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	ll k, a, b;
	cin >> k >> a >> b;
	cout << (b / k - (a - 1) / k > 0 ? "OK" : "NG") << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    set<string> gacha;

    rep(i,N) {
        string S;
        cin >> S;
        gacha.insert(S);
    }
    
    cout << gacha.size() << endl;

    return 0;
}

Measured memory_bytes: 19196
#include <cstdio>
int main()
{
	int k, x;
	scanf("%d%d", &k, &x);
	for (int i = x - k + 1; i <= x + k - 1; i++) {
		if (i != x - k + 1) putchar(' ');
		printf("%d", i);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    scanf("%d",&n);
    cin >> s;
    if(n%2==1)
    {
        printf("No");
        return 0;
    }
    else
    {
        int j=n/2;
        for(int i=0;i<=(n/2)-1;i++)
        {
            if(s[i]!=s[j])
            {
                printf("No");
                return 0;
            }
            j++;
        }
        printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[1000],n[1000],x[1000];
int main() {
	int count=0;
	
	for (int b =0 ; b < 1000; b++) {
		a[b] = 0;

	}
	for (int b = 0; b < 1000; b++) {

cin >> n[b] >> x[b];
if (n[b] == 0 && x[b] == 0) break;
for (int s = 1; s <= n[b]; s++) {
	for ( int d = 1; d <= n[b]; d++) {
		for (int f = 1; f <= n[b]; f++) {
			if (s == d)break;
			else if (s == f)break;
			else if (d == f)break;
			if (s + d + f == x[b])a[b] += 1;
}
	}
}

count++;
}
	for (int b = 0; b < count; b++) {
		a[b] /= 2;
	}
	for (int b = 0; b < count; b++) {
		cout << a[b] << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[100004];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int p=0;
    for(int i=1;i<=n;i++)p^=a[i];
    if(p==0)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 640