akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

char mp[333][333];
ll ans[333][333];

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

    ll h, w, k;cin >> h >> w >> k;

    int cou = 0;
    REP(i, h){
        ll now = 0;
        REP(j, w){
            cin >> mp[i][j];
            if(mp[i][j] == '#'){
                cou++;
                now = cou;
            }
            ans[i][j] = now;
        }
    }

    REP(i, h){
        ll now = 0;
        REV(j, w){
            if(ans[i][j] != 0)now = ans[i][j];
            ans[i][j] = now;
        }
    }

    REP(i,h){
        REP(j, w){
            if(i == 0)continue;
            if(ans[i][j] == 0)ans[i][j] = ans[i-1][j];
        }
    }

    REV(i,h){
        REP(j, w){
            if(i == h-1)continue;
            if(ans[i][j] == 0)ans[i][j] = ans[i+1][j];
        }
    }

    REP(i, h){
        REP(j, w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }


	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    while(cin>>n>>m, n){
        vs f(n);cin>>f;
        vs ss;
        rep(i,n)rep(j,m){
            for(auto vy:vl{n-1,0,1})for(auto vx:vl{m-1,0,1})if(vy or vx){
                vvb v=vvb(n,vb(m,false));
                string s = "";
                ll y=i, x=j;
                while(!v[y][x]){
                    s+=f[y][x];
                    v[y][x]=true;
                    y=(y+vy)%n;
                    x=(x+vx)%m;
                }
                ss.push_back(s+"/");
            }
        }
        sort(all(ss));
        vs sss;
        sss.push_back("0");

        rep(i,ss.size()-1){
            rep(j, min(ss[i].size(), ss[i+1].size())){
                if(ss[i][j]!=ss[i+1][j] or ss[i][j]=='/'){
                    sss.push_back(ss[i].substr(0,j));
                    break;
                }
            }
        }
        sort(all(sss), [](string a, string b){return a.size()>b.size() or (a.size()==b.size() and a<b);});
        puta(sss[0]);
    }
    return 0;
}


Measured memory_bytes: 3472
n=int(input())
a=list(map(int,input().split()))
num=[0]*(max(a)+1)
for i in range(n):
    num[a[i]]+=1
ans=0
if max(a)<3:
    ans=sum(num)
else:
    for i in range(1,max(a)):
        num2=num[i-1]+num[i]+num[i+1]
        if ans<num2:
            ans=num2
print(ans)


Measured memory_bytes: 14008
function sadness(b, A){
  var result = 0;
  for(var i=0;i<A.length;i++){
    result += Math.abs(A[i]-(b+i+1))
  }
  return result;
}

function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0]);
  const As = lines[1].split(' ').map(x => parseInt(x));

  const median_index = Math.floor(N/2);
  var sorted_A_diffs = [];
  for(var i=0;i<As.length;i++){
    sorted_A_diffs.push(As[i]-(i+1));
  }
  sorted_A_diffs.sort(function(a,b){return a-b;})
  const b = sorted_A_diffs[median_index];

//  console.log(N);
//  console.log(As);
//  console.log(sorted_A_diffs);
//  console.log([median_index,b, sorted_A_diffs[median_index+1]]);
//  console.log([sadness(b, As), sadness(sorted_A_diffs[median_index+1], As)]);
  var result = sadness(b, As)

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 38012
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string inp;
    cin >> inp;
    sort(all(inp));
    
    if (inp == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int A, B, price;
  
  scanf("%d%d", &A, &B);
  
  price = 0;
  
  while((int)(price*0.08) <= A && (int)(price*0.1) <= B){
    if((int)(price*0.08) == A && (int)(price*0.1) == B){
      printf("%d\n", price);
      return 0;
    }
    price ++;
  }
  printf("-1\n");
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

tmp = a[0]
tc = 1
ans = 0
for i in range(1, n):
    if a[i] == tmp:
        tc += 1
    else:
        ans += tc // 2
        tmp = a[i]
        tc = 1
else:
    ans += tc // 2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb emplace_back
using namespace std;

struct node{
	int u,v,w;
};
vector <node> edge;

int main(){
	int l;
	scanf("%d",&l);
	int n = 0;
	for (;(1 << n) <= l;n++);
	for (int i = 1; i < n; i++) { 
		edge.pb(node{i , i + 1 , (1 << (i - 1))});
		edge.pb(node{i , i + 1 , 0});
	}
	int now = (1 << (n - 1));
	for (int i = n - 1; i >= 1; i--) {
		if (now + (1 << (i - 1)) - 1 < l) {
			edge.pb(node{i , n , now});
			now += (1 << (i - 1));
		}
	}
	printf("%d %d\n" , n , edge.size());
	for (auto ans : edge)
		printf("%d %d %d\n" , ans.u , ans.v , ans.w);
} 


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

int dp[3001][3001];
int main() {
  int N, T;
  cin >> N >> T;
  vector<P> ab(N);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    ab[i] = P(a, b);
  }
  sort(ab.begin(), ab.end());

  int ans = 0;
  rep(i, N) {
    int a = ab[i].first, b = ab[i].second;
    rep(j, T) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (j + a < T) dp[i + 1][j + a] = max(dp[i][j]+b, dp[i][j + a]);
    }
    int now = dp[i][T - 1] + b;
    ans = max(ans, now);
  }

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

Measured memory_bytes: 35456
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

x, y = na()
ans = 0
if x < 4:
    ans += (4-x) * 100000
if y < 4:
    ans += (4-y) * 100000
if x==1 and y==1:
    ans = 10*100000

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string T;
  cin >> T;

  if(T.size()==1){
    if(T.at(0)=='?'){
      T.at(0)='D';
    }
  }

  if(T.size()>1){
    if(T.at(0)=='?'){
      if(T.at(1)=='P'){
        T.at(0)='D';
      }
      else{
        T.at(0)='P';
      }
    }

    if(T.at(T.size()-1)=='?'){
      T.at(T.size()-1)='D';
    }

    for(int i=1; i<T.size(); i++){
      if(T.at(i)=='?'){
        if(T.at(i-1)=='P'){
          T.at(i)='D';
        }
        else if(T.at(i+1)=='P'){
          T.at(i)='D';
        }
        else{
         T.at(i)='P';
        }
      }
    }
  }
cout << T << endl;

return 0;
}

Measured memory_bytes: 3744
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int w,h,k;

int calc(int w,int h){
	int ans[2]={0,0};
	for(int y=1;y<h;y++)
		for(int d=0;d*y<=3*h+2*k&&d<w;d++){
			int r=__gcd(d,h)+2*k-2-d*y;
			int lim=min(max(r/h,0ll),w-d-1);
			ans[d==0]+=lim;
			for(int x1=lim+1;x1<=lim+2&&x1+d<w;x1++) if(x1*h-__gcd(x1+d,h-y)-__gcd(x1,y)<=r) ans[d==0]++;
		}
	return 2*ans[0]+ans[1];
}

signed main(){
	read(w,h,k);
	write(calc(w,h)+calc(h,w)<<1);
}

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

using namespace std;

typedef long long LL;

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    if (a >= b) {
        cout << "delicious" << endl;
    } else if (a + x >= b) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  long ans = 0;
  long n = s.length();

  for (int bit = 0; bit < (1<<n-1); bit++) {
    string save = {s[0]};
    for(int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        ans += atoll(save.c_str());
        save = {s[i+1]};
      }else {
        save += {s[i+1]};
      }
    }
    ans += atoll(save.c_str());
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    VI m(3);
    string s,s1,s2;
    cin >> m[0] >> m[1] >> m[2];   
    sort(ALL(m));
    cout << m[2]- m[0] << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clock_t begin = clock();
	int n;
	cin >> n;
	vector<ll>dp(n + 5, 1e9);
	vector<ll>choice;
	ll have = 1;
	while (n >= have) {
		have = have * 6;
		choice.pb(have);
	}
	have = 1;
	while (n >= have) {
		have = have * 9;
		choice.pb(have);
	}
	dp[0] = 0;
	for (int i = 0; i <= n; i++) {
		dp[i + 1] = min(dp[i + 1], 1 + dp[i]);
		for (auto k : choice) {
			if (i + k <= n) {
				dp[i + k] = min(dp[i + k], 1 + dp[i]);
			}
		}
	}
	cout << dp[n] << endl;
	clock_t end = clock();
	cerr << "Time run: " << (float)(end - begin) / CLOCKS_PER_SEC << " s" << endl;
}


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

const int INF = 10000000;

vector<int> to[100005];

int main(){
  cout << "Yes" << endl;
  int n,m;
  cin >> n >> m;
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n,-1);
  dist[0] = 0;
  q.push(0);
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u : to[v]) {
      if(dist[u] != INF) continue;
        dist[u] = dist[v] + 1;
        pre[u] = v;
        q.push(u);
      
    }
  }

  rep(i,n) {
    if(i == 0) continue;
    int ans = pre[i];
    ++ans;
    
    cout << ans << endl;
  }
}


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

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

using namespace std;
using lint=long long;

template<class T> T gcd(const T& a,const T& b){ return b==0?a:gcd(b,a%b); }

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	int n; scanf("%d",&n);

	int z=0;
	map<pair<lint,lint>,int> f;
	rep(i,n){
		lint a,b; scanf("%lld%lld",&a,&b);
		if(a==0 && b==0) z++;
		else{
			lint g=gcd(a,b);
			a/=g;
			b/=g;
			if(b<0 || (b==0 && a<0)) a*=-1, b*=-1;
			++f[{a,b}];
		}
	}

	mint ans=1;
	for(auto p:f){
		lint a,b; tie(a,b)=p.first;

		lint a2,b2;
		if(a>0) a2=-b, b2=a;
		else    a2=b, b2=-a;

		lint c1=p.second;
		lint c2=(f.count({a2,b2})>0?f[{a2,b2}]:0);
		if(c1>0 && c2>0 && a<=0) continue;

		ans*=pow(mint(2),c1)+pow(mint(2),c2)-1;
	}
	ans+=z-1;
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 16124
// Lets go to the next level
// AIM EXP at CF *__* asap
// Hit A,B,C faster and reach Expert
// Remember you were also a novice when you started,
// hence never be rude to anyone who wants to learn something!Be calm and help everyone.
// Never open the rank list until and unless you are done with solving problems!

//Author: kaiyu
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};

bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 2e5+ 10;

#define int long long
int32_t main() {
//#ifndef ONLINE_JUDGE
    //freopen("inp1.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
//#endif
    fio
    int a[5];
    int ans = 1;
    for (int i = 0; i <5 ; ++i) {
        cin >> a[i];
        if(a[i]==0) {
            ans = i+1;
        }
    }
    cout << ans << endl;




    //cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 3640
import java.io.*;

public class Main {
    static final int MAX_GRAM = 5001;
    static final int MAX_SHOP = 3;
    static final int INF = 10000000;

    public static void main(String[] args) throws IOException {
        BufferedReader br
        = new BufferedReader(new InputStreamReader(System.in));

        int[] gram = {200, 300, 500};
        int[] price = {380, 550, 850};
        double[] disc = {0.8, 0.85, 0.88};
        int[][] dp = new int[MAX_SHOP][MAX_GRAM];
        for (int i = 0; i < MAX_SHOP; i++) {
            for (int j = 0; j < MAX_GRAM; j++) {
                dp[i][j] = INF;
            }
        }
        
        dp[0][0] = dp[1][0] = dp[2][0] = 0;
        for (int j = 1; j <= 5000 / 200; j++) {
            int mod = j % 5;
            dp[0][200 * j] = (int)((380 * (j - mod)) * 0.8 + 380 * mod);
        }

        for (int j = 1; j <= 5000 / 300; j++) {
            int mod = j % 4;
            dp[1][300 * j] = (int)((550 * (j - mod)) * 0.85 + 550 * mod);
        }

        for (int j = 1; j < 5000 / 500; j++) {
            int mod = j % 3;
            dp[2][500 * j] = (int)((850 * (j - mod)) * 0.88 + 850 * mod);
        }

        for (int i = 0; i < MAX_SHOP; i++) {
            for (int j = 200; j <= MAX_GRAM; j += 100) {
                for (int k = 1; (k * gram[i]) <= j; k++) {
                    int diff = j - (k * gram[i]);
                    dp[2][j] = Math.min(dp[2][j], dp[2][diff] + dp[i][k * gram[i]]);
                }
            }
        }

        String line;
        while (true) {
            line = br.readLine();
            int g = Integer.parseInt(line);
            if (g == 0) break;
            System.out.println(dp[2][g]);
        }
    }
}

Measured memory_bytes: 24376
N, K, Q = map(int, input().split())
L =  list(int(input()) for i in range(Q))

keys = list(range(1,N+1,1))
havePoint=[K]*N
dic = dict(zip(keys, havePoint))

for num in L:
    tmp = dic[num]+1
    dic[num]= tmp

for p in dic.values():
    if p-len(L)>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 21016
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
x=int(input())
l=make_divisors(x)
ll=[(i,i-j) for i in range(200) for j in l]
for a,b in ll:
  if a**5-b**5==x:
    print(a,b)
    break

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string s;
	int a=1;
	cin >> s;
	for (int i = 1; i < 3; i++) {
		if (s[i - 1] == s[i]&&a==1) {
			a = 1;
		}
		else {
			a = 0;
		}
	}
	if (a == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

}

Measured memory_bytes: 256
/* Life is all about calculated risks.
    But man am I bad at math. */

#include <bits/stdc++.h> 
#define ll long long int
#define INF (ll)1e12
#define MOD 1000000007
#define ld long double

#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ld a,b;
    cin>>a>>b;
    cout<<(ll)(a*b)<<endl;

    return 0;
}

Measured memory_bytes: 3744
from fractions import gcd
a, b = map(int, input().split())
g = gcd(a, b)
ans = 1
for i in range(2, int(g ** 0.5) + 1):
  if g % i != 0:
    continue
  while g % i == 0:
    g //= i
  ans += 1
if g > 1:
  ans += 1
print(ans)


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    vector<pair<int, int>> v;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        v.push_back({a, i+1});
    }
    sort(v.begin(), v.end());
    
    for(int i = 0; i < N; i++){
        cout << v[i].second << " ";
    }
    return 0;
}


Measured memory_bytes: 1780
#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 = 1000000001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> to[100001];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for(int u : to[v]) {
      if(dist[u] != INF)
        continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i, n) {
    if(i == 0)
      continue;
    int ans = pre[i];
    ans++;
    cout << ans << endl;
  }
}


Measured memory_bytes: 10552
#include <iostream>
using namespace std;
int main () {
	int b, f, r, v, n, x[4][3][10]={0};
	cin >> n;
	for(int i=0; i<n; i++) {
		cin>>b>>f>>r>>v;
		x[b-1][f-1][r-1]+=v;
	}
	for(int j=0;j<4;j++){
		for(int k=0;k<3;k++){
			for(int l=0;l<10;l++) 
			cout<<' '<<x[j][k][l];
			cout<<endl;
		}
		if (j<3) cout<<"####################\n";
	}
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ll long long

#define rep(i, a, b) for (int i = a; i < b; i++)
#define For(i, a, b) for (int i = a; i <= b; i++)

using namespace std;

const int mod = 1000000000 + 7;

string s;

int main(){
    getline(cin, s);
    int a = 0, ans = 0;
    for (int i = 0; i < s.length(); i++){
        if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
            ans = max(++a, ans);
        }
        else a = 0;
    }
    printf("%d", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
int main() {
	ll X,Y;	cin >>X>>Y;
	cout << X + Y / 2 << endl;
	

	cin >> X;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    B = LI()

    ans = 0
    for i in range(N - 2):
        ans += min(B[i], B[i+1])
    ans += B[0] + B[-1]

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10072
for _ in [0]*int(input()):
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6
    s=30*(h+(m/60))
    if l<s:l,s=s,l
    if l-s>180:d=360-l+s
    else:d=l-s
    if d<30: print('alert')
    elif d<90: print('warning')
    else: print('safe')

Measured memory_bytes: 7548
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define RFor(i,b,a) for(ll i = b;i>=a;i--)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define mp(x,y)  make_pair(x,y)
#define pb push_back
#define ins insert
#define er erase
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 2e18;
const ll MAX = 5001;

int main() {
    LAPAK
    string s,t;
    cin>>s>>t;
    ll ans = 0;
    For(i,0,s.len){
        ans += (s[i]!=t[i]);
    }
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2005;

int n;
int a[N], cache[N][N];
pair<int, int> b[N];

int dp(int idx, int i, int j)
{
	if(idx > n)
		return 0;
	int &ans = cache[idx][i];
	if(ans != -1)
		return ans;
	ans = abs(i - b[idx].second) * b[idx].first + dp(idx + 1, i + 1, j);
	ans = max(ans, abs(j - b[idx].second) * b[idx].first + dp(idx + 1, i, j - 1));
	return ans;

}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		b[i].first = a[i];
		b[i].second = i;
	}
	sort(b + 1, b + n + 1);
	reverse(b + 1, b + n + 1);
	int ans = dp(1, 1, n);
	cout << ans;
	return 0;
}

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

int main() {
	int n;
	cin>>n;
	int k;
	cin>>k;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	
	int dp[n];
	for(int i=0;i<n;i++)
	dp[i]=INT_MAX;
	
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
	    int val;
	    if(i-k>0)
	    val=i-k;
	    else
	    val=0;
	    for(int j=val;j<i;j++){
	        if(dp[i]>(dp[j]+abs(arr[i]-arr[j])))
	         dp[i]=dp[j]+abs(arr[i]-arr[j]);
	    }
	}

	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
N=gets.to_i
as=gets.split.map(&:to_i).sort

ar=Array.new
cnt=0
mark=as.first
as.each_with_index do |e,i|
  if i != N-1
    if e==mark
      cnt+=1
    else
      ar << cnt
      cnt=1
      mark=e
    end
  else
    if e==mark
      cnt+=1
      ar << cnt
    else
      ar << cnt
      ar << 1
    end
  end
end
ar.delete_if{|e|e==1}
if ar.empty?
  puts N
  exit
end
puts N-2*(((ar.inject(:+)-ar.size)/2.0).ceil).to_i


Measured memory_bytes: 10488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  string s; cin >> s;
  int l = s.size();

  int cnt = 0;
  //char c = 'a';
  vector<int> cum;
  rep(i,26) {
    char cc = 'a' + i;
    int cnt = 0, ans = -1;
    rep(j,l) {
      if (s[j] != cc) cnt++;
      else {ans = max(ans, cnt); cnt = 0;}
    }
    ans = max(ans, cnt); 
    cum.push_back(ans);
  }
  cout << *min_element(cum.begin(), cum.end()) << endl;
  return 0;
}

Measured memory_bytes: 3604
i , max = gets.chomp.split(" ").map(&:to_i)
array = gets.chomp.split(" ").map(&:to_i).sort
count =0
(0..i-1).each do |n|
    if max<array[n] 
       break
    end
    if n == array.length-1 && max > array[n]
        break
    end
     max = max - array[n]
     count += 1
end
puts count

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

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int i = 1; i <= h; i++) {
	  for (int j = 1; j <= w; j++) {
		  if ((i <= b && j <= a) || (i > b && j > a)) {
			  cout << 1;
			} else {
			  cout << 0;
			}
		}
	  cout << endl;
	}
  return 0;
}


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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[210000];
main(){
  ll k,x,ans=0;
  cin>>k>>x;
  ll g=k*500;
  if(g<x)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
int n,m,s[N],sum[N],dif[N],flag[N],l,r,mi;
int get_flag(int pos){
	return flag[pos]==pos?pos:flag[pos]=get_flag(flag[pos]);
}
void fit(int& x){
	if(x>n/2) x=n-x+1;
}
int fix(int x){
	if(x<0) x=26-(-x)%26;
	x%=26;
	return x;
}
int main() {
	for(char tmp=getchar();tmp>='a'&&tmp<='z';tmp=getchar())
		s[++n]=tmp-'a';
	for(int i=1;i<=n/2;++i)
		s[i]-=s[n-i+1],dif[i]=s[i]-s[i-1],flag[i]=i;
	dif[n/2+1]=-s[n/2];
	scanf("%d",&m);
	mi=n/2+1;
	for(int i=1;i<=m;++i){
		scanf("%d%d",&l,&r);
		if(n&1){
			if(l==mi&&r==mi) continue;
			if(l==mi) l++;
			if(r==mi) r--;
		}
		if(l<=n/2&&r>n/2){
			fit(r);
			if(l>r) swap(l,r);
			r--;
		}else{
			fit(l);fit(r);
			if(l>r) swap(l,r);
		}
		flag[get_flag(l)]=flag[get_flag(r+1)];
	}
	for(int i=1;i<=n/2+1;++i) sum[get_flag(i)]+=dif[i];
	for(int i=1;i<=n/2+1;++i) if(fix(sum[i])!=0)
		return 0*puts("NO");
	puts("YES");
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
  int m,n;
  cin>>n>>m;
  int ans=n*(n-1)/2;
  int ans1=m*(m-1)/2;
  cout<<ans+ans1;
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   
    int N;
    int ans = 0;
    string s;
    cin >> s >> N;
    
    for(int i = 0; i < N; i++){
        int position = 0;
        string ring;
        cin >> ring;
        ring += ring;
        
        while(ring.find(s,position) != string::npos ){
            position = ring.find(s,position) + s.size();
            ans++;
            break;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>

struct Card{
  char suit;
  char value;
};

int main(){
  struct Card C1[101],C2[101],a;
  int n,i,j,mini;
  char ch;

  scanf("%d%c",&n,&ch);
  for(i=0;i<n;i++){
    scanf("%c%c%c",&C1[i].suit,&C1[i].value,&ch);
    C2[i]=C1[i];
  }

  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(C1[j].value<C1[j-1].value){
	a=C1[j];
	C1[j]=C1[j-1];
	C1[j-1]=a;
      }
    }
  }
  
  for(i=0;i<=n-1;i++){
    mini=i;
    for(j=i;j<n;j++){
      if(C2[j].value<C2[mini].value)
	mini=j;
    }
    a=C2[i];
    C2[i]=C2[mini];
    C2[mini]=a;
  }

  for(i=0;i<n-1;i++){
    printf("%c%c ",C1[i].suit,C1[i].value);
  }
  printf("%c%c\n",C1[n-1].suit,C1[n-1].value);
  printf("Stable\n");

  for(i=0;i<n-1;i++){
    printf("%c%c ",C2[i].suit,C2[i].value);
  }
  printf("%c%c\n",C2[n-1].suit,C2[n-1].value);

  for(i=0;i<n;i++){
    if(C2[i].suit!=C1[i].suit){
      printf("Not stable\n");
      break;
    }
  }
  if(i==n)
    printf("Stable\n");
  return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            if (Console.ReadLine() == "1")
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int a = int.Parse(Console.ReadLine());
                int b = int.Parse(Console.ReadLine());
                Console.WriteLine(a + b);
            }
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    map<string,int> b;
    map<string,int> r;
    for(int i=0;i<n;i++){
        string w;
        cin>>w;
        if(b.find(w)==b.end()){
            b[w]=1;
        }
        else b[w]+=1;
        r[w]=0;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        string w;
        cin>>w;
        if(r.find(w)==r.end()){
            r[w]=1;
        }
        else r[w]+=1;
    }
    int ans=0;
    for(auto itr=b.begin();itr!=b.end();itr++){
            ans=max(ans,b[itr->first]-r[itr->first]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 10000;
typedef pair<int,int> P;
int maxdis = 0;
int main(){
    int h,w;
    cin >> h >> w;
    char s[h][w];
    int dis[h][w];
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cin >> s[i][j];
        }   
    }
    for(int i3 = 0;i3 < h;i3++){
        for(int i4 = 0;i4 < w;i4++){
            for(int i5 = 0;i5 < h;i5++){
                for(int i6 = 0;i6 < w;i6++){
                    queue<P> que;
                    while(que.size()){
                        que.pop();
                    }
                    int sx = i3;
                    int sy = i4;
                    int gx = i5;
                    int gy = i6;
                    for(int i = 0;i < h;i++){
                        for(int j = 0;j < w;j++){
                            dis[i][j] = inf;
                        }    
                    }
                    dis[sx][sy] = 0;
                    que.push(P(sx,sy));
                    while(que.size()){
                        P p = que.front();que.pop();
                        if((p.first == gx && p.second == gy) || s[sx][sy] == '#'){
                            maxdis = max(maxdis,dis[p.first][p.second]);
                            break;
                        }
                        for(int i1 = -1;i1 <= 1;i1++){
                            for(int i2 = -1;i2 <= 1;i2++){
                                if(abs(i1-i2) != 1)continue;
                                if(p.first + i1 >= 0 && p.first + i1 < h && p.second + i2 >= 0 && p.second + i2 < w && s[p.first + i1][p.second + i2] != '#' && dis[p.first + i1][p.second + i2] == inf){
                                    que.push(P(p.first + i1,p.second + i2));
                                    dis[p.first + i1][p.second + i2] = dis[p.first][p.second] + 1;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << maxdis << endl;    
}



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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<vector<string>> ans(N);
    ans[0] = {"a"};
    rep(i, N - 1) {
        int n = ans[i].size();
        rep(j, n) {
            string s = ans[i][j];
            int c = 0;
            rep(k, s.size()) {
                c = max(c, s[k] - 'a');
            }
            rep(k, c + 2) {
                ans[i + 1].push_back(s + (char)('a' + k));
            }
        }
    }
    rep(i, ans[N - 1].size()) {
        cout << ans[N - 1][i] << "\n";
    }
}

Measured memory_bytes: 11380
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  string o, e;
  cin >>o >> e;

  auto i = o.begin();
  auto j = e.begin();

  while(i != o.end()) {
    putchar(*i++);
    if (j != e.end()) putchar(*j++);
  }
  putchar('\n');

  return 0;
}



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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 10+5;
const int D = 10+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, d;
int a[N][D];

bool dis(int a[], int b[]){
	double res = 0.0;
	for(int i=0; i<d; i++){
		res += (a[i]-b[i])*(a[i]-b[i]);
	}
	if (pow((int)sqrt(res), 2) == res) return true;
	return false;
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> d;
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin >> a[i][j];
		}
	}
	int cnt = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if (dis(a[i], a[j])) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c;
  int i;
  
  scanf("%d%d%d",&a,&b,&c);
  
  if(a<b){
    for(i=a;i<b;i++){
      if(i == c){
        printf("Yes");
        return 0;
      }
    }
  }else{
     for(i=b;i<a;i++){
      if(i == c){
        printf("Yes");
        return 0;
      }
     }
  }
  
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;
int main()
{
    int v,v1,n;
    cin>>v>>v1>>n;
    int x;
    if(v>v1)x = v;
    else x = v1;int s,sum=0;
    for(int i=1;i<=n;i+=1){
        s = x*i;sum++;
        if(s==n || s>n){
            cout<<sum<<endl;

            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    count = [0] * 2019
    count[0] = 1
    val = 0
    res = 0
    for i, d in enumerate(reversed(input())):
        d = int(d)
        val += d * pow(10, i, 2019)
        val %= 2019
        res += count[val]
        count[val] += 1
    print(res)
resolve()

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

int main() {
  
  int N;
  cin >> N;
  string c;
  bool m=1;
  
  for (int i = 0; i < N; i++) {
    
    cin >> c;
    if (c=="Y") {
      cout << "Four" << endl;
      m=0;
      break;
    }
    
  }
  if(m){
  cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> u(N); for (int i=0; i<N; ++i) cin >> u[i];  // 昇順
    sort(u.begin(), u.end());

    if (N % 2 != 0) {
        ll sump1 = 0, sump2 = 0, sumn1 = 0, sumn2 = 0;
        sump1 += u[N/2] + u[N/2 + 1];
        for (int i = N/2 + 2; i < N; ++i) {
            sump1 += 2 * u[i];
        }
        for (int i = 0; i < N/2; ++i) {
            sumn1 += 2 * u[i];
        }
        
        for (int i = N/2 + 1; i < N; ++i) {
            sump2 += 2 * u[i];
        }
        sumn2 += u[N/2] + u[N/2 - 1];
        for (int i = 0; i < N/2 - 1; ++i) {
            sumn2 += 2 * u[i];
        }

        cout << max(sump1 - sumn1, sump2 - sumn2) << endl;
    } else {
        ll sump = 0, sumn = 0;
        sump += u[N/2];
        for (int i = N/2 + 1; i < N; ++i) {
            sump += 2 * u[i];
        }
        sumn += u[N/2-1];
        for (int i = 0; i < N/2 - 1; ++i) {
            sumn += 2 * u[i];
        }

        cout << max(sump - sumn, sumn - sump) << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n, p[200020];
double z;
int main() {
	scanf("%d", &n);
	n *= 2;
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		z += p[i] / (n - 1.) * i;
	}
	printf("%.12f\n", z);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iterator>
using namespace std;

const int INF = 1e9;

int main() {
	int n, m, pp, q, r;

	while (cin >> n&&n){	
		int save = -1, ans = 0;
		vector<int>vep, vep2, vep3;
		vep.push_back(1);
		vep.push_back(n);
	    vector<int> vec, vec2, vec3;
		vec.push_back(1);
		vec.push_back(n);
		cin >> m >> pp >> q >> r;
		for (int i = 0; i < m; i++) {
			int x, y, p, p2;
			scanf("%d%d", &x, &y);
			p = lower_bound(vec.begin(), vec.end(), x) - vec.begin();
			if (vec[p] != x) {
				vec.insert(vec.begin() + p, x);
				vep.insert(vep.begin() + p, vec[p] - vec[p - 1] + vep[p - 1]);
			}
			if (vec[p] + 1 != vec[p + 1]) {
				vec.insert(vec.begin() + p + 1, x + 1);
				vep.insert(vep.begin() + p + 1, vep[p] + 1);
			}
			p2 = lower_bound(vec.begin(), vec.end(), y) - vec.begin();
			if (vec[p2] != y) {
				vec.insert(vec.begin() + p2, y);
				vep.insert(vep.begin() + p2, vec[p2] - vec[p2 - 1] + vep[p2 - 1]);
			}
			if (vec[p2] + 1 != vec[p2 + 1]) {
				vec.insert(vec.begin() + p2 + 1, y + 1);
				vep.insert(vep.begin() + p2 + 1, vep[p2] + 1);
			}
			for (int j = p2 + 1; j < vec.size(); j++) {
				vec2.push_back(vec[j] - vec[p2 + 1] + 1);
				vep2.push_back(vep[j]);
			}
			int size = vec2[vec2.size() - 1];
			for (int j = p + 1; j < p2 + 1; j++) {
				vec2.push_back(vec[j] - vec[p + 1] + 1 + size);
				vep2.push_back(vep[j]);
			}
			size = vec2[vec2.size() - 1];
			for (int j = 0; j < p + 1; j++) {
				vec2.push_back(vec[j] - vec[0] + 1+size);
				vep2.push_back(vep[j]);
			}
			vec3 = vec;
			vep3 = vep;
			vec = vec2;
			vep = vep2;
			vec2 = vec3;
			vep2 = vep3;
			vec2.clear();
			vep2.clear();
		}
		int p, p2;
		p = lower_bound(vec.begin(), vec.end(), pp) - vec.begin();
		
		if (vec[p] != pp) {
			vec.insert(vec.begin() + p, pp);
			vep.insert(vep.begin() + p, vec[p] - vec[p - 1] + vep[p - 1]);
		}
		if (vec[p] + 1 != vec[p + 1]) {
			vec.insert(vec.begin() + p + 1, pp + 1);
			vep.insert(vep.begin() + p + 1, vep[p] + 1);
		}
		p2 = lower_bound(vec.begin(), vec.end(), q) - vec.begin();
		if (vec[p2] != q) {
			vec.insert(vec.begin() + p2, q);
			vep.insert(vep.begin() + p2, vec[p2] - vec[p2 - 1] + vep[p2 - 1]);
		}
		if (vec[p2] + 1 != vec[p2 + 1]) {
			vec.insert(vec.begin() + p2 + 1, q + 1);
			vep.insert(vep.begin() + p2 + 1, vep[p2] + 1);
		}
		for (int i = p; i <= p2; i++) {
			if (i + 1<=p2 && vep[i + 1] - vep[i] == vec[i + 1] - vec[i]) {
				if (vep[i + 1] <= r) {
					ans += vep[i + 1] - vep[i];
					if (save != vep[i])
						ans++;
					save = vep[i + 1];
				}
				if (vep[i] <= r&&vep[i + 1] > r) {
					ans += r - vep[i];
					if (save != vep[i])
						ans++;
					save = q;
				}
			}
			else{
				if (vep[i] <= r&&save != vep[i]) {
					ans++;
					save = vep[i];
				}
			}
	}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1764
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

const int mod = 1e9 + 7;

int mpow(int a, int b) {
  if (b == 0) return 1;
  int nesf = mpow(a, b / 2);
  if (b % 2 == 0) {
    return nesf * nesf % mod;
  }
  return a * nesf % mod * nesf % mod;
}

const int N = 1e6 + 100;
int mx[N];

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int tmp = a[i];
    for (int j = 2; j * j <= tmp; j++) {
      if (tmp % j == 0) {
        int cnt = 0;
        while (tmp % j == 0) {
          cnt++, tmp /= j;
        }
        mx[j] = max(mx[j], cnt);
      }
    }
    if (tmp > 1) {
      mx[tmp] = max(mx[tmp], 1ll);
    }
  }
  int mul = 1;
  for (int i = 2; i < N; i++) {
    mul *= mpow(i, mx[i]);
    mul %= mod;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += mul * mpow(a[i], mod - 2) % mod;
    ans %= mod;
  }
  cout << ans << "\n";
}



Measured memory_bytes: 6656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		boolean b = true;
		int cnt = 0;

		if ((S.length() == A + B + 1) && (S.charAt(A) == '-')) {
			for (int i = 0; i < S.length(); i++) {
				if (!(S.charAt(0) == '-') || !(S.charAt(S.length() - 1) == '-')) {
					if (!(S.charAt(i) == '-')) {
						if ((S.charAt(i) < 0) || (S.charAt(i) < 10)) {
							b = false;
						}
					} else {
						cnt++;
						if (cnt != 1) {
							b = false;
							break;
						}
					}
				} else {
					b = false;
					break;
				}
			}
		} else {
			b = false;
		}

		if (b == true) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22868
s=input()
ans="WA"
if s[0]=="A" and "C" in s[2:-1] and s.count("A")==1 and s.count("C")==1:
  s=s.replace("A","")
  s=s.replace("C","")
  if s.islower():
    ans = "AC"
print(ans)
  

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main() {
  int n, d, x;
  cin >> n >> d >> x;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 1; j <= d; j += a) x++;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

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

int main(){
 
  int n, k;
  int dis = 1;
  
  cin >> n >> k;
  
  rep(i, n){
    if(dis < k){
      dis *= 2;
    }
    else{
      dis += k;
    }
  }
  
  cout << dis << endl;
  
  return 0;
}

Measured memory_bytes: 256