akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const int match[9] = {2,5,5,4,5,6,3,7,6};
int n, m, a;
string dp[10010];
bool exist[9];

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    fill(exist, exist+9, false);
    for (int i = 0; i < m; i++) {
        cin >> a;
        a--;
        exist[a] = true;
    }

    fill(dp, dp+10010, "");
    for (int i = 0; i < n; i++) {
        if (i && dp[i].size() == 0) continue;

        for (int j = 0; j < 10; j++) {
            if (!exist[j]) continue;

            int t = i + match[j];
            string s1 = dp[t];
            string s2 = dp[i] + to_string(j + 1);

            if (s1.size() <= s2.size()) {
                if (s1.size() < s2.size()) {
                    dp[t] = s2;
                } else {
                    int k = 0;
                    bool s2_is_big = false;
                    while (true) {
                        if (s1[k] > s2[k]) {
                            break;
                        } else if (s1[k] < s2[k]) {
                            s2_is_big = true;
                            break;
                        }
                        k++;
                    }

                    if (s2_is_big) {
                        dp[t] = s2;
                    }
                }
            }
        }
    }

    cout << dp[n] << "\n";
    return 0;
}

Measured memory_bytes: 29696
import sys
sys.setrecursionlimit(2*10**5)
N, M = map(int, input().split())
E = [[] for i in range(N + 1)]
for _ in range(M):
    l, r, d = map(int, input().split())
    E[l].append((r, d))
    E[r].append((l, -d))
INF = 10**10
dp = [INF for i in range(N + 1)]


def dfs(i):
    for r, d in E[i]:
        if dp[r] == INF:
            dp[r] = dp[i] + d
            if not dfs(r):
                return False
        elif dp[r] != dp[i] + d:
            return False
    return True


for i in range(1, N + 1):
    if dp[i] == INF:
        dp[i] = 0
        if not dfs(i):
            print('No')
            break
else:
    print('Yes')


Measured memory_bytes: 129004
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	string s; cin >> s;
	string res = "";
	for (int i = 0; i < 12; i++) {
		res += s[i];
		if (i == 3) res += " ";
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

//#define DEBUG


int main(void)
{
  int N,M;
  cin >> N >> M;
  if(N==M)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

stack<char> st;

ll cnt;
string S;
char tmp;

void solve(){
    st.push(S[0]);

    for(int i = 1; i < S.size(); ++i){
        if(!st.empty())
            tmp = st.top();
        else
            tmp = '0';

        if(tmp == 'S' && S[i]=='T'){
            cnt++;
            st.pop();
        } else
            st.push(S[i]);
    }

    cout << S.size() - 2*cnt << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 644
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=5e5+1;
 
#define ll int
// typedef long long ll;
typedef long double ld;

ll blocksize = 2000, n, m, ans = 0;
ll a[N];
ll cont[N];

void remove(ll ind)
{
	if(cont[a[ind]] == 1)
		ans--;
    cont[a[ind]]--;
}
void add(ll ind)
{
    cont[a[ind]]++;
    if(cont[a[ind]] == 1)
		ans++;
}
struct Query
{
    ll l, r, ind;
    bool operator<(Query other) const
    {
        return make_pair(l/blocksize, r)<make_pair(other.l/blocksize, other.r);
    }
};

vector<ll> mosalgo(vector<Query> queries)
{
    vector<ll> answer(queries.size());
    sort(all(queries));
    ll curl=0, curr=-1;
    for(Query q : queries)
    {
        while(curl>q.l)
        {
            curl--;
            add(curl);
        }
        while(curr<q.r)
        {
            curr++;
            add(curr);
        }
        while(curl<q.l)
        {
            remove(curl);
            curl++;
        }
        while(curr>q.r)
        {
            remove(curr);
            curr--;
        }
        answer[q.ind]=ans;
    }
    return answer;
}

void test_case()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<Query> v;
    for(int i = 0; i < m; i++)
    {
        ll x,y;
        cin >> x >> y;
        x--;y--;
        v.pu({x,y,i});
    }
    vector<ll> res = mosalgo(v);
    for(int i = 0; i < m; i++)
        cout<<res[i]<<'\n';

}

int main()
{
    IOS();
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define int long long
using namespace std;
char N;
signed main(){
  cin >> N;
  if(N=='A') cout << "T" << endl;
  else if(N=='T') cout << "A" << endl;
  else if(N=='G') cout << "C" << endl;
  else if(N=='C') cout << "G" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);

int N,M,Q,dis[MX],col[MX];
vi adj[MX];
vector<array<int,3>> todo;

void process(int v, int d, int c) {
    if (d <= dis[v]) return;
    dis[v] = d;
    if (col[v] == 0) col[v] = c;
    for (int i: adj[v]) process(i,d-1,c);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    FOR(i,1,N+1) dis[i] = -1;
    F0R(i,M) {
        int a,b; cin >> a >> b;
        adj[a].pb(b), adj[b].pb(a);
    }
    int Q; cin >> Q;
    F0R(i,Q) {
        int v,d,c; cin >> v >> d >> c;
        todo.pb({v,d,c});
    }
    reverse(all(todo));
    for (auto a: todo) process(a[0],a[1],a[2]);
    FOR(i,1,N+1) cout << col[i] << "\n";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 8816
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
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;}

int main() {
	ll n, a, b;;
	cin >> n >> a >> b;
    vector<ll> X(n);
    rep(i,n) cin >> X[i];
    ll ans = 0;
    rep(i,n-1) ans += min((X[i+1]-X[i])*a, b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;
int main(){
  
  char ch[1200];
    int i=0,m;
  
  while(1){
    scanf("%c",&ch[i]);
    if(ch[i]=='\n')break;
    i++;
  }

  for(m=0; m<i+1; m++){

    if(islower(ch[m]))printf("%c",toupper(ch[m]));
    else printf("%c",tolower(ch[m]));
  }

}

Measured memory_bytes: 1104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCoins solver = new BCoins();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCoins {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int x = Integer.parseInt(in.next());

            int aMax = Math.min(x / 500, a);
            int bMax = Math.min(x / 100, b);
            int cMax = Math.min(x / 50, c);

            int count = 0;
            for (int i = 0; i <= aMax; i++) {
                for (int j = 0; j <= bMax; j++) {
                    for (int k = 0; k <= cMax; k++) {
                        if (500 * i + 100 * j + 50 * k == x) {
                            count++;
                        }
                    }
                }
            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 21844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 2e5+5, OO = 0x3f3f3f3f;
//int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Directio
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class BBeautifulStrings {
public:
	void solve(std::istream& in, std::ostream& out) {
        string w; in >> w;
        map<char, int> mp;
        for (int i = 0; i < w.size(); ++i) {
            mp[w[i]]++;
        }
        bool f = 0;
        for (auto x: mp) {
            if (x.second&1) {
                f = 1;
                break;
            }
        }
        if (f) out << "No\n";
        else out << "Yes\n";
	}
};


int main() {
	BBeautifulStrings solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

struct FordFulkerson {
    typedef long long flow_type;
    struct edge {
        int src, dst;
        flow_type capacity, flow;
        size_t rev;
    };
    int n;
    vector<vector<edge>> adj;
    FordFulkerson(int n) : n(n), adj(n) { }
    void add_edge(int src, int dst, flow_type capacity) {
        adj[src].push_back({src, dst, capacity, 0, adj[dst].size()});
        adj[dst].push_back({dst, src, 0, 0, adj[src].size()-1});
    }
    flow_type max_flow(int s, int t) {
        vector<bool> visited(n);
        function<flow_type(int,flow_type)> augment = [&](int u, flow_type cur) {
            if (u == t) return cur;
            visited[u] = true;
            for (auto &e: adj[u]) {
                if (!visited[e.dst] && e.capacity > e.flow) {
                    flow_type f = augment(e.dst, min(e.capacity - e.flow, cur));
                    if (f > 0) {
                        e.flow += f;
                        adj[e.dst][e.rev].flow -= f;
                        return f;
                    }
                }
            }
            return flow_type(0);
        };
        for (int u = 0; u < n; ++u)
            for (auto &e: adj[u]) e.flow = 0;

        flow_type flow = 0;
        while (1) {
            fill(visited.begin(),visited.end(), false);
            flow_type f = augment(s, INF);
            if (f == 0) break;
            flow += f;
        }
        return flow;
    }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  vll a(N),b(N),c(N),d(N);
  for(ll i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
  for(ll i=0;i<N;i++){
    cin>>c[i]>>d[i];
  }
  FordFulkerson g(2+2*N);
  int src=2*N,dst=2*N+1;
  for(ll i=0;i<N;i++){
    g.add_edge(src,i,1);
    for(ll j=0;j<N;j++){
      if(a[i]<c[j]&&b[i]<d[j]){
        g.add_edge(i,j+N,1);
      }
    }
  }
  for(ll j=0;j<N;j++){
    g.add_edge(j+N,dst,1);
  }
  cout<<g.max_flow(src,dst)<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

int n;
Vi poly, cand;
mt19937_64 rnd;

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

bool check(ll p, ll x) {
	ll res = 0, mult = 1;
	x %= p;
	each(a, poly) {
		res = (res + a*mult) % p;
		mult = (mult*x) % p;
	}
	return res%p == 0;
}

constexpr int MAX_P = 1e4;
bitset<MAX_P+1> primes;

void sieve() {
	primes.set();
	primes.reset(0);
	primes.reset(1);
	for (int i = 2; i*i <= MAX_P; i++)
		if (primes[i])
			for (int j = i*i; j <= MAX_P; j += i)
				primes.reset(j);
	rep(i, 0, MAX_P+1) if (primes[i]) cand.pb(i);
}

void run() {
	cin >> n;
	poly.resize(n+1);
	rep(i, 0, n+1) cin >> poly[n-i];

	int tmp = 0;
	each(e, poly) tmp = gcd(tmp, abs(e));
	sieve();

	for (int k = 2; k*k <= tmp; k++) {
		if (tmp%k == 0) {
			cand.pb(k);
			while (tmp%k == 0) tmp /= k;
		}
	}
	if (tmp > 1) {
		cand.pb(tmp);
	}

	sort(all(cand));
	cand.erase(unique(all(cand)), cand.end());

	while (clock() < ll(1.8*CLOCKS_PER_SEC)) {
		ll x = rnd();
		for (int i = 0; i < sz(cand);) {
			if (check(cand[i], x)) {
				i++;
			} else {
				cand[i] = cand.back();
				cand.pop_back();
			}
		}
	}

	sort(all(cand));
	each(c, cand) cout << c << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int a, b, ans = 0;
	char op;

	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?') break; 
		if (op == '+') ans = a + b;
		else if (op == '-') ans = a - b;
		else if (op == '*') ans = a * b;
		else if (op == '/') ans = a / b;
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int dp[100105];
int INF = 1001001001;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n,0);
  rep(i,n) cin >> h.at(i);
  rep(i,k) h.emb(INF);

  rep(i,n) dp[i] = INF;
  dp[0] = 0;

  rep(i,n) {
    FOR(j,1,k+1) dp[i+j] = min(dp[i+j],dp[i]+abs(h.at(i)-h.at(i+j)));
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
w = input()
while "?" in w:
	p = w.rfind("?")
	try:
		if w[p+1] == "D":
			w = w.replace("?", "P", 1)
		else:
			w = w.replace("?", "D", 1)
	except IndexError:
		w = w.replace("?", "D", 1)
print(w)

Measured memory_bytes: 9288
Sa = list(input())
Sb = list(input())
Sc = list(input())
turn = Sa
ans ="A"
while turn != []:
  card =turn[0]
  turn.pop(0)
  if card =="a":
    turn =Sa
    ans ="A"
  elif card =="b":
    turn =Sb
    ans ="B"
  else:
    turn =Sc
    ans ="C"
print(ans)

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

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_c() {
	ll n, m;
	ll k;
	ll h, w;
	//ll x;
	//ll a;
	//string s;
	string s_ans;
	ll l_ans = 0;
	double d_ans = 0;

	cin >> n;

	ll red;
	rep1(a, n - 1) {
		l_ans += (n - 1) / a;
	}

	cout << l_ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
int Search(int *,int, int);

int main(){
 int S[100000],T[50000];
    int n,q,i,count=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)    scanf("%d",&S[i]);

    scanf("%d",&q);

    for(i=0;i<q;i++) {
        scanf("%d",&T[i]);
        if(Search(S,n,T[i])==1) count++;
    }

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

    return 0;
}

int Search(int *A,int n,int key){
    int left=0,middle=0,right=0;
    right=n;

    while(left<right){
        middle=(left+right)/2;
        if(A[middle]==key) return 1;
        if(A[middle]<key) left=middle+1;
        else if(A[middle]>key) right=middle;
    }
    return 0;
}


Measured memory_bytes: 2300
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	// gcd(a, d)=1
	int a, d, n;

	void run(){
		for(;;){
			a=sc.nextInt();
			d=sc.nextInt();
			n=sc.nextInt();
			if((a|d|n)==0){
				break;
			}
			solve();
		}
	}

	void solve(){
		for(int i=0;; i++){
			if(isPrime(a+d*i)&&--n==0){
				println(""+(a+d*i));
				return;
			}
			// debug(a, d, n, a+d*i);
		}
	}

	// {2,7,61,-1} is for n < 4759123141 (= 2^32)
	// {2,3,5,7,11,13,17,19,23,-1} is for n < 10^16 (at least)
	boolean isPrime(int n){
		if(n<=1||(n>2&&n%2==0))
			return false;
		int test[]={2, 3, 5, 7, 11, 13, 17, 19, 23, -1};
		int d=n-1, s=0;
		for(; d%2==0; d/=2)
			++s;
		for(int i=0; test[i]<n&&test[i]!=-1; i++)
			if(!suspect(test[i], s, d, n))
				return false;
		return true;
	}

	boolean suspect(int a, int s, int d, int n){
		long x=powMod(a, d, n);
		if(x==1)
			return true;
		for(int r=0; r<s; ++r){
			if(x==n-1)
				return true;
			x=x*x%n;
		}
		return false;
	}

	long powMod(long x, int k, int m){
		if(k==0)
			return 1;
		if(k%2==0)
			return powMod(x*x%m, k/2, m);
		else
			return x*powMod(x, k-1, m)%m;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

int main() {
 	int n;
	int s;
	int a[100000];
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> s;
		a[s] = i;
	}
	for(int i=1; i<=n; i++){
		cout << a[i];
		if(i!=n){
			cout << ' ';
		}
	}
  	cout << '\n';
  	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
double be(double a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod)); else return (be(a,b/2,mod)*be(a,b/2,mod));}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
int has[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}


signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{	
		string s;
		cin>>s;

		if(s == "ABC")
		{
			cout<<"ARC";
		}
		else
		{
			cout<<"ABC";
		}
	}
}

Measured memory_bytes: 3652
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    D, X = map(int, input().split())
    A = [int(input()) for _ in range(N)]

    c = 0
    for a in A:
        i = 0
        while (i * a) + 1 <= D:
            c += 1
            i += 1

    print(c + X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;
int main()
{
    int N;
    string S;
    cin >> N >> S;

    ll ans = 1;
    map<char, ll> mp;

    rep(i, N) mp[S[i]]++;

    rep(i, 26) {
        ans *= mp[i + 'a'] + 1;
        ans %= MOD;
    }

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

Measured memory_bytes: 3740
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int q, h, s, d, n;
    long long ans = 0;
    
    scanf("%d %d %d %d", &q, &h, &s, &d);
    scanf("%d", &n);
    
    s = min(s, min(q * 4, h * 2));
    d = min(d, s * 2);
    
    ans = (long long)n / 2 * d;
    if (n % 2 == 1) ans += s;
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Restaurant[] r = new Restaurant[n];
        for (int i = 0; i < n; i++) {
            r[i] = new Restaurant(sc.next(), Integer.parseInt(sc.next()), i + 1);
        }

        Arrays.sort(r, (o1, o2) -> {
            int s = o1.s.compareTo(o2.s);
            if (s == 0) {
                return o2.p - o1.p;
            }
            return s;
        });

        for (Restaurant res : r) {
            System.out.println(res.n);
        }
    }

    public static class Restaurant {
        String s;
        int p;
        int n;

        public Restaurant(String s, int p, int n) {
            this.s = s;
            this.p = p;
            this.n = n;
        }
    }
}


Measured memory_bytes: 26964
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <climits>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef pair<int, int> pii;

int main()
{
	double mi, ma, x;
	ma = -1; mi = 99999999999999999;
	while (cin >> x)
	{
		ma = max(ma, x);
		mi = min(mi, x);
	}
	printf("%lf\n", ma - mi);
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A, B;
  char op;
  cin >> A >> op >> B;
  if(op == '+') cout << A+B << endl;
  else cout << A - B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; ++i)

typedef long long ll;

int main(void) {
  ll i, j, k, n, s = 0;
  scanf("%d", &n);
  ll nt = n;
  for(i = 2; i <= sqrt(n); ) {
    if(!(n % i)) {
      n /= i;
      s = 1;
    } else {
     if(s) nt = nt / i * (i - 1);
     s = 0;
     ++i;
    }
  }
  if(s) {
    if(i == n) nt = nt / i * (i - 1);
    else nt = nt / i * (i - 1) / n * (n - 1);
  } else {
    nt = nt / n * (n - 1);
  }
  printf("%lld\n", nt);
  return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    int snuke[n + 5] = {};
    for (int i = 0, d; i < k; i++) {
        cin >> d;
        for (int j = 0, a; j < d; j++) {
            cin >> a;
            snuke[a]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (snuke[i] <= 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<cstdio>
#include<map>
#include<queue>

using namespace std;

int main(void){
	int n;
	int a;
	long long int dp[31];
	for(a=0;a<=30;a++){
		dp[a]=0;
	}
	dp[1]=1;
	dp[2]=2;
	dp[3]=4;
	for(a=4;a<=30;a++)dp[a]=dp[a-1]+dp[a-2]+dp[a-3];
	while(1){
		cin >> n;
		if(n==0)break;
		cout << (dp[n]+3649)/3650 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

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

  // 移動のステップ
  vector<int> ans(s.size(), 0);

  for (int i = 0; i < s.size() - 1; i++) {
    // L が出てくるまで進む
    int l = 0;
    while (s[i + l] != 'L') {
      l++;
    }
    if (l == 0) {
      continue;
    }

    for (int j = 0; j < l; j++) {
      if (abs(l - j) % 2 == 0) {
        ans[i + l]++;
      } else {
        ans[i + l - 1]++;
      }
    }
    i += l;
  }

  for (int i = s.size() - 1; i > 0; i--) {
    // R が出てくるまで進む
    int r = 0;
    while (s[i - r] != 'R') {
      r++;
    }
    if (r == 0) {
      continue;
    }

    for (int j = 0; j < r; j++) {
      if (abs(r - j) % 2 == 0) {
        ans[i - r]++;
      } else {
        ans[i - r + 1]++;
      }
    }
    i -= r;    
  }

  for (size_t i = 0; i < s.size(); i++) {
    cout << ans[i];
    if (i == s.size() - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll wa=INF;
    REP(i,5){
        ll a;
        cin >> a;
        wa = min(wa,a);
    }
    cout << (n + (wa - 1)) / wa + 4 << endl;;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<vector>
#define pb push_back
using namespace std;

int n,m,p;
map<string,vector<int> > d;
string der[20];
map<string,string> v;

vector<int> parse(string s){
  vector<char> op;
  vector< vector<int> > res;
 
  for(int i=0;i<m;i++){
    if(der[i] == v[s])return d[v[s]];
  }

  int pos = 0;
  string tmp;
  while(pos<(int)s.size()){
    if(s[pos] == '('){
      int k = 1;
      pos++;

      while(pos<(int)s.size()){
	if(s[pos] == '(')k++;
	if(s[pos] == ')')k--;
	if(!k)break;
	tmp += s[pos];
	pos++;
      }
      res.pb( parse(tmp) );
      tmp.clear();
      pos++;
    }else if(s[pos] == '+' || s[pos] == '-' || 
	     s[pos] == '*' || s[pos] == '/'){
      if(tmp.size()){
	res.pb( parse(tmp) );
	tmp.clear();
      }
      op.pb( s[pos++] );
    }else tmp += s[pos++];
  }
  if(tmp.size())res.pb(parse(tmp));

  for(int i=0;i<(int)res.size();i++){
    if(res[i].empty())return res[i];
  }

  bool f = true;
  while(f){
    f = false;
    for(int i=0;i<(int)op.size();i++){
      vector<int> hoge;
      if(op[i] == '*'){
	for(int j=0;j<p;j++){
	  hoge.pb(res[i][j]+res[i+1][j]);
	}
      }else if(op[i] == '/'){
	for(int j=0;j<p;j++){
	  hoge.pb(res[i][j]-res[i+1][j]);
	}
      }
      if(hoge.size()){
	res.erase(res.begin()+i);
	res.erase(res.begin()+i);
	res.insert(res.begin()+i,hoge);
	op.erase(op.begin()+i);
	f = true;
	break;
      }
    }
  }

  while(res.size()>1){
    for(int i=0;i<n;i++){
      if(res[0][i] != res[1][i]){
	res[0].clear();
	return res[0];
      }
    }
    res.erase(res.begin());
  }
  return res[0];
}

int main(){
  while(cin >> n >> m >> p && (n||m||p)){
    for(int i=0;i<m;i++){
      cin >> der[i];
      vector<int> hoge;
      for(int j=0;j<n;j++){
	int a;
	cin >> a;
	hoge.pb(a);
      }
      d[der[i]] = hoge;
    }
    string str;
    cin >> str;
    for(int i=0;i<p;i++){
      string t1,t2;
      cin >> t1 >> t2;
      v[t1] = t2;
    }      
    vector<int> ans = parse(str);
    if(ans.empty())cout << "error\n";
    else{
      int i,j;
      for(i=m-1;i>=0;i--){
	bool f = true;
	for(j=0;j<n;j++){
	  if(d[der[i]][j] != ans[j])break;
	}
	if(j==n){
	  cout << der[i] << endl;
	  break;
	}
      }
      if(i<0)cout << "undefined\n";
    }
  }

}

Measured memory_bytes: 1808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if (s.endsWith("s")) {
			System.out.println(s + "es");
		} else {
			System.out.println(s + "s");
		}

	}

}

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){
    
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++){
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <climits>
#include <cstdio>
#include <vector>
#include <bitset>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define PI 3.14159265
#define base 27
#define  fi first
#define  se second

#define TASK "Non decreasing"

using namespace std;
typedef long long lli;
typedef long double lb;
typedef unsigned long long ull;
typedef pair<int,int> pa;
const long long mod =1e9+7;
const long long oo=1e15+7;
const int maxn=1e6+1;
const int maxN=1e3+1;

/******************************************************************************
 *                                                                            *
 *                       Be a warrior not a worrier!! =)))                    *
 *                                                                            *
 *                                                                            *
 *****************************************************************************/
int n;
lli a[maxn];
lli b[maxn];
lli am=oo,duong=-oo;
int id1=0,id2=0;
int dem=0;
pa ans[maxn];
void in()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}
void toanam()
{
    for(int i=n-1; i>=1; i--)
    {
        a[i]+=a[i+1];
        ans[++dem]= {i+1,i};
    }
}
void toanduong()
{
    for(int i=2; i<=n; i++)
    {
        ans[++dem]= {i-1,i};
        a[i]+=a[i-1];
    }
}
void solve()
{
    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
        if(a[i]<0)
        {
            if(am>a[i])
            {
                am=a[i];
                id1=i;
            }
        }
        if(a[i]>0)
        {
            if(duong<a[i])
            {
                duong=a[i];
                id2=i;
            }
        }
    }
    if(id1==0)
    {
        toanduong();

    }
    else if(id2==0)
    {
        toanam();
    }
    else
    {
        if(abs(am)<abs(duong))
        {
            for(int i=1; i<=n; i++)
            {
                if(a[i]<0)
                {
                    ans[++dem]= {id2,i};
                    a[i]+=a[id2];
                }
            }
            toanduong();
        }
        else
        {
            for(int i=1; i<=n; i++)
            {
                if(a[i]>0)
                {
                    ans[++dem]= {id1,i};
                    a[i]+=a[id1];
                }
            }
            toanam();

        }
    }
    cout<<dem<<"\n";
    for(int i=1; i<=dem; i++)
    {
        cout<<ans[i].fi<<" "<<ans[i].se<<"\n";
    }

}

int main()
{
    //in();
    solve();

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vv<int> graph(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> dist(N, INF), to(N, -1);
    dist[0] = 0;
    using P = pair<int, int>;
    queue<P> q;
    q.emplace(0, 0);
    while (!q.empty()) {
        auto u = q.front();
        q.pop();
        for (int v : graph[u.second]) {
            if (dist[u.second] + 1 < dist[v]) {
                dist[v] = dist[u.second] + 1;
                to[v] = u.second;
                q.emplace(0, v);
            }
        }
    }

    write("Yes");
    rep(i, 1, N) {
        write(to[i] + 1);
    }
}

Measured memory_bytes: 10852
#include<bits/stdc++.h>
using namespace std;
string s[105];
bool cmp(string x,string y)
{
	return x+y<y+x;
}
int main()
{
	int n,l,i;
	cin>>n>>l;
	for(i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n,cmp);
	for(i=0;i<n;i++)
		cout<<s[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;
int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	int ans=min(a+b,b+c);
	ans=min(a+c,ans);
	cout<<ans<<"\n";
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  int64_t count=0;
  for(int i=1;i<N+1;i++){
    if(i%3!=0&&i%5!=0) count+=i;
  }
  cout<<count<<endl;
}
    


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

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;

  int count = 0;

  for (; A < B + 1; A++)
  {
    if (A % 10 == A / 10000 && A % 100 / 10 == A / 1000 % 10)
    {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
n,c = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
now = 0
s = []
t = []
for i in range(n):
    now += a[i][1]
    s.append(now)
    #if (now-a[i][0] > ans):
        #ans = now-a[i][0]
#print(ans)
now = 0
for i in range(n):
    now += a[n-1-i][1]
    t.append(now)
    #if (now-(c-a[n-1-i][0]) > ans):
        #ans = now-(c-a[n-1-i][0])
#print(ans)
back = 0
ans = max(ans, s[-1]-a[-1][0])
for i in range(n-2,-1,-1):            
    back = max(back, t[n-2-i]-2*(c-a[i+1][0]))
    ans = max(ans,s[i]-a[i][0]+back)
    
back = 0
ans = max(ans, t[-1]-(c-a[0][0]))
for i in range(n-2,-1,-1):
    back = max(back, s[n-2-i]-2*a[n-2-i][0])
    ans = max(ans, t[i]-(c-a[n-i-1][0])+back)
print(ans)

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

int main(){
    
    int a,b,c,x;
    int ans = 0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);    
    scanf("%d", &x);

    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c;k++){
                if(500 * i + 100 * j + 50 * k == x){
                    ans++;
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	ll N;
	cin >> N;

	vll draw = { 1 };

	for(ll i = 1;i<20;i++)
	{
		if (pow(6, i) <= N)
		{
			draw.emplace_back(ll(pow(6, i)));
		}
		if (pow(9, i) <= N)
		{
			draw.emplace_back(ll(pow(9, i)));
		}
	}


	vvll dp(draw.size()); // i個目までを使ってj円引き出すのに必要な回数の最小値
	for (int i = 0; i < draw.size(); i++)
	{
		for (int j = 0; j <= N; j++)
		{
			dp[i].emplace_back(LLINF);
		}
		dp[i][0] = 0;
	}

	for (int j = 0; j <= N; j++)
	{
		dp[0][j] = j;
	}


	// 個数制限なしDP
	for (int i = 1; i < draw.size(); i++)
	{
		for (int j = 0; j <= N; j++)
		{
			if (j - draw[i] >= 0)
			{
				dp[i][j] = min(dp[i - 1][j], min(dp[i][j], dp[i][j - draw[i]] + 1));
			}
			else
			{
				dp[i][j] = min(dp[i - 1][j], dp[i][j]);
			}

		}
	}

	cout << dp[draw.size()-1][N] << endl;






}





Measured memory_bytes: 10484
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int N;
std::vector<int> v(1000000,LINF);
int dp[201][100005];
int f(int i,int x){
  if(dp[i][x]!=-1)return dp[i][x];
  if(i==0)return dp[i][x]=x%v[0];
  int res=0;
  res+=f(i-1,x%v[i]);
  res+=f(i-1,x)*i;
  res%=MOD;
  return dp[i][x]=res;
}

//main
signed main(){
  int X;cin>>N>>X;
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  cout<<f(N-1,X)<<endl;
}


Measured memory_bytes: 165120
Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let judge a b c =
        let mx = max a (max b c) in
        let mi = min a (min b c) in
        print_endline @@ if mx - mi <= 1 then "YES" else "NO"
    in

    let rec loop i a b c =
        if i = n then judge a b c else
            match s.[i] with
            | 'a' -> loop (i + 1) (a + 1) b c
            | 'b' -> loop (i + 1) a (b + 1) c
            | 'c' -> loop (i + 1) a b (c + 1)
            | _ -> failwith "??"
    in
    loop 0 0 0 0
)

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define loop(i,k,n) for(int i=k;i<n;i++)
#define rloop(i,k,n) for(int i=k;i>=n;i--)
#define tests int l; cin>>l; while(l--)
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define lli long long int
#define ld long double
#define pb push_back
using namespace std;
int main()
{
  lli n,count=0,ans=1;
  cin>>n;
  lli a[n];
  bool flag=0;
  //int freq[1000000001]={0};
  loop(i,0,n)
  {
    cin>>a[i];
    //freq[a[i]]++;
  }
  sort(a,a+n);
  rloop(i,n-1,1)
  {
    if(a[i]==a[i-1])
    {
      //freq[a[i]]-=2;
      count++;
      ans*=a[i];
      i--;
    }
    if(count==2)
    break;
  }
  if(count==2)
  cout<<ans;
  else
  cout<<0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = 0;
		String answer = "No";

		// 数字の入力
		num = scan.nextInt();

		// 1~9の2つの整数の積で表すことができるか調査
		for (int i = 1; i <= 9; i++) {
			if (num > i * 9) {
				continue;
			}
			if (num % i == 0) {
				answer = "Yes";
				break;
			}
		}

		// 結果の出力
		System.out.println(answer);

	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef long double ldbl;

char abcd[4];
const char op[2] = {'+', '-'};

int main() {
  scanf("%s", abcd);
  int a = abcd[0] - '0';
  int b = abcd[1] - '0';
  int c = abcd[2] - '0';
  int d = abcd[3] - '0';

  int s1 = a;
  for (int i = 0; i < 2; i++) {
    int s2 = (i == 0) ? s1 + b : s1 - b;
    for (int j = 0; j < 2; j++) {
      int s3 = (j == 0) ? s2 + c : s2 - c;
      for (int k = 0; k < 2; k++) {
        int s4 = (k == 0) ? s3 + d : s3 - d;
        if (s4 == 7) {
          printf("%d%c%d%c%d%c%d=7", a, op[i], b, op[j], c, op[k], d);
          return 0;
        }
      }
    }
  }
  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;


int main(){
    int N,D1,D2,cnt=0;
    bool flg = false;
    cin >> N;

    rep(i,N){
        cin >> D1 >> D2;
        if(D1 == D2){
            cnt++;
            if(cnt >= 3) flg = true;
        }else{
            cnt = 0;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(){
    char b;
    
  scanf("%s",&b);
    if(b=='A')
    printf("T");
    if(b=='T')
    printf("A");
    if(b=='C')
    printf("G");
    if(b=='G')
    printf("C");
    
    return 0;
}

Measured memory_bytes: 128
#import sys
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
pre = -1
man = 0
for i in A:
    man += B[i - 1]
    if pre == i - 1 :
        man += C[pre - 1]
    pre = i
print(man)


Measured memory_bytes: 3060