akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from operator import mul
from functools import reduce
def modmul(a,b):
    return a * b % 1000000007
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m
def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(modmul, range(n, n - r, -1))
    under = reduce(modmul, range(1,r + 1))
    return over * modinv(under, 1000000007)
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K * x) % 1000000007
        x = (x * x) % 1000000007
        n //= 2
    return (K * x) % 1000000007
n,a,b = (int(x) for x in input().split())
binary = bin(n)
l = []
for i in range(1,len(binary)-1):
    if binary[-i] == "1":
        l.append(pow_k(2,pow_k(2,i-1)))
prod = 1
for value in l:
    prod = (prod * value) % 1000000007
print((prod-(1+(comb(n, a)%1000000007)+(comb(n, b)%1000000007)))%1000000007)

Measured memory_bytes: 12492
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
/* main */
int main(){

    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    
    int q; cin >> q;
    int l, r;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;
        reverse(v.begin() + l, v.begin() + r);
    }

    for (int i = 0; i < n; i++) {
        if (i) cout << ' ' ;
        cout << v[i];
    } cout << '\n';

    return 0;
}



Measured memory_bytes: 3100
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<bool> vis(101, false);
    int cnt=0;
    for(int i=a;i<=b;i++)   vis[i] = true;
    for(int i=c;i<=d;i++)   if(vis[i])  cnt++;
    if(cnt>0)   cnt--;
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll dp[105][305];

int main(){
  int N;
  ll W;
  cin >> N >> W;
  vector<ll> v, w;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    w.push_back(a);
    v.push_back(b);
  }

  rep(i,N){
    for(int j=N; j>=0; j--){
      for(int k=305; k>=0; k--){
        if(j*w[0]+k>W) continue;
        if(j>0 && k>=w[i]-w[0]){
          dp[j][k] = max(dp[j][k], dp[j-1][k-(w[i]-w[0])] + v[i]);
        }
      }
    }
  }

  ll ret = 0;
  rep(i,N+1){
    rep(j,305){
      if(i*w[0]+j<=W){
        ret = max(ret, dp[i][j]);
      }
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;


public class Main {


    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        long sum = 0;
        long min = Long.MAX_VALUE;
        for (int i = 0; i < n - (k - 1); i++) {
            if (arr[i] < 0 && arr[i + (k - 1)] < 0) {
                sum = Math.abs(arr[i]);
            } else if (arr[i] < 0 && arr[i + (k - 1)] > 0) {
                if (Math.abs(arr[i] * 2) <= arr[i + (k - 1)] * 2) {
                    sum = Math.abs(arr[i] * 2) + arr[i + (k - 1)];
                } else {
                    sum = Math.abs(arr[i]) + arr[i + (k - 1)] * 2;
                }
            } else {
                sum = arr[i + (k - 1)];
            }
            min = Math.min(min, sum);

        }
        out.println(min);

    }

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }


        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

}


Measured memory_bytes: 36216
#include "bits/stdc++.h"
#include <random>
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;
 
 
void reader(int &a){scanf("%d",&a);}
void reader(double &a){scanf("%lf",&a);}
void reader(char a[]){scanf("%s",a);}
void reader(ll &a){scanf("%lld",&a);}
void reader(ull &a){scanf("%llu",&a);}
// void reader(string& a){cin >> a;};
template<class T,class U> void reader(T& t,U& u){reader(t); reader(u);}
template<class T,class U,class V> void reader(T& t,U& u,V& v){reader(t); reader(u); reader(v);}
 
void writer(int a,char c) {printf("%d",a); putchar(c);}
void writer(ll a,char c) {printf("%lld",a); putchar(c);}
void writer(double a,char c) {printf("%.20lf",a); putchar(c);}
void writer(char a[]) {printf("%s",a);};
void writer(char a[],char c) {printf("%s",a);putchar(c);};
void writer(char a,char c) {putchar(a); putchar(c);};
template<class T>void writerLn(T t){writer(t,'\n');}
template<class T,class U>void writerLn(T t,U u){writer(t,' ');writer(u,'\n');}
template<class T,class U,class V> void writerLn(T t,U u,V v){writer(t,' ');writer(u,' ');writer(v,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
template<class T> void writerVec(vector<T> x){int n=x.size();int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
 
vector<std::string> split(const std::string &str, char sep){std::vector<std::string> v;std::stringstream ss(str);std::string buffer;while(std::getline(ss,buffer,sep)){v.push_back(buffer);}return v;}
 
// #define int ll
bool test = 1;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };

//..................
ull mod = (int)1e9 + 7;
signed main(){
  int i,j,k,l;
  string s;
  while(1) {
	int N,K;
	vector<int> connect[100];
	int l[100];
	cin >> N;
	if(N == 0) return 0;
	rep(i,N) {
	  int M;
	  cin >> M;
	  rep(j,M) {
		int p;
		cin >> p;
		connect[i].push_back(p);
	  }
	  sort(ALL(connect[i]));
	}
	cin >> K;
	rep(i,K) cin >> l[i];
	int ans = -1;
	rep(i,N) {
	  bool correct = true;
	  rep(j,K) {
		if(binary_search(ALL(connect[i]),l[j]) == false) {
          correct = false;
        }
	  }
	  if(ans != -1 && correct) {
		ans = -1;
		break;
	  }
	  else if(ans == -1 && correct) ans = i;
	}
	if(ans == -1) cout << -1 << endl;
	else cout << ans+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll mod=1e9+7;
int vx[]={-1,0,1,0},vy[]={0,-1,0,1};
int main(){
  vector<P> ans;
  while(1){
    int h,w;
    cin>>h>>w;
    swap(h,w);
    if(h==0&&w==0) break;
    int grid[55][55]={0};
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        char a;
        cin>>a;
        if(a=='W') grid[i][j]=1;
        else if(a=='B') grid[i][j]=2;
      }
    }
    int bcnt=0,wcnt=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(grid[i][j]==0){
          bool used[55][55];
          for(int k=0;k<55;k++){
            for(int l=0;l<55;l++) used[k][l]=false;
          }
          bool black=false,white=false;
          queue<P> que;
          que.push(P(i,j));
          used[i][j]=true;
          while(!que.empty()){
            P pos=que.front();
            que.pop();
            int x=pos.first,y=pos.second;
            for(int k=0;k<4;k++){
              int nx=x+vx[k],ny=y+vy[k];
              if(0<=nx&&nx<h&&0<=ny&&ny<w){
                if(!used[nx][ny]){
                  used[nx][ny]=true;
                  if(grid[nx][ny]==1) white=true;
                  else if(grid[nx][ny]==2) black=true;
                  else que.push(P(nx,ny));
                }
              }
            }
          }
          if(black) if(!white) bcnt++;
          if(white) if(!black) wcnt++;
          int c=0;
          if(black) c++;
          if(white) c+=2;
          //cout<<c;
        }
        //else cout<<4;
      }
      //cout<<endl;
    }
    ans.push_back(P(bcnt,wcnt));
  }
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }
}



Measured memory_bytes: 3132
#include<stdio.h>

int Te[5];
int judge();
void judge1();
int main(){
  int i;
  while(1){
    for(i=0;i<5;i++){
      scanf("%d",&Te[i]);
      if(Te[0]==0)break;
    }
    if(Te[0]==0)break;
    
    if(judge()==1){
      for(i=0;i<5;i++)printf("3\n");
      continue;
    }
    else{
      judge1();
    }
  }
  return 0;
}

int judge()
{
  int TT[3];
  int i;
  TT[0]=Te[0];
  TT[1]=Te[0];
  for(i=1;i<5;i++){
    if(Te[i]!=TT[0])break;
  }
  if(i==5)return 1;
  for(i=1;i<5;i++){
    if(Te[i]!=TT[0]&& TT[0]==TT[1])TT[1]=Te[i];
    if(TT[0]!=TT[1] && Te[i]!=TT[0] &&Te[i]!=TT[1])return 1;
  }
  return 0;
}

void judge1()
{
  int i,n1,n2,m1,m2;
  n1=Te[0];
  for(i=1;i<5;i++){
    if(n1!=Te[i]){
    m1=Te[i];
    break;
    }
  }
 
  if((n1==1 &&m1==2) ||(n1==2 &&m1==3) ||(n1==3 && m1==1)){
    n2=1;
    m2=2;
  }
  if((n1==2 &&m1==1) ||(n1==3 &&m1==2) ||(n1==1 && m1==3)){
    n2=2;
    m2=1;
  }
  for(i=0;i<5;i++){
    if(Te[i]==n1)printf("%d\n",n2);
    else printf("%d\n",m2);
  }
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e17+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
//ll x[100001]={0};
ll a[200001]={0};
//ll b[200001]={0};
//bool c[100000001]={0};
//vector<pair<ll,ll> > adj[100001];
//vector<ll> adj[100001];
//vpii edges;
//bool visited[100001]={0};
//bool color[100001]={0};
//ll dist[100001]={0};
ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}

double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr)+1;
        }
    }
}*/

/*void dfs(ll x,ll y,ll px,ll py,char color){
    if(x<0 || y<0 || x>=n || y>=m)return;
    if(grid[x][y]!=color)return;

    if(visited[x][y]){
        f=true;
        return;
    }
    visited[x][y]=true;

    if(px!=(x+1) || py!=y)
        dfs(x+1,y,x,y,color);
    if(px!=(x-1) || py!=y)
        dfs(x-1,y,x,y,color);
    if(px!=(x) || py!=y+1)
        dfs(x,y+1,x,y,color);
    if(px!=(x) || py!=y-1)
        dfs(x,y-1,x,y,color);
}*/

/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};

/*void dfs(ll s,bool colr){
    if(visited[s])return;
    visited[s]=true;
    color[s]=colr;
    for(auto u:adj[s]){
        dfs(u,!colr);
    }
}*/
//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/

void solve(){
    string s;
    cin>>s;

    if(s[0]>='A' && s[0]<='Z'){
        cout<<'A';
    }
    else cout<<'a';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //sieve(10000001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define ni(n) scanf("%d", &n)
#define nl(n) scanf("%lld", &n)
#define nai(a,n) for (int i = 0; i < (n); i++) ni((a)[i])
#define nal(a,n) for (int i = 0; i < (n); i++) nl((a)[i])
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
using namespace std;

int main()
{
    int n;
    ni(n);
    int fl = 0;
    ll ans = 0, val = INF;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        ni(a), ni(b);
        if (a != b)
            fl = 1;
        ans += a;
        if (a > b)
            val = min(val, (ll)b);
    }
    if (!fl)
        printf("0\n");
    else
        printf("%lld\n", ans - val);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
ll A;
long double B;

int main() {
  cin >> A >> B;
  B *= 100.0;
  ll b = B + 0.1;
  ll ans = A * b / 100LL;
  cout << ans << endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define mod 100000007
#define start int t;cin>>t;while(t--)
#define debug(x) cout<<"#"<<x<<"\n"
#define en "\n"
#define vi vector<int>
#define vli vector<long long int>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define print_all(x) for(auto t:x) cout<<t<<" "; cout<<en
#define F first
#define S second
#define ss(s) scanf("%s",&s)
#define si(x) scanf("%d",&x)
#define sli(x) scanf("%lld",&x)
#define ss(s) scanf("%s",&s)
using namespace std;
ll mod_pow(ll x, int n){
    if(n == 0)      return 1;
 
    ll res = 1;
    while(n > 0){
        if(n & 1)   res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
 
    return res;
}
vector<ll> allDivisors(ll n) 
{ 
    vector<ll> v;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
                v.pb(i);
  
            else {
                v.pb(i);
                v.pb(n/i);
            } 
        }
    }
    return v;
} 
//int hash[1001];
void solve(){
        ll a,b;
  		cin>>a>>b;
  		unsigned ll xx=(a*b);
        if(a==1 || b==1){
            cout<<"1"<<en;
        }
        else cout<<(xx+1)/2<<en;
}

int main(){
    fast;
    //start{
        solve();
    //}
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

int main() {
	int n, m, a[100001], b[100001], c[100001], idxa, idxcb;
	pair<int, int> cb[100001];
	long long sum=0;
	
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int j=0;j<m;j++) cin>>b[j]>>c[j];
	for(int j=0;j<m;j++) cb[j]=make_pair(c[j],b[j]);
	
	sort(cb,cb+m); sort(a,a+n);
	
	idxa=0; idxcb=m-1;
	while(idxa<n&&idxcb>=0){
		if(a[idxa]>=cb[idxcb].first) break;
		if(cb[idxcb].second>0){
			a[idxa]=cb[idxcb].first;
			idxa++; cb[idxcb].second--;
		}
		else idxcb--;
	}
	
	for(int i=0;i<n;i++) sum+=a[i];
	cout<<sum;
	
	return 0;
}

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

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

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n; cin >> n;
  ll ans = 0;
  vi cnt(n+1);
  for(ll i = 1; i <= n; i++){
    for(ll j = i; j <= n; j += i) cnt[j]++;
    ans += cnt[i]*i;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int h[N];
  rep(i,N) {
    int a;
    cin >> a;
    h[a-1] = i+1;
  }
  
  rep(i, N) cout << h[i] << endl;
  return 0;
}



Measured memory_bytes: 1152
import sys
import math

# Sieve of Eratosthenes
N = 999999
searchList = list(range(3, N + 1, 2))
primes = [2]
while True:
  top = searchList.pop(0)
  primes.append(top)
  if top > math.sqrt(N):
    break
  searchList = [s for s in searchList if s % top != 0]
primes.extend(searchList)

# solve
for line in sys.stdin:
  try:
    n = int(line)
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    break

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

#define N 200000

int main(){
	int n;
	ll d;
	ll a;
	P monsters[N];
	scanf("%d%lld%lld",&n,&d,&a);
	d *= 2;
	for(int i=0;i<n;++i){
		scanf("%lld%lld",&monsters[i].first,&monsters[i].second);
	}
	sort(monsters,monsters+n);

	ll ans = 0;
	ll sum_damage = 0;
	int rp = 0;
	for(int i=0;i<n;++i){
		while(rp<n&&monsters[rp].first<=monsters[i].first+d){
			monsters[rp].second += sum_damage;
			++rp;
		}
		ll hp = monsters[i].second - sum_damage;
		if(hp>0){
			ll time = (hp + a - 1) / a;
			ans += time;
			sum_damage += time * a;
		}

	}

	printf("%lld\n",ans);

}


Measured memory_bytes: 3328
def div(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
lis = list(set(div(n)))
ans = 0
for b in lis:
    c = b - 1
    if c != 0:
        
        if n//c == n%c:
            ans += c
print(ans)


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

using namespace std;

const long mod=1000000007;
const char c[4]={'A','B','C','?'};

int main(){
  string s;
  cin >> s;
  
 long dp[100005][5]={{}};
  dp[s.length()][3]=1;
  
  for(int i=s.length()-1;i>=0;i--){
    for(int j=3;j>=0;j--){
    if(s[i]==c[3]) {
      dp[i][j]=3*dp[i+1][j]+dp[i+1][j+1];
    }
      else {
        dp[i][j]=dp[i+1][j];
        if(s[i]==c[j]) dp[i][j]+=dp[i+1][j+1];
      }
    dp[i][j]%=mod;
    }
 
  }
 cout << dp[0][0] << endl;

}


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

int N, p[100000];
bool dp[100000] = { false };
queue<int> q;

int rec() {
	int turn = 1;
	while (true) {
		int r, d;
		int sz = q.size();
		for (int I = 0; I < sz; I++) {
			r = q.front(); q.pop();
			for (int i = 6; i >= 0; i--) {
				d = i;
				while (true) {
					if (r + d < N - 1) {
						if (!dp[r + d]) {
							dp[r + d] = true;
							if (p[r + d] != 0) {
								d += p[r + d];
								continue;
							}
							else {
								q.push(r + d);
								break;
							}
						}
						else {
							break;
						}
					}
					else {
						return turn;
					}
				}
			}
		}
		turn++;
	}
}

int main(){
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	dp[0] = true;
	q.push(0);
	int a = rec();
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	int N, D;
	cin >> N >> D;
	int ans = 0;
	Rep(i, N) {
		ll x, y;
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= D) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>

using namespace std;
typedef pair<int, int> P;

int h, w, c;
vector<vector<int>> original_field;

int vx[4] = { 0,1,0,-1 }, vy[4] = { 1,0,-1,0 };

int ans = 0;
int ans1 = 0;

bool used[8][8];

void dfs3(vector<vector<int>> &f) {
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)used[i][j] = false;
	}

	int i = 0, j = 0;

	if (!used[i][j] && f[i][j] == c) {
		int cnt = 1;
		stack<P> s;
		s.push(P(i, j));
		used[i][j] = true;
		while (s.size()) {
			auto tmp = s.top(); s.pop();
			for (int k = 0; k < 4; k++) {
				int nx = tmp.first + vx[k], ny = tmp.second + vy[k];
				if (nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
				if (!used[nx][ny] && f[nx][ny] == c) {
					cnt++;
					used[nx][ny] = true;
					s.push(P(nx, ny));
				}
			}
		}
		ans = max(ans, cnt);
		
	}
}

void dfs2(int c, vector<vector<int>> &f) {
	for (int i = 0; i < 8; i++)for (int j = 0; j < 8; j++)used[i][j] = false;
	stack<P> s;
	int d = f[0][0];
	s.push(P(0, 0));
	used[0][0] = true;
	f[0][0] = c;

	while (s.size()) {
		auto tmp = s.top(); s.pop();
		for (int i = 0; i < 4; i++) {
			int nx, ny;
			nx = tmp.first + vx[i], ny = tmp.second + vy[i];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
			if ((f[nx][ny] == d) && !used[nx][ny]) {
				//これから決めていく色と同じもしくは、今までの色と同じ
				f[nx][ny] = c;
				used[nx][ny] = true;
				s.push(P(nx, ny));
			}
		}
	}
}

void dfs1(int cnt, vector<vector<int>>& filed) {

	if (cnt == 5) {
		dfs3(filed);
	}
	else {
		for (int color = 1; color <= 6; color++) {
			if (color == filed[0][0])continue;
			auto cpy_f = filed;
			dfs2(color, cpy_f);
			dfs1(cnt + 1, cpy_f);
		}
	}
}

int main() {
	while (1) {
		cin >> h >> w >> c;
		if (!(h + w + c))break;
		original_field.resize(h);
		for (int i = 0; i < h; i++) {
			original_field[i].resize(w);
			for (int j = 0; j < w; j++) {
				cin >> original_field[i][j];
			}
		}
		
		dfs1(0, original_field);

		cout << ans << endl;
		original_field.clear();
		ans = 0;
	}
	return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    string S;
    cin >> S;
    ll i,j;
    if(S[0]==S[1]&&S[2]==S[3]&&S[3]!=S[1]){cout << "Yes";return 0;}
    if(S[0]==S[2]&&S[1]==S[3]&&S[1]!=S[2]){cout << "Yes";return 0;}
    if(S[0]==S[3]&&S[2]==S[1]&&S[0]!=S[1]){cout << "Yes";return 0;}
    cout << "No";
    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	res := true
	for i := 1; i <= len(s); i++ {
		if i%2 == 0 {
			if s[i-1:i] == "R" {
				res = false
				break
			}
		} else {
			if s[i-1:i] == "L" {
				res = false
				break
			}
		}
	}
	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int x = sc.NextInt();
        int a = sc.NextInt();
        int b = sc.NextInt();

        string answer = Math.Abs(x - a) <= Math.Abs(x - b) ? "A" : "B";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
import java.io.*;
import java.util.*;
import java.util.Arrays;

class Main {

    // Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String S;
        S = sc.next();
        solve(S);
    }

    static void solve(String S){
        String[] arr = {"Sunny", "Cloudy", "Rainy"};
        int index = Arrays.asList(arr).indexOf(S);
        if (index == 2) {
            index = 0;
        } else {
            index++;
        }
        System.out.println(arr[index]);

    }
}


Measured memory_bytes: 21844
program main
    integer n
    integer :: a(10**5)
    integer, allocatable :: str_a(:)
    integer, allocatable :: ans(:)
    integer(8) :: first=0, second=0
    integer(8) :: answer
    integer restart
 
    read *, n
    read *, (a(i), i=1,n)
    str_a = a(1:n)
    ans = quick(str_a)
    
    do i=1,n-1
        if(ans(i)==ans(i+1)) then
            first = ans(i)
            restart = i+2
            exit
        end if
    end do
 
    if (result < n) then
        do i=restart,n-1
            if(ans(i)==ans(i+1)) then
                second = ans(i)
                exit
            end if
        end do
    end if
    
    answer = first * second
    print *, answer
 
contains
    recursive function quick(a) result(r)
        integer, intent(in) :: a(:)
        integer, allocatable :: r(:)
        integer :: p
        if(size(a) < 2) then
            r = a
        else
            p = a(1)
            r = [quick(pack(a(2:), a(2:) > p)), pack(a, a == p), quick(pack(a(2:), a(2:) < p))]
        end if
    end function quick
end program main

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    int flag = 1;
    rep(i, n) {
        if (a[i] == flag) {
            flag++;
        }
        else cnt++;
    }

    if (cnt == n) cout << "-1" << endl;
    else cout << cnt << endl;
    return 0;
}

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

#define MAX 100

int main(void) {
  int n;
  int input[MAX];

  cin >> n;

  for(int i = 0; i < n; i++) {
    cin >> input[i];
  }

  int count = 0;
  
  for(int i = 0; i < n; i++) {
    int minJ = i;
    for(int j = i; j < n; j++) {
      if(input[j] < input[minJ]) {
        minJ = j;
      }
    }
    if(minJ != i) {
      count++;
    }
    swap(input[i], input[minJ]);
  }

  for(int i = 0; i < n; i++) {
    if(i == 0) {
      cout << input[i];
    }
    else {
      cout << " " << input[i];
    }
  }
  cout << endl;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1160
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  vector<int> a(3);
  rep(i,3)cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[0]+a[1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    string str;
    cin >> str;
    if(str[3] == str[2] and str[5] == str[4]) cout << "Yes"; 
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll x;
  string s;
  cin>>x>>s;
  int y = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='.')continue;
    y = y * 10 + s[i] - '0';
  }
  ll ret = x * y/100;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3624
n = int(input())
nums = []
time = 0
check = True
for i in range(n):
    a,b = map(int,input().split())
    nums.append((a,b))
nums.sort(key=lambda x:x[1])
for n in nums:
    time+=n[0]
    if time>n[1]:
        check = False
if check==True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 31872
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define ll long long
#define add(x,y)(x=((ll)y+x)%mo)
using namespace std;
const int N=55,mo=1e9+7;
int n,jc[N],ny[N],iv[N][N],f[2][N][N+N],v,ans,o;
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
int main(){
	cin>>n;
	jc[0]=1;
	fo(i,1,n)jc[i]=(ll)jc[i-1]*i%mo;
	ny[n]=ksm(jc[n],mo-2);
	fd(i,0,n-1)ny[i]=(ll)ny[i+1]*(i+1)%mo;
	fo(i,0,n)fo(j,0,n-i)iv[i][j]=(ll)ny[i]*ny[j]%mo;
	f[0][1][n]=1;
	f[0][1][n-1]=1;
	ans=f[0][n][n];
	fo(q,1,n-1){
		o^=1;memset(f[o],0,sizeof f[o]);
		fo(i,0,n)fo(j,-n,n)if(v=f[!o][i][n+j])
			fo(k,0,n-i)fo(l,0,n-i-k)
				if(k+l&&-k-l<=j&&j<=k+l&&!(j+k+l&1)&&-n-n<=j+k-l&&j+k-l<=n+n)
					add(f[o][i+k+l][n+(j+k-l>>1)],v*iv[k][l]);
		ans=(ans+f[o][n][n])%mo;
	}
	cout<<(ll)ans*jc[n]%mo;
}

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

using namespace std;

const int N = 3005;

int n, vis[N][N];
double p[N], dp[N][N];

double rec(int i, int c) {
  if (i == n) return c > n / 2 ? 1.0 : 0.0;
  if (vis[i][c] != -1) return dp[i][c];
  vis[i][c] = 1;
  double x = p[i] * rec(i + 1, c + 1);
  double y = (1.0 - p[i]) * rec(i + 1, c);
  return dp[i][c] = x + y;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  memset(vis, -1, sizeof vis);
  cout << setprecision(10) << fixed << rec(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 104576
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <vector>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	vector<int> d(n);
	vector<int> s;
	for(int i=0;i<n;i++)
	{
		cin>>d[i];
		s.push_back(d[i]);
	}
	for(int i=1;i<n;i++)
	{
		int a=d[i-1]*10+d[i];
		s.push_back(a);
	}
	for(int i=2;i<n;i++)
	{
		int a=d[i-2]*100+d[i-1]*10+d[i];
		s.push_back(a);
	}
	sort(s.begin(),s.end());
	unique(s.begin(),s.end());
	int ans=0;
	for(auto it = s.begin();it!=s.end();it++)
	{
		if(ans==*it)
			ans++;
		else
			break;
	}

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


Measured memory_bytes: 3212
a = [1, 3, 5, 7, 8 ,10,12]
b = [4, 6, 9, 11]
c = [2]

x,y = map(int,input().split())
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes') 
else:
    print('No')

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N, K;
  cin >> N >> K;
  vector< int > A(N);
  cin >> A;

  int ret = 0;
  for(int L = 0; L <= N; L++) {
    for(int R = 0; R <= N; R++) {
      if(L + R > K) continue;
      if(L + R > N) continue;
      vector< int > U;
      for(int i = 0; i < L; i++) {
        U.emplace_back(A[i]);
      }
      for(int i = 0; i < R; i++) {
        U.emplace_back(A[N - i - 1]);
      }
      sort(begin(U), end(U));

      int sum = 0;
      for(int i = 0; i < U.size(); i++) {
        sum += U[i];
      }
      chmax(ret, sum);
      for(int i = 1; i <= U.size(); i++) {
        if(L + R + i > K) continue;
        sum -= U[i - 1];
        chmax(ret, sum);
      }

    }
  }
  cout << ret << endl;
}






Measured memory_bytes: 256
class Calculator
    def calc(n)
        max = (n / 2).floor + 1
        addNext = proc do |current, m|
            if(current > n)
                false
            elsif(current == n)
                true
            else
                addNext.call(current + m, m + 1)
            end
        end

        foundArr = []
        for num in 1...max do
            if addNext.call(num, num + 1)
                foundArr.push num
            end
        end
        foundArr.size
    end
end

calculator = Calculator.new()

while true do
    n = gets.chomp!.to_i
    if(n == 0)
        break
    end
    puts calculator.calc(n)
end


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

int a[2005];
int b[2005][2005];

int main(){
	int n, x, rec;
	long long ans, sum;
	scanf("%d %d",&n,&x);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	for (int i = 1; i <= n; i++){
		b[i][0] = a[i];
		for (int j = 1; j <= n - 1; j++){
			rec = (i - j + n - 1) % n + 1;
			b[i][j] = min(b[i][j - 1], a[rec]);
		}
	}
	ans = 1e18;
	for (int j = 0; j <= n - 1; j++){
		sum = 1LL * x * j;
		for (int i = 1; i <= n; i++) sum += b[i][j];
		ans = min(ans, sum);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 15872
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(0, a+1):
  for j in range(0, b+1):
    for k in range(0, c+1):
      total = 500*i + 100*j + 50*k
      if total == x:
        cnt = cnt + 1
print(cnt)



Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int H, W, K;
	scanf("%d %d %d", &H, &W, &K);
	char m[H * W];
	for (int i = 0; i < H * W; i++) {
		scanf(" %c", &m[i]);
	}
	int count = 0;
	for (int h = 0; h < 1 << H; h++) {
		for (int w = 0; w < 1 << W; w++) {
			int black = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (h >> i & 1 && w >> j & 1 && m[i * W + j] == '#') {
						black++;
					}
				}
			}
			if (black == K) {
				count++;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 1728
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
using namespace std; 
const int maxn=1000+50;
const int maxm=200000+50;
int N,M;
int p[maxn];
int q[maxn];
int c[maxn][maxn];
bool an[maxm];
struct edge
{
	int to,id;
	edge(int to=0,int id=0):to(to),id(id){}
};
vector<edge> adj[maxn];
void dfs(int u,int root)
{
	if(c[root][u]) return;
	c[root][u]=1;
	for(unsigned int i=0;i<adj[u].size();++i)
	{
		int v=adj[u][i].to;
		dfs(v,root); 
	}
}
void dfs(int u,int c,int *p)
{
	if(p[u]!=-1) return;
	p[u]=c;
	for(unsigned int i=0;i<adj[u].size();++i)
	{
		int v=adj[u][i].to;
		dfs(v,c,p);
	}
}
void solve()
{
	for(int i=1;i<=N;++i)
	{
		dfs(i,i);
	}
	for(int u=1;u<=N;++u)
	{
		memset(p,-1,sizeof(p));
		memset(q,-1,sizeof(q));
		int l=p[u]=q[u]=adj[u].size();
		for(int i=0;i<l;++i)
		{
			int v=adj[u][i].to;
			dfs(v,i,p);
		}
		for(int i=l-1;~i;--i)
		{
			int v=adj[u][i].to;
			dfs(v,i,q);
		}
		for(int i=0;i<l;++i)
		{
			int v=adj[u][i].to;
			int d=adj[u][i].id;
			an[d]=c[v][u]^(p[v]!=i||q[v]!=i);
		}
	}
}
int main()
{
	scanf("%d%d",&N,&M);
	for(int i=1;i<=M;++i)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		adj[a].push_back(edge(b,i));
	}
	solve();
	for(int i=1;i<=M;++i)
	{
		puts(an[i]?"diff":"same");
	}
	return 0;
}

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

#define all(x)        (x).begin(),(x).end()
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int,int>
#define vi            vector<int>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;

int n;
string alph = "abcdefghij";
vector<string> ans;
void dfs(int i, int j, string &s) {
  if (i == n) {
    ans.pb(s);
    return;
  }
  string t;
  rep(k, 0, j + 1) {
    t = s + alph[k];
    dfs(i + 1, j, t);
  }
  if (j + 1 < n) {
    t = s + alph[j + 1];
    dfs(i + 1, j + 1, t);
  }
}

void solve() {
  cin >> n;
  string base = "a";
  dfs(1, 0, base);
  rep(i, 0, sz(ans))
    cout << ans[i] << "\n";
}

int main() {
  // freopen("input.in", "r", stdin);
  // freopen("input.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// cout<<setprecision(15);
	// int t; cin>>t; while(t--)
	solve();
	return 0;
}

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

class Dice
{
    public int up;
    public int front;
    public int right;
    public int left;
    public int back;
    public int down;
    public int [] dice=new int [6];
    
    public Dice(int [] saikoro)
    {
        this.dice=saikoro;
    }
    public void kaiten(char keyword)
    {
        if(keyword=='N')
        {
            int a=dice[0];
            dice[0]=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=a;
        }
        if(keyword=='S')
        {
            int a=dice[0];
            dice[0]=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=a;
        }
        if(keyword=='W')
        {
            int a=dice[0];
            dice[0]=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=a;
        }
        if(keyword=='E')
        {
            int a=dice[0];
            dice[0]=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=a;
        }
        if(keyword=='R')
        {
            int a=dice[1];
            dice[1]=dice[3];
            dice[3]=dice[4];
            dice[4]=dice[2];
            dice[2]=a;
        }
        if(keyword=='A')
        {
            int a=dice[1];
            dice[1]=dice[4];
            dice[4]=a;
            a=dice[2];
            dice[2]=dice[3];
            dice[3]=a;
        }
    }
    
}


public class Hello{
    public static void Main(){
        int [] saikoro=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int [] saikoro2=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Dice d=new Dice(saikoro);
        
        string str="SSSSESSSSESSSSESSSSERSSSSASSSS";
        bool v=false;
        foreach(char ch in str)
        {
            d.kaiten(ch);
            if(saikoro2.SequenceEqual(d.dice)==true)
            {
                Console.WriteLine("Yes");
                v=true;
                break;
            }
        }
        if(v==false)Console.WriteLine("No");
        
    }
}


Measured memory_bytes: 20252
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
using ll=int64_t;

template <typename T>
T gcd(T a, T b) { a = std::abs(a);b = std::abs(b);while (b > 0) { a %= b;swap(a, b); }return a; }

using VI=vector<int>;
using VVI=vector<VI>;
const size_t MD = 1000000007ull;

void solve() {
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll ans = n * 1ll * m / gcd(n, m);
    ll ns = ans / n;
    ll ms = ans / m;

    for (int i = 0; i < n; ++i) {
        ll i1 = i * ns;
        if (i1 % ms == 0) {
            ll j = i1 / ms;
            if (j < m) {
                if (s[i] != t[j]) {
                    cout << "-1\n";
                    return;
                }
            }
        }
    }

    for (int i = 0; i < m; ++i) {
        ll i1 = i * ms;
        if (i1 % ns == 0) {
            ll j = i1 / ns;
            if (j < n) {
                if (s[j] != t[i]) {
                    cout << "-1\n";
                    return;
                }
            }
        }
    }
    cout << ans << "\n";
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
//    cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
    return 0;
}

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

using ll=long long;
const ll MOD= 1000000007;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(ll i = k; i<=n+1; i++){
    ans += i*n % MOD - (i-1)*i % MOD + 1;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640