akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  ll N;
  cin >> N;
  ll m=0;
  for (ll i=1; i<=pow(10,6)+1; i++) {
    if (N<i*i) {
      m=i-1;
      break;
    } 
  }
  
  int n;
  for (ll i=m; i>=1; i--) {
    if (N/i*i==N) {
      n=i;
      break;
    }
  }
  
  cout << N/n+n-2 << endl;
}

Measured memory_bytes: 3588
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

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

   int rohan;
   cin>>rohan;
   int arr[rohan];
   for (int i = 0; i <rohan; ++i)
   {
   	/* code */
   	cin>>arr[i];
   }

   map<int,int>rakesh;
   for (int i = 0; i < rohan; ++i)
   {
   	/* code */
   	rakesh[arr[i]]++;
   }
   ll count=0;

   for (auto x:rakesh)
   {
   	if(x.second>=2){
   		cout<<"NO"<<endl;
   		count=1;
   		break;
   	}
   	/* code */
   }

   if(count==0){
   	cout<<"YES"<<endl;
   }

   return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;

int main(){
    int a, b, c;
    int count5 = 0;
    int count7 = 0;
    cin >> a >> b >> c;
    if (a == 5) {
        count5 ++;
    } else if (a == 7) {
        count7 ++;
    }
    if (b == 5) {
        count5 ++;
    } else if (b == 7) {
        count7 ++;
    }
    if (c == 5) {
        count5 ++;
    } else if (c == 7) {
        count7 ++;
    }
    if ((count5 == 2) && (count7 == 1)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int a, b, c, x, y;

int main() {
    cin >> a >> b >> c >> x >> y;
    if (x > y) {
        swap(a,b);
        swap(x,y);
    }
    if (a+b <= 2*c) {
        cout << x*a + b*y << endl;
    } else {
        if (b <= 2*c) {
            cout << 2*c*x+b*(y-x) << endl;
        } else {
            cout << 2*c*y << endl;
        }
    }
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

h1, m1, h2, m2, k = na()

m1 += k
if m1 // 60 != 0:
    h1 += m1 // 60
    m1 %= 60

t1 = h1 * 60 + m1
t2 = h2 * 60 + m2

print(t2 - t1)

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

ll n,m,k;
vector<ll> sa,sb;

bool isok(ll i,ll j){
  if(sb[j]<=k-sa[i])return true;
  else return false;
}

    
int nibutan(ll i){
  int ok=0,ng=m+1;
  while(ng-ok>1){
    ll naka=(ng+ok)/2;
    if(isok(i,naka))ok=naka;
    else{
      ng=naka;
    }
  }
    return ok+i;
  }
    
 int main(){
   cin>>n>>m>>k;
   sa.resize(n+1);
   sb.resize(m+1);
   sa[0]=0, sb[0]=0;
   for(ll i=0;i<n;i++){
     int a;
     cin>>a;
   sa[i+1]=sa[i]+a;
   }
   for(ll j=0;j<m;j++){
     int b;
     cin>>b;
    sb[j+1]=sb[j]+b;
   }
   ll ans=0;
   for(ll i=0;i<=n;i++){
     if(sa[i]<=k){
     ll ima=nibutan(i);
     ans=max(ans, ima);
     }
   }
cout<<ans<<endl;
}
       

Measured memory_bytes: 6384
#include <iostream>

using namespace std;

int main(){
    int x,y;
    scanf("%2d%2d",&x,&y);

    if(x>0 && x<13 && y>0 && y<13){
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(x>=0 && x<100 && y>0 && y<13){
        cout<<"YYMM"<<endl;
    }
    else if(y>=0 && y<100 && x>0 && x<13){
        cout<<"MMYY"<<endl;
    }
    else{
        cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long double PI =(acos(-1));

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin >> a.at(i);
    }
    for(int i=n-1;i>=0;--i){
        cout << a.at(i);
        if(i>0){
            cout << " ";
        }
    }cout << endl;
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#define ll unsigned long long
using namespace std;

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

	ll n,a,b;
	cin >> n >> a >> b;
	if(a==0 and b==0) cout << 0;
	else{
		ll ans = n/(a+b)*a;
		if(n%(a+b) <= a) ans+= n%(a+b);
		else ans+=a;
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = int.Parse(spl[1]);

        double r = 0;

        for(int i=1; i<=n; i++) {
            double a = 1.0 / n;
            
            long p = i;
            while (p < k) {
                p *= 2;
                a /= 2;
            }

            r += a;
        }

        return r;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &e : A) cin >> e;
  sort(A.begin(), A.end());
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        if (A[i] == A[j] || A[j] == A[k]) continue;
        if (A[i]+A[j]>A[k]) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        List<Integer> a = new ArrayList<>(n);
        for (int i = 0; i < n; i++) a.add(scan.nextInt());
        int k = 1;

        for (int item : a
        ) {
            if (item == k) {
                k++;
            }
        }

        if (k == 1) {
            System.out.println(-1);
        } else {
            System.out.println(n - (k - 1));
        }
    }
}


Measured memory_bytes: 88996
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n; vector<string> s;
int main() {
	while (cin >> n, n) {
		s.resize(n);
		for (int i = 0; i < n; i++) cin >> s[i];
		vector<vector<bool> > flag(n, vector<bool>(n, false)); // i -> j
		vector<vector<int> > cost(n, vector<int>(n)); // i -> j
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (s[i].find(s[j]) != string::npos) {
					flag[i][j] = true;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k <= s[i].size(); k++) {
					string ret = s[i].substr(0, k) + s[j];
					if (ret.substr(0, s[i].size()) == s[i]) {
						cost[i][j] = ret.size() - s[i].size();
						break;
					}
				}
			}
		}
		vector<vector<int> > dp(1 << n, vector<int>(n, 999999999));
		dp[0][0] = 0;
		for (int i = 1; i < 1 << n; i++) {
			for (int j = 0; j < n; j++) {
				if (!(i & (1 << j))) continue;
				int p = i - (1 << j);
				for (int k = 0; k < n; k++) {
					if(p != 0) dp[i][j] = min(dp[i][j], dp[p][k] + cost[k][j]);
					else dp[i][j] = min(dp[i][j], dp[p][k] + (int)s[j].size());
				}
			}
		}
		int ret = 999999999;
		for (int i = 1; i < 1 << n; i++) {
			int bit = i;
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (flag[j][k] && (i & (1 << j))) bit |= 1 << k;
				}
			}
			if (bit == (1 << n) - 1) {
				for (int j = 0; j < n; j++) ret = min(ret, dp[i][j]);
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 4272
#include <stdio.h>
int main(){
	int a,b;
	char op;
	refrain:
	scanf("%d %c %d",&a,&op,&b);
	if(op=='?'){
		return 0;
	}
	else if(op=='+'){
		printf("%d\n",a+b);
	}
	else if(op=='-'){
		printf("%d\n",a-b);
	}
	else if(op=='/'){
		printf("%d\n",a/b);
	}
	else if(op=='*'){
		printf("%d\n",a*b);
	}
	goto refrain;
}

Measured memory_bytes: 600
// Contest: Panasonic Programming Contest 2020 (https://atcoder.jp/contests/panasonic2020)
// Problem: B: Bishop (https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    ll w, h; cin >> h >> w;
    if (w == 1 || h == 1)
        cout << "1\n", exit(0);
    ll sum = (w * h + 1) / 2;
    cout << sum << '\n';

    return 0;
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
    int N;
    cin >> N;
    long a[N];
    for (int i = 0; i < N; ++i) cin >> a[i];
    
    // 解法
    int Alice = 0;
    int Bob = 0;
    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
    for (int i = 0; i < N; ++i){
    	if (i%2==0) Alice += a[i];
    	else Bob += a[i];
    }
    
    //出力
    cout << Alice - Bob << endl;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];
int n;
vector<int> v;

int main()
{
	scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	int i=0;
	while(i<n){
		int s=i;
		while((a[i+1]^a[i])&&i<n-1){
			i++;
		}
		i++;
		v.push_back(i-s);
	}
	if(v.size()==1||v.size()==2){
		printf("%d\n",n);
	}else{
		int rsum = v[0]+v[1]+v[2];
		int ans = rsum;
		int i=0;
		while(i+3<v.size()){
			rsum += v[i+3];
			rsum -= v[i];
			ans = max(ans,rsum);
			i++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3780
import math
Q=int(input())

def isPrime(num):
    
    if num < 2: return False
    
    elif num == 2: return True
    
    elif num % 2 == 0: return False

    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    
    return True


def callIsPrime(input_num=1000):
    numbers = []
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    return numbers
A=callIsPrime(100000)
b=[False]*100000
for i in A:
  b[i-1]=True
s=[0]*100000
for i in range(1,100000):
  if b[i]:
    if b[int((i+2)/2)-1]:
      s[i]=s[i-1]+1
    else:s[i]=s[i-1]
  else:
    s[i]=s[i-1]
for i in range(Q):
  l,r=map(int,input().split())
  if l==1:print(s[r-1])
  else:print(s[r-1]-s[l-2])

Measured memory_bytes: 53084
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
struct DisjointSet {
	vi rank, p;
	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size) makeSet(i);
	}
	inline void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	inline bool same(int x, int y) { return findSet(x) == findSet(y); }
	inline void unite(int x, int y) { link(findSet(x), findSet(y)); }
	inline void link(int x, int y) {
		if(rank[x] > rank[y]) p[y] = x;
		else {
			p[x] = y;
			if(rank[x] == rank[y]) ++rank[y];
		}
	}
	inline int findSet(int x) {
		if(x != p[x]) p[x] = findSet(p[x]);
		return p[x];
	}
};
struct Edge {
	int source = 0, target = 0, cost = 0;
	Edge(int source = 0, int target = 0, int cost = 0):
		source(source), target(target), cost(cost) {}
	inline bool operator < (const Edge &e) const { return cost < e.cost; }
};
inline int kruskal(int n, vector<Edge> edges) {
	sort(all(edges));
	DisjointSet dset = DisjointSet(n + 1);
	rep(i, 0, n) dset.makeSet(i);
	Edge e;
	int totalCost = 0;
	rep(i, 0, len(edges)) {
		e = edges[i];
		if(!dset.same(e.source, e.target)) {
			totalCost += e.cost;
			dset.unite(e.source, e.target);
		}
	}
	return totalCost;
}
int main() {
	int n, m; cin >> n >> m;
	vector<Edge> edges;
	int source, target, cost;
	rep(i, 0, m) {
		cin >> source >> target >> cost;
		edges.eb(Edge(source, target, cost));
	}
	P(kruskal(n, edges));
	return 0;
}

Measured memory_bytes: 5432
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

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

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for ( ll i = k; i <= n+1; ++i ) {
        ll l = i * ( i - 1 ) / 2;
        ll r = n * i - l;
        ans += r - l + 1;
//        cout << ans << endl;
    }

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


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b,x;
	cin>>a>>b>>x;
	if(a*a*b==x){
		cout<<0;
		return 0;
	}
	if(a*a*b>=x*2){
		double h=x/a*1.0;
		h=h/b*2.0;
		double s=double(h*h)*1.0/double(sqrt(b*b+h*h));
		h=double(sqrt(h*h-s*s));
		cout<<fixed<<setprecision(13)<<90-asin(h/b)*180/3.1415926535;
	}
	else
	{
		double c=double(double(2*x/a)/a)-b;
		x-=a*a*c;
		b-=c;
		double h=double(double(x/a)/b)*2;
		double s=double(h*h)/double(sqrt(b*b+h*h));
		h=double(sqrt(h*h-s*s));
		cout<<fixed<<setprecision(13)<<90-asin(h/b)*180/3.1415926535;
	}
}

Measured memory_bytes: 256
n = int(input())
ans = 0
p = -999
a = [i - 1 for i in map(int, input().split())]
b = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in a:
    ans += b[i]
    if i == p + 1:
        ans += c[p]
    p = i
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>

using namespace std;

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

#define M 2000

bool ab[100000],ac[100000],bc[100000];

bool match(char c1, char c2){
  return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main(void){
  int i,j;

  string a,b,c;
  cin >> a >> b >> c;

  int A = a.length();
  int B = b.length();
  int C = c.length();

  REP(i,A) REP(j,B) if(!match(a[i], b[j])) ab[i-j+50000] = true;
  REP(i,A) REP(j,C) if(!match(a[i], c[j])) ac[i-j+50000] = true;
  REP(i,B) REP(j,C) if(!match(b[i], c[j])) bc[i-j+50000] = true;

  int ans = 3 * M;
  for(i=-2*M;i<=2*M;i++) for(j=-2*M;j<=2*M;j++) if(!ab[i+50000] && !ac[j+50000] && !bc[j-i+50000]){
    int L = min(0, min(i, j));
    int R = max(A, max(B + i, C + j));
    ans = min(ans, R - L);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

    static class A {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt(), c;
            int a[][] = new int[n][3];
            for (int i = 1; i <= n - 1; i++) {
                a[i][0] = in.scanInt();
                a[i][1] = in.scanInt();
                a[i][2] = in.scanInt();
            }
            for (int i = 1; i < n; i++) {
                c = a[i][1];
                for (int j = i; j < n; j++) {
                    if (c < a[j][1]) c = a[j][1];
                    else if (c > a[j][1]) {
                        if (c % a[j][2] != 0) {
                            c = ((c / a[j][2]) + 1) * a[j][2];
                        }
                    }
                    c += a[j][0];
                }
                out.println(c);
            }
            out.println(0);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 23380
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int n;
  int p[16];
  int i;
  int max=0,ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(i=0;i<n;i++){
    if(max<p[i]){
      max=p[i];
    }
    ans+=p[i];
  }
  ans-=max/2;
  printf("%d\n",ans);

  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int sign(int s){
	return s == 0 ? -1 : 1;
}

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

	int n,m;
	cin >> n >> m;

	ll x[n], y[n], z[n];
	rep(i, n) cin >> x[i] >> y[i] >> z[i];

	ll ans = 0;
	rep(i,8){
		ll a[n];
		rep(j, n){
			a[j] = sign(i & (1 << 2)) * x[j] + sign(i & (1 << 1)) * y[j] + sign(i & 1) * z[j];
		}

		sort(a, a+n, greater<ll>());
		ll t = 0;
		rep(j, m) t += a[j];
		ans = max(ans, t);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(iim())

    S = [0] * N
    for ai in A:
        S[ai-1] += 1
    print(*S, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 32376
while true do
  x, y, z = gets.chomp.split(" ").map(&:to_i)
  if x == -1 && y == -1 && z == -1
    break
  end

  sum = x + y
  if sum < 50 && z >= 50
    puts "C"
  elsif x == -1 && z == -1
    puts "F"
  elsif y == -1 && z == -1
    puts "F"
  else
    if sum >= 80
      puts "A"
    elsif sum < 80 && sum >= 65
      puts "B"
    elsif sum < 65 && sum >= 50
      puts "C"
    elsif sum >= 30 && sum < 50
      puts "D"
    else
      puts "F"
    end
  end
end



Measured memory_bytes: 6872
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    if a==2 or b==2:
        print('No')
    else:
        print('Yes')
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <unordered_map>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int n, ans;
vector<int> v(200010);
unordered_map<int,int> M;

int main() {
	fastio;
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> v[i+1];
		M[v[i+1]]++;
	}
	for (int i=1; i<=n; i++) {
		int flag=1;
		for (int j=1; j*j<=v[i]; j++) {
			if (v[i]%j==0) {
				if (j==v[i] && M[j]>=2 || j!=v[i] && M[j]>=1 || v[i]/j==v[i] && M[v[i]/j]>=2 || v[i]/j!=v[i] && M[v[i]/j]>=1) {
					flag=0;
					break;
				}
			}
		}
		if (flag) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 32524
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>
#include <map>
#include <utility>

using namespace std;

int main(){

    int a, x;
    cin >> a;
    cin >> x;

    if(a < x){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define MAXN 2005
#define open(s) freopen( s".in", "r", stdin ), freopen( s".out", "w", stdout )
#define fp( i, b, e ) for ( int i(b), I(e); i <= I; ++i )
#define fd( i, b, e ) for ( int i(b), I(e); i >= I; --i )
#define go( i, b ) for ( int i(b), v(to[i]); i; v = to[i = nxt[i]] )
template<typename T> inline void cmax( T &x, T y ){ x < y ? x = y : x; }
template<typename T> inline void cmin( T &x, T y ){ y < x ? x = y : x; }
#define getchar() ( p1 == p2 && ( p1 = bf, p2 = bf + fread( bf, 1, 1 << 21, stdin ), p1 == p2 ) ? EOF : *p1++ )
char bf[1 << 21], *p1(bf), *p2(bf);
template<typename T>
inline void read( T &x ){ char t(getchar()), flg(0); x = 0;
	for ( ; !isdigit(t); t = getchar() ) flg = t == '-';
	for ( ; isdigit(t); t = getchar() ) x = x * 10 + ( t & 15 );
	flg ? x = -x : x;
}

clock_t t_bg, t_ed;

int N, M, Q;
int s[MAXN][MAXN];
int s1[MAXN][MAXN], s2[MAXN][MAXN];
#define sum( s, a, b, c, d ) ( s[c][d] + s[a-1][b-1] - s[c][b-1] - s[a-1][d] )

int main(){
	t_bg = clock();
	read(N), read(M), read(Q);
	fp( i, 1, N ) fp( j, 1, M ){
		while( (s[i][j] = getchar()) != '0' && s[i][j] != '1' );
		s[i][j] &= 1;
	}
	fp( i, 1, N ) fp( j, 1, M - 1 ) s1[i][j] = s1[i][j - 1] + s1[i - 1][j] - s1[i - 1][j - 1] + (s[i][j] & s[i][j + 1]);
	fp( i, 1, N - 1 ) fp( j, 1, M ) s2[i][j] = s2[i][j - 1] + s2[i - 1][j] - s2[i - 1][j - 1] + (s[i][j] & s[i + 1][j]);
	fp( i, 1, N ) fp( j, 1, M ) s[i][j] += s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1];
	while( Q-- ){
		int a, b, c, d;
		read(a), read(b), read(c), read(d);
		printf( "%d\n", sum(s, a, b, c, d) - sum(s1, a, b, c, d - 1) - sum(s2, a, b, c - 1, d) );
	}
	t_ed = clock();
	fprintf( stderr, "\n========info========\ntime : %.3f\n====================\n", (double)( t_ed - t_bg ) / CLOCKS_PER_SEC );
	return 0;
}


Measured memory_bytes: 50944
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() {
    loop {
        let m: i64 = read();
        let f: i64 = read();
        let r: i64 = read();
        if m == f && f == r && m == -1 {
            break;
        }
        let x = m + f;
        let mut ans = "F";
        if m == -1 || f == -1 {
            ans= "F";
        } else if x >= 80 {
            ans = "A";
        } else if x >= 65 {
            ans = "B";
        } else if x >= 50 {
            ans = "C";
        } else if x >= 30 {
            ans = if r >= 50 {"C"} else {"D"};
        } else {
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 5028
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	long n,k,r=0;
    n=sc.nextLong();
    k=sc.nextLong();
    while((n/(int)Math.pow(k,r))>0){
      r++;
    }
    System.out.print(r);
  }
}

Measured memory_bytes: 22100
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define BOOK_MAX 12
#define ALGO_MAX 12
#define INF (1e+7)

void read(int *profits, int *out, int size) {
    int i;
    for(i = 0; i < size; i++) {
        out[i] += profits[i];
    }
}

int main(void) {
    int books, algos, llimit;
    int prices[BOOK_MAX];
    int profits[BOOK_MAX][ALGO_MAX];
    get_int3(&books, &algos, &llimit);
    int i;
    for(i = 0; i < books; i++) {
        prices[i] = get_int();
        fget_array(profits[i], algos);
    }

    int pat, bit;
    int ans = INF;
    for(pat = 1; pat < (1<<books); pat++) {
        int cost = 0;
        int skills[ALGO_MAX] = {0};
        // judge
        int flag = 1;
        for(bit = 0; bit < books; bit++) {
            if(!(pat & (1<<bit))) continue;
            read(profits[bit], skills, algos);
            cost += prices[bit];
            if(ans < cost) { flag = 0; break; }
        }
#ifdef DEBUG
        printf("%d -> %d\n", pat, cost);
#endif
        if(!flag) continue; // skip
        for(i = 0; i < algos; i++) {
            if(skills[i] < llimit) flag = 0;
        }
        if(flag) ans = min(ans, cost);
    }
    printf("%d\n", ans == INF ? -1 : ans);
    return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;


void solve(long long A, long long B, long long C, long long D, long long E, long long F){
    double maxdens=0;
    pair<long long, long long>ans = make_pair(0,0);

    for(auto a=0l; a<=F; a+=100*A){
        for(auto b=0l; a+b<=F; b+=100*B){
            for(auto c=0l; a+b+c<=F && E*(a+b)/100 >= c; c+=C){
                for(auto d=0l; a+b+c+d<=F && E*(a+b)/100 >= c+d; d+=D) {
                    double dens=(double)(c+d)/(double)(a+b+c+d);
                    if(dens >= maxdens){
                        maxdens=dens;
                        ans = make_pair(a+b+c+d, c+d);
                    }
                }
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    long long F;
    scanf("%lld",&F);
    solve(A, B, C, D, E, F);
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
/*#define fast ios_base::sync_with_stdio(0); cin.tie(0)*/
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const double pi = acos(-1);
typedef long long ll;
int main()
{
	//fast;
	
	ll a,b,c,d;
	cin>>a>>b;
	cout<<(--a)*(--b);
}

Measured memory_bytes: 3616
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        k: usize,
        s: chars,
    }

    let mut chunk = Vec::new();
    let mut l = s[0];
    let mut lc = 0;
    for (i, &x) in s.iter().enumerate() {
        if x != l {
            chunk.push((l, i - lc));
            lc = i;
        }

        l = x;
    }
    chunk.push((l, n - lc));

    let mut ans = 0;
    let mut r = 0;
    let mut p = 0;
    let mut t = 0;
    for h in 0..chunk.len() {
        if chunk[h].0 == '0' {
            p += 1;
        }

        if p > k {
            while chunk[t].0 != '0' {
                r -= chunk[t].1;
                t += 1;
            }
            r -= chunk[t].1;
            t += 1;
            p -= 1;
        }

        r += chunk[h].1;
        ans = std::cmp::max(ans, r);
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int main() {
    int n, ans = 0, t[1000], u[1000];
    bool visited[1000];
    map<int, int> change;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        change[t[i]] = i;
        u[i] = t[i];
        visited[i] = false;
    }
    sort(u, u + n);
    for (int i = 0; i < n; i++) {
        int w = i, x = 0, y = 0, z = 10000;
        while (!visited[w]) {
            z = min(z, t[w]);
            y += t[w];
            x++;
            visited[w] = true;
            w = change[u[w]];
        }
        if (x >= 2)ans += min(y + z + u[0] * (x + 1), y + z * (x - 2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0 ; i < (n); ++i)
#define rrep(i,n) for(i  1; i <= (n); ++i)
#define drep(i,n) for(i  (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int n,i,T,A,c;
int ans = INF;

cin >> n >> T >> A;
int H[n];
rep(i,n){
    cin >> H[i];
}
int t[n];
rep(i,n){
 
   t[i] = 1000*T-H[i]*6;
 
 if(ans>abs(A*1000-t[i])){
     c = i+1;
     ans = abs(A*1000-t[i]);
 }
}



cout << c << endl;


///////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s,char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

std::string revString(std::string s) {
	string ret;
	auto it = s.rend();
	while (it != s.rbegin()) {
		ret.push_back(*it);
		++it;
	}
	return ret;
}

signed main() {
	makei(n);
	vi ans;
	FOR(i, 1, n + 1) {
		if (!(i % 3) || to_string(i).find('3') != string::npos)
			ans.push_back(i);
	}
	rep(ans.size())cout << " " << ans[i];
	cout << endl;
}


Measured memory_bytes: 3292
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int H, W;
string board[100];

vector<pii> getPos(char c, int sy, int sx) {
    vector<pii> ret;
    queue<int> que;
    que.push(sy); que.push(sx);
    ret.emplace_back(sy, sx);
    while (!que.empty()) {
        int y = que.front(); que.pop();
        int x = que.front(); que.pop();
        for (int i = 0; i < 4; i++) {
            int ny = y+dy[i];
            int nx = x+dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
            if (board[ny][nx] == c && find(ret.begin(), ret.end(), pii(ny, nx)) == ret.end()) {
                que.push(ny); que.push(nx);
                ret.emplace_back(ny, nx);
            }
        }
    }
    return ret;
}

bool ok() {
    for (int y = 0; y < H; y++) for (int x = 0; x < W; x++) {
        // c ?????¢???
        char c = board[y][x];
        if (c == '.') continue;
        vector<pii> ps = getPos(c, y, x);
        int xl = 100, xr = -1;
        for (pii p : ps) {
            int y = p.first, x = p.second;
            if (y == H-1) {
                xl = min(xl, 2*x);
                xr = max(xr, 2*x+2);
            } else {
                int ny = y+1;
                if (board[ny][x] != '.' && board[ny][x] != c) {
                    xl = min(xl, 2*x);
                    xr = max(xr, 2*x+2);
                }
            }
        }
        // cerr << c << " : " << xl << "  " << xr << endl;
        // ps ????????????????????????????????¢???
        vector<pii> up = ps;
        while (1) {
            bool finish = true;
            for (pii p : up) {
                int y = p.first, x = p.second;
                if (y==0) continue;
                char tmp = board[y-1][x];
                if (tmp == '.') continue;
                vector<pii> cs = getPos(tmp, y-1, x);
                assert(!cs.empty());
                if (find(up.begin(), up.end(), cs[0]) == up.end()) {
                    finish = false;
                    for (pii pp : cs) up.push_back(pp);
                    break;
                }
            }
            if (finish) break;
        }
        int sum = 0;
        for (pii p : up) {
            sum += 2*p.second+1;
        }
        if (sum <= xl * up.size() || sum >= xr * up.size()) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> W >> H) {
        if (H==0 && W==0) break;
        for (int i = 0; i < H; i++) cin >> board[i];
        if (ok()) cout << "STABLE" << endl;
        else cout << "UNSTABLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    e=a*b;
    f=c*d;
    if(e>f)
    {
        printf("%d\n",e);
    }
    else
        printf("%d\n",f);
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"
func Otoshidama(bill int,money int) (int, int, int) {
	for i:=0; i <= bill; i++ {
		for j:=0; j <= bill - i; j++ {
			k := bill - i - j
			if 10000*i + 5000*j + 1000*k == money {
				return i,j,k
			}
		}
	}
	return -1,-1,-1

}

func main() {
	var bill int
	var money int
	fmt.Scan(&bill)
	fmt.Scan(&money)
	fmt.Println(Otoshidama(bill,money))
}

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

int64_t mp(int x, int y){
    return min(x, y) + 1000 * max(x, y);
}

vector<int> edges[1000000];
int a[1000][1000];
int in[1000000] = {0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int v;
        for(int j=0;j<n-1;j++){
            cin >> v;
            a[i][j] = v-1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=1;j<n-1;j++){
            edges[mp(i, a[i][j])].push_back(mp(i, a[i][j-1]));
            in[mp(i, a[i][j-1])]++;
        }
    }

    vector<int> toposo;
    unordered_map<int,int> idx;
    size_t cnt = 0;
    queue<int> st;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(in[mp(i, j)] == 0) st.push(mp(i, j));
        }
    }
    while(!st.empty()){
        int i, j;
        i = st.front() / 1000;
        j = st.front() % 1000;
        st.pop();
        for(auto t: edges[mp(i, j)]){
            in[t]--;
            if(in[t] == 0) st.push(t);
        }
        idx[mp(i, j)] = cnt;
        toposo.push_back(mp(i, j));
        ++cnt;
    }
    if(cnt < n*(n-1)/2){
        cout << -1 << endl;
        return 0;
    }    

    for(int i=0;i<toposo.size();i++) in[i] = 1;
    for(int i=0;i<toposo.size();i++){
        for(auto to: edges[toposo[i]]){
            in[idx[to]] = max(in[idx[to]], in[i]+1);
        }
    }    
    int ans = 0;
    for(int i=0;i<toposo.size();i++) ans = max(ans, in[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 68836
n = int(input())
a = list(map(int,input().strip().split()))

import collections
c = collections.Counter(a)
_max = 0
for i in range(max(a)+1):
  _sum = c[i-1] + c[i] + c[i+1]
  if _max < _sum:
    _max = _sum
print(_max)

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

using namespace std;

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

template<class T>
T read() {
    T x{};
    cin >> x;
    return x;
}

template<class T>
vector<T> read(int N){
    vector<T> x(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }
    return x;
}

template<class T>
void write(const T &x){ cout << x << endl; }

int main(){
    auto N = read<ll>();
    auto K = read<ll>();
    auto Q = read<ll>();
    auto A = read<ll>(Q);
    
    vector<ll> score(N);
    for(auto a : A){
        ++score[a-1];
    }
    
    for(auto s: score){
        if(K > (Q - s)){ write("Yes"); }
        else { write("No"); }
    }
}



Measured memory_bytes: 2176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            out.println(T + S);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21332
n,m = list(map(int,input().split()))
x=[]
for i in range(n):
    x.append(list(map(int,input().split())))
x.sort()
result=0
while 1:
    if x[0][1]>=m:
        result+=m*x[0][0]
        break
    else:
        result+=x[0][0]*x[0][1]
        m-=x[0][1]
        del x[0]
print(result)

Measured memory_bytes: 27760
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll n, m, d;
  cin >> n >> m >> d;
  double ans = 0;
  if(d > 0) {
    ans = (double)max((ll)0, n - 2 * d) * (m - 1) * 2.0 / (n * n) +
          2.0 * d * (m - 1) * 1.0 / (n * n);
  } else {
    ans = (double)n * (m - 1) * 1.0 / (n * n);
  }

  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3680
X = int(input())

ans = 0
    
if 400 <= X <= 599:
    ans  = 8
elif 600 <= X <= 799:
    ans = 7
elif 800 <= X <= 999:
    ans = 6
elif 1000 <= X <= 1199:
    ans = 5
elif 1200 <= X <= 1399:
    ans = 4
elif 1400 <= X <= 1599:
    ans = 3
elif 1600 <= X <= 1799:
    ans = 2
elif 1800 <= X <= 1999:
    ans = 1
    
print(ans)

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll p,q,r;
  cin >> p >> q >> r;
  ll ans = min(p+q,q+r);
  ans = min(ans,p+r);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256