akhauriyash/Code-Regression huggingface dataset:
//
// Created by Takaaki Hirano on 2018/09/05.
//
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


const int MAX_N = 100;
int N, X, m[MAX_N];

void solve() {
    int count = 0, minm = INF;
    REP(i, N) {
        X -= m[i];
        minm = min(minm, m[i]);
        count++;
    }
    count += X / minm;
    cout << count << endl;
}

int main() {
    cin >> N >> X;
    REP(i, N)cin >> m[i];
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int>l(n);
  for(int i=0;i<n;++i) {
    cin >> l[i];
  }
  int sum=0;
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  for(int i=0;i<k;++i) sum+=l[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B;

int main(){
    cin>>A>>B;
    cout<<B*2-A<<endl;
    return 0;

}


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

long P[100000]; 
long Y[100000]; 
map<long, long> m[100000];
char ans[100000][13];

int main()
{
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        m[P[i] - 1][Y[i]] = i;
        //cout << "m[" << P[i] - 1 << "][" << Y[i] << "] = " << i << endl;
    }
    for(int i = 0; i < N; i++) {
        int k = 0;
        for(auto j = m[i].begin(); j != m[i].end(); j++) {
            //cout << "ans[" << j->second << "] = " << i + 1 << ", " << k + 1 << endl;
            sprintf(ans[j->second], "%06d%06d", i + 1, k + 1);
            k++;
        }
    }
    for(int i = 0; i < M; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 16256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

int main() {
	string X;
	while (1) {
		cin >> X;
		if (X == "0") break;
		int count = 0;
		for (int i = 0; i < X.size(); i++) {
			count += (X[i] - 48);
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3172
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int P,Q,R;
    cin >> P >> Q >> R;
    cout << min({ P + Q,Q + R,R + P });
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		if (s[i] == '+') ans++;
		else ans--;
	}

	cout << ans << endl;

	return 0;
}



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();
		
		long[] map = new long[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextLong();
		}
		
		Arrays.sort(map);
		
		Map<Long, Integer> table = new HashMap<>();
		for (int i = 0; i < N; i++) {
			if (table.containsKey(map[i])) {
				int val = table.get(map[i]);
				val++;
				table.put(map[i], val);
			} else {
				table.put(map[i], 1);
			}
		}
		
		int ans = 0;
		for (Map.Entry<Long, Integer> entry: table.entrySet()) {
			if (entry.getKey() > 100_000) {
				ans += entry.getValue();
			} else if (entry.getKey() != (long)entry.getValue()) {
				if (entry.getKey() < entry.getValue()) {
					ans += entry.getValue() - entry.getKey();
				} else {
					ans += entry.getValue();
				}
			}
		}
		
		System.out.println(ans);
	}

}

Measured memory_bytes: 61372
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = list(int(x) for x in input().split())

key = [[0]*n for i in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans = ans + ((s[i][0]-s[j][0])**2+(s[i][1]-s[j][1])**2)**0.5

ans = ans * 2 / n
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;
int main(void){
    int k,s;
    cin>>k>>s;
    int count=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(z<=k&&z>=0){
                count++;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    static Scanner sc = new Scanner(System.in);
    
    private static boolean binarySearch(int[] array, int key){
        int left = 0;
        int right = array.length;
        int mid = 0;
        while(left < right){
            mid = (left + right) / 2;
            if(array[mid] == key) return true;
            if(array[mid] < key){
                left = mid + 1;
            }else if(array[mid] > key){
                right = mid;
            }
        }
        return false;
    }
    
    private static int[] inputArray(){
        int num = sc.nextInt();
        int[] array = new int[num];
        for(int i = 0; i < num; i++){
            array[i] = sc.nextInt();
        }
        return array;
    }    
    
    public static void main(String[] args){
        int[] s = inputArray();
        int[] t = inputArray();
        int count = 0;
        
        for(int i = 0; i < t.length; i++){
            if(binarySearch(s, t[i])){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 67688
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define REP(i,n) for (int i=1;i<=n;i++)
 
int main() {
  int n, m; cin >> n >> m;
  int ans;
  if (n>=10) ans=m;
  else ans=m+100*(10-n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

typedef long long ll;
typedef pair<ll, ll> P;

ll remainNumber[201000];
ll lastPos[201000];
ll nextSame[201000];
ll a[201000];


int main(){
    ll N, K;   cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    fill(lastPos, lastPos+201000, -1);
    fill(nextSame, nextSame+201000, -1);
    remainNumber[N] = 0;

    for(int i = N-1; i >= 0; i--){
        if(lastPos[a[i]] == -1){
            remainNumber[i] = a[i];
        }
        else{
            remainNumber[i] = remainNumber[lastPos[a[i]] + 1];
            nextSame[i] = lastPos[a[i]];
        }
        lastPos[a[i]] = i;
    }

    vector<ll> indexHist;
    set<ll> indexSet;
    ll index = 0;

    while(indexSet.find(index) == indexSet.end()){
        indexHist.push_back(index);
        indexSet.insert(index);

        int remainFirst = remainNumber[index];
        // 返ってくるのが空文字
        if(remainFirst == 0){
            index = 0;
        }
        else {
            index = lastPos[remainFirst] + 1;
        }
    }

    ll startPos = indexHist[(K-1) % ((ll)indexHist.size())];
    vector<ll> res;

    while(startPos < N){
        if(nextSame[startPos] == -1){
            res.push_back(a[startPos]);
            startPos++;
        }
        else{
            startPos = nextSame[startPos] + 1;
        }
    }

    for(auto x: res){
        cout << x << " ";
    }
    cout << endl;

}

Measured memory_bytes: 20464
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RD;
	auto B = RD;

	writeln(min(N * A, B));
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cstdlib>

using namespace std;

int getLength( int x1, int x2, int y1, int y2 ) {
  return ( abs( x1 - x2 ) + abs( y1 - y2 ) );
}

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--;
  b--;
  c--;
  d--;
  int minL = INT_MAX;
  for( int w = 1; w <= n; w++ ) {
    int ax = a % w;
    int ay = a / w;
    int bx = b % w;
    int by = b / w;
    int cx = c % w;
    int cy = c / w;
    int dx = d % w;
    int dy = d / w;
    
    int ablen = getLength( ax, bx, ay, by );
    int cdlen = getLength( cx, dx, cy, dy );
    int len = ablen + cdlen;

    minL = minL > len ? len : minL;
  }

  cout << minL << endl;

  return 0;
}

Measured memory_bytes: 1160
<?php
while(($max = trim(fgets(STDIN))) !== '') {
    $count = 0;
    $tmp = 1;
    $max = intval($max);

    if ($max === 1) {
        echo 0 . "\n";
        continue;
    }

    $str = str_repeat('01', $max/2+1);
    $loopmax = ceil(sqrt($max));

    for ($i=3; $i <= $loopmax; $i+=2) {
        if ($str[$i] === '0') {
            continue;
        }
        $loop = 2;
        $now = $i * 2;
        while ($now <= $max) {
            $str[$now] = '0';
            $loop++;
            $now = $i * $loop;
        }
    }

    $prime_count = 1;
    for ($i=3; $i <= $max; $i+=2) {
        if ($str[$i] === '1') {
            $prime_count++;
        }
    }

    echo $prime_count . "\n";
}

Measured memory_bytes: 17192
#include <bits/stdc++.h>
using namespace std;
static const int M=10000;
static const int INF=(1<<20);
int n;
vector<pair<int,int > > a[M];
void dijkstra(){
	priority_queue<pair<int,int> > Q;
	int col[M];
	int d[M];
	for(int i=0;i<n;i++){
		col[i]=0;
		d[i]=INF;
	}
	d[0]=0;col[0]=1;
	Q.push(make_pair(0,0));
	while(!Q.empty()){
		pair<int,int>f=Q.top();Q.pop();
		int u=f.second;col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<a[u].size();j++){
			int v=a[u][j].first;
			if(col[v]==2)continue;
			if(d[v]>d[u]+a[u][j].second){
				d[v]=d[u]+a[u][j].second;
				Q.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}
	for(int i=0;i<n;i++)cout<<i<<' '<<(d[i]==INF?-1:d[i])<<endl;
}
int main() {
	int k,u,v,c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u>>k;
		for(int j=0;j<k;j++){
			cin>>v>>c;
			a[u].push_back(make_pair(v,c));
		}
	}
	dijkstra();
}

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

int main()
{
    string w;
    cin >> w;
    int c = 0;
    if (w == "RRR")
    {
        c = 3;
    }
    else if (w== "RRS" || w == "SRR")
    {
        c= 2;
    }
    else if (w == "SRS" || w == "RSR" || w == "SSR" || w == "RSS")
    {
        c = 1;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3600
/**********************************************

1.
2.炭田高輝
3.sumita.takaki@gmail.com

last updated: 2013-07-10@17:33

 **********************************************/
#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;


int main(void){


        while(1){

                int yen = 0;
                int oturi =0;
                int count = 0;

                cin >> yen;
                if(yen == 0)break;
                oturi = 1000 - yen;

                while(oturi/500 != 0){
                        oturi = oturi -500;
                        count++;        
                }
        

                while(oturi/100 != 0){
                        oturi = oturi -100;
                        count++;
                }
        

                while(oturi/50 != 0){
                        oturi = oturi -50;
                        count++;
                }
        

                while(oturi/10 != 0){
                        oturi = oturi -10;
                        count++;
                }
        

                while(oturi/5 != 0){
                        oturi = oturi -5;
                        count++;
                }
        

                count = count + oturi;        

                cout << count <<endl;

        }
    

        return 0;    


}

Measured memory_bytes: 1156
n = int(input())
T = [0];X = [0];Y = [0]
for i in range(n):
    t, x, y = [int(i) for i in input().split()]
    T.append(t);X.append(x);Y.append(y)

for i in range(1, n+1):
    t_diff = T[i] - T[i-1]
    pos_diff = abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1])
    a = t_diff - pos_diff
    if a % 2 != 0 or a < 0:
        break
else:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 11816
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string ans = "hon";
		if(N%10==3){
			ans = "bon";
		} else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
			ans = "pon";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17628
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
string s;
void solve(){
	for(int i = 0;i < s.size();i++){
		if(s[i] == '?') s[i] = 'D';
	}
	cout << s << endl;
	return;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	solve();	
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3724
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; 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 all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const int MAX = 1000000000;
int main() {
    int n, k;
    ll s;
    cin >> n >> k >> s;

    if (s == 1 || n == k) {
        vector<ll> ans(n);
        rep(i,k) ans[i] = s;
        srep(i,k,n) ans[i] = MAX;
        rep(i,n) cout << ans[i] << " ";
        cout << endl;
        return 0;

    }
    
    vector<ll> ans(n,(s-1));
    
    int id = 0;
    
    while(k>0) {
        ans[id+1] = abs(ans[id]-s);
        --k;
        ++id;
    }
    if (id<n-1) {
        ++id;
        srep(i,id,n) {
            if (s!=MAX) ans[i] = MAX;
            else ans[i] = MAX-2;
        }
    }
    rep(i,n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}



























Measured memory_bytes: 2048
N = int(input())
s = []
for i in range(N):
  tmp = list(input())
  tmp.sort()
  s.append("".join(tmp))

s.sort()
m = {}
for i in range(len(s)):
  if s[i] in m.keys():
    m[s[i]] += 1
  else:
    m[s[i]] = 1

v = [int(x * (x-1) / 2) for x in list(m.values())]
print(sum(v))


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

#define endl '\n'
using namespace std;
using ll = long long;

const int N = 3030;
const ll MOD = 1e9+7;

int n;
char arr[N];
ll dp[N][N]; // dp[i][j] = # of considering first n op, ended with j

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n;
    for(int i = 1; i < n; i++) cin >> arr[i];
    dp[0][0] = 1;
}

void add_self(ll &lhs, ll rhs)
{
    lhs += rhs;
    if(lhs > MOD) lhs -= MOD;
}

void process()
{
    for(int i = 1; i < n; i++)
    {
        for(int j = 1; j <= i; j++) add_self(dp[i-1][j], dp[i-1][j-1]);
        for(int j = 0; j <= i; j++)
        {
            if(arr[i] == '>')
            {
                if(j== 0) 
                    add_self(dp[i][j], dp[i-1][i]);
                else
                    add_self(dp[i][j], (dp[i-1][i]-dp[i-1][j-1]+MOD)%MOD);
//                for(int k = j; k <= i; k++) add_self(dp[i][j], dp[i-1][k]);
            }
            else
            {
                if(j != 0) add_self(dp[i][j], dp[i-1][j-1]);
//                for(int k = 0; k < j; k++) add_self(dp[i][j], dp[i-1][k]);
            }
        }
    }
    ll ans = 0;
    for(int j = 0; j < n; j++) add_self(ans, dp[n-1][j]);
    cout << ans << endl;
}



Measured memory_bytes: 70272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

	char input[10];
	int acFlag = 1;

	scanf("%s", input);

	int str_length = (strlen(input) <= 10 ? strlen(input) : 10);

	//printf("%d", str_length);

	if (input[0] != 'A') acFlag = 0;

	int i, cnt = 0;
	for (i = 1; i < str_length; i++) {

		if (i>=2 && i<=str_length-2 && input[i] == 'C') {
			cnt++;
		}
		else {
			if (!(input[i] >= 'a' && input[i] <= 'z')) {
				acFlag = 0;
			}
		}

	}
	if (cnt != 1) acFlag = 0;

	if (acFlag == 1) {
		printf("AC");
	}
	else {
		printf("WA");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const int MOD = 1e9 + 7;
ll D[1<<15];
int n, m, E[20][20];
int P[500];

inline int f(int a){return a == n-1 ? a-1 : a; }

void solve() {
	cin >> n >> m;
	P[0] = 1;
	for(int i=1;i<500;i++) P[i] = (P[i-1] + P[i-1]) % MOD;
	rep(i, m){
		int x, y; cin >> x >> y;
		x = n - x, y = n - y;
		E[x][y] = 1;
	}
	D[0] = 1;
	for(int i=1;i<1<<(n-1);i++) {
		for(int j=i;j;j=(j-1)&i){
			ll C = 1;
			for(int b=0;b<n;b++) if(!(1<<f(b) & j)) {
				int cnt = 0;
				for(int a=0;a<n;a++) if(1<<f(a) & j) {
					cnt += E[b][a];
				}
				if(!(1<<f(b) & i)) C = C * (P[cnt] + MOD - 1) % MOD;
				else C = C * P[cnt] % MOD;
			}
			D[i] = (D[i] + D[i-j] * C) % MOD;
		}
	}
	ll ans = P[m] - D[(1<<(n-1))-1];
	if(ans < 0) ans += MOD;
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
};

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll a,b;cin>>a>>b;
    if(b%a==0) cout<<a+b<<endl;
    else cout<<b-a<<endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

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

		while(sc.hasNext())
		{
			int a =sc.nextInt();
			int b =sc.nextInt();
			int n=sc.nextInt();
			int sum=0;
			int di = a%b; 
			while(n-->0)
			{
				sum += (di*10)/b;
				di = (di*10)%b;
				if(di == 0)
					break;
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> num(10);
    for(int i = 0; i < n; i++) {
        int a = (int)(s[i] - '0');
        num[a].emplace_back(i);
    }
    for(int i = 0; i < 10; i++) {
        sort(ALL(num[i]));
    }
    int ans = 0;
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int k = 0; k < 10; k++) {
                if(num[i].empty() || num[j].empty() || num[k].empty()) {
                    continue;
                }
                int beg = num[i].front();
                int end = num[k].back();
                for(auto e : num[j]) {
                    if(beg < e && e < end) {
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set <int> s;//集合大法好！
    while(n--)
    {
        int x;
        cin>>x;
        if(s.find(x)!=s.end())
            s.erase(x);//有了，删除！
        else
            s.insert(x);//没有，添加！
    }
    cout<<s.size();//打印输出集合里元素的个数！
    return 0;
 } 

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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>

int main(){
    int n;cin>>n;
    string s;
    if(n==0)s="0";
    while(n!=0){
        int temp=n%-2>=0?n%-2:n%-2+2;
        cerr<<n<<"\t"<<temp<<endl;
        s+=to_string(temp);
        n-=temp;
        n/=-2;
    }
    reverse(ALL(s));
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {

  val sc = new java.util.Scanner(Console.in)

  val dict = collection.mutable.HashSet[String]()

  def next() = sc.next()
  def nextInt() = next().toInt

  def loop(n: Int): Unit = if (n != 0) {
    next() match {
      case "insert" => dict.add(next())
      case "find"   => println(if(dict.contains(next())) "yes" else "no")
    }
    loop(n - 1)
  }

  loop(nextInt())
}



Measured memory_bytes: 462660
ss = input()
t = input()

ls = len(ss)
lt = len(t)

before = []
after = []

for i in range(ls-lt+1):
    for j in range(lt):
        if ss[i+j]!="?":
            if ss[i+j]!=t[j]:
                break
    else:
        before += [ss[:i]+t+ss[i+lt:]]
  
for k in before:
    after += [k.replace("?","a")]

if after:
    after = sorted(after)
    print(after[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 9084
var
i,t,j:longint;
a:array[0..4] of longint;
begin
read(a[1],a[2],a[3]);
for i:=1 to 2 do
 for j:=i+1 to 3 do
  if a[i]>a[j] then
   begin
    t:=a[i]; a[i]:=a[j]; a[j]:=t;
   end;
  write(a[1]+a[2]);
 end.

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); <-- PUT IN main()/solve()!

using namespace std;

class AWeatherPrediction {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		string ans[3]={"Sunny", "Cloudy", "Rainy"};
		in >> s;
		f(i,0,3)
			if(s==ans[i])
				out << ans[(i+1)%3] << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	AWeatherPrediction solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool solve(string s){
  queue<int> qt;
  qt.push(0);
  while(!qt.empty()){
	int pos = qt.front();
	qt.pop();
	if(pos == s.size()) return true;
	//dream
	if(pos + 4 < s.size()){ //検索可
	  if(s.substr(pos,5) == "dream") qt.push(pos+5);
	}
	//dreamer
	if(pos + 6 < s.size()){
	  if(s.substr(pos,7) == "dreamer") qt.push(pos+7);
	}
	//erase
	if(pos + 4 < s.size()){
	  if(s.substr(pos,5) == "erase") qt.push(pos+5);
	}
	//eraser
	if(pos + 5 < s.size()){
	  if(s.substr(pos,6) == "eraser") qt.push(pos+6);
	}
  }
  return false;
}
int main(){
  string s;
  cin >> s;
  cout << (solve(s) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
N,Z,W = map(int, input().split())
A = [int(a) for a in input().split()]

if N > 1:
    last = A[-1]
    ans = max(abs(W-last), abs(A[-2]-last))
    i = N-2
    while i > 0:
        if A[i] == last:
            ans = max(ans, A[i-1]-last)
            i -= 1
        else:
            i = 0
else:
    ans = abs(W-A[0])
    
print(ans)

Measured memory_bytes: 3188
N, K, Q = map(int, input().split())

Anslist = [0 for i in range(N)]
for _ in range(Q):
    a = int(input())
    Anslist[a-1] += 1

for i in range(N):
    if Anslist[i] > Q - K:
        print("Yes")
    else:
        print("No")


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int pre = -999;
	rep(i,n){
		if(pre <= a[i] - 1){
			pre = a[i] - 1;
		}else if(pre <= a[i]){
			pre = a[i];
		}else{
			puts("No");
				return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
string s;
int loc1,loc2;
int main()
{
	cin>>s;
	loc1=s.find('C');
	loc2=s.rfind('F');
	if(loc1!=-1&&loc2!=-1&&loc1<loc2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   ll k;
   cin>>k;
   cout<<arr[k-1];
   
   return 0;        
}  
   

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[][] f = new int[n][10];
    int[][] p = new int[n][11];
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < 10; j++) {
        f[i][j] = sc.nextInt();
      }
    }
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < 11; j++) {
        p[i][j] = sc.nextInt();
      }
    }
    int ans = (-1) * Integer.MAX_VALUE;
    for(int i = 1; i < (int)Math.pow(2, 10); i++) {
      int[] kaiten = new int[n];
      for(int j = 0; j < 10; j++) {
        if((i & (1 << j)) != 0) {
          for(int k = 0; k < n; k++) {
            if(f[k][j] == 1) kaiten[k]++;
          }
        }
      }
      int sum = 0;
      for(int j = 0; j < n; j++) {
        sum += (p[j][kaiten[j]]);
      }
      ans = Math.max(ans, sum);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26072
import sys
from itertools import accumulate
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, K, *AB = map(int, read().split())
    A = AB[:N]
    B = AB[N:]

    time_A = [0]
    time_A.extend(accumulate(A))

    time_B = [0]
    time_B.extend(accumulate(B))

    ans = 0
    for i in range(N + 1):
        tmp = i
        ta = time_A[i]
        if ta <= K:
            tb = K - ta
            j = bisect_right(time_B, tb)
            tmp += j - 1

            if ans < tmp:
                ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 150164
function main()
	N=parse(Int,readline())
	D=map(x->parse(Int,x),split(readline()))
	cnt=zeros(Int,N)
	for d=D
		cnt[d+1]+=1
	end
	if D[1]!=0||cnt[1]!=1
		println(0)
	else
		ans=1
		mod=998244353
		for i=2:N
			ans=ans*powermod(cnt[i-1],cnt[i],mod)%mod
		end
		println(ans)
	end
end
main()


Measured memory_bytes: 150664
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mod 1000000007
int main()
{
    FASTIO
    //   L(T)

    lli n, k;
    cin >> n >> k;
    lli a = (k * (k - 1)) / 2 % mod;
    lli b = (k * (2 * n - k + 3)) / 2 % mod;
    lli s = 0;
    fe(i, k, n + 1)
    {
        a = (i * (i - 1)) / 2 % mod;
        b = (i * (2 * n - i + 1)) / 2 % mod;
        s += (b - a + 1);
        s = s % mod;
    }
    if (s < 0)
    {
        s += mod;
        cout << s << "\n";

    }
    else
        cout << s << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n;cin>>n;
    if(n==0) cout<<1<<endl;
    else if(n==1) cout<<2<<endl;
    else if(n==2) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 3164
def main():
    S = input()
    K = int(input())
    Sset = set()
    for i in range(len(S)):
        for j in range(1, K+1):
            Sset.add(S[i:i+j])
    Slist = list(Sset)
    Slist.sort()
    # print(Slist)
    print(Slist[K-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 10412
N = int(input())
s = [input() for i in range(N)]
for i in range(N):
    s_list = list(s[i])
    s_list.sort()
    s[i] = ''.join(s_list)

s.sort()
s.append('end')

result = 0
count = 1

for i in range(N):
    if s[i] == s[i + 1]:
        count += 1
    else:
        result += count * (count - 1) / 2
        count = 1

print(int(result))


Measured memory_bytes: 63960
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int count[4][3][10];
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                count[i][j][k]=0;
            }
        }
    }
    cin >> n;
    int b,f,r,v;
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        count[b-1][f-1][r-1]+=v;
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " " << count[i][j][k];
            }
            cout << endl;
        }
        if(i<3) cout << "####################" << endl;
    }
    //cout << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);

    long long sum = 0;

    for(int i=1;i<N;i++){
        if(A.at(i)<A.at(i-1)){
            sum += A.at(i-1) - A.at(i);
            A.at(i) = A.at(i-1);
        }
    }
    cout << sum << endl;
    return 0;
}


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


int main() {
	int x, y;

	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		else if (x <= y) cout << x << " " << y << endl;
		else if (x > y) cout << y << " " << x << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define DEBUG
// #define TIME
/*
Learn : -
Problem Type : -
Source : -
*/
#pragma GCC optimize ("Ofast")
#define sint(a) int a; qread(a);
#define sint2(a,b) int a,b; qread(a),qread(b);
#define sint3(a,b,c) int a,b,c; qread(a),qread(b),qread(c);
#define int1(a) qread(a);
#define int2(a,b) qread(a),qread(b);
#define int3(a,b,c) qread(a),qread(b),qread(c);
#define mkp make_pair
#define mkt make_tuple
#define pb emplace_back
#define inf INT_MAX
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sdouble(a) double a; scanf("%lf",&a);
#define slong(a) long long a; scanf("%lld",&a);
#define cstring(a,x) char a[x]; scanf("%s",a);
#define sstring(a) string a;cin>>a;
#define rev(s) reverse(all(s));
#define FOR(a,b,c) for(int a=b;a<c;a++)
#define ROF(a,b,c) for(int a=b;a>c;a--)
#define pause system("pause")
#define endl printf("\n")
#define fastio {ios::sync_with_stdio(false);cin.tie(NULL);}
#define null NULL
#ifdef DEBUG
#define debug(x) cout<< #x << " = " << x;endl;
#else
#define debug(x)
#endif
#define OPEN freopen("input.txt","r",stdin)
#define SEND freopen("output.txt","w",stdout)
#ifdef COM
#define IN(x)
#define OUT(x)
#else
#define IN(x) freopen(x,"r",stdin);
#define OUT(x) freopen(x,"w",stdout);
#endif
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
void qread(int &x){
	int neg=1;x=0;
	register char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}
void Wl(int x)
{
    printf("%d\n",x);
}
void Wl(double x)
{
    printf("%lf\n",x);
}
void Wl(string x)
{
    printf("%s\n",x.c_str());
}
void Wl(ll x)
{
    printf("%lld\n",x);
}
void W(int x)
{
    printf("%d ",x);
}
void W(double x)
{
    printf("%lf ",x);
}
void W(string x)
{
    printf("%s ",x.c_str());
}
void W(ll x)
{
    printf("%lld ",x);
}

multiset<int> Dist;
multiset<int>::iterator it;
int main()
{
	vi v;
    sint(n);
	for(int i=0;i<n;i++)
	{
		sint(x);
		v.pb(x);
		Dist.insert(x);
	}
	sort(all(v));




	if(v[n-1] == v[n-2])
	{
		int maxLength = v[n-1];
		int minLength;
		if(maxLength % 2)
		{
			minLength = maxLength/2 + 1;
			for(int i=minLength ; i<=maxLength ; i++)
			{
				FOR(j,0,2)
				{
					it = Dist.find(i);
					if(it==Dist.end())
					{
						Wl("Impossible");
						return 0;
					}
					Dist.erase(it);
				}
			}
			minLength +=1;
 		}
		else
		{
			minLength = maxLength/2;
			it = Dist.find(minLength);
			if(it==Dist.end())
			{
				Wl("Impossible");
				return 0;
			}
			Dist.erase(it);
			minLength+=1;
			for(int i=minLength ; i<=maxLength ; i++)
			{
				FOR(j,0,2)
				{
					it = Dist.find(i);
					if(it==Dist.end())
					{
						Wl("Impossible");
						return 0;
					}
					Dist.erase(it);
				}
			}
		}
		it = Dist.begin();
		while(it!=Dist.end())
		{
			if((*it)  > maxLength || (*it) < minLength)
			{
				Wl("Impossible");
				return 0;
			}
			it++;
		}
		Wl("Possible");
	}
	else
	{
		Wl("Impossible");
	}
}
/*

*/


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 2005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    string s;
    cin >> s;
    bool f = s[2] == s[3] && s[4] == s[5];
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int hoge(int x){
  int ans = 0;
  while(x){
    ans+=x%10;
    x/=10;
  }
  return ans;
}

signed main(){
  int n;
  int a, b;
  cin >> n >> a >> b;
  int ans = 0;
  iFOR(i,1,n+1){
    int x = hoge(i);
    if(x >= a && x <= b){
      ans+=i;
    }
  }
  cout << ans fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

ll a, b, c;

int main()
{
	fastio;		
	cin>>a>>b>>c;
	ll ans = 0;
	if ((a+b) >= c)
		ans = b+c;
	else
		ans = 2*b + a + 1;

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

campus = []

campus.append("."*(W+2))
for _ in range(H):
    s = list("."+input()+".")
    campus.append(s)
campus.append("."*(W+2))

# print(campus)

flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if campus[i][j] == "#":
            if campus[i-1][j] != "#" and campus[i+1][j] != "#" and campus[i][j-1] != "#" and campus[i][j+1] != "#":
                flag = False

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
N = gets.to_i
Ds = gets.split.map(&:to_i)
M = gets.to_i
Ts = gets.split.map(&:to_i)

qs = Hash.new
Ds.each do |x|
  qs[x] = 0 unless qs.has_key? x
  qs[x] += 1
end

flag = true
Ts.each do |x|
  if !qs.has_key?(x) || qs[x] <= 0
    flag = false
    break
  else
    qs[x] -= 1
  end
end
if flag
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 42012
#include <stdio.h>

int main(void)
{
 char S[100],T[100];
 int N,i;

 scanf("%d",&N);
 scanf("%s%s",S,T);

 for(i=0;i<N;i++){
  printf("%c%c",S[i],T[i]);
 }
  printf("\n");
  return 0;
 }


Measured memory_bytes: 128
#include "iostream"
#include "algorithm"
using namespace std;

int main()
{
	int n, *a,l;
	cin >> n;
	a = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n - 1] << ' ';
	for (int i = 0; true; i++) {
		if (a[n - 1] / 2 < a[i]) {
			l = i;
			break;
		}
	}
	if (l == n - 1)cout << a[l - 1] << endl;
	else if (a[n - 1] / 2 - a[l - 1] < a[l] - a[n - 1] / 2)cout << a[l-1] << endl;
	else cout << a[l] << endl;
	return 0;
}

Measured memory_bytes: 640
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n, k = getList()
MOD = 1000000007

def make_factorial(n, mod):
    fact = [1]
    tmp = 1
    for i in range(1, n+1):
        tmp *= i
        # tmp = tmp % mod
        fact.append(tmp)

    return fact


factorial = make_factorial(n, MOD)
def nck(fact, n, k):
    return fact[n] // (fact[k] * fact[n-k])


def solve(r, b, k, fact):
    if b > r + 1:
        print(0)
        return

    sukima = nck(fact, r+1, b)
    amari = k - b
    tyohuku = nck(fact, k-1, b-1)
    tyohuku = tyohuku % MOD

    # print(sukima, amari, tyohuku)
    print((sukima * tyohuku) % MOD)
    return


for trial in range(1, k+1):
    solve(n - k , trial, k, factorial)

Measured memory_bytes: 44144
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
    for j in range(B+1):
        for v in range(C+1):
            if 500*i + 100*j + 50*v == X:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll> s(N);
  REP(i,N)cin>>s[i];

  ll ans=0;
  FOR(C,1,N){
    ll sum=0ll;
    if((N-1)%C==0){
      for(int i=0;i*C<N-1-i*C;i++){
        sum+=s[N-1-i*C];
        sum+=s[i*C];
        ans=max(ans,sum);
      }
    }else{
      for(int i=0;i*C+C<N-1;i++){
        sum+=s[N-1-i*C];
        sum+=s[i*C];
        ans=max(ans,sum);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024