akhauriyash/Code-Regression huggingface dataset:
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> v(n);
    vector<lint> c(n);
    lint ans = -LINF;
    for (int i=0; i<n; ++i){
        cin >> v[i];
    }
    for (int i=0; i<n; ++i){
        cin >> c[i];
    }
    lint loop = 1;
    for (int i=1; i<=n; ++i){
        loop *= 2;
    }
    // debug(loop);
    bitset<20> b;
    lint cost;
    lint value;
    for (int i=0; i<loop; ++i){
        value = 0;
        cost = 0;
        b = static_cast<bitset<20>>(i);
        for (int j=0; j<n; ++j){
            if(b[j] == 1){
                value += v[j];
                cost += c[j];
            }
        }
        ans = max(ans, value - cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<iostream>
#include<string>
#include<map>

using namespace std;

int n;

int c[500];
int s[500];
int f[500];


void arrivetime(int stnum,int nowtime){
      if (stnum == n-1){cout << nowtime << endl;}
  //        return(nowtime)
      else{
          if (nowtime < s[stnum]){
              nowtime = s[stnum];
              nowtime += c[stnum];
            }
          else if (nowtime%f[stnum] == 0){nowtime += c[stnum];}
          else{
          nowtime += f[stnum] - (nowtime%f[stnum]) + c[stnum];}
  //       print("st : " + str(stnum) + " nowtime is " + str(nowtime))
          arrivetime(stnum+1,nowtime);
        }
}

int main(void){

cin >> n;

  for (int i = 0; i < n-1 ; i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < n; i++){
      if (i == n-1){cout << '0' << endl;}
      else{
          arrivetime(i,s[i]);
        }}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const int N=300005;
int n,f[N],g[N];
char s[N];
int main(){
	//freopen("aa.in","r",stdin);
	int i,j;
	scanf("%d%s",&n,s+1); 
	for(i=1;i<=n;++i)f[i]=f[i-1]+(s[i]=='W');
	for(i=n;i;--i)g[i]=g[i+1]+(s[i]=='E');
	int ans=n;
	for(i=1;i<=n;++i){
		ans=min(ans,f[i-1]+g[i+1]);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int N, M;
    cin>>N>>M;
    priority_queue<long> que;
    long tmp;
    for(int i=0;i<N;++i){
        cin>>tmp;
        que.push(tmp);
    }
    long state;
    for(int i=0;i<M;++i){
        state = que.top();
        que.pop();
        que.push(state/2);
    }
    long ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> H(N);
	rep(i, N) cin >> H[i];
	sort(H.rbegin(), H.rend());
	ll score = 0;
	for (int i = K; i < N; ++i) {
		score += H[i];
	}

	cout << score << endl;
	return 0;
} 

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll x[MAXn];
vector<ii> e[MAXn];
bool ok;
void dfs(ll u){
  debug(u);
  for( auto i:e[u] ){
    if( x[i.X]!=-INF ){
      debug(x[u],i.Y,x[i.X],u);
      if( x[u]+i.Y == x[i.X] ) continue;
      else ok = false;
      return;
    }
    else{
      if( !ok ) return;
      x[i.X] = x[u]+i.Y;
      dfs(i.X);
    }
  }
}
int main(){
  IOS();
  ll n,m;
  cin>>n>>m;
  REP(i,MAXn) x[i] = -INF;
  REP(i,m){
    ll l,r,tmp;
    cin>>l>>r>>tmp;
    l--,r--;
    e[l].eb(r,tmp);
    e[r].eb(l,-tmp);
  }
  ok = true;
  REP(i,n)if( x[i]==-INF && SZ(e[i]) ){
    debug(i);
    x[i] = 0;
    dfs(i);
  }
  cout<<(ok ?"Yes":"No")<<endl;
}


Measured memory_bytes: 16512
import java.util.Scanner;
public class Main {
  
  public static void main (String[] args) {
    Scanner scan = new Scanner(System.in);
    int mai = Integer.parseInt(scan.next());
    int kei = Integer.parseInt(scan.next());
     if (mai * 500 >= kei) {
    	System.out.println("Yes");
     } else {
		System.out.println("No");
     }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin>>n>>k;
  vector<int> score(n);
  for(int i=0; i<n; i++){
    cin>>score.at(i);
  }
  for(int i=k; i<n; i++){
    if(score.at(i)>score.at(i-k)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4044
'use strict'
function main(input) {
  input = input.trim().split('\n');
  let nums = input.shift().split(' ')
  input = input[0].split('')
  input[nums[1] - 1] = input[nums[1] - 1].toLowerCase()
  console.log(input.join(''))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main() {
	int K;
	cin >> K;
	string S;
	cin >> S;

	if(S.size() <= K) {
		cout << S << endl;
	} else {
		S = S.substr(0, K);
		cout << S << "..." << endl;
	}

	return 0;
}

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

int atcg(char c) {
  if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
    return 1;
  } else {
    return 0;
  }
}

int main() {
  char s[10];
  scanf("%s", s);

  int slen=strlen(s);
  int len=0, max_len=0;
  int i;

  for (i=0;i<slen;i++) {
    if (atcg(s[i]) == 1) {
      len++;
    } else {
      if (len > max_len) {
        max_len = len;
      }
      len = 0;
    }
  }
  if (len > max_len) {
    max_len = len;
  }
  printf("%d", max_len);
  return 0;
}


Measured memory_bytes: 128
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count = 0
n.times do
  a = gets.split.map(&:to_i)
  sum = c
  m.times do |i|
    sum += a[i] * b[i]
  end
  if sum > 0
    count += 1
  end
end

p count

Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<algorithm>
#define pb(x) push_back(x)
#define ll long long int
#define M 10000000
using namespace std;
int main()
{
    ll n;
    cin>>n;
    vector<ll>a,b;
    ll input; 
    for(ll i=0;i<n;i++)
    {
        cin>>input;
        a.pb(input);
    }
    for(ll i=0;i<n;i++)
    {
        cin>>input;
        b.pb(input);
    }
    ll count=0;
    if(a>b) swap(a,b);
    while(1)
    {
        if(a==b)
        {
            break;
        }
        else
        {
            next_permutation(a.begin(),a.end());
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>

using namespace std;

#define pi (acos(-1))

int main()
{
    int a,b,x;
    scanf("%d%d%d",&a,&b,&x);
    double A=a,B=b,X=x,ans;
    if(X<A*A*B/2.0)ans=atan(A*B*B/2.0/X)/pi*180;
    else ans=atan(2*(A*A*B-X)/A/A/A)/pi*180;
    printf("%.10f",ans);
    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    int gcnt=0;
    rep(i,n) if(s[i]=='G') gcnt++;
    int rcnt=0;
    rep(i,n) if(s[i]=='R') rcnt++;
    int bcnt=0;
    rep(i,n) if(s[i]=='B') bcnt++;
    int memo=gcnt*rcnt*bcnt;
    if(n<=2){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            int dist=j-i;
            int k=j+dist;
            if(k>=n) continue;
            if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i]){
                ans++;
                // cout<<i<<" "<<j<<" "<<k<<endl;
            }
        }
    }
    // debug(memo);
    // debug(ans);
    cout<<memo-ans<<endl;
}

Measured memory_bytes: 7820
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 100;

int N, T;
int c[kMaxN], t[kMaxN];
// int ans = 0;

signed main() {
  cin >> N >> T;
  REP(i, N) { cin >> c[i] >> t[i]; }

  int mincost = 10000;
  REP(i, N) { if (t[i] <= T) { mincost = MIN(mincost, c[i]); } }

  if (mincost == 10000) {
    cout << "TLE" << endl;
  } else {
    cout << mincost << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<algorithm>
#define fo(i,a,b)for(int i=a,E=b;i<=E;i++)
#define max(a,b)(a>b?a:b)
using namespace std;
const int N=262144;
int n,a[N],an[N],f[N][2],u[4];
bool cmp(int x,int y){return a[x]>a[y];}
int main(){
	scanf("%d",&n);
	fo(i,0,(1<<n)-1)scanf("%d",&a[i]);
	f[0][0]=0;
	fo(i,1,(1<<n)-1){
		f[i][0]=i;
		for(int j=i,k;k=j&-j,k;j-=k)if(i-k){
			u[0]=f[i-k][0];u[1]=f[i-k][1];u[2]=f[i][0];u[3]=f[i][1];
			sort(u,u+4,cmp);
			f[i][0]=u[0];f[i][1]=u[0]==u[1]?(u[0]==u[2]?u[3]:u[2]):u[1];
		}
		an[i]=a[f[i][0]]+a[f[i][1]];
	}
	fo(i,1,(1<<n)-1)an[i]=max(an[i],an[i-1]),printf("%d\n",an[i]);
}

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

int main(){

  int N;
  cin>>N;
  double d=N;
  if(N%2==0)cout<<0.50<<endl;
  else if(N==1)cout<<1<<endl;
  else cout<< double((d+1)/2/d) <<endl;
}


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

int main(){
	int a,b,c,ans=3;
	cin>>a>>b>>c;
	if(a==b)--ans;
	if(b==c)--ans;
	if(c==a)--ans;
	if(a==b&&b==c)++ans;
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<math.h>
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 1e9
#define eps 1e-6
#define PI acos(-1.0)
#define M 10010
typedef pair<int, int>P;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;

int n;
ll a[maxn];

int main()
{
   cin >> n ;
   for(int i = 0 ; i < n ; i++)
   cin  >> a[i];
   if(n == 2 )
   {
       cout << abs(a[0] - a[1]) << endl;
       return 0;
   }
   sort(a,a+n);
   deque<ll> q;
   q.push_back(a[n-1]);
   q.push_back(a[0]);
   q.push_back(a[n-2]);
   int st = 1, ed = n-3;
   int tot = 0;
   while(1){
      if(!tot){
         if(st <= ed) {
                q.push_front(a[st]);
                st++;
          }
         if(st <= ed) {
                q.push_back(a[st]);
                st++;
          }
      }
      else {
         if(ed >= st ) {
              q.push_front(a[ed]);
              ed --;
         }
        if(ed >= st ) {
              q.push_back(a[ed]);
              ed --;
         }
      }
      tot = (tot + 1) %2 ;
      if(st > ed) break;
    }
    ll ans1 = 0;
    for(int i = 0;i< q.size() - 1; i++)
        ans1 += abs(q[i] - q[i+1]);

   deque<ll> d;
   d.push_back(a[0]);
   d.push_back(a[n-1]);
   d.push_back(a[1]);
   st = 2, ed = n-2;
   tot = 0;
   while(1){
      if(tot){
         if(st <= ed) {
                d.push_front(a[st]);
                st++;
          }
         if(st <= ed) {
                d.push_back(a[st]);
                st++;
          }
      }
      else {
         if(ed >= st ) {
              d.push_front(a[ed]);
              ed --;
         }
        if(ed >= st ) {
              d.push_back(a[ed]);
              ed --;
         }
      }
      tot = (tot + 1) %2 ;
      if(st > ed) break;
    }
    ll ans2 = 0;
    for(int i = 0;i< d.size() - 1; i++)
        ans2 += abs(d[i] - d[i+1]);

    cout << max(ans1,ans2)<<endl;
    return 0;
}


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

vector<string> v;
string s; 
signed main(){
	cin>>s;
	for(int i = 0; i < s.size(); i++){
		for(int j = i; j < s.size(); j++){
			if(j-i+1 > 5) break;
			v.push_back(s.substr(i, j-i+1));
		}
	}
	int k;
	cin>>k;
	sort(v.begin(), v.end());
	unique(v.begin(), v.end()); 
	cout<<v[k-1]; 
	return 0;
}


Measured memory_bytes: 1660
n = int(input())
dic = {}
for i in range(n):
  a = int(input())
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
ans = 0
for c in dic.values():
  if c % 2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 15068
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	public static void main(String[] __){
		long r0,w,c,r;
		while(true){
			r0=s.nextInt();
			w=s.nextInt();
			c=s.nextInt();
			r=s.nextInt();
			if(r0+w+c+r==0) return;
			
			int res=0;
			while((r0+res*r)/w<c) {
				res++;
			}
			System.out.println(res);
		}
	}
}

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

int main() {
  int N;
  cin >> N;

  vector<int> cards(N);
  int Alice, Bob;

  for (size_t i = 0; i < N; i++) {
    cin >> cards.at(i);
  }

  sort(cards.begin(), cards.end(), greater<int>());

  bool is_Alice = true;
  for (size_t i = 0; i < N; i++) {
    if (is_Alice) {
      Alice += cards.at(0);
    } else {
      Bob += cards.at(0);
    }
    cards.erase(cards.begin());
    is_Alice = !is_Alice;
  }

  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int k;
    cin >> k;
    if ( k % 2 == 0 ) cout << k * k / 4 << endl;
    else              cout << ( k / 2 + 1 ) * ( k / 2 ) << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    // 入力受け取り, 入次数も管理する
int a,b,k;
    cin >> a>>b>>k;
int count=0;
for(int i=min(a,b);i>=1;i--){
if(a%i==0 && b%i==0){
count++;
//cout << "--" << i<<"\n";
if(count==k)cout << i;
}
}




}




Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))
    cnt = 0
    if A[0] > x:
        cnt += A[0] - x
        A[0] = x
    for i in range(N - 1):
        if A[i] + A[i + 1] > x:
            cnt += A[i] + A[i + 1] - x
            A[i + 1] = x - A[i]
    print(cnt)


resolve()

Measured memory_bytes: 63856
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int p[20000+10],a[20000+10];
int main(){
	int n;
	cin>>n;
	rb(i,1,n) cin>>p[i];
	int Sta=1;
	rb(i,1,n)
		cout<<(a[i]=Sta)<<" ",Sta+=n+1;cout<<endl;
	int Fir=800000000;
	int b[20000+10];
	rb(i,1,n)
	{
		b[p[i]]=Fir-a[p[i]];
		Fir+=1;
	}
	rb(i,1,n)	
		cout<<b[i]<<" ";
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int M,D,a=0;
    cin >>M>>D;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            int b=j/10;
            if(b*(j%10)==i&&b>=2&&(j%10)>=2){
                a=a+1;
            }
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define PI 3.1415926535897932384626433

int main(void){
	double x,y,r,s,c,theta,dx,dy;
	int n,t;
	
	x=0.0;
	y=0.0;
	theta=0.0;
	
	while(1){
		scanf("%d,%d",&n,&t);
		if(n==0 && t==0)break;
		
		if(t<0)t+=360;
		
		
		y+=(double)n*cos(theta*PI/180);
		x+=(double)n*sin(theta*PI/180);
		
		theta+=(double)t;
		while(theta>=360)theta-=360;
		while(theta<0)theta+=360;
	}
	
	n=x;
	x=n;
	t=y;
	y=t;
	
	printf("%.0lf\n%.0lf\n",x,y);
	
	return 0;
}

Measured memory_bytes: 0
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;
using System.Numerics;

public class Program
{
    public void Solve()
    {
        var B = Reader.String().Select(c => "gp".IndexOf(c)).ToArray();
        int ans = 0, stack = 0;

        foreach (int b in B)
        {
            if (b == 0)
            {
                if (stack > 0) { stack--; ans++; }
                else stack++;
            }
            else
            {
                if (stack > 0) stack--;
                else { stack++; ans--; }
            }
        }

        Console.WriteLine(ans);
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 5080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int l = s.length();
		char[] ss = new char[l];
		for(int i=0;i<l;i++) {
			ss[i] = s.charAt(i);
		}
		int[] count = new int[4];
		for(int i=0;i<l;i++) {
			if(ss[i] == 'K') count[0]++;
			if(ss[i] == 'U') count[1]++;
			if(ss[i] == 'P') count[2]++;
			if(ss[i] == 'C') count[3]++;
		}
		int ans = 300;
		for(int i=0;i<4;i++) {
			ans = Math.min(ans, count[i]);
		}
		System.out.println(ans);
	}	
}





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

int main(int argc, char const *argv[])
{
    int a[5], k;
    for(int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    cin >> k;

 
    for(int i = 0; i < 5; i++)
    {
        for(int j = 0; j < i+1; j++)
        {
            int temp = abs(a[i] - a[j]);
            if (temp > k) {
                cout << ":(" << endl;
                return 0;
            }
            
        }
        
    }

    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
T,A = map(int, input().split())
hN = list(map(int, input().split()))

ans = -1
tmp = float('inf')
for i in range(N):
    t = T - hN[i] * 0.006
    if abs(t - A) < tmp:
        tmp = abs(t - A)
        ans = i + 1
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}


const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10], *K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = C;
		K[1] = di;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = di;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.K[X]; *i != '\n'; i++)* di++ = *i;
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 7324
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    if(S[0]==S[SZ(S)-1]){
        if(SZ(S)%2){
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    } else {
        if(SZ(S)%2){
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[200005];
bool cmp(int a1,int a2)
{
	return a1>a2;
}
int main()
{
	int n;cin>>n;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	sort(a,a+n,cmp);
	ll ans=0;
	int tot=n-1;
	for (int i = 0; i < n; i++)
	{
		if(tot)
		{
			ans+=a[i];tot--;
		}
		if(tot&&i)
		{
			ans+=a[i];tot--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

bool f[300000];
int main(){
    fill_n(f,300000,true);
    f[0]=f[1]=false;
    for(int i=0;i<300000;i++){
        if(!f[i])continue;
        for(int j=2;i*j<300000;j++)f[i*j]=false;
    }

    int n;
    while(cin>>n,n){
        int cnt=0;
        for(int i=n+1;i<=n*2;i++)cnt+=f[i];

        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1452
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;
int a, b;
int arr[100][100], arr2[100], arr3[100];
int main()
{
	scanf("%d%d",&a, &b);
	for(int i=0; i<b; i++)
	{
		scanf("%d",&arr2[i]);
		for(int j=0; j<arr2[i]; j++)
		{
			scanf("%d",&arr[i][j]);
			arr[i][j]--;
		}
	}
	for(int i=0; i<b; i++)
		scanf("%d",&arr3[i]);
	int count = 0;
	int hehe = 0;
	while(hehe < pow(2, a))
	{
		int temp = hehe;
		int temp2 = a;
		string str;
		while(temp2--)
		{
			if(temp % 2) str += '1';
			else         str += '0';
			temp /= 2;
		}
//		cout << str << endl;
		int yes = 1;
		for(int i=0; i<b; i++)
		{
			int temp = 0;
			for(int j=0; j<arr2[i]; j++)
			{
				if(str[arr[i][j]] == '1') temp++;
			}
			if(temp % 2 != arr3[i]) yes = 0;
		}
		if(yes) count++;
		hehe++;
	}
	printf("%d\n",count);
	return 0;
}

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

bool exist[200];
int a[100005];
vector<int> b;
int ans;
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int tmp = 0;
  for(int i = 0; i < n; i++) {
    tmp ^= a[i];
    int k = 0;
    int t = a[i];
    while(t % 2 == 0) {
      t /= 2;
      k++;
    }
 
    exist[k] = true;
  }

  while(tmp > 0) {
    b.push_back(tmp % 2);
    // cout << tmp % 2 << endl;
    tmp /= 2;
  }

  int i = b.size() - 1;
  while(i >= 0) {
    //cout << "iii = "<<i<<endl;
    if(exist[i]) ans++;
    else {
      cout << -1 << endl;
      return 0;
    }
    while(i >= 0 && b[i] == 1) {
      i--;
    }
    if(i < 0) break;
    // cout << "i = "<<i<<endl;
    if(exist[i]) ans++;
    else {
      cout << -1 << endl;
      return 0;
    }
    while(i >= 0 && b[i] == 0) {
      i--;
    }
    if(i < 0) break;
  }

  cout << ans << endl;
}
    


Measured memory_bytes: 640
package main

import (
    "fmt"
    "os"
)

func main() {

    var N int
    fmt.Fscanf(os.Stdin, "%d", &N)

    mochi := make(map[int]bool)
    for i := 0; i < N; i++ {
        var v int
        fmt.Fscanf(os.Stdin, "%d", &v)
        mochi[v] = true
    }

    fmt.Printf("%d\n", len(mochi))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

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

  int ans = 0;
  while(true) {
    ans++;
    H -= A;
    if (H <= 0) break;
  }

  cout << ans << endl;

  return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    string a, b, c;
    cin >> a >> b >> c;
    
    transform(a.begin(), a.end(), a.begin(), ::toupper);
    transform(b.begin(), b.end(), b.begin(), ::toupper);
    transform(c.begin(), c.end(), c.begin(), ::toupper);
    
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    l: i64,
    a: [i64; n],
  }
  let mut last = n;
  for i in 0 .. n - 1 {
    if a[i] + a[i+1] >= l {
      last = i;
      break;
    }
  }
  if last == n {
    println!("Impossible");
  } else {
    println!("Possible");
    for i in 0 .. last {
      println!("{}", i + 1);
    }
    for i in (last .. n - 1).rev() {
      println!("{}", i + 1);
    }
  }
}


Measured memory_bytes: 6908
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int[] ans = new int[n];
		for (int i = 0; i < n - 1; i++) {
			int[] ia = readNums();
			int c = ia[0];
			int s = ia[1];
			int f = ia[2];
			for (int j = 0; j <= i; j++) {
				int ss = s;
				while (ss < ans[j])
					ss += f;
				ans[j] = ss + c;
			}
		}
		for (int i = 0; i < n; i++) {
			pln(ans[i]);
		}
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll k;
    cin>>k;
    queue <ll> q;
    for(int i=1;i<=9;i++)
    {
        q.push(i);
    }
    ll x;
    while(k>0)
    {
        x=q.front();
        q.pop();
        if(x%10)
        {
            q.push(10*x + x%10 -1);
        }
        q.push(10*x + x%10);
        if(x%10 !=9)
        q.push(10*x + x%10 + 1);
        k--;
    }
    cout<<x;
  }  
  return 0;
}

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

signed main(void)
{
	int n, sum, ans;
	cin >> n;
	int a[n];
	sum = 0;
	rep(i, n)
	{
		cin >> a[i];
		sum += a[i];
	}
	double ave, mn;
	ave = (double)sum / n;
	mn = 1e9;
	rep(i, n)
	{
		double b = abs((double)ave - a[i]);
		if (mn > b)
		{
			mn = b;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;

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

    LL n, m;
    cin >> n >> m;

    if( n * 2 >= m ) {
        cout << m / 2 << endl;

    } else {
        LL cnt = n;
        m -= n * 2;
        cout << cnt + m / 4 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  char str[200000];
  int i;
  scanf("%s", str);
  for (i=0;str[i]!='\0';i++){
    if(str[i]=='?')
      str[i]='D';
  }
  printf("%s", str);  
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 1e9+7;
ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}

vl fac;
ll inv(ll x) { return modpow(x, mod-2); }
ll ncr(ll n, ll r) {
  if (r < 0 or r > n) return 0;
  return (fac[n] * inv(fac[r]) % mod) * inv(fac[n-r]) % mod;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  fac.pb(1);
  rep(i,1,512345) fac.pb(fac.back()*i%mod);

  ll n, m;
  cin >> n >> m;

  ll ans = 0;
  rep(i,0,n+1) {
    ll res = ncr(n, i);
    res *= ncr(m-i, n-i);
    res %= mod;
    res *= fac[n-i];
    res %= mod;
    if (i&1) res = -res;
    res %= mod; res += mod; res %= mod;
    ans += res;
    ans %= mod;
  }

  ans *= ncr(m, n);
  ans %= mod;
  ans *= fac[n];
  ans %= mod;

  cout << ans << '\n';
}

Measured memory_bytes: 7420
integer(16) H,W,ans,i
read*,H,W
ans=huge(ans)
do i=1,H
  ans=min(ans,maxmin1(i,H,W))
  ans=min(ans,maxmin2(i,H,W))
end do
do i=1,W
  ans=min(ans,maxmin1(i,W,H))
  ans=min(ans,maxmin2(i,W,H))
end do

print"(i0)",ans

contains
function maxmin1(n,H,W)
  integer(16),intent(in)::n,H,W
  integer(16) a,b,c
  integer(16) maxmin1
  a=n*W
  b=(H-N)*((W+1)/2)
  c=(H-N)*(W/2)
  maxmin1=max(a,b,c)-min(a,b,c)
end function
function maxmin2(n,H,W)
  integer(16),intent(in)::n,H,W
  integer(16) a,b,c
  integer(16) maxmin2
  a=n*W
  b=(H-N)/2*W
  c=((H-N+1)/2)*W
  maxmin2=max(a,b,c)-min(a,b,c)
end function
end

Measured memory_bytes: 256
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

lli dp[1 << 19] = {};
lli ans = 0;
template <class T> class bit {
public:
  vector<T> dat;
  int n;

  bit(int n) : n(n) { dat.assign(n, 0); }
  bit(int n, T ini) : n(n) { dat.assign(n, ini); }
  // sum [0,i)
  T sum(int i) {
    int ret = 0;
    for (--i; i >= 0; i = (i & (i + 1)) - 1)
      ret += dat[i];
    return ret;
  }
  // sum [i,j)
  T sum(int i, int j) { return sum(j) - sum(i); }
  // add x to i
  void add(int i, T x) {
    for (; i < n; i |= i + 1)
      dat[i] += x;
  }
};
int trans(vector<int> a) {
  int n = a.size();
  vector<pair<int, int>> v;
  rep(i, n) v.push_back(make_pair(a[i], i));
  bit<lli> bi(n);
  lli sum = 0;
  sort(v.begin(), v.end());
  rep(i, n) {
    sum += bi.sum(v[i].second, n);
    // cout << bi.sum(v[i].second, n) << endl;
    bi.add(v[i].second, 1);
  }
  return sum;
}
void solve(long long N, std::vector<long long> A, std::vector<long long> B) {
  rep(i, 1 << N) dp[i] = 1e9;

  lli ans = 1e9;
  rep(i, 1 << N) {
    vector<int> u(N);
    rep(j, N) {
      if ((1 << j) & i) {
        u[j] = B[j];
      } else {
        u[j] = A[j];
      }
      // cout << u[j] << " ";
    }
    vector<int> v = u;
    vector<int> g(N);
    bool used[55] = {};
    sort(v.begin(), v.end());
    rep(j, N) {
      if ((i & (1 << j)) == 0) {
        rep(l, N) {
          if (((j % 2) == (l % 2)) && v[l] == u[j] && !used[l]) {
            g[j] = l;
            used[l] = true;
            break;
          }
        }
      } else {
        rep(l, N) {
          if (((j % 2) != (l % 2)) && v[l] == u[j] && !used[l]) {
            g[j] = l;
            used[l] = true;
            break;
          }
        }
      }
    }
    bool flag = true;
    rep(j, N) {
      if (!used[j])
        flag = false;
    }
    if (flag) {
      ans = min(ans, (lli)trans(g));
    }
  }
  if (ans != 1e9) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


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

using LL = long long;
struct Vertex {int id; LL coin, time;};
struct Edge {int from, to; LL coin, time;};
using Graph = vector<vector<Edge>>;

int main() {
  int N, M; LL S;
  cin >> N >> M >> S;
  Graph G(N);
  for(auto i=0; i<M; ++i) {
    int U, V; LL A, B;
    cin >> U >> V >> A >> B;
    --U; --V;
    G[U].push_back({U, V, A, B});
    G[V].push_back({V, U, A, B});
  }
  vector<Vertex> V(N);
  for(auto i=0; i<N; ++i) V[i].id = i;
  for(auto& v: V) cin >> v.coin >> v.time;

  vector<LL> d(N, -1);

  priority_queue<Vertex, vector<Vertex>, function<bool(Vertex&, Vertex&)>> q([](auto& l, auto& r){
    if(l.time != r.time) return l.time > r.time;
    if(l.coin != r.coin) return l.coin < r.coin;
    return l.id < r.id;
  });
  vector<vector<LL>> memo(N, vector<LL>(2500+1, -1));

  q.push({0, min<LL>(S,2500), 0});
  while(!q.empty()) {
    auto cur = q.top();
    q.pop();

    if(memo[cur.id][cur.coin] != -1) continue;
    memo[cur.id][cur.coin] = cur.time;
    if(d[cur.id] == -1) d[cur.id] = cur.time;

    for(auto& e: G[cur.id]) {
      auto& v = V[cur.id];
      for(auto nex: {Vertex{e.to, cur.coin-e.coin, cur.time+e.time}, Vertex{v.id, min<LL>(cur.coin+v.coin,2500), cur.time+v.time}})
        if(0 <= nex.coin)
          if(memo[nex.id][nex.coin] == -1)
            q.push({nex.id, nex.coin, nex.time});
    }
  }

  for(auto i=1; i<N; ++i) cout << d[i] << endl;
}


Measured memory_bytes: 10560