akhauriyash/Code-Regression huggingface dataset:
#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<double> v(N);rep(i,N) cin>>v[i];
  
  sort(v.begin(),v.end());
  
  double ans=v[0];
  for(int i=0;i<N;i++){
    ans+=v[i+1]*pow(2,i);
  }
  ans/=pow(2,N-1);
  
  cout << fixed << setprecision(6) << ans << endl;
}
 

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    int ans=1000000;
    for(int i=1;i<101;i++){
        int b=0;
        for(int h=0;h<n;h++){
            b+=pow(i-a.at(h),2);



        }
        ans=min(ans,b);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){

  ll N, M, V, P, tmp;
  vector<ll> A;

  cin >> N >> M >> V >> P;
  for(ll i = 0; i < N; i++){
    cin >> tmp;
    A.push_back(tmp);
  }

  sort(A.begin(), A.end(), greater<ll>());

  cerr << "A:";
  for(ll i = 0; i < N; i++){
    cerr << A[i] << " ";
  }cerr << endl;

  vector<ll> A_accum(N);
  A_accum[0] = A[0];
  for(ll i = 1; i < N; i++){
    A_accum[i] = A_accum[i-1] + A[i];
  }

  ll minscore = 1e10; 
  ll sum_max;
  for(ll prob = 0; prob < N; prob++){
    if(prob < P){
      minscore = A[prob];
      continue;
    }

    if(A[P-1] > A[prob]+M){
      break;
    }

    sum_max = N*M - A_accum[prob] + A_accum[P-2] + A[prob]*(prob+2-P);
    if(sum_max >= V*M){
      minscore = A[prob];
    }
    else{
      break;
    }
  }

  ll ans = 0;
  for(ll i = 0; i < N; i++){
    if(A[i] >= minscore){
      ans++;
    }
  }

  cerr << "Answer:" << endl;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
long long modinv(long long a, long long m) {//modの逆元
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll Factrial(ll num){
  if(num==1||num==0){
    return 1;
  }else if(num<0){
    printf("ERROR_minus\n");
    return 0;
  }else{
    return (num*Factrial(num-1))%d9_7;
  }
}
ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める
  ll ans=1;
  for(ll i=n;i>=n-k+1;i--){
    ans*=i;
    ans%=mod;
  }
  ll k1=Factrial(k);
  k1%=mod;
  ans*=modinv(k1,mod);
  ans%=mod;
  return ans;
}
int main(void){
  ll n,m,k;
  cin>>n>>m>>k;
  ll sum1=0;
  for(ll i=1;i<=n-1;i++){
    sum1+=(n-i)*i;//iが距離
    sum1%=d9_7;
  }
  sum1*=m*m;
  sum1%=d9_7;
  ll sum2=0;
  for(ll i=1;i<=m-1;i++){
    sum2+=(m-i)*i;//iが距離
    sum2%=d9_7;
  }
  sum2*=n*n;
  sum2%=d9_7;
  sum1+=sum2;
  cout<<(sum1*linercomb(n*m-2,k-2,d9_7))%d9_7<<endl;
  return 0;
}

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

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

static const int dx[]={0,1,0,-1};
static const int dy[]={1,0,-1,0};
//right→front→left→back

struct Dice{
   int front, top, right;
   Dice(){}
   Dice(int f, int t, int r):front(f),top(t),right(r){}
};

int n;
int canSee[200][200], height[200][200], ans[7];
int dicePos[7][7];//dicePos[top][front] = right
Dice dice[100];

void init(){
   memset(dicePos,0,sizeof(dicePos));
   dicePos[1][2] = 3; dicePos[1][3] = 5; dicePos[1][5] = 4; dicePos[1][4] = 2;
   dicePos[2][1] = 4; dicePos[2][4] = 6; dicePos[2][6] = 3; dicePos[2][3] = 1;
   dicePos[3][1] = 2; dicePos[3][2] = 6; dicePos[3][6] = 5; dicePos[3][5] = 1;
   dicePos[4][1] = 5; dicePos[4][5] = 6; dicePos[4][6] = 2; dicePos[4][2] = 1;
   dicePos[5][1] = 3; dicePos[5][3] = 6; dicePos[5][6] = 4; dicePos[5][4] = 1;
   dicePos[6][2] = 4; dicePos[6][4] = 5; dicePos[6][5] = 3; dicePos[6][3] = 2;
}

void input(){
   int t,f;
   for(int i = 0 ; i < n ; i++){
      cin >> t >> f;
      dice[i] = Dice(f, t, dicePos[t][f]);
   }      
}

void solve(){
   memset(canSee,0,sizeof(canSee));
   memset(height,0,sizeof(height));
   memset(ans,0,sizeof(ans));   

   for(int i = 0 ; i < n ; i++){
      int x = 100, y = 100;

      if(canSee[x][y]==0){
	 canSee[x][y] = dice[i].top;
	 height[x][y] = 1;
      }
      else{
	 while(true){
	    int dir = -1, val = 3;
	    rep(k,4){
	       int nx = x + dx[k];
	       int ny = y + dy[k];
	       if(height[x][y] > height[nx][ny]){
		  if(k==0){//right
		     if(dice[i].right > val){
			dir = 0;
			val = dice[i].right;
		     }
		  }
		  if(k==1){//front
		     if(dice[i].front > val){
			dir = 1;
			val = dice[i].front;
		     }
		  }
		  if(k==2){//left
		     if(7 - dice[i].right > val){
			dir = 2;
			val = 7 - dice[i].right;
		     }
		  }
		  if(k==3){//back
		     if(7 - dice[i].front > val){
			dir = 3;
			val = 7 - dice[i].front;
		     }
		  }
	       }
	    }
	    
	    if(dir==-1){
	       canSee[x][y] = dice[i].top;
	       height[x][y]++;
	       break;
	    }
	    else{
	       x += dx[dir];
	       y += dy[dir];
	       if(dir==0)dice[i] = Dice(dice[i].front, 7-dice[i].right, dice[i].top);//right
	       if(dir==1)dice[i] = Dice(dice[i].top, 7-dice[i].front, dice[i].right);//front
	       if(dir==2)dice[i] = Dice(dice[i].front, dice[i].right, 7-dice[i].top);//left
	       if(dir==3)dice[i] = Dice(7-dice[i].top, dice[i].front, dice[i].right);//back
	    }
	 }
      }
   }

   //count
   for(int i = 0 ; i < 200 ; i++){
      for(int j = 0 ; j < 200 ; j++){
	 ans[canSee[i][j]]++;
      }
   }
   
   //output
   for(int i = 1 ; i <= 6 ; i++){
      if(i==6)cout << ans[i] << endl;
      else cout << ans[i] << " ";
   }
}

int main(){
   init();
   while(cin >> n){
      if(n==0)break;
      input();
      solve();
   }
   return 0;
}


Measured memory_bytes: 3428
N = int(input())
S = input()
max_value = 0
current_value = 0
for i in range(len(S)) :
    if (S[i] == 'I') :
        current_value += 1
        if (max_value < current_value) :
            max_value = current_value
    else :
        current_value -= 1

print(max_value)

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

using namespace std;

int main() {
	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n);
	vector<int> b(m);

	for (int i = 0; i < n; i++) cin >> a[i];
	for (int j = 0; j < m; j++) cin >> b[j];

	vector<long long> asum(n + 1, 0);
	vector<long long> bsum(m + 1, 0);

	for (int i = 0; i < n; i++) asum[i + 1] = asum[i] + a[i];
	for (int i = 0; i < m; i++) bsum[i + 1] = bsum[i] + b[i];

	int total = 0;

	for (int i = 0; i <= n; i++) {
		long long sb = k - asum[i];
		if (sb < 0) continue;
		int l = lower_bound(bsum.begin(), bsum.end(), sb) - bsum.begin();
		if (l > m || bsum[l] > sb) l--;
		total = max(total, l + i);
	}

	cout << total;
}


Measured memory_bytes: 8012
#include<stdio.h>

int main(void) {
    
    int H[300] = {};
    int W[300] = {};
    int i, j, k, l;
    
    for(i = 0; i < 300; i++) {
        scanf("%d %d", &H[i], &W[i]);
        if(H[i] == 0 && W[i] == 0) {
            break;
        }
    }
    
    for(j = 0; j < i; j++) {
        for(k = 1; k <= H[j]; k++) {
            for(l = 1; l <= W[j]; l++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct Fordfulkerson{
  const int INF = 1 << 28;
  struct edge{
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> used;
  
  Fordfulkerson(){}
  Fordfulkerson(int sz):n(sz),G(n),used(n){}
  
  void add_edge(int from,int to,int cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
 
  int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to] && e.cap > 0 ){
	int d=dfs(e.to,t,min(f,e.cap));
	if(d>0){
	  e.cap-=d;
	  G[e.to][e.rev].cap+=d;
	  return d;
	}
      } 
    }
    return 0;
  }
 
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      fill(used.begin(),used.end(),0);
      int f=dfs(s,t,lim);
      if(f==0) return fl;
      fl+=f;
      lim-=f;
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }
  
};
//END CUT HERE

signed main(){
  int V,E;
  cin>>V>>E;
  Fordfulkerson flow(V);
  for(int i=0;i<E;i++){
    int u,v,c;
    cin>>u>>v>>c;
    flow.add_edge(u,v,c);
  }
  cout<<flow.flow(0,V-1)<<endl;
  return 0;
}

/*
verified on 2017/10/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
*/



Measured memory_bytes: 3128
from collections import deque

N,D,A = map(int,input().split())
mons = [list(map(int,input().split())) for i in range(N)]
for i in range(N):
    mons[i][1] = (mons[i][1]+A-1)//A

mons.sort(key=lambda x: x[0])

damages = deque()
nowdmg = 0
ans = 0
for i in range(N):
    while len(damages) != 0:
        if mons[i][0] >= damages[0][0]+1:
            rec = damages.popleft()
            nowdmg += rec[1]
        else:
            break
    if mons[i][1]+nowdmg > 0:
        c = mons[i][1]+nowdmg
        ans += c
        damages.append([mons[i][0]+2*D,c])
        nowdmg -= c

#print(mons)
print(ans)


Measured memory_bytes: 66460
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin>>n;
	pair<int,int> job[n];
	rep(i,n){
		int a,b; cin>>a>>b;
		job[i]={b,a};
	}
	sort(job,job+n);
	int now=0;
	for(int i=0;i<n;i++){
		// cerr<<now<<endl;
		now+=job[i].second;
		if(now>job[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(1e9+7)
using namespace std;
signed main(){
	fastIO

    int r;
    cin >> r;
    cout << 2*r*(3.14);


    return 0;

}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,begin,end) for(__typeof(end) i = (begin)-((begin)>(end)); i != (end)-((begin)>(end)); i += 1-2*((begin)>(end)))
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 1e-8
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 101010
#define LOGN 20
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

int n, ans;
vi v;
char ss[MAXN];
string s;


int main(){
	scanf("%s",ss);
	n = strlen(ss);
	rep(i,0,n) s += ss[i];
	v.pb(1);
	rep(i,1,sz(s)){
		if(s[i]==s[i-1]) v.back()++;
		else v.pb(1);
	}
	ans = max(n/2,*max_element(all(v)));
	ans = max(ans, min(v[0],n-v[0]));
	ans = max(ans, min(v.back(),n-v.back()));
	int l = 0, r = n-v[0];
	rep(i,1,sz(v)-1){
		r -= v[i];
		l += v[i-1];
		ans = max(ans, v[i]+min(l,r));
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 896
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split(" "))))

for i in range(201):
    ans = sum([k ** 2 for k in X - i])
    if i > 0:
        ans_min = min(ans_min, ans)
    else:
        ans_min = ans
print(ans_min)

Measured memory_bytes: 18880
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	int a = read() , b = read() ;
	print(a * b / __gcd(a , b)) ; 
	return 0 ;
}

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

#define MAXN 100001

using namespace std;

using wvp = pair<int, int>;
using ull = unsigned long long int;

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

    int N, W;
    cin >> N >> W;
    vector<wvp> WV(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> WV[i].first >> WV[i].second;
    }

    vector<ull> dp(MAXN, 1ll<<30);
    dp[0] = 0;

    for (int i = 0; i < N; ++i)
    {
        for (int j = MAXN-1; j >=WV[i].second; --j)
        {
            dp[j] = min(dp[j], dp[j-WV[i].second]+WV[i].first);
        }
    }

    for (int j = MAXN-1; j >=0; --j)
    {
        if(dp[j]<=W) {
            cout << j <<"\n";
            break;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

void print(vector<vector<char>>& grid)
{
    return;
    for (auto& row : grid)
    {
        for (auto& cell : row)
        {
            cout << cell;
        }
        cout << endl;
    }
    cout << endl;
}

int main()
{
    size_t H, W;
    cin >> H >> W;

    vector<vector<char>> s(H); // y, x
    for (auto& row : s)
    {
        row.resize(W);
        for (auto& cell : row)
        {
            cin >> cell;
        }
    }

    vector<vector<char>> canvas(H);
    for (auto& row : canvas)
    {
        row.resize(W);
        for (auto& cell : row)
        {
            cell = '.';
        }
    }

    print(s);
    print(canvas);

    // vertical
    for (size_t x = 0; x < W; ++x)
    {
        for (size_t y = 0; y < H; ++y)
        {
            auto cell = s.at(y).at(x);
            if (cell == '.')
            {
                continue;
            }
            else
            {
                if (H != y + 1 && s.at(y + 1).at(x) == '#')
                {
                    canvas.at(y).at(x) = '#';
                    canvas.at(y + 1).at(x) = '#';
                }
            }
        }
    }

    // horizontal
    for (size_t y = 0; y < H; ++y)
    {
        for (size_t x = 0; x < W; ++x)
        {
            auto cell = s.at(y).at(x);
            if (cell == '.')
            {
                continue;
            }
            else
            {
                if (W != x + 1 && s.at(y).at(x + 1) == '#')
                {
                    canvas.at(y).at(x) = '#';
                    canvas.at(y).at(x + 1) = '#';
                }
            }
        }
    }

    print(s);
    print(canvas);

    if (canvas == s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
//ABC 155 E Payment
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1e9;

int dp[1000010][2];
    
int main() {
    string s;
    
    cin >> s;
    s = '0'+s+'0';
    //reverse(s.begin(),s.end())
	//s += '0';
    
	for(int i=0; i<s.size(); ++i)  
	  s[i] -= '0';
    
    dp[0][1] = INF;
    
	for(int i=1; i<=s.size()-1; ++i){
      dp[i][0]=min(dp[i-1][0]+s[i],dp[i-1][1]+s[i]+1);
      dp[i][1]=min(dp[i-1][0]+10-s[i],dp[i-1][1]+9-s[i]);
    }
    
    cout << dp[s.size()-1][0] << '\n';
    return 0;
}


Measured memory_bytes: 9136
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

signed main() {
    int N, X; cin >> N >> X;

    int g = -1;
    for(int i=0; i<N; i++) {
        int val; cin >> val;
        val = abs(X - val);

        g = (g < 0 ? val : __gcd(g, val));
    }

    cout << g << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,acount=0,bcount=0;
  cin >>n;
  string s;
  cin >>s;
  for(int i=0;i<n;i++){
    if(s[i]=='R')acount++;
    else bcount++;
  }
  if(acount>bcount)cout << "Yes" <<endl;
  else cout <<"No" <<endl;
}

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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll p[N][3];
ll dp[N][3];
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int c = count(s.begin(), s.end(), '1');
	if(!c)
	{
		while(n --)
			cout << 1 << '\n';
		return 0;
	}
	ll q1 = 1, q2 = 1, q3 = 1;
	for(int i = n - 1; ~i; i --)
	{
		p[i][0] = q1;
		p[i][1] = q2;
		p[i][2] = q3;
		if(c != 1)
		dp[i][0] =  (dp[i + 1][0] + p[i][0]*(s[i] == '1')) % (c - 1);
		dp[i][1] = (dp[i + 1][1] + p[i][1]*(s[i] == '1')) % c;
		dp[i][2] = (dp[i + 1][2] + p[i][2]*(s[i] == '1')) % (c + 1);
		q1 *= 2ll;
		q2 *= 2ll;
		q3 *= 2ll;
		if(c != 1)
		q1 %= (c - 1);
		q2 %= (c);
		q3 %= (c + 1);
	}
	q1 = 0; q2 = 0; q3 = 0;
	for(int i = 0; i < n; i ++)
	{
		int ans = 0;
		if(s[i] == '1')
		{
			if(c == 1)
			{
			}
			else
			{
			ll q = (dp[i + 1][0] + q1) % (c-1);
			ans ++;
			while(q > 0)
			{
				ll o = __builtin_popcount(q);
				q = q % o;
				ans ++;
			}
			}
		}
		else
		{
			ll q = (dp[i + 1][2] + q3 + p[i][2]*(s[i] == '0')) % (c + 1);
			ans ++;
			while(q > 0)
			{
				ll o = __builtin_popcount(q);
				q = q % o;
				ans ++;				
			}
		}
		q1 += p[i][0]*(s[i] == '1');
		q2 += p[i][1]*(s[i] == '1');
		q3 += p[i][2]*(s[i] == '1');
		if(c != 1)
			q1 %= (c - 1);
		q2 %= (c);
		q3 %= (c + 1);
		cout << ans << '\n';
	}
	
	





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 13128
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import accumulate
    dh = 10

    n = int(readline())
    t_ = [0] + list(map(int, readline().split()))
    t_list = list(accumulate(t_))
    v_list = list(map(int, readline().split())) + [0]
    lim = [0] * (sum(t_list) * dh + 1)

    for i in range(n):
        st = dh * t_list[i]
        nt = dh * t_list[i + 1]
        cv = v_list[i]
        pv = lim[st]
        nv = v_list[i + 1]
        for ct in range(st, nt + 1):
            lim[ct] = min(cv, pv + (ct - st) / dh)

    for i in range(1, n + 1):
        st = dh * t_list[i]
        sv = v_list[i]
        for ct in range(st, -1, -1):
            lim[ct] = min(lim[ct], sv + (st - ct) / dh)

    ans = 0
    pv = 0
    for v in lim[1:]:
        ans += (pv + (v - pv) / 2) / dh
        pv = v

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 223052
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
using namespace std;

const int NMAX=2005;
const int inf=1<<29;

int n,k,dp[NMAX][NMAX],sub[NMAX];
int a[NMAX],b[NMAX],c[NMAX];
vector<int>t[NMAX],v[NMAX];

void Dfsaux(int x,const int f)
{
    sub[x]=1;
    for (auto it : t[x])
        if (it!=f)
        {
            v[x].push_back(it);
            Dfsaux(it,x);
            sub[x]+=sub[it];
        }
}

void Dfs(int x)
{
    for (auto it : v[x])
        Dfs(it);
    if (!v[x].size())
        {
            dp[x][1]=0;
            dp[x][0]=1;
        }
    else
    {
        int i,j,aux;
        dp[x][0]=sub[x];
        for (i=1;i<=(k+1);i++) dp[x][i]=dp[v[x][0]][i-1];
        for (i=1;i<v[x].size();i++)
        {
           aux=v[x][i];
           for (j=0;j<=n;j++)
           {
               a[j]=dp[x][j];
               if (j>=1) a[j]=min(a[j],a[j-1]);
               b[j]=dp[aux][j];
               if (j>=1) b[j]=min(b[j],b[j-1]);
           }
           for (j=1;j<=(k+1);j++)
           {
               c[j]=inf;
               //case 1
               c[j]=min(c[j],dp[aux][j-1]+a[min(j,k-j+2)]);
               //case 2
               c[j]=min(c[j],dp[x][j]+b[min(j-1,k-j+1)]);

               dp[x][j]=c[j];
           }
        }

    }
}

int main()
{
    int i,j,x,y,sol;
  //  freopen("date.in","r",stdin);
  //  freopen("date.out","w",stdout);
    cin.sync_with_stdio(false);
    cin>>n>>k;
    for (i=1;i<n;i++)
    {
        cin>>x>>y;
        t[x].push_back(y);
        t[y].push_back(x);
    }
    for (i=0;i<=n;i++)
        for (j=0;j<=n;j++)
            dp[i][j]=inf;
    Dfsaux(1,0);
    Dfs(1);

    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++) dp[i][j]=min(dp[i][j],dp[i][j-1]);
    sol=inf;
    for (i=1;i<=n;i++) sol=min(sol,dp[i][k+1]+(n-sub[i]));
    cout<<sol<<"\n";
    return 0;
}



Measured memory_bytes: 16256
import bisect
import sys

x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p.sort()
tmp_ans = 100000
index = bisect.bisect_left(p, x)
if len(p) == 0 or p[index] != x:
  print(x)
else:
  i = index
  cnt = 0
  while True:
    cnt += 1
    if i - cnt < 0:
      tmp_ans = x-cnt
      break
    if p[i-cnt] != x-cnt:
      tmp_ans = x-cnt
      break
  i = index
  cnt = 0
  while True:
    cnt += 1
    if i + cnt >= len(p):
      if abs(tmp_ans-x) > abs(cnt):
        tmp_ans = x+cnt
      break
    if p[i+cnt] != x+cnt:
      if abs(tmp_ans-x) > abs(cnt):
        tmp_ans = x+cnt
      break

  print(tmp_ans)

Measured memory_bytes: 62032
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> q;//设置优先队列，进入优先队列都会从小到大排好 
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		q.push(t);//进入队列 
	}
	while(m--)
	{
		int flag=q.top();
		flag/=2;
		q.pop();
		q.push(flag);
	}
	long long sum=0;
	while(!q.empty())
	{
		sum+=q.top();
		q.pop();
	 } 
	 cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 892
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int x=scan.nextInt();
    int Ans=0, x1=0;
    boolean flag=false;
    if(x==2){
      Ans=2;
      flag=true;
    }else if(x%2==0){
      x1=x+1;
    }else{
      x1=x;
    }
    while(!flag){
      for(int a=2; a<x1; a++){
        if(x1%a==0){
          flag=true;
        }
      }
      if(!flag){
        Ans=x1;
        flag=true;
      }else{
        flag=false;
      }
      x1+=2;
    }
    System.out.println(Ans);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define inf 1e9+1
ll int maxProfit(ll a[],ll v[],int w,int n){

    
    int m=n*1000;

    ll int dp[n+1][m+1];

    for(int i=1;i<=m;i++){
        dp[0][i]=inf;
    }

    dp[0][0]=0;

    

    for(int i=1;i<=n;i++){
        dp[i][0]=0;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){

            if(v[i-1]<=j){
                dp[i][j]=min(dp[i-1][j],a[i-1]+dp[i-1][j-v[i-1]]);
            }else{
                dp[i][j]=dp[i-1][j];

            }

        }
    }


    int ans=0;

    for(int i=0;i<=m;i++){
        
        if(dp[n][i]<=w){
            ans=max(ans,i);
        }
    }


    return ans;

}

int main() {
    int n,w;
    cin>>n>>w;
    
    ll a[n];
    ll v[n];


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

    }

    cout<<maxProfit(a,v,w,n);





}


Measured memory_bytes: 82500
import collections
class Dinic:
    def __init__(self, n):
        self.n = n
        self.g = [[] for i in range(n)]
    def add_edge(self, fr, to, cap):
        self.g[fr].append([to, cap, len(self.g[to])])
        self.g[to].append([fr, 0, len(self.g[fr])-1])
    def add_multi_edge(self, v1, v2, cap1, cap2):
        self.g[v1].append([v2, cap1, len(self.g[v2])])
        self.g[v2].append([v1, cap2, len(self.g[v1])-1])
    def bfs(self, s):
        level = [-1]*self.n
        deq = collections.deque()
        level[s] = 0
        deq.append(s)
        while deq:
            v = deq.popleft()
            for e in self.g[v]:
                if e[1]>0 and level[e[0]]<0:
                    level[e[0]] = level[v] + 1
                    deq.append(e[0])
        self.level = level
    def dfs(self, v, t, f):
        if v==t: return f
        es = self.g[v]
        level = self.level
        for i in range(self.it[v], len(self.g[v])):
            e = es[i]
            if e[1]>0 and level[v]<level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d>0:
                    e[1] -= d
                    self.g[e[0]][e[2]][1] += d
                    self.it[v] = i
                    return d
        self.it[v] = len(self.g[v])
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0: break
            self.it = [0]*self.n
            while True:
                f = self.dfs(s, t, 10**9+7)
                if f>0:
                    flow += f
                else:
                    break
        return flow

N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
Q = [list(map(int, input().split())) for i in range(N)]
dinic = Dinic(2*N+2)
for i in range(N):
    dinic.add_edge(0, 2+i, 1)
    dinic.add_edge(2+N+i, 1, 1)
for i in range(N):
    a, b = P[i]
    for j in range(N):
        c, d = Q[j]
        if a < c and b < d:
            dinic.add_edge(2+i, 2+N+j, 1)
print(dinic.max_flow(0, 1))

Measured memory_bytes: 3956
#include<stdio.h>
int main(void){
  int N,n;
  scanf("%d",&N);
  n=N%10;
  if(n==3){
    printf("bon\n");
  }
  else if(n==0 || n==1 || n==6 || n==8){
    printf("pon\n");
  }
  else{
    printf("hon\n");
  }
  return 0;
}


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

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

  vector<int> x(n);
  //vectorに全入力値を代入する
  rep(i,n) cin >> x[i];

  //座標Pを全パターンを検証する
  int ans = 1001001001;//無限大の値
  for (int p = 1; p <= 100; ++p) {
    int now = 0;
    rep(i,n) now += (x[i] - p) * (x[i] - p);
    ans = min(ans, now);//最小値を出すため、小さい方を採用する
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include<cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>

using namespace std;
const int mod=1000000007;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int t,n,m,k,q,d,x,l,a,b,c;
    cin>>a>>b;
    if(a==1||b==1) {cout<<1<<"\n";return 0;}
    cout<<(long long)(ceil(b/2.0)*ceil(a/2.0)+(a-ceil(a/2.0))*ceil((b-1)/2.0))<<"\n";
    
    return 0;
}


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

long long INF = 1e18;

struct Edge{
    int from;
    int to;
    int cost;
};
int main(){
    string s;
    char d[110];
    cin>>s;

    for( int i=0;i<s.size();i++){
        d[i] = s[i];
    }
    reverse(s.begin(),s.end());
     int ans = 0;

     for(int i = 0; i<s.size();i++){
         if(d[i] != s[i]){
             ans++;
         }
     }
     cout<<ans/2<<endl;
     return 0;
}

Measured memory_bytes: 384
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	K := readInt()
	var ans float64
	for i := 1; i <= N; i++ {
		var t int64 = 1
		for j := i; j < K; j *= 2 {
			t *= 2
		}
		ans += 1 / float64(t)
	}
	println(ans / float64(N))
}

// -----------------------------------------------------------------------------


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << (a + b >= c ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 4/29
// Problem:/ / / a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

string A, B;

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

  cin >> A >> B;

  string ans;
  if (A.size() > B.size()) {
    ans = "GREATER";
  } else if (A.size() < B.size()) {
    ans = "LESS";
  } else {
    if (A > B) ans = "GREATER";
    else if (A < B) ans = "LESS";
    else ans = "EQUAL";
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
/*
 * Author: luyanan
 * Created Time:  2011/8/24 12:49:43
 * File Name: a.cpp
 */
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define SZ(v) ((int)(v).size())
#define lson (t<<1)
#define rson (t<<1|1)
#define maxn 100
int a[maxn];
int t;
void work()
{
    int last = 0;
    int now = 0;
    for( int i = 0; i < t - 1; i++)
    {
        if( a[i+1] - a[i]  > 1)
        {
            if( a[last] > a[0])
                printf(" ");
            now = i;
            if( now != last )
            {
                printf("%d-%d",a[last],a[now]);
            }
            else
            {
                printf("%d",a[now]);
            }
            last = i+1;
        }
    }
    if( a[last] > a[0])
        printf(" ");
    if( a[last] == a[t-1])
        printf("%d",a[last]);
    else
    {
        printf("%d-%d",a[last],a[t-1]);
    } 
}
int main() 
{  
    //freopen("1.out","w",stdout);
    while(true)
    {
        scanf("%d", &t);
        if( t == 0)
            break;
        for( int i = 0; i < t; i++)
        {
            scanf("%d", &a[i]);
        }
        work();
        printf("\n");
    }    
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
typedef long long ll;
using namespace std;
const int N=100000;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,a[N],dp[N],i,j;
	cin>>n;
	for(i=0;i<n;++i) cin>>a[i];
	dp[1]=abs(a[0]-a[1]);
	dp[2]=abs(a[0]-a[2]);
	for(i=3;i<n;++i){
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
}

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

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

  int cnt = 0;
  for(int x = a; x <= b; x++){
    if(c % x == 0) cnt++;
  }

  cout<<cnt<<endl;

  return 0;

}



Measured memory_bytes: 3108
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char O[50];
    char E[50];
    char temp[100];
    scanf("%s",&O);
    scanf("%s", &E);
    int lo=strlen(O),i,j,c;
    int le=strlen(E);
    c=lo+le;
    for(i=0,j=0; i<c; i++,j++){
        temp[i]=O[j];
        temp[i+1]=E[j];
        i++;
    }
    temp[i]='\0';
        printf("%s\n",temp);

    return 0;
}



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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

// OBS: EACH NUMBER HAS AT MOST ∛N DIVISORS
vector<int> divisors(int n) {
  int sq = sqrt(n);
  vector<int> ans;
  for (int i=1; i<=sq+1; i++) {
    if (n%i==0) {
      // If divisors are equal, print only one
      if (n/i == i)
        ans.pb(i);
  
      else // Otherwise print both
        ans.pb(i), ans.pb(n/i);
    }
  }
  return ans;
}

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

  int n, k;

  cin >> n >> k;

  vector<int> arr(n);

  int sum = 0;
  for(int &x: arr)
    cin >> x, sum += x;

  vector<int> div = divisors(sum);
  sort(div.begin(), div.end(), greater<int>());

  for(int x: div) {
    multiset<int> v;

    int tot, used;
    tot = used = 0;

    for(int j = 0; j < n; j++) {
      v.insert(arr[j]%x);
      tot += x - (arr[j] % x);
    }

    for(int y: v) {
      used += y;
      tot -= x - y;
      if(used == tot and used <= k)
        return cout << x << endl, 0;
    }
  }

  cout << 1 << endl;

}



Measured memory_bytes: 256
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(str(type(var)) + name +":" + " = " + repr(var), file=stderr)
    return


def main():
    N, K = list(map(int,input().split()))
    K = bin(K)[2:].zfill(51)
    a = list(map(int,input().split()))
    for i in range(len(a)):
        a[i] = bin(a[i])[2:].zfill(51)
    # memo[決めた桁目(上位から)][K未満 == 1 not == 0] = そのときの最大値
    memo = [0 for __ in range(51)]
    LT = False
    for i in range(51):
        val = 0
        br = 0
        # 1と0の場合,ただしKのi桁目と超えたかにもよって0だけ
        for b in range(2 if LT or K[i] == '1' else 1):
            valtmp = 0
            for n in a:
                valtmp += b ^ int(n[i])
            if val < valtmp :
                br = b
                val = valtmp
        memo[i] = val
        LT = br < int(K[i]) or LT


    p = 1
    ans = 0
    for i in range(50,-1,-1):
        ans += p*memo[i]
        p *= 2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 91352
import sys
from math import floor
import itertools
import collections

def solve(A,B,N):
    if(B > N):
        x = N
    else:
        x = B - 1
    return floor((A*x)/B) - A * floor(x/B)

# def solve2(A,B,N):
#     ans = 0
#     for n in range(1,N+1):
#         ans = max(ans,floor(A*n/B) - A * floor(n/B))
#         # print(n,floor(A*n/B) - A * floor(n/B))
#     return ans

def main():
    A,B,N = map(int,input().split())
    # solve()
    print(solve(A,B,N))
    # print(solve2(A,B,N))
if __name__ == '__main__':
   main()




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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> costDay(M);
    for (int i = 0; i < M; i++)
    {
        cin >> costDay.at(i);
    }
    int sumCostDays = 0;
    for (int i = 0; i < costDay.size(); i++)
    {
        sumCostDays += costDay.at(i);
    }
    int playDays = N - sumCostDays;
    if (playDays < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << playDays << endl;
    }
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mod=1e9+7;
int main(int argc, char const *argv[]) {
    int s; cin>>s;
    vector<int>dp(s+1);
    dp[0]=1;
    for(int sum=1;sum<=s;sum++) {
        for(int x=3;x<=s;x++) {
            if(sum-x>=0) {
                dp[sum]=(dp[sum]+dp[sum-x])%mod;
            }
        }
    }
    cout<<dp[s]<<endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0;i < n;i++) cin >> d[i];
    sort(d.begin(),d.end());
    int ans = d[n/2] - d[n/2 - 1];
    cout << ans << endl;
     return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int upto(int a) {
    ++a;
    int ans = (a%4 == 2 || a%4 == 3 ? 1 : 0);
    for(int i = 1; 1LL<<i < a; ++i) {
        int num = 1LL<<(i+1);
        int cur = a%num;
        cur -= num/2;
        if(cur > 0 && cur%2) {
            ans += 1LL<<i;
        }
    }
    return ans;
}

int32_t main() {

    int a, b; cin >> a >> b;
    int ans = upto(a-1) ^ upto(b);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(long long i=0;i<n;i++)
#define SFOR(i,a,b) for(long long i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  double ans=0,a;
  cin>>n;
  FOR(i,n){
    cin>>a;
    ans+=(double)1/a;
  }
  cout<<(double)1/ans<<endl;
  return 0;
}



Measured memory_bytes: 256
M;m;main(N,q){
int c[8]={};
scanf("%d",&N);
for(int i=0;i<N;i++){
	scanf("%d",&q);
  	q/=400;
  	q<8?c[q]=1:M++;
}
for(int j=0;j<8;j++){
	M+=c[j];   
	m+=c[j];
}
if(!m)m++;
	printf("%d %d",m,M);
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n;
    cin >> n;

    string ans = "";
    rep(i, 60) {
        ll now = 1LL<<i;
        if (i%2==1) now *= -1;
        if (abs(n)%abs(now*2)) {
            ans += '1';
            n -= now;
        }
        else ans += '0';
        if (n==0) break;
    }
    reverse(whole(ans));
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <climits>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
using namespace std;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define fi first
#define se second
#define ii pair<int, int>
#define ll long long
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("Test.inp", "r", stdin);
	//freopen("Test.out", "w", stdout);
	int n, m, x = 0;
	cin >> n >> m;
	rep(i, 1, m) {
		int t;
		cin >> t;
		x += t;
	}
	if (x > n) cout << -1;
	else cout << n - x;
	return 0;
}

Measured memory_bytes: 3656
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int f(int X){
    int res = 0;
    while(X){
        res += X%10;
        X /= 10;
    }
    return res;
}

int main(void){
    int N,A,B; cin >> N >> A >> B;
    int ans=0;
    FOR(i,1,N+1){
        if(A <= f(i) && f(i) <= B) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt()-1;
        int b = sc.nextInt()-1;
        int c = sc.nextInt()-1;
        int d = sc.nextInt()-1;
        char[] s = sc.next().toCharArray();
        boolean ans = true;
        boolean cross = d < c;
        int idx = a;
        boolean tmp1 = false;
        while(true){
            if(c - idx < 3){
                tmp1 = true;
                break;
            }
            if(idx+2 < n && s[idx+2] != '#') idx += 2;
            else if(idx+1 < n && s[idx+1] != '#') idx += 1;
            else {
                tmp1 = false;
                break;
            }
        }
        idx = b;
        boolean tmp2 = false;
        while(true){
            if(d - idx < 3){
                tmp2 = true;
                break;
            }
            if(idx+2 < n && s[idx+2] != '#') idx += 2;
            else if(idx+1 < n && s[idx+1] != '#') idx += 1;
            else {
                tmp2 = false;
                break;
            }
        }
        if(tmp1 && tmp2){
            if(cross){
                int tmp = 0;
                int max = 0;
                for (int i = b-1; i <= d+1; i++) {
                    if(s[i] == '.'){
                        tmp++;
                    }else{
                        if(max < tmp) max = tmp;
                        tmp = 0;
                    }
                }
                if(2 < Math.max(max, tmp)) ans = true;
                else ans = false;
            }else{
                ans = true;
            }
        }else{
            ans = false;
        }
        System.out.println(ans ? "Yes":"No");
        sc.close();

    }

}


Measured memory_bytes: 26196