akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
   string s;
   cin>>s;int ans=1;
   for(int i=0;i<s.size();i+=2)
   {
       if(i!=s.size()-1&&s[i]=='h'&&s[i+1]=='i');
       else ans=0;
   }
   if(ans==0)cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
}


return 0;
}





Measured memory_bytes: 384
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll mod = 12345678910;
const int maxn = (int)1e5 + 5;
using namespace std;

int main()
{
	int a[5];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if(a[0] == 5 && a[1] == 5 && a[2] == 7) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
	int n, i, a[100];
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=n-1;i>-1;i--){
		if(i==0){
			printf("%d\n",a[i]);
		}
		
		else{
			printf("%d ",a[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   if(a+b >= 10 ) cout << "error" << endl;
   else cout << a+b << endl;


   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String str = scan.next();
		
		
		for(int i = 0; str.length() > i; i = i + 2){
			sb.append(str.charAt(i));
		}
		System.out.println(sb.toString());
		scan.close();
	}

}

Measured memory_bytes: 26036
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;
const int mod = 998244353;

int n, m, k;

int fact[maxn], inv[maxn];

void read_input()
{
    cin >> n >> m >> k;
}

int powmod(int x, int k)
{
    if(k == 0) return 1;
    int t = powmod(x, k / 2);
    if(k % 2 == 0) return t * 1LL * t % mod;
    else return t * 1LL * t % mod * x % mod;
}

void prep()
{
    fact[0] = 1;
    for(int i = 1; i < maxn; ++i)
        fact[i] = fact[i - 1] * 1LL * i % mod;
    inv[maxn - 1] = powmod(fact[maxn - 1], mod - 2);
    for(int i = maxn - 2; i >= 0; --i)
        inv[i] = inv[i + 1] * 1LL * (i + 1) % mod;
}

void add(int&tar, int val)
{
    tar += val;
    if(tar >= mod) tar -= mod;
}

int C(int k, int n)
{
    return fact[n] * 1LL * inv[k] % mod * inv[n - k] % mod;
}

void solve()
{
    int ans = 0;
    for(int x = 1; x <= n; ++x)
    {
        if(n - x > k) continue;
        add(ans, m * 1LL * powmod(m - 1, x - 1) % mod * C(x - 1, n - 1) % mod);
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    prep();
    solve();
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int v[105], w[105], dp[10010];
signed main(void)
{
  int n, W;
  cin >> n >> W;
  REP(i, n) cin >> v[i] >> w[i];

  REP(i, n) for(int j=W; j>=w[i]; --j) {
    dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
  }
  cout << dp[W] << endl;
  return 0;
}

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

int main()
{
    int c1, c5, c10, c50, c100, c500, sum;
    scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500);
    sum = c500*500+c100*100+c50*50+c10*10+c5*5+c1;
    printf("%d\n", sum>=1000);
    return 0;
}



Measured memory_bytes: 2760
a, b, c=map(int,input().split())

if a > b:
  tmp = a
  a = b
  b = tmp
if b > c:
  tmp = b
  b = c
  c = tmp
if a > b:
  tmp = a
  a = b
  b = tmp
  
print(a, end=' ')
print(b, end=' ')
print(c)


Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
class Main {
	public static void main(String[] args) {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		ArrayList<String> output = new ArrayList<String>();
		String input;
		int n;
		try {
			n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				input = br.readLine();
				int[] sides = new int[3];
				sides[0] = Integer.parseInt(input.split(" ")[0]);
				sides[1] = Integer.parseInt(input.split(" ")[1]);
				sides[2] = Integer.parseInt(input.split(" ")[2]);
				Arrays.sort(sides);
				if(sides[2]*sides[2]-sides[1]*sides[1]-sides[0]*sides[0]==0){
					output.add("YES");
				}else{
					output.add("NO");
				}
			}
			for (String i : output) {
				System.out.println(i);
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 27504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <math.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    double a, b, x;
    cin >> a >> b >> x;

    double ans;
    if (a * a * b / 2.0 < x){
        ans = atan(2.0 * (a * a * b - x) / (a * a * a));

    }else if (a * a * b / 2.0 == x){
        ans = atan(b / a);
    }else{
        ans = atan(a * b * b / 2.0 / x);

    }
    ans = ans / M_PI * 180.0;

    //cout << ans << endl;
    printf("%.7f\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;


int main(){
	string S;
	cin >> S;
	int sz = S.size();
	int mi1,mi2;
	mi1 = sz;
	mi2 = sz;
	rep(i,sz){
		if(S[i]=='0') mi1 = min(mi1,max(i,sz-i-1));
	}
	rep(i,sz){
		if(S[i]=='1') mi2 = min(mi2,max(i,sz-i-1));
	}
	cout << max(mi1,mi2);
}


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

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = a[0];
  REP(i,n){
    ans = gcd(ans, a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
using System;

namespace abc60
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int T = int.Parse(str[1]);
            int[] t = new int[N];
            str = Console.ReadLine().Split(' ');
            for(int i = 0; i < N; i++)
            {
                t[i] = int.Parse(str[i]);
            }
            int ans = 0;
            for(int i = 0; i < N - 1; i++)
            {
                if (t[i + 1] - t[i] < T)
                {
                    ans += t[i + 1] - t[i];
                }else
                {
                    ans += T;
                }
            }
            Console.WriteLine(ans + T);
        }
    }
}


Measured memory_bytes: 28164
N = int(input())
T_res = list(map(int,input().split()))
M = int(input())
PX = []
for i in range(M):
      PX.append(input().split())
      PX[i][0] = int(PX[i][0])
      PX[i][1] = int(PX[i][1])

for i in range(M):
      org = T_res[PX[i][0]-1]
      T_res[PX[i][0]-1] = PX[i][1]
      print(sum(T_res))
      T_res[PX[i][0]-1] = org


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

int N, M;
int bit[1000010];
vector<pair<long long, long long> >range[100005];

void add(int a, int w){
	for(int x = a; x < 1000010; x += x & -x){
		bit[x] += w;
	}
}

int sum(int a){
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += bit[x];
	}
	return ret;
}

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++){
		long long l, r;
		cin >> l >> r;
		range[r-l+1].push_back(make_pair(l, r));
	}

	for(long long d = 1; d <= M; d++){
		//add range d - 1, N--;
		for(int i = 0; i < range[d].size(); i++){

			add(range[d][i].first, 1);
			add(range[d][i].second + 1, -1);
			N--;
		}
		long long ans = N;
		for(long long cur = d; cur <= M; cur += d){
			ans += sum(cur);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)

int main() {
	auto f = [](LL & a, LL & b, const LL c) {
		dec(i, 41) {
			if(bit(a ^ b ^ c, i) != 0) {
				LL m = (1LL << i) - 1;
				LL A = (a & m) + 1;
				LL B = m - (b & m) + 1;
				LL mi = min(A, B);
				a -= mi;
				b += mi;
				break;
			}
		}
	};
	
	IN(int, n);
	IN(LL, a, b);
	LL c = 0;
	inc(i, n - 2) { IN(LL, x); c ^= x; }
	
	LL a0 = a;
	while(true) {
		f(a, b, c);
		if(a <= 0) { OUT(-1); break; }
		if((a ^ b ^ c) == 0) { OUT(a0 - a); break; }
	}
}


Measured memory_bytes: 3628
a=[],m=l=0,n=c='';require("fs").readFileSync("/dev/stdin","utf8").trim().split(' ').some(function(i){a[i]?(++a[i]>m?m=a[n=i]:0):a[i]=1;(t=i.length)>l?(c=i,l=t):0});console.log(n+' '+c)

Measured memory_bytes: 7648
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main(){
    int  n;
    while(1){
        cin>>n;
        if(n==0)break;
        double s[n]={ };
        double m=0,sum=0,a=0;
        for(int i=0;i<n;i++){
            cin>>s[i];
            sum += s[i];
        }
        m=sum/n;
        
        for(int i=0;i<n;i++){
            a += (s[i]-m)*(s[i]-m)/n;
        }
        double ans = sqrt(a);
        printf("%8lf\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    for (int i = 0; i < k; i++) {
        if (a >= b) {
            b *= 2;
            continue;
        }
        if (b >= c) {
            c *= 2;
            continue;
        }
    }
    
    if (a < b && b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

ll gcd(ll a, ll b) {
    if (!a)return b;
    return gcd(b % a, a);
}

int main() {
    init();

    int n; ll x; cin >> n >> x;
    VL a(n); cin >> a;
    a.push_back(x);
    SORT(a);
    ll ans = a[1] - a[0];
    FOR(i, 0, n)ans = gcd(ans, a[i + 1] - a[i]);
    cout << ans << "\n";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

int main() {
  INIT;
  
  int n;
  cin >> n;// >> c >> d;
  
  cout << 800*n - 200*(n / 15) << endl;
  
  return 0;
}

Measured memory_bytes: 892
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> I(N);
    vector<int> P(N);
    vector<int> Q(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        I[i] = i + 1;
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }
    int count = 0;
    int a = 0, b = 0;
    do {
        if (I == P) a = count;
        if (I == Q) b = count;
        count++;
    } while (next_permutation(I.begin(), I.end()));
    cout << abs(a - b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int a,b,x;
  cin>>a>>b>>x;
  if(x<a||(x>a+b))
  {
  NO
  }
  else
  {
  YES
  }

}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
int main(){
    string s;
    cin>>s;
    if(s[0]!=s[1]){
        cout<<"Yes\n";
    }
    else if(s[0]!=s[2]){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}


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

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

fn main() {
    let n: usize = read();
    let mut a: Vec<(usize, usize, usize)> = vec![];
    for _ in 0..n - 1 {
        let c: usize = read();
        let s: usize = read();
        let f: usize = read();
        a.push((c, s, f));
    }

    for j in 0..n - 1 {
        let mut current = 0;

        for i in j..n - 1 {
            let ai = a[i];
            if current < ai.1 {
                current = ai.1 + ai.0;
                continue;
            } else {
                if current % ai.2 != 0 {
                    current += ai.2 - (current % ai.2)
                }
                current += ai.0
            }
        }
        println!("{}", current);
    }
    println!("{}", 0);
    // 4
    // 10 11 5
    // 10 12 10
    // 10 20 2
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

int a, b;
int main()
{
    cin >> a >> b;
    if(a < 0)
    {
        if(b < 0)
        {
            if((b - a + 1) & 1) puts("Negative");
            else puts("Positive");
        }
        else if(b >= 0) puts("Zero");
    }
    else 
    {
        if(!a) puts("Zero");
        else puts("Positive");
    }

    return 0;
}

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

#define INF 1e18

int N;
vector<long long> x;
vector<long long> y;
vector<char> d;

double f( double t )
{
	double xmax = -INF;
	double xmin = INF;
	double ymax = -INF;
	double ymin = INF;
	for( int i = 0; i < N; i++) {
		double xx = x[i];
		double yy = y[i];
		char dd = d[i];
		if( dd == 'R' ) {
			xx += t;
		}
		else if( dd == 'L' ) {
			xx -= t;
		}
		else if( dd == 'U' ) {
			yy += t;
		}
		else if( dd == 'D' ) {
			yy -= t;
		}
		xmax = max( xmax, xx );
		xmin = min( xmin, xx );
		ymax = max( ymax, yy );
		ymin = min( ymin, yy );
	}
	return ( xmax - xmin ) * ( ymax - ymin );
}

int main() {

	cin >> N;
	x = vector<long long>( N );
	y = vector<long long>( N );
	d = vector<char>( N );
	for( int i = 0; i < N; i++ ) {
		cin >> x[i] >> y[i] >> d[i];
	}

	double l = 0;
	double r = 1e9;
	double ans = INF;
	for( int i = 0; i < 200; i++ ) {
		double t1 = ( l * 2 + r ) / 3;
		double t2 = ( l + r * 2 ) / 3;
		double res1 = f( t1 );
		double res2 = f( t2 );
		if( res1 > res2 ) {
			l = t1;
		}
		else {
			r = t2;
		}
		ans = min( ans, min( res1, res2 ) );
	}

	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}



int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    vector<ll> a(n), d(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>d[i];

    sort(a.begin(), a.end());
    sort(d.begin(), d.end(), greater<>());

    auto check = [&](ll X) -> bool {
        vector<ll> A(a),D(d);
        ll K = k;
        rep(i,n) {
            if (K==0) continue;
            if (A[i]*D[i]<=X) continue;
            else {
                ll t = X/D[i];
                t = min(A[i]-t,K);
                A[i] -= t;
                K -= t;
            }
        }
        ll ret = 0;
        rep(i,n) {
            chmax(ret, A[i]*D[i]);
        }
        return (ret<=X);
    };

    ll ng = -1; ll ok = LINF;
    while (abs(ok-ng)>1) {
        ll mid = (ok+ng)/2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << '\n';
    return 0;
}

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

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dx=tx-sx;
  int dy=ty-sy;
  for(int i=0;i<dy;i++){
    cout<<"U";
  }
  for(int i=0;i<dx;i++){
    cout<<"R";
  }
  for(int i=0;i<dy;i++){
    cout<<"D";
  }
  for(int i=0;i<dx;i++){
    cout<<"L";
  }
  cout<<"L";
  for(int i=0;i<dy+1;i++){
    cout<<"U";
  }
  for(int i=0;i<dx+1;i++){
    cout<<"R";
  }
  cout<<"DR";
  for(int i=0;i<dy+1;i++){
    cout<<"D";
  }
  for(int i=0;i<dx+1;i++){
    cout<<"L";
  }
  cout<<"U"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  int m,n;
  cin>>m>>n;
  //vector<int> V;
  int x;
  ll sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    sum+=x;
  }
  if(sum>m)
  cout<<-1;
  else
  cout<<m-sum;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll N,M;
int ans=0;
void solve();
vector<vector<int> > connect(10);
vector<int> flag(10);

void solve(int s){
	bool root=true;
	flag[s]=1;
	FOR(i,1,N+1){
		if(!flag[i]){
			root=false;
		}
	}
	if(root){
		ans++;
		flag[s]=0;
		return;
	}
	rep(i,connect[s].size()){
		if(flag[connect[s][i]]==0){
			solve(connect[s][i]);
		}	
	}
	flag[s]=0;
	return;
}

int main(){
	cin>>N>>M;
	int a,b;
	rep(i,M){
		cin>>a>>b;
		connect[a].pb(b);
		connect[b].pb(a);
	}

	solve(1);
	cout<<ans<<endl;

	return 0;
}














Measured memory_bytes: 256
s = gets.strip.split('')

result=1
pre=[s.shift]
current = []
s.each_with_index do |c, i|
#p [pre, current, result]
  current.push(c)
  if !pre.empty? && pre != current
    result += 1
    pre = current
    current=[]
  end
end

p result


Measured memory_bytes: 17404
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let h: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut v = vec![i64::max_value(); n];
    v[0] = 0;
    for i in 1..n {
        for j in 1..k + 1 {
            if i >= j {
                v[i] = std::cmp::min(v[i], v[i - j] + (h[i] - h[i - j]).abs());
            }
        }
    }

    println!("{}", v[n - 1]);
}


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

int main() {
    int s; cin >> s;
    vector<int> vec;

    //vec.at(0) = s;
    vec.push_back(s);
    
    int is_ans = false;
    int ans = 0;
    for (int i = 1; i < 200; i++) {

        if (vec.at(i - 1) % 2 == 0) {
            //vec.at(i) = vec.at(i - 1) / 2;
            vec.push_back(vec.at(i - 1) / 2);
            //cout << vec.at(i) << endl;
        }
        else {
            //vec.at(i) = 3 * vec.at(i-1) + 1;
            vec.push_back(3 * vec.at(i-1) + 1);
            //cout << vec.at(i) <<endl;
        }
        
        for (int j = i - 1; j >= 0 && is_ans == false; j--) {
            if (vec.at(i) == vec.at(j)) {
                is_ans = true;
                ans = i;
            }
        }

        if (is_ans == true) {
            break;
        }
    }

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

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int C[101010],D[101010];
int R,AC;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>j>>s;
		
		if(s=="AC") {
			if(D[j]==0) {
				D[j]=1;
				AC++;
				R+=C[j];
			}
		}
		else {
			C[j]+=1;
		}
	}
	cout<<AC<<" "<<R<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=100010;
void read(int& x){
	x=0;
	char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
}
int a[maxn];
bool cmp(int x,int y){
	return x>y;
}
int ans,n;
int main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+1+n,cmp);
	//for(int i=1;i<=n;i++) printf("%d ",a[i]);puts("");
	for(int i=1;i<=n;i++){
		if(i+1>a[i+1]){
			for(int j=i+1;j<=n && a[j]==i;j++) ans^=1;
			ans|=(a[i]-i)&1;
			printf("%s",ans?"First":"Second");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    N = int(readline())
    div = divisors(N)
    ans = 0
    for m in div:
        if m!=1:
            if N//(m-1) == N%(m-1):
                ans += m-1
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
   long int h,i=0,count =0,j=1;
    cin>>h;
   while(h>1)
   {
     h = h/2;
     count = count + pow(2,i);
     j = j*2;
     i++;
   }
   cout<<count+j;

    return 0;
}


Measured memory_bytes: 512
//
// Created by Wangzhe on 2019/10/19.
//

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5 + 10, INF = 0x3f3f3f3f;

const ll INFF = 1e12;

int a[maxn];

int main() {
    ll x; cin >>x;
    ll res = 1e18;
    for (ll i = 1; i * i <= x; i++){
        if (x % i == 0) res = min(res, i + x / i - 2);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# D - Built?

import sys

class UnionFind(object):
    def __init__(self, n=1):
        self.root = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find_root(self, x):
        if self.root[x] == x:
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.root[y] = x

    def is_same_root(self, x, y):
        return self.find_root(x) == self.find_root(y)

# edges : [[start, end, edge_weight], ...]
def kruskal(max_v, edges):
    uf = UnionFind(max_v)
    sum_cost = 0
    edges.sort(key = lambda x: x[2])
    for e in edges:
        if not uf.is_same_root(e[0], e[1]):
            uf.unite(e[0], e[1])
            sum_cost += e[2]
    return sum_cost


N = int(sys.stdin.buffer.readline())
xyi = []
for i in range(N):
    x, y = map(int, sys.stdin.buffer.readline().split())
    xyi.append([x,y,i])

edges = []
xyi.sort(key = lambda x:x[0])
for j in range(N):
    if 0 < j:
        edges.append([xyi[j-1][2], xyi[j][2], xyi[j][0]-xyi[j-1][0]])
    if j < N-1:
        edges.append([xyi[j][2], xyi[j+1][2], xyi[j+1][0]-xyi[j][0]])

xyi.sort(key=lambda x: x[1])
for j in range(N):
    if 0 < j:
        edges.append([xyi[j-1][2], xyi[j][2], xyi[j][1]-xyi[j-1][1]])
    if j < N-1:
        edges.append([xyi[j][2], xyi[j+1][2], xyi[j+1][1]-xyi[j][1]])

print(kruskal(N, edges))


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

long mod = 1000000007;

int main() {
  long n, k;
  cin >> n >> k;
  long ans = 0;
  for (long i = k; i <= n+1; i++) {
    ans += i*(2*n-i+1)/2 - i*(i-1)/2 + 1;
    ans %= mod;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3636
h,w,k=map(int,input().split())
mod = 10**9+7
l=[]
a=[[0 for i in range(w)] for j in range(w)]

def dsf(i,v):
  if i==w-1:
    t = list()
    for j in range(0,w):
      t.append(j)
    for j in range(w-1):
      if v & 2**(j):
        t[j],t[j+1]=t[j+1],t[j]
    for x in range(w):
      a[x][t[x]] += 1
    l.append(v)
  else:
    dsf(i+1,v)
    if v & 2**(i-1) == 0:
      dsf(i+1,v | 2**i)

if w==1:
  print(1)
  exit()

dsf(1,0)
dsf(1,1)

t=[[0 for i in range(w)] for j in range(2)]
t[0][0]=1

for i in range(h):
  for j in range(w):
    t[(i+1)%2][j] = 0
    t[i%2][j] %= mod
  for j in range(w):
    for x in range(w):
     t[(i+1)%2][x] += t[i%2][ｊ] * a[j][x]

print(t[h%2][k-1]%mod)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    string S;
    ll A,count=0,num=0,sum=0,check=0;
    cin>>S>>A;
    ll L=S.length();
    if(L==1){
        ll c,d;
        if(A%2==0){
            c=A/2;
            d=A-c;
        }else{
            d=floor(A/2);
            c=A-d;
        }
        cout<<d<<endl;
    return 0;
    }
    string O(S);
    if(S[0]==S[L-1]&&A!=1){//1回の時は末尾を考慮する必要はない
        rep(i,L-1){
            if(S[i]==S[i+1]){
            count++;
            S.erase(S.begin()+i+1);
            S.insert(S.begin()+i+1,num);
            num++;
            }
            if(O[i]==O[i+1])check++;
        }
        if(check==L-1){
            cout<<(L*A)/2<<endl;
            return 0;
        }
        sum+=count;
        if(S[L-1]==O[0]){
            O.erase(O.begin());//Sの長さを逐一取得するコードによって文字の挿入位置にズレが生じた？
            O.insert(O.begin(),num);
            count=1;
        }else count=0;
        rep(i,L-1){
            if(O[i]==O[i+1]){
                count++;
                O.erase(O.begin()+i+1);
                O.insert(O.begin()+i+1,num);
                num++;
            }
        }
        sum+=count*(A-1);
        cout<<sum<<endl;
        return 0;
    }
    rep(i,L-1){
        if(S[i]==S[i+1]){
            count++;
            S.erase(S.begin()+i+1);
            S.insert(S.begin()+i+1,num);
            num++;
        }
    }
    cout<<count*A<<endl;
    return 0;
}

//abaaa 2 のパターンで最適解ではない
//abaaa 3 の時一番目以降は同じ変更回数である。
//4以降はについても同様のことが言える。
//aaa 4 で最適解が出なかった。

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

int main()
{
  int t;
  t=1;
  //cin>>t;
  
  while(t--)
  {
    ll i;
     double x,y,d,ans=0,z,n,m;
     cin>>n>>d;
     FOR(i,1,n)
     {
      cin>>x>>y;
      m=x*x+y*y;
      m=sqrt(m);
      if(m<=d) ans++;
     }
     cout<<ans<<endl;
  }

}


Measured memory_bytes: 3828
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();
    let t: String = read();
    println!(
        "{}",
        s.chars().zip(t.chars()).filter(|&(c1, c2)| c1 == c2).count()
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    repl(i, 1, s.size()) {
        if(s[i] == s[i - 1]) {
            ans++;
            if(s[i - 1] == '0') s[i] = '1';
            else s[i] = '0';
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
from collections import Counter
def combination(n, r): # nCrを求める
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
    for i in range(1, r+1):
        result //= i
    return result
n,p = map(int,input().split())
a =list(map(int,input().split()))
for i in range(n):
    a[i] = a[i]%2
b = Counter(a)
c = b[1]
d = b[0]
ans = 0
if p ==0:
    for i in range(0,c+1,2):
        ans += combination(c,i)
else:
    for i in range(1,c+1,2):
        ans += combination(c, i)
ans *= 2**d
print(ans)

Measured memory_bytes: 3316
def round10(n)
  (n + 9) / 10 * 10
end

# 1..123
ts = Array.new(5) { gets.to_i } # a..e

t_max, i = ts.each_with_index.max_by { |t, _i| round10(t) - t } # min loss
ts.map! { |t| round10(t) }
ts[i] = t_max

p ts.reduce(:+)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<ll> H(N);
  vector<ll> n(N, 0);
  rep(i, N)
  {
    cin >> H[i];
  }
  vector<int> A(M), B(M);
  rep(i, M)
  {
    cin >> A[i] >> B[i];
    n[A[i] - 1] = max(n[A[i] - 1], H[B[i] - 1]);
    n[B[i] - 1] = max(n[B[i] - 1], H[A[i] - 1]);
  }
  int ans = 0;
  rep(i, N)
  {
    if (n[i] == 0)
    {
      // cout << "sita" << i << endl;
      ans++;
    }
    else if (H[i] > n[i])
    {
      ans++;
      //cout << "ue" << i << endl;
      //  cout << i << endl;
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<int> c(N), d(N);
	rep(i, N) {
		int a, b;
		cin >> a >> b >> c[i];
		d[i] = Ma*b - Mb*a;
	}
	vector<int> plus(4001, INF), minus(4001, INF);
	plus[0] = 0;
	minus[0] = 0;
	int ans = INF;
	rep(i, N) {
		if (d[i] > 0) {
			reprev(j, 4001 - d[i]) {
				plus[j + d[i]] = min(plus[j + d[i]], plus[j] + c[i]);
			}
		}
		else if (d[i] < 0) {
			reprev(j, 4001 + d[i]) {
				minus[j - d[i]] = min(minus[j - d[i]], minus[j] + c[i]);
			}
		}
		else {
			ans = min(ans, c[i]);
		}
	}
	rep(i, 4001) {
		if (plus[i] != 0 && minus[i] != 0)
			ans = min(ans, plus[i] + minus[i]);
	}

	if (ans == INF) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    vector<int> d(K);
    vector<int> A(N);

    int a;
    for(int j = 0; j < K; j++){
        cin >> d[j];
        for(int i = 0; i < d[j]; i++){
            cin >> a;
            A[a-1] += 1;
        }
    }

    int result = 0;
    for (int i = 0;i < N;i++) {
        if(A[i] == 0) {
            result++;
        }
    }
    cout << result << endl;

    return 0;

 }

Measured memory_bytes: 3636
#include <iostream>
#define NMAX 100000
#define SENTINEL 1000000001
using namespace std;

int partition(int array[], char array2[], int p, int r) {
    int x = array[r];
    int i = p - 1;
    for (int j = p; j < r; j++){
        if (array[j] <= x) {
            i++;
            int temp = array[i];
            array[i] = array[j];
            array[j] = temp;
            char tem = array2[i];
            array2[i] = array2[j];
            array2[j] = tem;
        }
    }
    int temp = array[i + 1];
    array[i + 1] = array[r];
    array[r] = temp;
    char tem = array2[i + 1];
    array2[i + 1] = array2[r];
    array2[r] = tem;
    return i + 1;
}

void merge(int A[],char B[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    int L[NMAX],R[NMAX];
    char LL[NMAX],RR[NMAX];

    for(int i=0;i<=n1-1;i++){
        L[i]=A[left+i];
        LL[i]=B[left+i];
    }
    for(int i=0;i<=n2-1;i++){
        R[i]=A[mid+i];
        RR[i]=B[mid+i];
    }
    L[n1]=SENTINEL;
    R[n2]=SENTINEL;
    int i=0,j=0;
    for(int k=left;k<=right-1;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
            B[k]=LL[i];
            i++;
        }
        else{
            A[k]=R[j];
            B[k]=RR[j];
            j++;
        }
    }
}

void merge_sort(int A[],char B[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        merge_sort(A,B,left,mid);
        merge_sort(A,B,mid,right);
        merge(A,B,left,mid,right);
    }
}


void quicksort(int array[], char arr2[], int p, int r) {
    if (p < r) {
        int q = partition(array, arr2,  p, r);
        quicksort(array, arr2, p, q-1);
        quicksort(array, arr2, q + 1, r);
    }
}

int main() {
    int pickles, i;
    int stable = 0;
    cin >> i;
    int array[i] = {};
    char array2[i] = {};
    char array3[i] = {};
    int array4[i] = {};

    for (int j = 0; j < i; j++) {
        cin >> array2[j] >> array[j];
    }

    for (int p = 0; p < i; p++) {
        array3[p] = array2[p];
        array4[p] = array[p];
    }
    merge_sort(array4, array3,0,i);

    quicksort(array, array2, 0, i - 1);
    for (int j = 0; j < i; j++) {
        if ((array2[j] != array3[j])) stable = 1;
        }
    if (stable == 0) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    for (int j = 0; j < i; j++) {
        cout << array2[j] << " " << array[j] << endl;
    }

}


Measured memory_bytes: 4560
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000

// O(ElogE)

// pq<pair> はfirstが大きい順に出てくるのですか？
// s:= 開始ノード  v:= 頂点数  adjlist:= 隣接リスト (first:= コスト   second:= 行先)
vector<int> dijk(int s, int v, vector<vector<pair<int, int> > > adjlist){
    
    priority_queue <pair<int, int> > wait;
    vector<int> result(v, INF);

    //スタート地点を追加
    result[s] = 0;
    wait.push(make_pair(0, s));

    //ダイクストラ本体
    while(!wait.empty()){    //waitが空になるまで

        int nowpoint = wait.top().second;
        int nowcost = -wait.top().first;
        wait.pop();

        if(result[nowpoint] < nowcost) continue;


        //今いる頂点と隣接しているすべての頂点をなめる
        for(int i = 0; i < adjlist[nowpoint].size(); i++){

            int nextpoint = adjlist[nowpoint][i].second;
            int nextcost = nowcost + adjlist[nowpoint][i].first;
            //現時点より安く到達できそうであれば、結果を更新して優先度付きキューに格納
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }
    
    return result;         //結果列を返す
}

int main(){

    int V; cin >> V;
    vector<vector<pair<int, int> > > adjlist(V);      //first := コスト　second := 行先

    //入力
    for(int i = 0; i < V; i++){
        int gomi; cin >> gomi;
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int v, c; cin >> v >> c;           // a ,b 間に コスト c の辺がある
            adjlist[i].push_back(make_pair(c, v));
        }     
    }

    vector<int> result(V);
    result = dijk(0, V, adjlist);
    //cout << result[G] << endl;

    for(int i = 0; i < V; i++){
        cout << i << " " << result[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 11820
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,s;
	cin>>s>>n;
	k=0;
	for(i=1;i<=n;i++){
		cin>>l;
		k+=l;
	}
	if(k>=s){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#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((i%2 != 0 || i == 1) &&(j%2 != 0 || j ==1)){
	  cout <<"#";
	}else if((i%2 != 0 || i == 1) && j%2 == 0){
	  cout <<".";
	}else if(i%2 == 0 &&( j%2 != 0 || j ==1)){
	  cout <<".";
	}else if(i%2 == 0 && j%2 == 0){
	  cout <<"#";
	}
      }
      cout <<endl; 
    }
    cout <<"\n";
  }
  return 0;
}

Measured memory_bytes: 1152
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
    
  while b[j] > K - a[i]:
    j -= 1
    
  ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47464