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

using namespace std;

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

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

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


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

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

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

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

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

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

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

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

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

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

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  int64 ret = 0, pre = 1;
  for(auto &p : A) {
    int64 ok = (p - 1) / pre;
    if(ok > 0) {
      ret += ok;
    }
    if(pre == 1 || p == pre) {
      ++pre;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 105005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll h[SIZE];
    REP(i,n){
        cin >> h[i];
    }
    ll ans[SIZE];
    fill(ans+1,ans+n,INF);
    ans[0] = 0;
    REP(i,n-1){
        FOR(j,1,k+1){
            ans[i+j] = min(abs(h[i]-h[i+j])+ans[i],ans[i+j]);
        }
    }
    cout << ans[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long ll;
const int MAXN=1e5+5;

int n,m,flag;
int cnt[3],ncnt,ecnt,c[MAXN];
bool vis[MAXN],evis[MAXN];
struct node{
    int v,w,id;
    node(int _v,int _w,int _id):v(_v),w(_w),id(_id){}
};
vector<node> E[MAXN];

void dfs(int u){
    vis[u]=1;
    ncnt++;
    cnt[c[u]]++;
    for(int i=0;i<(int)E[u].size();i++){
        int v=E[u][i].v,w=E[u][i].w,id=E[u][i].id;
        if(evis[id]) continue; evis[id]=1; ecnt++;
        if(!vis[v]){
            c[v]=(c[u]+w+3)%3;
            dfs(v);
        }
        else if(c[v]!=(c[u]+w+3)%3) flag=1;
    }
}

int main(){

	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
	    int u,v;
        scanf("%d%d",&u,&v);
        E[u].push_back(node(v,1,i));
        E[v].push_back(node(u,-1,i));
	}
	ll ans=0;
    for(int i=1;i<=n;i++){
        if(vis[i]) continue;
        flag=ncnt=ecnt=cnt[0]=cnt[1]=cnt[2]=0;
        dfs(i);
        if(flag) ans+=1ll*ncnt*ncnt;
        else if(!cnt[0]||!cnt[1]||!cnt[2]) ans+=ecnt;
        else ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
    }
    printf("%lld",ans);

	fclose(stdin);
	fclose(stdout);
}


Measured memory_bytes: 14080
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";t.__esModule=!0;var n=r(1),u=r(2),o=n.readFileSync("/dev/stdin","utf8").split("\n");console.log(u.solveB(o))},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";t.__esModule=!0,t.solve=function(e){var t=e[0],r=e[1],n=e[2],u=Number(t),o=r.split(" ").map(Number);return u+o[0]+o[1]+" "+n},t.solveA=function(e){return e[0].split("").filter(function(e){return"2"===e}).length},t.solveB=function(e){var t=e[0],r=e.slice(1),n=t.split(" ").map(Number),u=(n[0],n[1]),o=n[2];return r.map(function(e){return e.split(" ").map(Number)}).filter(function(e){var t=e[0],r=e[1];return t>=u&&r>=o}).length}}]);

Measured memory_bytes: 21320
//
//  main.cpp

#include <iostream>
using namespace std;
using ll = long long;
const ll MAX = 1000000000000;

ll min(ll x,ll y){
	if(x > y){
		return y;
	}else{
		return x;
	}
}


int main(){	
	while(1){
		int n,k;
		cin >> n >> k;
		if(n == 0 && k == 0)break;
		int isOrder;
		bool isChange=false;
		ll dist[101][101];
		for(int i=0;i<101;i++)for(int j=0;j<101;j++)dist[i][j] = MAX;
		
		for(int i=0;i<k;i++){
			cin >> isOrder;
			if(isOrder){
				int a,b,c;
				cin >> a >> b >> c;
				dist[a][b] = min(dist[a][b],c);
				dist[b][a] = min(dist[b][a],c);
				isChange = true;
			}else{
				if(isChange){
					for(int j=1;j<=n;j++)for(int k=1;k<=n;k++)for(int r=1;r<=n;r++)dist[k][r] = min(dist[k][r],dist[k][j] + dist[j][r]);
					isChange = false;
				}
				
				int a,b;
				cin >> a >> b;
				if(dist[a][b] >= MAX){
					cout << "-1" << endl;
				}else{
					cout << dist[a][b] << endl;
				}
			}
		}
	}
	return 0;
}

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

set<int> a[200005];
bool vis[200005];
int dis[200005];
int res=1;
stack<int>s;
void bfs(int source,int n)
{
    vis[source]=true;
    dis[source]=1;
    int count=1;
    queue<int> q;
    q.push(source);
    while(!q.empty())
    {
        int u= q.front();
        q.pop();
        for(auto b: a[u])
        {
            if(!vis[b])
            {
                count++;
                dis[b]= dis[u]+1;
                vis[b]=true;
                res = max(res, count);
                q.push(b);
            }
        }
    }
}


int main()
{
    int t=1;;
    //cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++)
        {
            int u,v;
            cin>>u>>v;
            a[u].insert(v);
            a[v].insert(u);

        }

        for(int i=1;i<=n;i++)
        {
            if(!vis[i])
                bfs(i,n);
        }

       // cout<<endl;
        cout<<res<<endl;
    }
}


Measured memory_bytes: 32964
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int x = n * 800;
    int y = n / 15;
    cout << x - y * 200;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<ll> hp(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> hp[i];
	}

	sort(rall(hp));
	ll res = 0;
	if (n >= k)
	{
		res = accumulate(hp.begin() + k, hp.end(), (ll)0);
	}
	println(res);
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

struct st{
	int cnt;
	string str;
	st(int i, string s){
		cnt = i; str = s;
	}
	bool operator <(const st &r) const{
		if(cnt == r.cnt) return str > r.str;
		return cnt < r.cnt;
	}
};

int main(){
	int n;
	while(cin >> n, n){
		cin.ignore();
		map<string, int> m;
		rep(i, n){
			stringstream ss;
			string s;
			getline(cin, s);
			ss << s;
			while(ss >> s) m[s]++;
		}
		char c;
		cin >> c;
		map<string, int>::iterator it;
		vector<st> v;
		for(it = m.begin(); it != m.end(); it++){
			if(it->first[0] != c) continue;
			v.push_back(st(it->second, it->first));
		}
		sort(rev(v));
		rep(i, min((int)v.size(),5) ){
			cout << (i?" ":"") << v[i].str;
		}
		if(v.empty()) cout << "NA";
		cout << endl;
	}

	return 0;
}

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

int main(){
    int n;
    int b[110];
    cin >> n;

    vector<int> vec;

    for(int i = 0;i < n;i++){
        cin >> b[i];
        vec.push_back(b[i]);
    }

    queue<int> ans;
    vector<int> num;
    for(int i = 0;i < n;i++){
        int j;
        for(j = n-1;j >= 0;j--){
            if(b[j] != -1){
                bool isOK = false;
                if(i+1 < b[j]){
                    continue;
                }
                int k;
                for(k = 0;k < b[j]-1;k++){
                    if(num[k] > j){
                        break;
                    }
                }
                if(k < b[j] - 1){
                    continue;
                }else{
                    ans.push(b[j]);
                    num.insert(num.begin()+b[j]-1, j);
                    b[j] = -1;
                    break;
                }
            }
        }
        if(j < 0){
            cout << -1 << endl;
            return 0;
        }
    }

    while(!ans.empty()){
        cout << ans.front() << endl;
        ans.pop();
    }
    return 0;
}





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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    REP(i, N)
    {
        ll a = i + 1;
        ll b = N - a;
        if (b <= a)
            break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
import java.util.*;
	import java.io.*;
	public class Main {
		static int n,vi[];
		static long dp[][],W,wi[];
		public static void main(String[] args) throws IOException{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			int t=1;
	//		Integer.parseInt(br.readLine().trim());
			StringBuilder printans=new StringBuilder();
			while(t-->0)
			{
				StringTokenizer tok=new StringTokenizer(br.readLine()," ");
				n=Integer.parseInt(tok.nextToken());
				W=Long.parseLong(tok.nextToken());
				
				wi=new long[n];
				vi=new int[n];
				int sm=0;
				for(int i=0;i<n;i++) {
					tok=new StringTokenizer(br.readLine()," ");
					wi[i]=Long.parseLong(tok.nextToken());
					vi[i]=Integer.parseInt(tok.nextToken());
					sm+=vi[i];
				}
				dp=new long[n+1][sm+1];
				memset();
			 
			    System.out.println(call());
			}
			
			
		}
		static void memset() {
			 long INF = 1_000_000_000_000L;
				for (int i = 1; i < dp[0].length; i++) dp[0][i] = INF;
			    
		}
static long call() {
			
			for(int i=1;i<=n;i++) {
				for(int j=0;j<dp[0].length;j++) {
					dp[i][j]=dp[i-1][j];
					if(j-vi[i-1]>=0) {
						dp[i][j]=Math.min(dp[i][j], wi[i-1]+dp[i-1][j-vi[i-1]]);
					}
					
					
					
				}
			}
			long aa=0;
			for(int j=0;j<dp[0].length;j++) {
				if(dp[n][j]<=W) {
					
					aa=Math.max(aa,j);
				}
			}
			
return aa;		
}	
			
	}


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

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

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

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

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

long long gcd(long long a, long long b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

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

ll N;
ll T[110];

int main() {
  cin >> N;
  ll ans = 1;
  rep(i, 0, N) {
    cin >> T[i];
    ans = lcm(ans, T[i]);
  }
  cout << ans;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>


#include <math.h>


using namespace std;


class Solution {
public:
    void solve(int num, std::istream& in, std::ostream& out) {
		int h1, m1, h2, m2, k; in >> h1 >> m1 >> h2 >> m2 >> k;
		int h = k / 60;
		int m = k % 60;
		h2 -= h;
		m2 -= m;
		if (m2 < 0) {
			m2 += 60;
			h2--;
		}

		m2 -= m1;
		if (m2 < 0) {
			m2 += 60;
			h2--;
		}

		h2 -= h1;

		out << m2 + 60 * h2;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
	//int T; in >> T;
	//for(int i = 0;i < T;i++)
		//solution.solve(i+1, in, out);
	solution.solve(0, in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

int a[310][310];
pair<int,int> mp[90010];
int ans[90010];

int dis(pair<int,int> a,pair<int,int> b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            scanf("%d",&a[i][j]);
            mp[a[i][j]] = make_pair(i,j);
        }
    for (int i = n * m; i >= 1; i--)
        if (i - k >= 1)
            ans[i - k] = ans[i] + dis(mp[i],mp[i - k]);
    int q;
    scanf("%d",&q);
    for (; q--;) {
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",ans[l] - ans[r]);
    }
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };


int main() {
  int N;cin>>N;
  vector<int> h(N);
  rep(i,N) cin>>h[i];
  vector<int> dp(N+1,1000100000);
  dp[0] = 0;
  rep(i,N - 1) {
    rep(j,2) {
      if(i+j+1 <= N) chmin(dp[i+j+1], dp[i] + abs(h[i+j+1] - h[i]));
    }
  }
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 3968
#include <iostream>

using namespace std;

int main()
{
    const int morning = 200;
    const int afternoon = 300;
    string str;
    int m, a;

    while (cin >> str >> m >> a) 
        cout << str << " " << m + a << " "
             << m * morning + a * afternoon << endl;

    return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long ans = 0;
		// a = 0考慮しているので、場合によっては後で引く
		for(long b = 1 ; b <= n ; b++) {
			long p = n / b;
			long r = n % b;
			ans += Math.max(0, b - k) * p + Math.max(0, r - k + 1);
		}
		System.out.println(k == 0 ? ans - n : ans);
	}
}


Measured memory_bytes: 21844
from collections import defaultdict


def solve(n, l, nums):
    xor = 0

    if n == 1:
        for i in range(min(nums), l + 1):
            xor ^= i & -i
        return xor

    for i in range(min(nums), l + 1):
        ni = nums[i]
        for k in ni:
            if k ^ 1 not in ni:
                xor ^= i & -i
            nums[i + 1].add(k // 2)
        del nums[i]
    return xor


n, l = map(int, input().split())
nums = defaultdict(set)
for s in (input() for _ in range(n)):
    nums[l - len(s) + 1].add(int(s, 2) + (1 << len(s)))

print('Alice' if solve(n, l, nums) else 'Bob')


Measured memory_bytes: 4204
#include<stdio.h>

int main(void){

int sah,sam,sas,tah,tam,tas,sbh,sbm,sbs,tbh,tbm,tbs,sch,scm,scs,tch,tcm,tcs,sa,sb,sc,a,b,c,d,e,f;

scanf("%d %d %d %d %d %d",&sah,&sam,&sas,&tah,&tam,&tas);
scanf("%d %d %d %d %d %d",&sbh,&sbm,&sbs,&tbh,&tbm,&tbs);
scanf("%d %d %d %d %d %d",&sch,&scm,&scs,&tch,&tcm,&tcs);

sa=tah*3600+tam*60+tas-sah*3600-sam*60-sas;
sb=tbh*3600+tbm*60+tbs-sbh*3600-sbm*60-sbs;
sc=tch*3600+tcm*60+tcs-sch*3600-scm*60-scs;

d=sa/3600;
e=sb/3600;
f=sc/3600;
a=sa-(d*3600);
b=sb-(e*3600);
c=sc-(f*3600);

printf("%d %d %d\n",sa/3600,a/60,a%60);
printf("%d %d %d\n",sb/3600,b/60,b%60);
printf("%d %d %d\n",sc/3600,c/60,c%60);

return 0;
}


Measured memory_bytes: 2044
import java.util.*;

public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int m = sc.nextInt();
            int ret = 0 ;
            if(n%m > 0){
                ret = n/m +1;
            }else{
                ret = n/m;
            }
                System.out.println(ret);
            }
        }

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int find(vector<int>& grp, int x) {
    if (grp[x] == x)
        return x;
    return grp[x] = find(grp, grp[x]);
}

int main() {
    int n, m, u, v;
    cin >> n >> m;
    vector<int> grp(n, 0);
    for(int i = 0; i < n; i++)
        grp[i] = i;
    for(int i = 0; i < m; i++) {
        cin >> u >> v;
        int r1 = find(grp, u-1);
        int r2 = find(grp, v-1);
        grp[r1] = grp[r2] = min(r1, r2);
    }
    int ans = 0;
    unordered_map<int, int> member;
    for(int i = 0; i < n; i++) {
        int r = find(grp, i);
        member[r] += 1;
        ans = max(ans, member[r]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  ll N,T; cin >> N >> T;
  vector<ll> t(N);
  rep(i,N) cin >> t[i];

  ll ans = 0;
  rep(i,N) {
    if (i == 0) continue;
    if (t[i-1] + T < t[i]) ans += T;
    else ans += (t[i] - t[i-1]);
  }

  ans += T;

  cout << ans << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
	char str[10001];
	bool f1=false,f2=false;
	scanf("%s",str+1);
	for(int i=1; i<=strlen(str+1); i++) {
		if(str[i]=='C'&&!f2)f1=true;
		if(str[i]=='F'&& f1)f2=true;
	}
	cout<<(f1&&f2?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
k = y//1000
candidate = []

for i in range(n+1):
    for j in range(n+1-i):
        if 9*i + 4*j == k-n:
            candidate.append((i, j))

for cand in candidate:
    i, j = cand[0], cand[1]
    if n-i-j>=0:
        t = n-i-j
        print(i, j, t)
        exit()

print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = 200005;
int ar[NN];
int n, m, k;


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

    set<string> S;
    cin >> n;
    for (int i = 0; i< n; i++){
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;

}

Measured memory_bytes: 19244
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    ll n,k;
    read(n),read(k);
    n-=n/k*k;
    printf("%lld\n",min(n,abs(n-k)));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;


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

    int N;
    LL K;
    cin >> N >> K;

    vector<int> nrs(N + 1);
    for (int i = 1; i <= N; ++i)
    {
        cin >> nrs[i];
    }

    vector<int> path(N + 1), last_idx(N + 1);
    for (int cur_nr = nrs[1], i = 1; ; ++i)
    {
        if (i == K)
        {
            cout << cur_nr;
            return 0;
        }
        if (last_idx[cur_nr])
        {
            int mod = i - last_idx[cur_nr];
            int res_idx, cur_mod;
            // for (cur_mod = (res_idx = last_idx[cur_nr]) % mod; cur_mod != K % mod; cur_mod = (cur_mod + 1) % mod, ++res_idx)
                // ;
            // cerr << "Res idx :) : " << res_idx << endl;
            cout << path[(mod - last_idx[cur_nr] % mod + K % mod) % mod + last_idx[cur_nr]];
            return 0;
        }

        path[i] = cur_nr;
        last_idx[cur_nr] = i;
        cur_nr = nrs[cur_nr];
    }
}


Measured memory_bytes: 5500
#include<iostream>
#include<map>
using namespace std;
int main() {
    int n; cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        mp[a]++;
    }
    int cnt = 0;
    for (auto e : mp) {
        if (e.second) {
            if (e.second > e.first) { //数が多い
                cnt += e.second - e.first;
            } else if (e.second < e.first) {
                cnt += e.second;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
    int n;
    int a;
    int count = 1e9;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> a;
        int key = 0;
        while(a%2 == 0){
            a /= 2;
            key++;
        }
        if(key<count){
            count = key;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

vector<int> X;

int main(){
    int N, m = 0;
    cin >> N;
    X.resize(N);
    rep(i, N){
        cin >> X[i];
        m += X[i];
    }
    int avg1 = m / N;
    int avg2 = avg1++;
    ll sum1 = 0, sum2 = 0;
    rep(i, N){
        sum1 += (avg1-X[i]) * (avg1-X[i]);
        sum2 += (avg2-X[i]) * (avg2-X[i]);
    }
    ll ans = sum1;
    chmin(ans, sum2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  int n; cin >>n;
  map<string,int> mp;
  int ma=0;
  rep(i,n){
    string s; cin >>s;
    mp[s]++;
    if(ma<mp[s]) ma=mp[s];
  }
  for(auto x: mp){
    if(x.second==ma) cout << x.first << "\n";
  }
}


Measured memory_bytes: 25216
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> 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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: i64,
        m: usize,
        a: [i64;m]
    }
    let mut ans:i64 = n;
    for i in 0..m {
        ans-=a[i];
    }
    if ans < 0 {
        println!("-1");
    }else{
        println!("{}", ans);
    }
}


Measured memory_bytes: 2216
#include <stdio.h>

int main(void)
{
  int n,m,i,in[10000],out[10000],rem,max,err=0;

  scanf("%d", &n);
  scanf("%d", &m);
  rem=m;
  max=m;
  for(i=0;i<n;i++){
    scanf("%d %d", &in[i], &out[i]);
    rem=rem+in[i]-out[i];
    if(rem<0) err++;
    if(rem>max) max=rem;
  }
  if(err==0) printf("%d\n", max);
  if(err>0) printf("0\n");

  return 0;
}


Measured memory_bytes: 672
#!/usr/bin/env python3
import sys
import math

def solve(N: int, X: int, T: int):
    print(int(T * math.ceil(N / X)))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, k;
ll h[100000];
ll dp[100001];

int main() {
    cin >> n >> k;
    rep(i,n) cin >> h[i];
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = MOD*MOD;
        for (int j = 1; j <= k; j++) {
            if (i < j) break;
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
}



Measured memory_bytes: 1792
n = int(input())
ans = 0
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))
ab.reverse()
for i in range(n):
    a = ab[i][0] + ans
    b = ab[i][1]
    if a%b != 0:
        ans +=b- a%b
print(ans)

Measured memory_bytes: 27380
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut cnt = 0;
    for i in 0..n-1 {
        if v[i] == i+1 {
            v.swap(i, i+1);
            cnt += 1;
        }
    }
    if v[n-1] == n {
        cnt += 1;
    }
    println!("{}", cnt);
}


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

int main() {
  int n;
  cin >> n;
  vector<long double> a(n);
  
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  for(int i = 0; i < n; i++){
    a.at(i) = 1.0/a.at(i);
  }
  
  long double sum = 0;
  
  for(int i = 0; i < n; i++){
    sum += a.at(i);
  }
  
  cout << (long double)1/sum << endl;
  
}

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

using namespace std;

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

int solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> dp(n, vector<int>(n, 1e9));
  rep(i, n) {
     dp[i][i] = 0;
  }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    dp[a][b] = -1;
  }
  rep(k, n) rep(i, n) rep(j, n) {
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  }
  rep(i, n) {
     if (dp[i][i] < 0) return 1;
  }
  return 0;
}

int main() {
  cout << solve() << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

int main(){
  string s;
  cin >> s;

  const int d = 'Z'-'A'+1;
  vector<int> frec(d, 0);

  rep(i, 0, s.size()){
    char c = s[i];
    frec[c-'a']++;
  }

  int i = 0;
  while( i < d && frec[i] > 0 )
    i++;

  //cout << i << endl;
  if( i < d )
    cout << char('a'+i) << "\n";
  else
    cout << "None\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S ;
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    };
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt(), s = sc.nextInt(), ret = 0;
        for(int i=0;i<=k;i++)for(int j=0;j<=k;j++){
            if(0<=s-i-j && s-i-j<=k)ret+=1;
        }
        System.out.println(ret);
    }
}

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

using namespace std;

int main(){
    
    int a, b;
    cin >> a >> b;
    
    if (a > b)cout << "a > b" << endl;
    else if (a < b)cout << "a < b" << endl;
    else cout << "a == b" << endl;
    
}


Measured memory_bytes: 3096
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  int x, y; readf("%d %d\n", &x, &y);

  auto prizes = [0, 300000, 200000, 100000];

  auto prize = 0;
  prize += x <= 3 ? prizes[x] : 0;
  prize += y <= 3 ? prizes[y] : 0;
  prize += x == 1 && y == 1 ? 400000 : 0;
  writeln(prize);
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * l.cc: L - Lazy Segment Tree
 */

#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 = 200000;
const int MAX_E2 = 1 << 19; // = 524288

/* typedef */

typedef long long ll;

struct Elm {
  int z, o;
  ll c0, c1;
  Elm() {}
  Elm(int _z, int _o): z(_z), o(_o), c0(0), c1(0) {}
  Elm(int _z, int _o, ll _c0, ll _c1): z(_z), o(_o), c0(_c0), c1(_c1) {}

  Elm operator+(const Elm &e) const {
    return Elm(z + e.z, o + e.o,
	       c0 + e.c0 + (ll)o * e.z, c1 + e.c1 + (ll)z * e.o);
  }

  Elm &rev() {
    swap(z, o); swap(c0, c1);
    return *this;
  }
};

template <typename T, const int MAX_E2>
struct SegTreeDelay {
  int e2;
  T nodes[MAX_E2], zero;
  bool dls[MAX_E2];
  SegTreeDelay() {}

  void init(int n, T _zero) {
    zero = _zero;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, zero);
    //fill(dls, dls + MAX_E2, false);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }
  void seti(int i, T v) { get(i) = v; }

  void setall() {
    for (int j = e2 - 2; j >= 0; j--)
      nodes[j] = nodes[j * 2 + 1] + nodes[j * 2 + 2];
  }

  void __update(int k) {
    if (dls[k]) {
      int k0 = k * 2 + 1, k1 = k0 + 1;
      nodes[k0].rev();
      nodes[k1].rev();
      dls[k0] ^= true;
      dls[k1] ^= true;
      dls[k] = false;
    }
  }

  void rev_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return;
    if (r0 <= i0 && i1 <= r1) {
      nodes[k].rev();
      dls[k] ^= true;
      return;
    }

    __update(k);

    int im = (i0 + i1) / 2;
    int k0 = k * 2 + 1, k1 = k0 + 1;
    rev_range(r0, r1, k0, i0, im);
    rev_range(r0, r1, k1, im, i1);
    nodes[k] = nodes[k0] + nodes[k1];
  }
  void rev_range(int r0, int r1) { rev_range(r0, r1, 0, 0, e2); }

  T sum_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return zero;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    __update(k);

    int im = (i0 + i1) / 2;
    T v0 = sum_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = sum_range(r0, r1, k * 2 + 2, im, i1);
    return v0 + v1;
  }
  T sum_range(int r0, int r1) { return sum_range(r0, r1, 0, 0, e2); }
};

/* global variables */

SegTreeDelay<Elm,MAX_E2> st;

/* subroutines */

/* main */

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

  st.init(n, Elm(0, 0));

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    st.seti(i, Elm(1 - ai, ai));
  }
  st.setall();

  while (q--) {
    int op, l, r;
    scanf("%d%d%d", &op, &l, &r);
    l--;

    if (op == 1) {
      st.rev_range(l, r);
    }
    else {
      Elm e = st.sum_range(l, r);
      printf("%lld\n", e.c0);
    }
  }
  return 0;
}


Measured memory_bytes: 16492
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

typedef string::const_iterator State;

int express(State& p);
int factor(State& p);
int term(State &p);
int number(State &p);

// 足し算
int express(State& p) {
	int r = term(p);
	
	for(;;) {
		if(*p == '+') {
			p++;
			int rs = term(p);
			r += rs;
		}
		else if(*p == '-') {
			p++;
			int rs = term(p);
			r -= rs;
		}
		else {
			break;
		}
	}
	
	return r;
}


// 掛け算
int term(State &p) {
	int r = factor(p);
	
	for(;;) {
		if(*p == '*') {
			p++;
			int rs = factor(p);
			r *= rs;
		}
		else if(*p == '/') {
			p++;
			int rs = factor(p);
			r /= rs;
		}
		else {
			break;
		}
	}
	
	return r;
}

// カッコ
int factor(State &p) {
	if(*p == '(') {
		p++;
		int ret = express(p);
		p++;
		return ret;
	}
	return number(p);
}

int number(State &p) {
	// if(*p == '(') return factor(p);
	int ret = 0;
	
	while(isdigit(*p)) {
		ret *= 10;
		ret += *p - '0';
		p++;
	}
	
	return ret;
}

int main() {
	int N; cin >> N;
	cin.ignore();
	while(N--) {
		string line;
		getline(cin, line);
		State p = line.begin();
		int ans = express(p);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll mod=1e9+7;
ll MAX=200105;
vector<ll> fact(MAX),fact_inv(MAX);
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll comb(ll n, ll r){
    if(n<r || n<0 || r<0) return 0;
    return(fact[n]*fact_inv[r])%mod*fact_inv[n-r]%mod;
}

int main(){
    ll h,w,a,b; cin>>h>>w>>a>>b;
    fact[0]=1;
    ll n=MAX;
    rep(i,n)fact[i+1]=fact[i]*(i+1)%mod;
    fact_inv[n]=power(fact[n],mod-2);
    rep(i,n)fact_inv[n-1-i]=fact_inv[n-i]*(n-i)%mod;
    ll res=0;
    for(ll i=b+1; i<=w; i++){
        ll tmp=comb(h-a+i-2, i-1);
        tmp%=mod;
        tmp*=comb(a+w-i-1, a-1);
        tmp%=mod;
        res+=tmp;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

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

int solve(int popcnt, string X) {
    int rem = 0;

    for(int i = 0; i < X.size(); i++) {
        rem = rem * 2;
        if(X[i] == '1') {
            rem = rem + 1;
        }

        rem = rem % popcnt;
    }

    return rem;
}

int main() {
    int N;
    string X;

    cin >> N;
    cin >> X;

    int popcnt = 0;

    int dp[200005];
    dp[0] = 0;

    const int MAX_NUM = N;

    for(int i = 1; i <= MAX_NUM; i++) {
        int cnt = __builtin_popcount(i);
        dp[i] = dp[i % cnt] + 1;
    }

    for(int i = N - 1; i >= 0; i--) {
        if(X[i] == '1') {
            popcnt++;
        }
    }

    int dpRem[5][200005];
    const int PLUS_ONE = 1;
    const int MIN_ONE = 0;
    dpRem[PLUS_ONE][0] = 1 % (popcnt + 1);
    dpRem[MIN_ONE][0] = popcnt > 1 ? 1 % (popcnt - 1) : 0;

    for(int i = 1; i <= N; i++) {
        dpRem[PLUS_ONE][i] = (dpRem[PLUS_ONE][i - 1] * 2) % (popcnt + 1);
        dpRem[MIN_ONE][i] = popcnt > 1 ? (dpRem[MIN_ONE][i - 1] * 2) % (popcnt - 1) : 0;
    }

    int plusOne = -1;
    int minOne = -1;

    for(int i = 0; i < N; i++) {
        int ans;
        int remind;
        if(X[i] == '1') {
            if(minOne == -1) {
                minOne = popcnt > 1 ? solve(popcnt - 1, X) : 0;
            }
            int reminder = minOne - dpRem[MIN_ONE][N - i - 1];
            while(reminder < 0) {
                reminder += (popcnt - 1);
            }
            if(popcnt - 1 == 0) {
                ans = 0;
            } else {
                reminder %= (popcnt - 1);
                ans = dp[reminder] + 1;
            }
            remind = reminder;
        } else {
            if(plusOne == -1) {
                plusOne = solve(popcnt + 1, X);
            }
            int reminder = plusOne + dpRem[PLUS_ONE][N - i - 1];
            while(reminder < 0) {
                reminder += (popcnt + 1);
            }

            reminder %= (popcnt + 1);
            ans = dp[reminder] + 1;

            remind = reminder;
        }

        cout << ans <<  endl;
        
    }

    return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long a[n]={};
  long b[n]={};
  int i,j;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  i=0;
  j=n-1;
  while(j>=0){
    b[i]=a[j];
    i++;
    j-=2;
  }
  if(n%2==0) j=0;
  else j=1;
  while(j<n){
    b[i]=a[j];
    i++;
    j+=2;
  }


  
  for(i=0;i<n;i++){
    cout << b[i] << " ";
  }
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 105
using namespace std;

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  int f = a[2]*10+a[1];
  cout << a[0]+f << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main(){
  int x,y,a,b,c; cin >>x >>y >>a >>b >>c; ll ans=0;
  priority_queue<int>p; priority_queue<int>q; priority_queue<int>r;
  for(int i=0; i<a; i++){int pp; cin >>pp; p.push(pp);}
  for(int i=0; i<x; i++){int pp=p.top(); r.push(pp); p.pop();}
  for(int i=0; i<b; i++){int qq; cin >>qq; q.push(qq);}
  for(int i=0; i<y; i++){int qq=q.top(); r.push(qq); q.pop();}
  for(int i=0; i<c; i++){int rr; cin >>rr; r.push(rr);}
  for(int i=0; i<x+y; i++){int s=r.top(); ans+=s; r.pop();}
  cout <<ans;
return 0;}

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){
  int R,C,a[10][10000];
  while(cin>>R>>C,R||C){
    for(int i=0;i<R;++i){
      for(int j=0;j<C;++j) cin>>a[i][j];
    }
    int m=0;
    for(int i=0;i<(1<<R);++i){
      int n=0;
      for(int j=0;j<C;++j){
	int p=0;
	for(int k=0;k<R;++k) if(a[k][j]^(i>>k)&1) ++p;
	n+=max(p,R-p);
      }
      m=max(m,n);
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 1548
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	scan(N>>M);
	vpint ans;
	int kinum=M/2+M%2;
	rep1(i,kinum){
		ans.push_back({i,kinum*2+1-i});
	}
	int gunum=M-kinum;
	rep1(i,gunum){
		ans.push_back({kinum*2+i,kinum*2+(gunum+1)*2-i});
	}
	rep(i,M){
		printf("%d %d\n",ans[i].first,ans[i].second);
	}
	return 0;
}


Measured memory_bytes: 4260