akhauriyash/Code-Regression huggingface dataset:
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  string s;cin>>s;
  int n = sz(s);

  int tmp = 0;
  int res = 0;
  rep(i, n){
    if (s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){
      tmp++;
      chmax(res, tmp);
    }
    else{
      tmp = 0;
    }
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<int> a(N);
    int four = 0, odd = 0;
    REP(i, N) {
        int a;
        cin >> a;
        if (a % 4 == 0) four++;
        else if (a % 2 == 1) odd++;
    }
    if (four + odd == N && four >= odd - 1) cout << "Yes" << endl;
    else if (four >= odd) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ff first 
#define ss second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define testcase(t) int t;cin>>t;while(t--)
#define mp(x,y) make_pair(x,y)
#define in(x) insert(x)
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,a,b)  for (__typeof((b)) i=(b);i>=(a);i--)
#define PI 3.14159265358979323846
#define SP(x) setprecision(x)
#define reflex ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define M 1000000007
#define sz(a) (int)a.size()
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(x) x.resize(distance(x.begin(), unique(all(x))))
#define mem(arr,val) memset(arr,val,sizeof(arr)) //For "0" and "-1"                  
#define inp0(a,n) rep(i,0,n-1) cin>>a[i];
#define inp1(a,n) rep(i,1,n) cin>>a[i]; 
#define prll(x) printf("%lld",x)
#define nth_ele(v,n) nth_element(v.begin(), v.begin()+n ,v.end())//O(N)
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUGV(x) for(auto IT:x) cout<<IT<<" "; cout<<endl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll gcd(ll n1, ll n2){if(n2!=0) return gcd(n2, n1%n2);else return n1;}
ll powerM(ll a,ll b){if(b==0) return 1;  if(b==1) return a%M; ll x=powerM(a,b/2)%M; if(b&1){return ((((a%M)*(x%M))%M)*(x%M))%M;}return ((x%M)*(x%M))%M;}
ll power(ll a,ll b){if(b==0) return 1;  if(b==1) return a; ll x=power(a,b/2); if(b&1){return ((((a)*(x)))*(x));}return ((x)*(x));}
 
const ll INF=1e18; 
const int SIZE = 200005;

int main(){
	reflex;
	ll n,W;
	cin>>n>>W;
	ll wt[n+1], val[n+1];
	rep(i,0,n-1){
		cin>>wt[i]>>val[i];
	}
	ll ans=0;	
	ll k[n+1][W+1];
	rep(i,0,n){
		rep(w,0,W){
			if(i==0||w==0) k[i][w]=0;
			else if(wt[i-1]<=w){
				k[i][w]=max(k[i-1][w], val[i-1]+k[i-1][w-wt[i-1]]);
			}
			else{
				k[i][w]=k[i-1][w];
			}
		}
	}
	cout<<k[n][W]<<endl;
}

Measured memory_bytes: 79104
X, Y = map(int, input().split())
ans = 0
if X == 3:
  ans += 100000
elif X == 2:
  ans += 200000
elif X == 1:
  ans += 300000

if Y == 3:
  ans += 100000
elif Y == 2:
  ans += 200000
elif Y == 1:
  ans += 300000

if X == Y == 1:
  ans += 400000
print(ans)

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

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

    int a;
    int b;
    char op;

    while(cin >> a >> op >> b){
        if(op == '?')
            break;

        switch(op) {
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 3156
// E - Crested Ibis vs Monster
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
vi A,B;
int H,N;

int solve(){
	int INF = INT_MAX>>2;
	vvi dp(N+1, vi(H+1, INF));
	dp[0][0] = 0;
	rp(i,1,N+1){
		int hp = A[i-1], mp = B[i-1];
		rp(j,0,H+1){
			if(j == 0) dp[i][j] = 0;
			else if(j-hp >= 0) dp[i][j] = min(dp[i-1][j], dp[i][j-hp] + mp);
			else dp[i][j] = min(dp[i-1][j], mp);
		}
	}
	return dp[N][H];
}

int main(){
	cin>>H>>N;
	rp(i,0,N){
		int a,b; cin>>a>>b;
		A.push_back(a);
		B.push_back(b);
	}
	cout<< solve() <<endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;
    vi a(n);
    int sx=0;
    rep(i,n){
        cin>>a[i];
        sx^=a[i];
    }

    rep(i,n){
        int ans=sx^a[i];
        cout<<ans<<"\n";
    }

    return 0;

}

Measured memory_bytes: 3952
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W=map(int,input().split())
A=[input() for i in range(H)]
b=[]
l=[[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            l[i][j]=1
            b.append((i,j))
c=0
while 1:
    a=[]
    for i in b:
        if i[0]>0 and not l[i[0]-1][i[1]]:
            a.append((i[0]-1,i[1]))
            l[i[0]-1][i[1]]=1
        if i[1]>0 and not l[i[0]][i[1]-1]:
            a.append((i[0],i[1]-1))
            l[i[0]][i[1]-1]=1
        if i[0]<H-1 and not l[i[0]+1][i[1]]:
            a.append((i[0]+1,i[1]))
            l[i[0]+1][i[1]]=1
        if i[1]<W-1 and not l[i[0]][i[1]+1]:
            a.append((i[0],i[1]+1))
            l[i[0]][i[1]+1]=1
    if not a:
        break
    b=a
    c+=1
print(c)

Measured memory_bytes: 119128
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    vector<int> num(N);
    rep(i, N) {
        num[i] = 3;
    }

    ll ans = 1;
    ll p = 1000000007;
    rep(i, N) {
        if (A[i] != 0) {
            ll already_app_1 = 3 - num[A[i] - 1];
            ll already_app_now = 3 - num[A[i]];
            ans *= max(0LL, (already_app_1 - already_app_now));
            ans %= p;
        }
        else {
            ll already_app_now = num[A[i]];
            ans *= already_app_now;
            ans %= p;
        }
        
        num[A[i]]--;

    }

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

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n;
	long k;
	int *a;
	int *visited;
	int *x;
	scanf("%d", &n);
	scanf("%ld", &k);
	a = (int *)malloc(sizeof(int) * n);
	visited = (int *)malloc(sizeof(int) * n);
	x = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		visited[i] = 0;
		x[i] = 0;
	}
	int tmp_city = 1;
	int j = 0;
	while(visited[tmp_city-1] == 0){
		visited[tmp_city-1] = 1;
		x[j] = tmp_city;
		j++;
		tmp_city = a[tmp_city-1];
	}
	
	int l = 0;
	while(x[l] != tmp_city){
		l++;
	}

	if(k >= l){
		k = (k-l)%(j-l);
		printf("%d\n", x[l+k]);
	}
	else{
		printf("%d\n", x[k]);
	}
	return 0;
}

Measured memory_bytes: 4080
using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		string[]s=Console.ReadLine().Split();
		int n=int.Parse(s[0]);
		int l=int.Parse(s[1]);
		int sum=0;
		for(int i=0;i<n;i++)
		{
		
			sum+=l+i;
		}
		int min=int.MaxValue;
		int ind=-1;
		for(int i=0;i<n;i++)
		{
			int sum1=0;
			for(int j=0;j<n;j++)
			{
				if(j==i)continue;			
				sum1+=l+j;
			}
			if(Math.Abs(sum1-sum)<min)
			{
				min=Math.Abs(sum1-sum);
				ind=sum1;
			}
		}
		Console.WriteLine(ind);
		
	}
}

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

int main(){
    int n; //the number of works
    vector<pair<int , int>> tasks; //仕事の所要時間と締め切り

    //input
    cin >> n;
    for(int i=0; i<n; i++){
        int time,line; //timeが所要時間、lineが締め切り
        cin >> time >> line;
        tasks.emplace_back(line,time);
    }

    //締め切りでsortする
    sort(tasks.begin(),tasks.end());

    int sum = 0; //仕事の所要時間の合計
    
    //所要時間の合計が締め切りに間に合うか確認
    for(auto task : tasks){
        sum += task.second;
        if(sum > task.first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 2420
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> val = new ArrayList<>();
        for(int i=0; i<N; i++){
            val.add(scanner.nextInt());
        }
        int minRight = val.get(N-1);
        String result = "Yes";
        for(int i=N-2; i>=0; i--){
            if(val.get(i) >= minRight+2){
                result = "No";
            }
            if(minRight>val.get(i)){
                minRight = val.get(i);
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 59392
n = int(input())
a = [0] * 10**5
for x in input().split():
    a[int(x)] += 1
c = 0
for i in range(1, 10**5 - 1):
    c = max(c, a[i] + a[i - 1] + a[i + 1])
print(c)


Measured memory_bytes: 10712
from decimal import *
def resolve():

    tn,ta, tb = map(int, input().split())
    n=Decimal(tn)
    a=Decimal(ta)
    b=Decimal(tb)
    if (b-a)%2 == 1:
        ans=min(a-1,n-b)+1+(b-a-1)/2
    else:
        ans=(b-a)/2

    print(int(ans))

resolve()

Measured memory_bytes: 5076
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> p(n, 0);
	for (int i = 0; i < p.size(); i++) {
		cin >> p[i];
	}
	
	vector<int> val;
	int ans = 0;
	for (int i = 1; i < (p.size() - 1); i++) {
		val.clear();
		for (int j = -1; j <= 1; j++) {
			val.push_back(p[i + j]);
		}
		sort(val.begin(), val.end());
		if (p[i] == val[1]) {
			ans += 1;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;


template <class T>
std::istream& operator>>(std::istream& in, std::vector<T>& data) {
    for (auto& item : data) {
        in >> item;
    }
    return in;
}

template <class T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& data) {
    bool first = true;
    for (const auto& item : data) {
        if (!first) {
            out << " ";
        }
        out << item;
        first = false;
    }
    return out;
}


int main() {
#ifdef LOCAL
    freopen("atcoder/input.txt", "r", stdin);
#endif

    string s;
    cin >> s;

    int n1 = (s[0] - '0') * 10 + (s[1] - '0');
    int n2 = (s[2] - '0') * 10 + (s[3] - '0');

    if (1 <= n1 && n1 <= 12 && 1 <= n2 && n2 <= 12) {
        cout << "AMBIGUOUS" << "\n";
    } else if (1 <= n1 && n1 <= 12 && !(1 <= n2 && n2 <= 12)) {
        cout << "MMYY\n";
    } else if (1 <= n2 && n2 <= 12 && !(1 <= n1 && n1 <= 12)) {
        cout << "YYMM\n";
    } else {
        cout << "NA\n";
    }

    return 0;
}











Measured memory_bytes: 256
#include<iostream>
#include<set>

using namespace std;
int main()
{
  int n;
  int l;
  cin>>n>>l;
  multiset<string> s;
  for(int i = 0 ; i < n ; i++){
    string input;
    cin>>input;
    s.insert(input);
  }
  for(auto i : s){
    cout<<i;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

typedef long long ll;

int main() {
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> A(x, 0);
  vector<ll> B(y, 0);
  vector<ll> C(z, 0);
  for (ll i = 0; i < x; i++) {
    cin >> A[i];
  }
  for (ll i = 0; i < y; i++) {
    cin >> B[i];
  }
  for (ll i = 0; i < z; i++) {
    cin >> C[i];
  }

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

  vector<ll> AB;
  for (ll i = 0; i < x; i++) {
    for (ll j = 0; j < y; j++) {
      AB.push_back(A[i] + B[j]);
    }
  }
  sort(AB.begin(), AB.end(), greater<ll>());
  AB.resize(k);

  vector<ll> ans;

  for (ll i = 0; i < k; i++) {
    for (ll j = 0; j < z; j++) {
      ans.push_back(AB[i] + C[j]);
    }
  }
  sort(ans.begin(), ans.end(), greater<ll>());
  for (ll i = 0; i < k; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 43368
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;


template<class T>
struct point{
    T x,y;
    point() : x(0), y(0) {}
    point(const T& x,const T& y) : x(x), y(y) {}
    point operator+(const point &a)const{ return point(x+a.x,y+a.y); }
    point& operator+=(const point &a){x += a.x; y += a.y; return *this;}
    point operator-(const point &a)const{ return point(x-a.x,y-a.y); }
    point& operator-=(const point &a){x -= a.x; y -= a.y; return *this;}
    point operator*(const double a)const{ return point(a*x,a*y); }
    point& operator*=(const double a)const{ x *= a; y *= a; return *this;}
    point operator/(const double a)const{ return point(a/x,a/y); }
    point& operator/=(const double a)const{ x /= a; y /= a; return *this;}
	
	//比較用
	bool operator<(const point &a)const{return (x != a.x) ? (x < a.x) : (y < a.y);}
 
};

template<class T> T SQ(T x){ return x*x; }
template<class T> T dist2(const point<T> &a,const point<T> &b){return SQ(a.x-b.x)+SQ(a.y-b.y);}
template<class T> T abs(const point<T>& p){return sqrt(SQ(p.x) + SQ(p.y));}
template<class T> T dot(const point<T>& a,const point<T>& b)
{return a.x*b.x + a.y*b.y;}
template<class T> T cross(const point<T>& a,const point<T>& b)
{return a.x*b.y - a.y*b.x;}
template<class T> point<T> rot(const point<T>& a,const double theta){
        return point<T>(a.x*cos(theta)-a.y*sin(theta),
			a.x*sin(theta)+a.y*cos(theta));
}

template<class T>
T area(const vector<point<T> >& v){
	T ans = 0;
	for (int i = 2; i < (int)v.size(); i++){
		ans += cross(v[i-1] - v[0],v[i] - v[0]);
	}
	return abs(ans) / 2;
}

int main(){
	double ans = 0.0;
	double x,y;
	vector<point<double> > p;

	while(~scanf("%lf,%lf",&x,&y)) p.push_back(point<double>(x,y));
	

	printf("%lf\n",abs(area(p)));

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
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) 配列の中のmin-max
// 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};
// ~ は、-1の時だけfalse

int main() {
    int n,a[16],x[16][16],y[16][16];
    cin>> n;
    rep(i,n) {
        cin>>a[i];
        rep(j,a[i]) {
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans = 0;
    for (int bit = 0;bit<(1<<n);bit++) {
        int count=0;
        bool end = false,last=false;
        for (int i = 0;i<n;i++) {
            if((1<<i) & bit) {
                rep(j,a[i]) {
                    if(y[i][j] != ((bit>>(x[i][j]-1))&1)) {
                        end = true;
                        break;
                    }
                }
                if(end) {
                    last=true;
                    break;
                } else {
                    count++;
                }
            }
        }
        if(!last) ans = max(ans,count); 
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		int t=0;
		LinkedList<Process> list=new LinkedList<Process>();
		for(int i=0;i<n;i++){
			String ps=sc.next();
			int pt=sc.nextInt();
			Process pr=new Process(ps,pt);
			list.addLast(pr);
		}
		while(list.size()>0){
			if((list.getFirst()).time>q){
				Process x=list.poll();
				t+=q;
				x.time-=q;
				list.add(x);				
			}else{
				Process x=list.poll();
				t+=x.time;
				System.out.println(x.name+" "+t);
			}
		}
	}
}

class Process{
	String name;
	int time;
	Process(String a,int b){
		name=a;
		time=b;
	}
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a,ans;

int gcd(int a ,int b) {
    if (!(a%b)) return b;
    a %= b;
    swap(a,b);
    gcd(a,b);
}

main() {
    cin >> n >> ans;
    rep(i,n-1) {
        cin >> a;
        ans = gcd(a,ans);
    }
    ct(ans)
}


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

//43
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	//double ans = 0;
	sort(v.begin(),v.end());
	for (int i = 1; i  < n; ++i) {
		//ans += (v[i] + v[i - 1]) / 2.0;
		v[i] = (v[i] + v[i - 1]) / 2.0;
	}
	cout << fixed << setprecision(12) << v[n - 1];
}


Measured memory_bytes: 3796
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N (1000*100)
#define MAX_AB (1000*100)

int N;
ull K;
ull numcnt[MAX_N+5];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N >> K;
	int maxa=0;
	FOR(n,N) {
		int a;
		ull b;
		cin >> a >> b;
		maxa = max(maxa,a);
		numcnt[a]+=b;
	}

	ull k=0;
	int a=0;
	for(a=1;a<=maxa;a++) {
		k+=numcnt[a];
		if(k>=K) {
			break;
		}
	}

	cout << a << endl;

	return 0;
}



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

using namespace std;

typedef long long int ll;

const int MAX_N = 100;

// 最大公約数を求める関数
long long int gcd(long long int x, long long int y)
{
  if(y == 0) return x;
  return gcd(y,x%y);
}

// 最大公約数を求める関数
long long int lcm(long long int x, long long int y)
{
  long long int g = gcd(x,y);
  return x / g * y;
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> vec(n,0);
  for (size_t i = 0; i < n; i++) cin >> vec[i];

  ll ans = lcm(vec[0], 1LL);
  for (long long int i = 1; i < vec.size(); i++) {
    ans = lcm(ans,vec[i]);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    string s; cin>>s;
    int sum = 0;
    for(i = 0; i < s.size(); i++) sum += s[i]-'0';
    if(sum % 9) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3728
/*
Author : N_o_o_B
Created : December 03 2019 22:56:57 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vi a(n);
    ll sum=0;
    fori(i,n) {cin >> a[i];sum+=a[i];}
    int mean = sum/n;
    ll ans1 = 0,ans2=0;
    fori(i,n){
        ans1 += pow(mean-a[i],2);
        ans2 += pow(mean+1-a[i],2);
    }

    cout << min(ans1,ans2) << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++ 
int n;
int a[200000];
signed main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		a[i]=a[i-1]+a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;){
		int j=i;
		int sum=0;
		while(j<n&&a[i]==a[j]){
			j++;
		}
		sum=j-i;
		if(a[i]==0){
			ans+=sum;
		}
		ans+=sum*(sum-1)/2;
		i=j;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

	int find(int e) {
		return d[e];
	}
};

int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

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

bool prime(int a) {
	if (a == 1)
		return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;
	}
	return true;
}

class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(int x, int y) {
		if (same(x, y))
			return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}

	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(int x, int y) {
		return Find(x) == Find(y);
	}

	int get_Size(int a) {
		return s[a];
	}
};

vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}

signed main() {
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    printf("%.9lf ",w*h/2.0);
    if(x==w/2.0&&y==h/2.0)cout<<1<<endl;
    else cout<<0<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

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

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

vector<int> ans[2];
int main() 
{
	int n;
	cin >> n;
	int turn = 0;
	for (int i = 0; i < n; i++) {
		int A;
		cin >> A;
		ans[turn].push_back(A);
		turn = (turn + 1) % 2;
	}
	if (turn == 0) {
		reverse(ans[1].begin(), ans[1].end());
		for (int i = 0; i < ans[1].size(); i++) {
			cout << ans[1][i] << " ";
		}
		for (int i = 0; i < ans[0].size(); i++) {
			cout << ans[0][i] << " ";
		}
		cout << endl;
	}
	else {
		reverse(ans[0].begin(), ans[0].end());
		for (int i = 0; i < ans[0].size(); i++) {
			cout << ans[0][i] << " ";
		}
		for (int i = 0; i < ans[1].size(); i++) {
			cout << ans[1][i] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;


int main(void) {
    int n, a, b;
    
    cin >> n >> a >> b;
    string s_input;
    cin >> s_input;
    
    int pass_limit = a + b;
    int b_counter = 0;
    int total_pass_counter = 0;
    
    for (int i = 0; s_input[i]; i++) {
        if (s_input[i] == 'c') {
            cout << "No" << endl;
            continue;
        }else if (s_input[i] == 'a' && (total_pass_counter < pass_limit)){
            cout << "Yes" << endl;
            total_pass_counter++;
        }else if (s_input[i] == 'b' && (total_pass_counter < pass_limit) && (b_counter < b)){
            cout << "Yes" << endl;
            total_pass_counter++;
            b_counter++;
        }else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
std::vector<bool> IsPrime;

void sieve(size_t max) {
    if (max + 1 > IsPrime.size()) {
        IsPrime.resize(max + 1, true);
    }
    IsPrime[0] = false;
    IsPrime[1] = false;

    for (size_t i = 2; i*i <= max; ++i)
        if (IsPrime[i])
            for (size_t j = 2; i*j <= max; ++j)
                IsPrime[i*j] = false;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    sieve(100004);
    if (IsPrime[x])cout << x << endl;
    else {
        while (IsPrime[x] == false) {
            x++;
        }
        cout << x << endl;
    }

    return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');
            int i;
            int[] num = new int[N];
            int wareru=0;
            int flag = 1;

            for (i = 0; i < N; i++)//代入
            {
                num[i] = int.Parse(a[i]);
            }

            while(true)
            {
                for (i = 0; i < N; i++)
                {
                    if (num[i] % 2 == 1) { flag = 0;break; }
                }
                if (flag == 0) { break; }
                wareru++;
                for (i = 0; i < N; i++)
                {
                    num[i] /= 2;
                }
            }

            Console.WriteLine(wareru);

        }
    }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long A[3][3];
	bool B[3][3] = {};
	long long N;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) cin >> A[i][j];
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		long long X;
		cin >> X;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (A[j][k] == X) B[j][k] = true;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		if (B[i][0] && B[i][1] && B[i][2]) {
			cout << "Yes" << endl;
			return 0;
		}
		if (B[0][i] && B[1][i] && B[2][i]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (B[0][0] && B[1][1] && B[2][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (B[0][2] && B[1][1] && B[2][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static int n;
        static boolean[][] f;
        static int[][] p;

        static long dfs(boolean[] b, int cn, long max, boolean tf) {
            b[cn] = tf;
            long cMax = max;
            if (cn + 1 < b.length) {
                cMax = dfs(b, cn + 1, cMax, false);
            }
            if (cn + 1 < b.length) {
                cMax = dfs(b, cn + 1, cMax, true);
            }

            boolean opened = false;
            for (int i = 0; i < b.length; i++) {
                if (b[i]) {
                    opened = true;
                    break;
                }
            }
            if (!opened) return max;

            if (cn == b.length - 1) {
                int cProfit = 0;
                for (int i = 0; i < n; i++) {
                    int iCount = 0;
                    for (int j = 0; j < 10; j++) {
                        if (b[j] && f[i][j]) iCount++;
                    }
                    cProfit += p[i][iCount];
                }
                if (cProfit > cMax) cMax = cProfit;
            }

            return cMax;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            f = new boolean[n][10];
            p = new int[n][11];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 10; j++) {
                    int c = in.nextInt();
                    f[i][j] = (c == 1);
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 11; j++) {
                    int c = in.nextInt();
                    p[i][j] = c;
                }
            }

            boolean[] open = new boolean[10];
            long max = Long.MIN_VALUE;
            max = dfs(open, 0, max, false);
            max = dfs(open, 0, max, true);

            out.println(max);
        }

    }
}



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

string S, T;
long long A[100005], B[100005];

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

    int N, M;
    cin >> N >> M >> S >> T;
        
    long long L = (long long) N * M / __gcd(N, M);
    
    long long x = L / N, y = L / M;
    
    for(int i=0; i<N; i++)
        A[i] = 1LL * i * x;
    for(int i=0; i<M; i++)
        B[i] = 1LL * i * y;
    
    int ptr = 0;
    
    for(int i=0; i<M; i++)
    {
        while(ptr < N && A[ptr] < B[i])
            ptr++;
        
        if(ptr < N && A[ptr] == B[i])
        {
            if(S[ptr] != T[i])
            {
                cout << "-1\n";
                return 0;
            }
            
            ptr++;
        }
    }
    
    cout << L << "\n";
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (j == W - 1) {
					cout << "#" << endl;
				}
				else {
					cout << "#";
				}
			}
		}
		cout << "" << endl;
	}
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main()
{
  string n;
  int f=0;
  cin>>n;
  for(int i=0;n[i]!='\0';i++)
  {
    if(n[i]=='7')
    {
      cout<<"Yes";
      f=1;
      break;
    }
  }
  if(f==0)
    cout<<"No";
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  vl A(N), B(N);
  rep(i, 0, N) in(A[i], B[i]);
  ll c = 0;
  rrep(i, N, 0) {
    int d = (A[i] + c) % B[i];
    if (d) {
      c += B[i] - d;
    }
  }
  print(c);
}


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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n, x, t;
    cin >> n >> x >> t;
    int cnt = (n + x - 1) / x;
    int ans = cnt * t;
    cout << ans;
}


Measured memory_bytes: 3648
import math
N = int(input())

def FindAllDivisors(x):
    divList = []
    y = 1
    while y <= math.sqrt(x):
        if x % y == 0:
            divList.append(y)
            divList.append(int(x / y))
        y += 1
    return divList
ans = 0
if (N == 105):
  ans = 1
elif (N > 105):
  ans += 1
  for i in range(106, N+1):
    if (i % 2 != 0):
      lst = FindAllDivisors(i)
      if (len(lst) == 8):
        ans += 1
print(ans)


Measured memory_bytes: 3064
f [] [] [] i = i
f (x:xs) (y:ys) (z:zs) i
  | x == y && y == z = f xs ys zs i
  | x /= y && y /= z && z /= x = f xs ys zs (i + 2)
  | otherwise = f xs ys zs (i + 1)

main = do
  getLine
  a <- getLine
  b <- getLine
  c <- getLine
  print $ f a b c 0


Measured memory_bytes: 508
N = int(input())
h = [int(i) for i in input().split()]

ans = 0
start = 0
end = 0
while any(h):
    for i in range(N):
        if h[i]!=0:
            start = i
            break
    end = N-1
    for i in range(start,N):
        if h[i]==0:
            end = i-1
            break
    m = min(h[start:end+1])
    for i in range(start,end+1):
        h[i] = h[i] - m
    ans += m

print(ans)


Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    from collections import Counter
    c=Counter(l)# ()にカウンターの対象のリストの変数名
    cnt=0
    for i in c.values():
        if i>=2:
            cnt+=i*(i-1)//2
    for j in l:
        x=(c[j]-1)*(c[j]-2)//2-c[j]*(c[j]-1)//2
        print(cnt+x)
resolve()

Measured memory_bytes: 83148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int m = 0;
    int count = 0;
    while(n != 0)
    {
        m = n % 10;
        if(m == 7)
        {
            cout<<"Yes";
            count++;
            break;
        }
        n /= 10;
    }
    if(count == 0)
    {
        cout<<"No";
    } 
    
}

Measured memory_bytes: 3576
import datetime

S = input()
a = "2019/04/30"

S_dateformated = datetime.datetime.strptime(S, "%Y/%m/%d")
a_dateformated = datetime.datetime.strptime(a, "%Y/%m/%d")

if S_dateformated<=a_dateformated:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 4464
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;
const int N = 5e5 + 9;

int n, m; 
ll to[N << 1], nxt[N << 1], beg[N], tot;
ll c[N], w[N << 1];
ll ans, f[4], flag;

inline void _read(int &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t)) t = getchar();
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}

inline void add(const int &u, const int &v, const int &c)
{
	to[++tot] = v;
	nxt[tot] = beg[u];
	w[tot] = c;
	beg[u] = tot;
}

inline void dfs(int u)
{
	f[c[u]]++;
	for (register int i = beg[u]; i; i = nxt[i])
	{
		if (w[i] == 1)f[3]++;
		if (!(~c[to[i]]))
		{
			c[to[i]] = (c[u] + w[i]) % 3;
			dfs(to[i]);
		}
		else if (c[to[i]] != (c[u] + w[i]) % 3)
			flag = 1;
	}
}

int main()
{
	_read(n), _read(m);
	for (register int i = 1, u, v; i <= m; i++)
	{
		_read(u), _read(v);
		add(u, v, 1), add(v, u, 2);
	}

	memset(c, -1, sizeof c);
	for (register int i = 1; i <= n; i++)
		if (!(~c[i]))
		{
			f[c[i] = 0] = f[1] = f[2] = f[3] = flag = 0;
			dfs(i);
			if (flag)
			{
				register ll cnt = f[0] + f[1] + f[2];
				ans += cnt * cnt;
				continue;
			}
			if ((!f[0]) || (!f[1]) || (!f[2]))
			{
				ans += f[3];
				continue;
			}

			ans += f[0] * f[1];
			ans += f[1] * f[2];
			ans += f[2] * f[0];
		}

	printf("%lld", ans);
	return 0;
}

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int m=in.nextInt();
		int [] a=new int [n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
		}
		int [][] b = new int [m][2];
		for(int i=0;i<m;i++)
		{
			b[i][1]=in.nextInt();
			b[i][0]=in.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b, (c, d) -> Integer.compare(c[0], d[0]));
		int q=m-1;
		long sum=0;
		for(int i=0;i<n;i++)
		{
			if(b[q][1]==0&&q>0)
			{
				q--;
			}
			if(b[q][0]>a[i]&&b[q][1]>0)
			{
				sum=sum=sum+b[q][0];
				b[q][1]--;
			}
			else
			{
				sum=sum+a[i];
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 95080