akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    char day[8]={};
    int next = 0;
    scanf("%s", day);

    if(strcmp(day, "SUN")==0){
        next = 7;
    }else if(strcmp(day, "MON")==0){
        next = 6;
    }else if(strcmp(day, "TUE")==0){
        next = 5;
    }else if(strcmp(day, "WED")==0){
        next = 4;
    }else if(strcmp(day, "THU")==0){
        next = 3;
    }else if(strcmp(day, "FRI")==0){
        next = 2;
    }else if(strcmp(day, "SAT")==0){
        next = 1;
    }

    printf("%d\n", next);

    return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

		 // 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main() {

	const ll mod = 1000000007;
	ll n; cin >> n;	
	map<ll, ll> mp;
	for (ll i = 1; i <= n; i++) {
		vector<pair<long long, long long>> a_prime;  // a^x ならば { a, x }
		a_prime = prime_factorize(i);
		for (ll i = 0; i < a_prime.size(); i++) {
			mp[a_prime[i].first] += a_prime[i].second;
		}
	}
	ll ans = 1;
	for (auto u : mp) {
		ans *= u.second + 1;
		ans %= mod;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int ans = 1;
	long long int v, i;
	if (n < 100)
	{
		for (i = 2; i < n; i++)
		{
			v = n;
			while (v % i == 0)
				v /= i;
			v %= i;
			if (v == 1)
				ans++;
		}
		printf("%lld\n", ans);
	}
	else
	{
		for (i = 2; i * i <= n; i++)
		{
			v = n;
			while (v % i == 0)
				v /= i;
			v %= i;
			if (v == 1)
				ans++;
		}
		long long int s = i - 1;
		for (i = 1; i * i <= n; i++)
		{
			if ((n - 1) % i == 0)
			{
				if ((n - 1) / i > s)
					ans++;
				else
					break;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
void bfs(ll node,ve <ll> adj[],ve<bool> &visit,ve<ll> &dis)
{
    queue<ll> q;
    // ve<bool> visit(n+1);
    // ve<ll> dis(n+1);
    visit[node] = true;
    dis[node] = 0;
    q.push(node);
    while (!q.empty())
    {
        ll s = q.front();
        q.pop();
        // process node s
        for (auto u : adj[s])
        {
            if (visit[u])
                continue;
            visit[u] = true;
            dis[u] = dis[s] + 1;
            q.push(u);
        }
    }
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,x,y;
    cin>>n>>x>>y;
    ve <ll> adj[n+1];
    rep (i,1,n)
    {
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    adj[x].pb(y);
    adj[y].pb(x);
    ve <ve <ll>> dis(n+1,ve <ll> (n+1,0));
    rep (i,1,n+1)
    {
        ve <bool> visit(n+1,false);
        bfs(i,adj,visit,dis[i]);
    }
    ve <ll> ans(n+1);
    rep (i,1,n+1)
    {
        rep (j,i+1,n+1)
        {
            ans[dis[i][j]]++;
        }
    }
    rep (i,1,n)
    {
        cout<<ans[i]<<"\n";
    }

}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    long long int sum=0;
    int count=-1;
    for (int i=b.size()-1;i>=0;i--) {
        string tmp="";
        if (b[i]!='.') {
            count++;
            int kuriagari=0;
            for (int j=a.size()-1;j>=0;j--) {
                int hoge=(b[i]-48)*(a[j]-48)+kuriagari;
                //cout<<b[i]<<" "<<a[j]<<endl;
                if (j!=0&&hoge>=10) {
                    tmp=to_string(hoge)[1]+tmp;
                    //cout<<tmp<<endl;
                    kuriagari=hoge/10;
                } else {
                    kuriagari=0;
                    tmp=to_string(hoge)+tmp;
                    //cout<<tmp<<endl;
                }
            }
        }
        for (int k=0;k<count;k++) {
            tmp+="0";
        }
        sum+=stoll(tmp);
        //cout<<sum<<endl;
    }
    cout<<sum/100<<endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else if (a + b > c + d) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/06  Problem: codefestival2017_team_relay_j / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	N *= 2;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	SORT(a);
	LL sum = 0;
	FOR(i, 0, N) {
		sum += 1LL *i* a[i];
	}
	cout << fixed << setprecision(15) << 1.0*sum / (N - 1) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int ans=min(n*a,b);
  cout<<ans<<endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
#define ullong unsigned long long
#define popb pop_back
#define popf pop_front
#define pushb push_back
#define pushf push_front
#define S second
#define F first
#define Need_for_speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const long long MXN = 1e5 + 7;
const long long MOD = 1e9 + 7;
const long double PI = 3.14;
const long long INF = 1e18 + 123;

int main()
{
    Need_for_speed;
    ll a, b, c = 3;
    cin >> a >> b;
    if ((a * b * c) % 2 == 1) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int h, n, a;

int main() {
    scanf("%d%d", &h, &n);
    int sm = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        sm += a;
    }
    printf("%s\n", (sm >= h) ? "Yes" : "No");
}   

Measured memory_bytes: 128
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		int n=s.nextInt();
		int a=s.nextInt();
		int b=s.nextInt();
		System.out.println(Math.min(a,b)+" "+Math.max(0,a+b-n));
	}
}

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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

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

	int n; cin >> n;
	int a[n][n];
	ll ans = 0;
	FOR (i, 0, n - 1) FOR (j, 0, n - 1) cin >> a[i][j];
	FOR (i, 0, n - 1) {
		FOR (j, i + 1, n - 1) if (i ^ j) {
			bool f = 1;
			FOR (k, 0, n - 1) if ((i ^ k) and (j ^ k)){
				if (a[i][j] == a[i][k] + a[k][j]) {
					f = 0;
				} else if (a[i][j] > a[i][k] + a[k][j]) {
					return cout << "-1\n", 0;
				}
			}
			if (f) ans += a[i][j];
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
  public static void main(String[] args){
    int dx[] = { 1, 0};
    int dy[] = { 0, 1};
    Scanner sc = new Scanner(System.in);
    int h=sc.nextInt();
    int w=sc.nextInt();
    StringBuilder[] a = new StringBuilder[h];
    for(int i=0;i<h;i++){
      a[i]=new StringBuilder(sc.next());
    }
    int[][] dp = new int[h][w];
    dp[0][0] = 1;
    Deque<Xy> dq = new ArrayDeque<>();
    dq.addLast(new Xy(0,0));
    while(!dq.isEmpty()){
      Xy p = dq.pollFirst();
      if(a[p.y].charAt(p.x)=='#'){continue;}
      a[p.y].setCharAt(p.x,'#');
      for(int i=0;i<2;i++){
        if(0<=p.x+dx[i]&&p.x+dx[i]<w&&0<=p.y+dy[i]&&p.y+dy[i]<h&&a[p.y+dy[i]].charAt(p.x+dx[i])=='.'){
          dp[p.y+dy[i]][p.x+dx[i]]=(dp[p.y+dy[i]][p.x+dx[i]]+dp[p.y][p.x])%1000000007;
          dq.addLast(new Xy(p.x+dx[i],p.y+dy[i]));
        }
      }
    }
    System.out.println(dp[h-1][w-1]);
  }
  static class Xy{
    int x;
    int y;
    Xy(int x,int y){
      this.x=x;
      this.y=y;
    }
  }
}

Measured memory_bytes: 58348
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using p = pair<ll,ll>;
using vv = vector<vector<ll>>;
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;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int main(void){
    int n;cin >> n;
    vector<int> a(3*n);
    rep(i,3*n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll ans =0;
    for(int i=0;i<2*n;i++){
	if(i%2==1)ans += a[i]; 
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}


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

int main(){
  ll N;
  cin >> N;
  ll res;
  for(ll i = 1; i * i <= N; i++){
    if(N % i == 0){
      res = N/i;
    }
  }
  int cnt = 0;
  while(res){
    cnt++;
    res /= 10;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws Exception{
		PrintWriter pw=new PrintWriter(System.out);
		MScanner sc = new MScanner(System.in);
		pw.println(2*Math.PI*sc.nextInt());
		
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 33292
// 円とスヌークについてdijkstraを2本張る
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

typedef long long ll;
const ll INF = 1ll<<60;

struct Edge{int to; ll cost;};

int n, m, s, t, u, v, a, b;

void dijkstra(int from, vector<vector<Edge>> &path, ll *dist){
    dist[from] = 0;
    priority_queue<pair<ll, int>> pq;

    pq.push({dist[from], from});

    while(!pq.empty()){
        pair<ll, int> now = pq.top();   pq.pop();
        ll c = -now.first;
        int pos = now.second;
        if(c > dist[pos])    continue;
        for(Edge e : path[pos]){
            if(dist[e.to] > c + e.cost){
                dist[e.to] = c + e.cost;
                pq.push({-dist[e.to], e.to});
            }
        }
    }

    return;
}

int main(){
    cin >> n >> m >> s >> t;
    s--, t--;
    vector<vector<Edge>> yen(n), snu(n);

    for(int i = 0; i < m; i++){
        cin >> u >> v >> a >> b;
        u--, v--;
        yen[u].push_back(Edge{v,a});
        yen[v].push_back(Edge{u,a});
        snu[u].push_back(Edge{v,b});
        snu[v].push_back(Edge{u,b});
    }

    ll dijky[n], dijks[n];
    for(int i = 0; i < n; i++)  dijky[i] = dijks[i] = INF;

    dijkstra(s, yen, dijky);
    dijkstra(t, snu, dijks);

    ll ans[n];
    ans[n-1] = dijky[n-1]+dijks[n-1];

    for(int i = n-2; i >= 0; i--){
        ans[i] = min(ans[i+1], dijky[i]+dijks[i]);
    }

    for(int i = 0; i < n; i++){
        cout << 1000000000000000-ans[i] << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;

int main()
{
  int n;
  while (cin >> n){
    vector<int> v;
    inpt(v, n, In<int>);
    sort(v);
    revs(v);
    int tot = 0;
    for (int i = 0; i < n; i++){
      tot += (i + 1) * v[i];
    }
    cout << tot << endl;
  }

  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1212
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int sum = 0;

    while(sum < b){
        if (ans == 0){
            sum += a;
        } else {
            sum += (a - 1);
        }
        ans += 1;
    }

    if (b == 1){
        ans = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=9982453;

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}

Measured memory_bytes: 3632
X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()

count_p = 0
count_q = 0
count_r = 0
summ = 0

for i in range(X+Y):
        
    if count_p==A:
        p = [0]
    if count_q==B:
        q = [0]
    if count_r==C:
        r = [0]
    
    if count_p==X:
        p[-1] = 0
    if count_q==Y:
        q[-1] = 0
    
    if (r[-1] >= p[-1] and r[-1] >= q[-1]):
        count_r += 1
        summ += r.pop(-1)
    elif p[-1] >= q[-1]:
        count_p += 1
        summ += p.pop(-1)
    else:
        count_q += 1
        summ += q.pop(-1)
        
print(summ)

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

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  ll c = a-k;
  if(c < 0){
    k -= a;
    c = 0;
    b -= k;
    if(b < 0) b = 0;
  }
  cout << c << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>

using namespace std;
int main() {
	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const LL MOD = 1e9+7;
const LL INF = (1e18);
const double EPS=1.0e-9;
const double PI=atan2(0,-1);



int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int p[3];
    CLR(p);
    REP(i,n)
    {
        switch(s[i]-'a')
        {
            case 0:
            if(p[0]+p[1]<a+b)
            {
                p[0]++;
                cout<<"Yes"<<endl;
            }
            else
                cout<<"No"<<endl;
            break;
            case 1:
            if(p[0]+p[1]<a+b && p[1]<b)
            {
                p[1]++;
                cout<<"Yes"<<endl;
            }
            else
                cout<<"No"<<endl;
            break;
            case 2:
            cout<<"No"<<endl;
            break;
        }
    }
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	ll n;
	cin >> n;
	ll sum = 0;
	if (n != 1) {
		for (ll i = 0; i < n - 1; i++) {
			sum += i + 1;
		}
		cout << sum << endl;
	}
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a;
  in2(n, k);
  vector<ll> c(n), d(n);
  rep(i, n){
    in(c[i]);
    d[i] = abs(k - c[i]);
  }
  a = d[0];
  rep(i, n)
    a = __gcd(a, d[i]);
  out(a);
  memi;
}

Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int a, b ,c;
	set<int> st;
	cin >> a >> b >> c;
	st.insert(a);
	st.insert(b);
	st.insert(c);


	cout << st.size() << endl;
	
}



Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        StringBuilder stb = new StringBuilder();
        for (int i=0;i<n;++i)
        {
            String ss = s.substring(i,i+1);
            String tt = t.substring(i,i+1);
            stb.append(ss);
            stb.append(tt);
        }
        System.out.println(stb.toString());

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

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

n_ab = 0
n_b = 0
n_a = 0
n_both = 0
for i in range(N):
    S = input()
    # 前後情報とABの数だけ調べておく
    n_ab += S.count("AB")
    if S[-1] == "A" and S[0] != "B":
        n_a += 1
    if S[0] == "B" and S[-1] != "A":
        n_b += 1
    if S[-1] == "A" and S[0] == "B":
        n_both += 1       

ans = n_ab+min(n_b+n_both,n_a+n_both)
if n_both > 0 and n_a==0 and n_b==0:
    ans -= 1

print(int(ans))

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999



int main(){
    ll dp[11][1100]={};
    dp[0][0]=1;
    for(int i=1;i<=101;i++){//テ」ツδォテ」ツδシテ」ツδ療」ツ?ョテ、ツクツュテ」ツ?ォテ・ツ?・テ」ツつ古」ツつ?
        for(int j=10;j>=1;j--){
            rep(k,1000+1){
                if(k-(i-1)>=0){
                    dp[j][k] += dp[j-1][k-(i-1)];
//                    cout<<"dp["<<j<<"]["<<k<<"]="<<dp[j][k]<<endl;
                }
            }
        }
    }
    
    
    int n,s;
    while(cin>>n>>s){
        if(n==0&&s==0)break;
        cout<<dp[n][s]<<endl;
    }
}

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

using namespace std;

typedef pair <int, int> pii;

vector < pii > v;
string S[15];
int n, m;
bool ans = false;

bool check(){
	for(auto f : v){
		S[f.first].swap(S[f.second]);
	}
	map <string, int> mp;
	string a, b;
	for(int i = 0; i < m; ++i){
		a = "";
		for(int j = 0; j < n; ++j){
			a += S[j][i];
		}
		mp[a] += 1;
	}
	int res = true;
	int cnt = 0;
	for(auto u : mp){
		b = u.first;
		reverse(b.begin(), b.end());
		if(b == u.first){
			if(u.second % 2) cnt += 1;
			if(cnt > 1){
				res = false;
				break;
			}
		}
		else{
			if(u.second != mp[b]){
				res = false;
				break;
			}
		}
	}
	res &= (cnt < 2);
	for(auto f : v){
		S[f.first].swap(S[f.second]);
	}
	return res;
}

void fn(int mask){
	if(ans) return;
	int sz = __builtin_popcount(mask);
	if(sz <= 1){
		ans |= check();
		return;
	}
	int k;
	for(int i = n - 1; i >= 0; --i){
		if(mask & (1 << i)){
			mask ^= (1 << i);
			fn(mask);
			for(int j = 0; j < i; ++j){
				if(mask & (1 << j)){
					v.push_back({i, j});
					fn(mask ^ (1 << j));
					v.pop_back();
				}
			}
			break;
		}
	}
}

int main(){
	cin >> n >> m;
	int mask = 0;
	for(int i = 0; i < n; ++i){
		cin >> S[i];
		mask |= (1 << i);
	}
	fn(mask);
	if(ans) cout << "YES\n";
	else cout << "NO\n";
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(void){
    int a[26];
    int i;
    char s[26];
    scanf("%s",s);
    int len=strlen(s);
    for(i=0;i<26;i++)a[i]=0;
    for(i=0;i<len;i++){
        if(a[s[i]-'a']==0){
            a[s[i]-'a']++;
        }
        else {printf("no\n");
            return 0;
        }
    }
    printf("yes\n");
    return 0;
}

Measured memory_bytes: 128
object Main {
    def main(args: Array[String]) : Unit = {
        val sc = new java.util.Scanner(System.in)
        val n  = sc.nextInt
        val ls = List.fill(n)(sc.nextLong)
        println(ls.reduceLeft((a,b) => lcm(a, b)))
    }
    def lcm(a: Long, b: Long): Long = a / gcd(a, b) * b
    def gcd(a: Long, b: Long): Long = if (b == 0) a.abs else gcd(b, a%b)
}


Measured memory_bytes: 25540
#include <iostream>

using namespace std;
typedef long long ll;

const int N=1e5+5;

int n,m;
int a[N];

struct fent {
        int sz;
        ll t[N];
};

void update(fent &t, int p, int x) {
        for (; p > 0; p -= p&-p)
                t.t[p] += x;
}

ll query(fent &t, int p) {
        ll ret=0;
        for (; p <= t.sz; p += p&-p)
                ret += t.t[p];
        return ret;
}

fent t1, t2;

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

        t1.sz = m, t2.sz = m;
        for (int i=0; i<n-1; i++) {
                if (a[i+1] >= a[i]) {
                        update(t1,a[i+1],a[i]);
                        update(t1,a[i],-a[i]);
                        update(t2,a[i+1],1);
                        update(t2,a[i],-1);
                } else {
                        update(t1,m,a[i]);
                        update(t1,a[i],-a[i]);
                        update(t2,m,1);
                        update(t2,a[i],-1);

                        update(t1,a[i+1],a[i]-m);
                        update(t2,a[i+1],1);
                }
        }

        ll mx=0;
        for (int i=1; i<=m; i++) {
                mx = max(mx, query(t2,i)*(i-1)-query(t1,i));
        }

        //for (int i=1; i<=m; i++)
        //      cout << i << " " << query(t1,i) << " " << query(t2,i) << "\n";

        ll ans=0;
        for (int i=0; i<n-1; i++) {
                if (a[i+1] >= a[i])
                        ans += a[i+1]-a[i];
                else
                        ans += a[i+1]-a[i]+m;
        }

        cout << ans-mx << "\n";
}

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

namespace AtCoder.ABC172
{
    public class Problem1
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var answer = Math.Pow(N, 1) + Math.Pow(N, 2) + Math.Pow(N, 3);

            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 27928
a=raw_input()
l=len(a)
i=ans=0
while i<l:
	lenj=leno=leni=0
	while i<l and a[i]=="J":
		lenj+=1
		i+=1
	while i<l and a[i]=="O":
		leno+=1
		i+=1
	while i<l and a[i]=="I":
		leni+=1
		i+=1
	if lenj>=leno and leni>=leno:
		ans=max(ans,leno)
print ans

Measured memory_bytes: 5644
#include<stdio.h>
#include<stdlib.h>


struct node{
  struct node* right;
  struct node* left;
  struct node* p;
  int key;
};

typedef struct node *Node;

Node root;

void insert(int  k){
  Node y = NULL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;
  
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  
    z->p = y;

    if(y == NULL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
}

void inorder(Node u){
  if(u != NULL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NULL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n,i,k;
  char com[10];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",com);
    
    if(com[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }
    else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25152
package main

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

func main() {
	resolve(os.Stdin)
}

func resolve(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	s := scanString(sc)
	b := bytes.NewBuffer([]byte{})
	for i := 0; i < len(s); i++ {
		b.WriteString("x")
	}
	fmt.Println(b.String())
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}
fn main() {
    input!{ n: i32, d: i32 }
    let q = n / (2*d +1);
    let r = n % (2*d +1);
    println!("{}", if r == 0 {q} else {q+1});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, K, ans = 1000000007;
    cin >> N >> K;
    vector<int64_t> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x.at(i);
    }
    for (int i = 0; i < N - K + 1; i++) {
        if (x.at(i) < 0 && x.at(i + K - 1) > 0) {
            ans = min(min(abs(x.at(i)), abs(x.at(i + K - 1))) * 2 + max(abs(x.at(i)), abs(x.at(i + K - 1))), ans);
        }
        else {
            ans = min(max(abs(x.at(i)), abs(x.at(i + K - 1))), ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    Q=int(input())
    for _ in range(Q):
        a,b=map(int,input().split())
        if a==b:
            print(a+b-2)
            continue
        
        ans=0
        if a<b:
            a,b=b,a
        ans+=b-1
        def nibutan(ok,ng):
            while abs(ok-ng) > 1:
                mid = (ok + ng) // 2
                if solve(mid):
                    ok = mid
                else:
                    ng = mid
            return ok
        
        def solve(mid):
            return mid**2<a*b
        
        sq=nibutan(0,10**9)
        if sq*(sq+1)<a*b:
            p,q=sq,sq+1
        else:
            p,q=sq,sq
        ans+=q-b
        ans+=p-1
        print(ans)
        
                

if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <cstdio>
#include <cstring>

long long gcd(long long a, long long b){
	return b?gcd(b,a % b):a;
}

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

int main(){
	int a[3], m[3], p[3] = {1,1,1}, c[3] = {0};
	while(scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2),a[0]){
		memset(c,0,sizeof(c));
		for(int i=0;i<3;i++){
			do{
			p[i] = a[i] * p[i] % m[i];
			c[i]++;
			}while(p[i] != 1);
		}
		printf("%lld\n",lcm(lcm(c[0],c[1]),c[2]));
	}
	return 0;
}

Measured memory_bytes: 0
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Collecting Balls (Easy Version)
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int xi;
    scanf("%d", &xi);
    sum += min(xi, abs(k - xi)) * 2;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
char c;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>c;
    if(c=='A')Cout('T');
    else if(c=='T')Cout('A');
    else if(c=='C')Cout('G');
    else if(c=='G')Cout('C');
    return 0;
}


Measured memory_bytes: 256
import Data.Bits
main = do
  n <- read  <$> getLine
  x <- getLine
  let p = length $ filter (=='1') x
      pow2_0 = reverse $ take n $ iterate (\t -> (2*t)  `mod` (p+1)) 1
      pow2_1 = reverse $ take n $ iterate (\t -> (2*t)  `mod` (p-1)) 1
      r0 = sum $ zipWith (\c m -> if c == '1' then m else 0) x pow2_0
      r1 = sum $ zipWith (\c m -> if c == '1' then m else 0) x pow2_1
      xs = zipWith3 (\c m0 m1 -> if c == '1' && p /= 1 then (r1 - m1) `mod` (p-1) else if c == '1' && p == 1 then -1 else (r0 + m0) `mod` (p+1)) x pow2_0 pow2_1
      ans = fmap (print . f) xs
  sequence ans

f :: Int -> Int
f n
  | n == -1 = 0
  | n == 0 = 1
  | otherwise = 1 + f n'
  where n' = n `mod` popCount n




Measured memory_bytes: 65316
import sys
sys.setrecursionlimit(10**7)


n=int(input())
X=str(input())

number=0
for i in range(n):
    if X[i]=='1':
        number+=1



def culc(x):
    bin_x=str(bin(x)[2:])
    one=0
    for i in range(len(bin_x)):
        if bin_x[i]=='1':
            one+=1
    return x%one
        



#dp[i](0<=i<=number)
dp=[-1]*(number+1)
dp[0]=0
def rec(x):
    if dp[x]>=0:
        return dp[x]
    else:
        dp[x]=rec(culc(x))+1
        return dp[x]



if number==0:
    for i in range(n):
        print(1)
    sys.exit()



base1=0
for i in range(n):
    if X[i]=='1':
        base1=(base1+pow(2,n-i-1,number+1))%(number+1)

if number==1:
    for i in range(n):
        if X[i]=='1':
            print(0)
        else:
            temp=(base1+pow(2,n-i-1,number+1))%(number+1)
            ans=rec(temp)+1
            print(ans)
    sys.exit()



base2=0
for i in range(n):
    if X[i]=='1':
        base2=(base2+pow(2,n-i-1,number-1))%(number-1)






for i in range(n):
    #base1
    if X[i]=='0':
        temp=(base1+pow(2,n-i-1,number+1))%(number+1)
        ans=rec(temp)+1
        print(ans)
    #base2
    if X[i]=='1':
        temp=(base2-pow(2,n-i-1,number-1))%(number-1)
        ans=rec(temp)+1
        print(ans)



Measured memory_bytes: 10228
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;
fn main() {
    input! {
        N:usize, K:usize,
        mut P:[i32;N]
    }
    P.sort();
    let mut ans = 0;
    for p in P[..K].iter() {
        ans += p;
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 2152
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
    }
    auto min=min_element(ALL(A));//イテレータで返す
    auto max=max_element(ALL(A));//イテレータで返す
    int num=*max-*min;
    cout<<num<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a) for (int i = 0; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 300;

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

    int n, w;
    cin >> n >> w;

    vpii a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].ff >> a[i].ss;
    }

    vii dp(n, vi(w + 1, -1));

    dp[0][0] = 0;
    dp[0][a[0].ff] = a[0].ss;

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= w; ++j) {
            if (dp[i - 1][j] != -1)
                dp[i][j] = dp[i - 1][j];

            if (j >= a[i].ff && dp[i - 1][j - a[i].ff] != -1)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i].ff] + a[i].ss);
        }
    }

    cout << *max_element(all(dp[n - 1]));
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w;
string s,t;
//vll a,b;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	x = c-a;
	y = d-b;

	cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;newl;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



Measured memory_bytes: 3640
import java.io.InputStream;
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {
        InputStream inputStream = System.in;
        Scanner sc = new Scanner(inputStream);
        String out;
        String A = sc.next();
        int B = sc.nextInt();
        for(int i=0;i<A.length();i+=B) {
        System.out.print(A.charAt(i));
        }
	}

}


Measured memory_bytes: 23124
class Circle
  def initialize(x, y, r)
    @x = x;
    @y = y;
    @r = r;
  end

  attr_reader :x, :y, :r
end

class Rectangle
  def initialize(w, h)
    @w = w;
    @h = h;
  end

  def contains?(circle)
    if circle.x < 0
      puts "No"
    elsif @w < circle.x
      puts "No"
    elsif circle.y < 0
      puts "No"
    elsif @h < circle.y
      puts "No"
    elsif circle.x < circle.r
      puts "No"
    elsif @w < circle.x + circle.r
      puts "No"
    elsif circle.y < circle.r
      puts "No"
    elsif @h < circle.y + circle.r
      puts "No"
    else
      puts "Yes"
    end
  end
end

nums_str = gets.split
nums = nums_str.map{|num_str| num_str.to_i}

rectangle = Rectangle.new(nums[0], nums[1])
circle = Circle.new(nums[2], nums[3], nums[4])

rectangle.contains?(circle);

Measured memory_bytes: 8656