akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
static long[] f;
static long mod=(long)1e9+7;
//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
				assign();
				int t=1;//int_v(read()),cn=1;
				while(t--!=0){
					int n=int_v(read());
					if(n>=30){out.write("Yes");}
					else out.write("No");
					
				}
			    
			    out.flush();

	}
}

	       

	       


Measured memory_bytes: 32680
#include<stdio.h>
int main()
{
    int i,n;
    scanf("%d",&n);
    int a[n+5],max=0,cnt=0;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(i=1;i<n;i++)
    {
        if(a[i]>=a[i+1]){
            cnt++;
            if(max<cnt)
            max=cnt;
        }
        else
        {

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,k,a[5050],s[5050],ans=0,l=1;
  cin>>n>>k;
  fr(i,n) cin>>a[i];
  sort(a,a+n);
  Fr(i,n) s[i]=s[i-1]+a[i-1];
  bool dp[5050][5050]={};
  dp[n][0]=1;
  ifr(i,n){
    fr(j,k){
      if(j-a[i]<0) dp[i][j]=dp[i+1][j];
      else dp[i][j]=dp[i+1][j]||dp[i+1][j-a[i]];
    }
  }
  fr(i,n){
    if(a[i]>=k) continue;
    if(a[i]==a[i+1]){
      l++;
      continue;
    }
    if(s[i+1]>=k){
      l=1;
      continue;
    }
    bool f=1;
    for(int j=max(0ll,k-s[i+1]);j<k;j++){
      f=f&&(!dp[i+1][j]);
    }
    ans+=f*l;
    //if(f) cout<<i<<" "<<f*l<<endl;
    l=1;
  }/*
  fr(i,n){
    fr(j,k) cout<<dp[i][j]<<" ";
    cout<<endl;
  }*/
  cout<<ans<<endl;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    ll n,c,k;cin>>n>>c>>k;
    vector<ll> t(n);
    rep(i,n) cin>>t[i];
    sort(t.begin(),t.end());
    ll lim=0;
    ll count=0;
    ll fst=t[0];
    t.push_back(100000000000);
    for(ll i=0;i<n;i++){
        lim++;
        if(lim==c || t[i+1]-fst>k){
            lim=0;
            fst=t[i+1];
            count++;
        }
    }
    if(lim!=0) count++;
    cout<<count<<endl;
}

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

# dp[i] := i円引き出すのに必要な最小操作回数
dp = [float('inf')] * (N + 1)
dp[0] = 0
operates = sorted([1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049])
for i in range(N):
    for ope in operates:
        if i + ope > N:
            break
        dp[i + ope] = min(dp[i + ope], dp[i] + 1)

print(dp[N])


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

int main() {
  int N;
  cin >> N;
  
  vector<int> cards(N);
  
  for (int i = 0; i < N; i++) {
    cin >> cards.at(i);
  }
  
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int alice = 0;
  int bob = 0;
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += cards.at(i);
    } else {
      bob += cards.at(i);
    }
  }
  
  cout << alice - bob << endl;
  
  return 0;
}

Measured memory_bytes: 256
import bisect

N = input()
N = int(N)
S = [-int(input()) for _ in range(N)]
result = []

for i in range(N):
    hoge = bisect.bisect(result,S[i])
    if hoge == len(result):
        result.append(S[i])
    else:
        result[hoge] = S[i]
print(len(result))

Measured memory_bytes: 7840
import collections

# def combinations_count(n, r):
#     return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A_list = list(map(int, input().split()))

counts = collections.Counter(A_list)
ans = 0
for _, v in counts.items():
    ans += v * (v - 1) / 2

for k in range(1, N + 1):
    n = counts[A_list[k - 1]]
    ans_k = ans
    if n > 1:
        ans_k -= n - 1

    print(int(ans_k))

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}


const int maxn=1e5+10;

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n;
    cin>>n;
    ll sum=0;
    ll cnt[maxn]={0};
    ll a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	cnt[a[i]]++;
    	sum+=a[i];
    }

    int q;
    cin>>q;
    while(q--)
    {
 		ll b,c;
 		cin>>b>>c;
 		if(cnt[b])
 		{
 			cnt[c]+=cnt[b];
 			sum+=cnt[b]*(c-b);
 			cnt[b]=0;
 		}

 		cout<<sum<<endl;  
    }

    
    return 0;
}

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

ll i,j;

int main(){
    int a,b;cin>>a>>b;  
    
    for(int money=1;money<=1250;money++){
        if(money*8/100==a && money*10/100==b){
            cout<<money<<endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long

using namespace std;


int solve(int n, int m, int cntr)
{
	if (n == m)
		return cntr;
	if (n > m)
	{
		return cntr;
	}

	return (solve(n * 3, m, ++cntr));
	return (solve(n * 2, m, ++cntr));
}
int main()
{
	assem99;

	ll sum = 0;
	int n, k, arr[200005];
	int cntr = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	if (n <= k)
		cout << '0';
	else
	{
		sort(arr, arr + n);
		for (int i = 0; i < n; i++)
		{
			if (cntr == n - k)
				break;
			sum += arr[i];
			cntr++;
		}

		cout << sum;
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define ll long long int
int main(){
    ll n;
    cin >> n;
    map<ll, ll> mp;
    vector<ll> v;
    mp.clear();
    for(ll i = 0; i < n; ++i){
        ll num;
        cin >> num;
        mp[num]++;
        v.push_back(num);
    }
    map<ll, ll>::iterator it = mp.begin();
    ll all_pair = 0;
    while(it != mp.end()){
        all_pair += it->second * (it->second - 1) / 2;
        it++;
    }
    for(ll i = 0; i < n; ++i){
        ll num = v[i];
        ll cur_ans = all_pair;
        ll cnt = mp[num];
        cur_ans -= (cnt - 1);
        cout << cur_ans << endl;
    }
}

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

#define fir first
#define sec second
using namespace std;
typedef long long LL;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
int inp() {
	int x = 0, f = 1;char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = -1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}
const int MaxN = 201234;
int n, m, a[MaxN], b[MaxN], c[MaxN], d[MaxN];
int main() {
	int i;
	n = inp(); m = inp();
	for(i = 1; i <= m; i++){
		a[i] = inp(), b[i] = inp();
		if(a[i] == 1) c[b[i]] = 1;
		if(b[i] == n) d[a[i]] = 1;
	}
	for(i = 2; i < n; i++)
		if(c[i] && d[i])
			return puts("POSSIBLE"), 0;
	puts("IMPOSSIBLE");
	return 0;
}




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

int main() {
  long N, M = 0;
  cin >> N;
  for (int i = sqrt(N); i >= 1; i--) M = (!(N % i) && !M) ? i : M;
  cout << int(max(log10(M), log10(N / M)) + 1) << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int n;
  while(cin >> n){
    vector<int> a(n); cin >> a;


    bool no = false;
    
    vector<int> b;

    vector<int> c(n+1);

    REV(i,n,1){
      int t = 0;
      for(int j=i; j<=n; j+=i){
        t += c[j];
      }

      //cerr << t << endl;

      if(t%2 != a[i-1]){
        c[i] = 1;
      }
    }

    

    FORE(i,1,n) if(c[i]%2==1) b.push_back(i);
    

    if(no){
      cout << -1 << endl;
    }else{
      cout << b.size() << endl;
      join(cout, ALL(b));
    }
  }
  
  return 0;
}


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

namespace Frog_2
{
    class Program
    {
        private int N;
        private int K;
        private int[] h;
        private int[] costs;

        static void Main(string[] args)
        {
            Program pr = new Program();
            pr.getInput();
            pr.jumpFrog();
            Console.WriteLine(pr.costs[pr.N-1]);
            Console.ReadLine();
        }

        private void getInput()
        {
            String line1 = Console.ReadLine();
            String[] partsLine1 = line1.Split(new Char[] { ' ' });
            N = int.Parse(partsLine1[0]);
            K = int.Parse(partsLine1[1]);
            String line2 = Console.ReadLine();
            String[] partsLine2 = line2.Split(new Char[] { ' ' });
            h = new int[N];
            costs = new int[N];
            int cnt = 0;
            foreach (String part in partsLine2)
            {
                h[cnt++] = int.Parse(part);
            }
        }

        private void jumpFrog()
        {
            costs[0] = 0;
            for(int i = 1; i < N; i++)
            {
                costs[i] = int.MaxValue;
            }
            for (int i = 0; i < N - 1; i++)
            {
                try
                {
                    for (int j = 1; j <= K; j++)
                    {
                        int jumpCost = Math.Abs(h[i] - h[i + j]) + costs[i];
                        costs[i + j] = Math.Min(costs[i + j], jumpCost);
                    }
                }
                catch (IndexOutOfRangeException e) { }
            }
        }

    }
}


Measured memory_bytes: 16736
#include <bits/stdc++.h>
#define isFile 0
#define NAME "taskA"
#define scan 1
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define bit(n, i) (n >> i) & 1
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void faster() {
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 27;
const int N = (int)1e2 + 5;
const int M = 123;

int n, w;
ll W[N], V[N];
ll dp[111111];
// dp[i] - the total minimum weight with value i

void solve() {
    cin >> n >> w;
    ll sum_values = 0;
    for(int i = 0; i < n; i++) {
        cin >> W[i] >> V[i];
        sum_values += V[i];
    }

    for(int i = 0; i <= sum_values; i++)
        dp[i] = INF;

    dp[0] = 0;

    for(int i = 0; i < n; i++) {
        for(int j = sum_values - V[i]; j >= 0; j--) {
            if (dp[j] != INF)
                dp[j + V[i]] = min(dp[j + V[i]], dp[j] + W[i]);
        }
    }

    ll ans = -1;
    for(int i = sum_values; i >= 0; i--) {
        if (dp[i] <= w)
            ans = max(ans, (ll) i);
    }

    cout << ans << endl;
}

int main() {
    faster();
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578
#define INF 1000000000000

using namespace std;

int MD(pair<int,int> a,pair<int,int> b){//ManhattanDisRance
    return abs(a.first-b.first) + abs(a.second-b.second);
}
int MOD(int a,int b){
    return abs(a%b);
}

signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    incin(n);
    vector<pair<int,pair<int,int> > > p(n+1);
    p.at(0)=make_pair(0,make_pair(0,0));
    for(int i=1;i<=n;i++){
        cin >> p.at(i).first >> p.at(i).second.first >> p.at(i).second.second;
    }
    sort(all(p));

    int flag = 0;
    for(int i=1;i<=n;i++){
        int time = p[i].first-p[i-1].first;
        int dis  = MD(p[i].second,p[i-1].second);
        if(time < dis){
            flag=1;
            break;
        }else{
            if((time-dis)%2==0){
                continue;
            }else{
                flag=1;
                break;
            }
        }
    }
    if(flag==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N;
    vector<unsigned long> a;
    unsigned long result, result_pre = 1;
    const unsigned long MAX = 1000000000000000000;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        unsigned long tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(), a.end(), greater<unsigned long>());

    if (a.back() == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    for (const auto &a_n : a)
    {
        if (result_pre < ULONG_MAX / a_n) // not overflow
        {
            result = result_pre * a_n;
            result_pre = result;

            if (result > MAX)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        else // overflow
        {
            cout << -1 << endl;
            return 0;
        }

        //cout<<result<<endl;
    }

    cout << result << endl;

    /*if (result > MAX)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << result << endl;
    }*/
}

Measured memory_bytes: 4232
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string FirstString;

    cin >> FirstString;

    int PanjangString = FirstString.length();

    for(int a = PanjangString-1; a >= 0; a--)
    {
        cout << FirstString[a];
    }
    cout << endl;

}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
char s[maxn];
int i,j,n;ll ans;
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	fo(i,1,n)if (s[i]=='B') j++;else ans+=j;
	printf("%lld\n",ans);
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;

	map<string,vector<lli>> m;

	set<string> ss;
	vector<string> v;
	vector<lli> w;

	for(lli i=0;i<n;i++){
		string s;
		lli tmp;
		cin>>s>>tmp;
		m[s].push_back(tmp);
		v.push_back(s);
		w.push_back(tmp);
		ss.insert(s);
	}
	for(auto e:ss){
		sort(m[e].begin(),m[e].end(),greater<lli>());
	}

	lli flag=0;
	vector<lli> ans(n);
	for(lli i=0;i<n;i++){
		lli cnt=0;
		flag=0;
		for(auto e:m){
			for(lli j=0;j<e.second.size();j++){
				cnt++;
				if(e.first == v[i] && e.second.at(j) == w[i]){
					//cout<<cnt<<endl;
					flag=1;
					ans[cnt-1]=i+1;
					break;
				}
			}
			if(flag==1)break;
		}
	}
	REP(i,0,n){
		cout<<ans[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const string s="snuke",ch="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string c;
int n,m;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){ 
    	for(int j=0;j<m;j++){
        	cin>>c;
        	if(c==s){
				cout<<ch[j]<<i<<endl;
				return 0;
			}
    	}
    }
    return 0;
}

Measured memory_bytes: 256
R=range
def F(a,b):A=len(a);return[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)]+[1]
def Z(X):
 i,j,k=X;A,B,C=map(len,[S[t]for t in X]);q=1e5
 for l in R(A+1):
  if M[i][j][l]:
   for r in R(l,A+B+1):
    if(B<r-l or M[j][k][r-l])*M[i][k][min(A,r)]:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in R(3)]
M=[[F(i,j)for j in S]for i in S]
from itertools import *;print(min([Z(i)for i in permutations(R(3))]))

Measured memory_bytes: 54236
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  while (in.hasNext())
	System.out.println(f(in.nextInt()));
}

static long f(long v) {
  return (v == 1) ? 1 : f(v - 1) * v;
}
}

Measured memory_bytes: 0
fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let a: Vec<usize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };
    let b: Vec<usize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let mut c = vec![0; n + 1];
    let mut d = vec![0; n + 1];
    for i in 0..n {
        c[a[i]] += 1;
        d[b[i]] += 1;
    }

    for i in 1..=n {
        if c[i] + d[i] > n as i32 {
            return println!("No");
        }
        c[i] += c[i - 1];
        d[i] += d[i - 1];
    }
    println!("Yes");
    let x = (1..=n).map(|i| c[i] - d[i - 1]).max().unwrap() as usize;
    println!(
        "{}",
        (0..n).map(|i| b[(i + n - x) % n].to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 18960
n = int(input())
h = list(map(int, input().split()))
count = 0
c = [0]
p = h[0]
for i in range(1, n):
  if p >= h[i]:
    count += 1
    p = h[i]
  else:
    c.append(count)
    count = 0
    p = h[i]
c.append(count)
print(max(c))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

vector<int> gr[2000];
//葉方向に最も遠い点との距離
int dfs(int s, int p, int d){
  int res=d;
  rep(i,gr[s].size()){
    if(gr[s][i]!=p){
      res=max(res,dfs(gr[s][i],s,d+1));
    }
  }
  return res;
}

int main(){
  int n,k;
  cin >> n >> k;
  int a,b;
  int u[n-1],v[n-1];
  rep(i,n-1){
    cin >> a >> b;
    a--;b--;
    gr[a].pb(b);
    gr[b].pb(a);
    u[i]=a;v[i]=b;
  }
  int lm=0;
  /*  rep(i,n){    
    lm=max(dfs(i,-1,0),lm);
    }*/
  //  cout << lm << endl;
  int ans=INT_MAX;
  if(k%2==0){
    rep(i,n){
      queue<pair<pair<int, int >, int> > q;
      int c=0;
      q.push(mp(mp(-1,i),0));
      while(!q.empty()){
	int par=q.front().first.first;
	int cur=q.front().first.second;
	int d=q.front().second;

	q.pop();
	if(d>k/2) continue;
	//	cout << "cur " << cur << " dist " << d << endl;		
	c++;
	rep(j,gr[cur].size()){
	  if(gr[cur][j]!=par){
	    q.push(mp(mp(cur,gr[cur][j]),d+1));
	  }
	}
      }
      //      cout << i << " " << c << endl;
      ans = min(ans,n-c);      
    }
  }
  else{
    rep(i,n-1){
      queue<pair<pair<int, int >, int> > q;
      int c=0;
      q.push(mp(mp(u[i],v[i]),0));
      q.push(mp(mp(v[i],u[i]),0));
      //    cout << pt_can[i] << " " << endl;
      while(!q.empty()){
	int par=q.front().first.first;
	int cur=q.front().first.second;
	int d=q.front().second;
	q.pop();
	if(d>(k-1)/2) continue;
	c++;
	//      cout << "dep " << d << " pt " << cur << endl;
	rep(j,gr[cur].size()){
	  if(gr[cur][j]!=par){
	    q.push(mp(mp(cur,gr[cur][j]),d+1));
	  }
	}
      }
      //    cout << pt_can[i] << " " << c << endl;
      ans = min(ans,n-c);
    }    
  }
  
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
using namespace std;

int main()
{
  const int INF = 1 << 30;

  int n, m;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    scanf("%d", &m);
    vector<vector<int> > edge(n, vector<int>(n, INF));
    for (int i = 0; i < m; ++i) {
      int a, b, d;
      scanf("%d,%d,%d", &a, &b, &d);
      d /= 100;
      edge[a][b] = edge[b][a] = d;
    }

    int ans = 0;
    vector<int> visited(n, 0);
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    que.push(pair<int, int>(1, 0));
    while (!que.empty()) {
      const pair<int, int> p = que.top();
      que.pop();

      if (visited[p.second])
	continue;

      visited[p.second] = 1;
      ans += p.first - 1;
      for (int i = 0; i < n; ++i) {
	if (visited[i] || edge[p.second][i] == INF)
	  continue;
	que.push(pair<int, int>(edge[p.second][i], i));
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

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

    int N;
    cin >> N;
    vector<long long> x(N), y(N), h(N);
    int t;
    REP(i, N){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0){
            t = i;
        }
    }

    REP(cx, 101){
        REP(cy, 101){
            long long H = h[t] + abs(x[t] - cx) + abs(y[t] - cy);
            bool f = (H >= 1);
            REP(i, N){
                long long tmp;
                tmp = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL);
                if(h[i] != tmp){
                    f = false;
                    break;
                }
            }
            if(f){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import math
N = int(input())
A = Counter(map(int, input().split()))
work = []
for key, val in A.items():
    while val > 2:
        val -= 2
    work.append(val)
len_work = len(work)
two_cnt = work.count(2)
if two_cnt % 2 == 0:
    print(len_work)
else:
    print(len_work - 1)

Measured memory_bytes: 27212
N, K = map(int, input().split())
p = [0] * N
p[0] = len(bin(K)) - 2
if 2 ** p[0] >= 2 * K:
    p[0] = p[0] - 1
for i in range(N - 1):
    if 2 ** p[i] * (i + 2) >= 2 * K:
        p[i + 1] = p[i] - 1
    else:
        p[i + 1] = p[i]
    if p[i + 1] == 0:
        break
ans = float(0)
for n in range(1, N + 1):
    ans += 1 / N * ((1/2) ** p[n-1])
print(ans)

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

int main(){
	ll N, assH; 
	cin >>  N;
	vector<int> x(N), y(N), h(N);
	for(int i= 0; i< N; i++){
		cin >> x[i] >> y[i] >> h[i];
	}
	
	for(int assX= 0; assX<= 100; assX++){
		for(int assY= 0; assY<= 100; assY++){
			
			assH= -1;
			
			for(int i= 0; i< N; i++){
				if(h[i]> 0){
					int tmp= h[i]+ abs(x[i]- assX)+ abs(y[i]- assY);
					
					if(assH== -1) assH= tmp;
					if(assH!= tmp) {
						assH= -2;
						break;
					}	
				}
			}
			if(assH== -2) continue;
			
			for(int i= 0; i< N; i++){
				if(h[i]== 0){
					if(assH- abs(x[i]- assX)- abs(y[i]- assY)  >  0){
						assH= -2;
						break;
					}
				}
			}
			
			
			
			if(assH== -2) continue;
			cout << assX << " " << assY << " " << assH << endl;
			return 0;
			
		}
	}
	
}

Measured memory_bytes: 256
count = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(int(input())):
  count[input()] += 1

print(f"AC x {count['AC']}")
print(f"WA x {count['WA']}")
print(f"TLE x {count['TLE']}")
print(f"RE x {count['RE']}")

Measured memory_bytes: 9184
def search(node, searched, goal):
  if searched == goal:
    return 1
  v = 0
  for nei in edges[node]:
    if searched & (1 << nei):
      continue
    v += search(nei, searched | (1<<nei), goal)
    
  return v

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(m):
  a, b = map(lambda x: int(x) - 1, input().split())
  edges[a].append(b)
  edges[b].append(a)
print(search(0, 1, (1<<n) - 1))


Measured memory_bytes: 3064
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n;
  cin >> n;
  int zero = 0;
  map<pair<ll,ll>,P> mp;
  rep(i,n) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      zero++;
      continue;
    }
    ll g = gcd(x,y);
    x /= g;
    y /= g;
    if (y < 0) x = -x, y = -y;
    if (y == 0 && x < 0) x = -x, y = -y;
    bool rot90 = (x <= 0);
    if (rot90) {
      ll tmp = x;
      x = y; y = -tmp;
    }
    if (rot90) mp[{x,y}].first++;
    else mp[{x,y}].second++;
  }

  mint ans = 1;
  for (auto p : mp) {
    int s = p.second.first;
    int t = p.second.second;
    mint now = 1;
    now += mint(2).pow(s) - 1;
    now += mint(2).pow(t) - 1;
    ans *= now;
  }
  ans -= 1;

  ans += zero;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15996
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<string> v(8);
    for (auto &&i : v) cin >> i;
    for (int i = 0; i < 3; ++i) {
        cout << 90*(i+1) << "\n";
        auto vv = v;
        for (int j = 0; j < 8; ++j) {
            for (int k = 0; k < 8; ++k) {
                vv[j][k] = v[7-k][j];
            }
        }
        for (auto &&l : vv) {
            cout << l << "\n";
        }
        v = vv;
    }
    return 0;
}


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

int main() {
	int n;
	while (cin >> n, n) {
		map<string, int>cost;
		map<string, vector<string>>c;
		rep(i, n) {
			string s; int d; cin >> s >> d;
			cost[s] = d;
		}
		int m; cin >> m;
		rep(i, m) {
			string s; int d; cin >> s >> d;
			rep(j, d) {
				string S; cin >> S;
				c[s].push_back(S);
			}
		}
		rep(i, n) {
			for (auto&p : cost) {
				if (!c[p.first].empty()) {
					int cnt = 0;
					for (auto j : c[p.first])cnt += cost[j];
					p.second = min(p.second, cnt);
				}
			}
		}
		string s; cin >> s;
		cout << cost[s] << endl;
	}
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(to_string(i).size()%2!=0){
			ans+=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int
main(void)
{
  int sec;
  int h, m, s;
  scanf("%d", &sec);
  h = sec * 1 / 60 * 1 / 60;
  m = (sec - h * 60 * 60) * 1 / 60;
  s = (sec - h * 60 * 60 - m * 60);
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}

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

using namespace std;

typedef long long ll;

multiset<ll> given;

int main()
{
	int n;
	cin >> n;
	ll a;
	for(int i = 0; i < n; i++)
	{
		cin >> a;
		given.insert(a);
	}
	int m;
	cin >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> a;
		auto iter = given.find(a);
		if(iter == given.end())
		{
			cout << "NO" << endl;
			return 0;
		}
		given.erase(iter);
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 9600
from statistics import mean, median,variance,stdev
import sys
import math

#x = input().split()
#y = input().split()


x = int(input())
y = int(input())
z = int(input())
a = int(input())
#for i in range(len(x)):
#   a.append(int(x[i]))
if x <= y: print(x*z)
else :print(y*z+(x-y)*a)

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, x, t;
  cin >> n >> x >> t;
  ll c = (n + x - 1) / x;
  cout << c * t << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    int res = 0;
    res+=h[0];
    for(int i=1;i<n;i++){
        res+=max(0,h[i]-h[i-1]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int X,Y,Z;
  cin>>X>>Y>>Z;
  
  int ans=0;
  
  
  while(true){
    ans++;
    X=X-(Y+Z);
    if(X-(Y+Z)<Z){
      break;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3496
M, K = list(map(int, input().split()))

if K == 0:
  print("0 0",end = "")
  for i in range(1, pow(2, M)):
    print("", i, i, end = "")
  print()
  exit()

if K == 1 and M == 1:
  print(-1)
  exit()

N = pow(2, M)
if K >= N:
  print(-1)
  exit()
 
if K == 1:
  k = 1
  a = 2
  b = 3
elif K % 2 == 1:
  k = K
  a = 1
  b = K - 1
else:
  k = K
  a = 1
  b = K + 1

print(a, k, end = " ")
for i in range(N):
  if i != a and i != b and i != k:
    print(i, end = " ")
print(a, b, end = " ")
for i in range(N - 1, -1, -1):
  if i != a and i != b and i != k:
    print(i, end = " ")
print(k, b)


Measured memory_bytes: 5004
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int mod = 1000000007;
	long long int n, k;
	long long int ans = 0LL;
	long long int scnt = 0LL;
	long long int lcnt = 0LL;
	long long int a[20005];
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]) scnt++;
			if(a[i]<a[j]) lcnt++;
		}
	}
	ans += ((k*(k+1)/2%mod)*scnt)%mod;
	ans += ((k*(k-1)/2%mod)*lcnt)%mod;
	ans = ans%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0), r(N, 0);
    for (int i = 0; i < N; i++) { (cin >> A[i]), A[i] = i - A[i]; }
    for (int i = 0, maxi = 0; i < N; i++) {
        if (A[i] < maxi or A[i] > i) { return (cout << -1 << endl), 0; }
        maxi = max(maxi, A[i]), r[A[i]] = i - A[i];
    }
    cout << accumulate(r.begin(), r.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(auto& i : v){
        cin >> i;
    }

    vector<ll> cost(n, 0);
    cost[1] = abs(v[1] - v[0]);
    cost[2] = abs(v[2] - v[0]);
    for(int i=3; i<n; i++){
        cost[i] = min(cost[i-1] + abs(v[i] - v[i-1]), cost[i-2] + abs(v[i] - v[i-2]));
    }
    
    cout << cost[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 1ll<<60
using namespace std;
const int N=2e5+100;
const int M=4e5+100;
const int mod=1e9+7;
int head[N],Next[M],ver[N],tot;
void add(int x,int y) {
    ver[++tot]=y;
    Next[tot]=head[x];
    head[x]=tot;
}
int vis[N];
int n,flag;

int tmp[N],kk=0;
void dfs(int x){
	if(x==n){
			tmp[++kk]=x;
			return ;
		}
	for(int i=head[x];i;i=Next[i]){
		
		int y=ver[i];
		if(vis[y])continue;
		vis[y]=1;
		
		dfs(y);
		if(kk){
			tmp[++kk]=x;
			return ;	
		}
	}
}
int mark[N];
int cal(int x){
	int cnt=0;
	for(int i=head[x];i;i=Next[i]){
		
		int y=ver[i];
		
		if(mark[y]||vis[y]==flag)continue;//cout<<y<<".."<<" "<<vis[y]<<" "<<flag<<endl;
		mark[y]=1;
		cnt+=cal(y);
		cnt++;
	}
	return cnt;
	
}
int main() {

    while(cin>>n) {
        tot=1;
        int num1=0,num2=0;
        memset(head,0,sizeof(head));
        memset(Next,0,sizeof(Next));
        memset(ver,0,sizeof(ver));
        memset(vis,0,sizeof(vis));
        memset(mark,0,sizeof(mark));
        tmp[0]=0;
        kk=0;
        int x,y;
        for(int i=1; i<n; i++) {
            cin>> x >> y;
            add(x,y);
            add(y,x);
        }
	vis[1]=1;
        dfs(1);
        
        memset(vis,0,sizeof(vis));
        int l=1,r=kk;
        while(l<=r){
        	int x=tmp[l];
        	int y=tmp[r];
        	if(vis[y]==0)vis[y]=1;
        	if(vis[x]==0)vis[x]=2;
        	l++;r--;
  	
		}
//		for(int i=1;i<=n;i++)cout<<vis[i]<<" ";
//		cout<<endl;
		flag=2;
		mark[1]=1;
		num1=cal(1);
		
		flag=1;
		memset(mark,0,sizeof(mark));
		mark[n]=1;
		num2=cal(n);
		
		
		//cout<<num1<<" "<<num2<<endl;
        if(num1>num2){
        	cout<<"Fennec"<<endl; 
        	
		}else{
			cout<<"Snuke"<<endl;
			
		}

    }
    return 0;

}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int max = 1000000;
	vi prime(max, 1);
	prime[0] = 0;
	prime[1] = 0;
	for (int i = 2; i <= sqrt(max); i++) {
		if (prime[i] == 1) {
			int j = 2;
			while (i*j < max) {
				prime[i*j] = 0;
				j++;
			}
		}
	}
	while (1) {
		int a, d, n;
		cin >> a >> d >> n;
		if (a == 0 && d == 0 && n == 0) break;
		int i = 0,num=0;
		while (1) {
			if (prime[a + d*i]) num++;
			if (num == n)break;
			i++;
		}
		cout << a + d*i << endl;
	}
}



Measured memory_bytes: 6520
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	set := make(map[int]int)
	for i := 0; i < N; i++ {
		set[sc.nextInt()]++
	}
	if len(set) <= K {
		fmt.Fprintln(wtr, 0)
	} else {
		A := []int{}
		for _, n := range set {
			A = append(A, n)
		}
		sort.Ints(A)
		ans := 0
		for i := 0; i < len(set)-K; i++ {
			ans += A[i]
		}
		fmt.Fprintln(wtr, ans)
	}

	wtr.Flush()
}


Measured memory_bytes: 16384
function main(input) {
    input = input.split(" ");
    var a = parseInt(input[0]);
    var b = parseInt(input[1]);
    if((a * b) % 2 == 0) {
        console.log("Even");
    } else {
        console.log("Odd");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29488
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long LL;
typedef long long int LLI;

int memo[20][20];

int mx[] = {0,0,-1,1};
int my[] = {-1,1,0,0};

char table[21][21];

int dfs(int x,int y);
int W=0,H=0;

int main(void)
{
    while(1){
    int i,j;
    int x,y;
    int ans=0;
    cin>> W >> H;
    
    if(W==0 && H==0)break;
    
    REP(i,0,H){
        REP(j,0,W){
            cin >> table[i][j];
            if(table[i][j] == '@'){
                x=i;
                y=j;
            }
        }
    }
    ans = dfs(x,y);
    cout << ans << endl;
    }
    return 0;
}

int dfs(int x,int y){
    int cnt=1;
    for(int i=0;i<4;i++){
        int nx = x+mx[i],ny = y+my[i];
        if(0 <= nx && 0 <= ny && ny < W && nx < H && table[nx][ny] == '.'){
            table[nx][ny] = '#';
            cnt += dfs(nx,ny);
        }
    }
    return cnt;
}

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

int main(void)
{
	int n, x;
	while (true)
	{
		cin >> n >> x;
		int sum = 0;
		if (n == 0 && x == 0)break;
		if (x < 6)
		{
			cout << 0 << endl;
			continue;
		}
		else if (n >= x)
		{
			for (int i = 1; i <= x; i++)
			{
				for (int j = i + 1; j <= x; j++)
				{
					for (int k = j + 1; k <= x; k++)
					{
						if (i + j + k == x)sum++;
					}
				}
			}
		}
		else
		{
			for (int i = 1; i <= n; i++)
			{
				for (int j = i + 1; j <= n; j++)
				{
					for (int k = j + 1; k <= n; k++)
					{
						if (i + j + k == x)sum++;
					}
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}


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

#define int             long long
#define INF             1e18
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)

const int MOD = 1e9 + 7;





int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int l, r, d;
	int cnt = 0;
	cin >> l >> r >> d;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0)
			cnt++;
	}
	cout << cnt;

	return 0;
}


Measured memory_bytes: 3608
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

void solve()
{
    int h, w;
    cin >> h >> w;
    int k;
    cin >> k;
    string s[h];
    for(int i = 0; i < h; i++)
        cin >> s[i];
    int ans = 0;
    int H = (1 << h), W = (1 << w);
    for(int hh = 0; hh < H; hh++)
    {
        for(int ww = 0; ww < W; ww++)
        {
            string t[h];
            for(int i = 0; i < h; i++)
                t[i] = s[i];
            for(int i = 0; i < h; i++)
                for(int j = 0; j < w; j++)
                {
                    bool ok = 0;
                    if((1 << i) & hh)
                        ok = 1;
                    if((1 << j) & ww)
                        ok = 1;
                    if(ok)
                        t[i][j] = '.';
                }
            int cnt = 0;
            for(int i = 0; i < h; i++)
                for(int j = 0; j < w; j++)
                    if(t[i][j] == '#')
                        cnt++;
            if(cnt == k)
                ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632