akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int all(Int n) {  // no bb
  Int rr = 1, bb = 1, rb = 0, br = 0;
  for (int i = 1; i < n; i++) {
    Int nrr = (rr + rb) % MOD;
    Int nbb = br;
    Int nrb = rr;
    Int nbr = (bb + br) % MOD;
    rr = nrr;
    bb = nbb;
    rb = nrb;
    br = nbr;
  }
  return (rr + rb + br) % MOD;
}

Int tmp[216000];
Int rdp[216000];
Int dp[216000];
void calc(Int n, Int limit) {
  dp[0] = 1;
  rdp[0] = 1;
  for (int i = 1; i <= n + 1; i++) {
    dp[i] =
        (rdp[i - 1] - ((i - limit - 1) >= 0 ? rdp[i - limit - 1] : 0)) % MOD;
    if (dp[i] < 0) dp[i] += MOD;
    rdp[i] = (rdp[i - 1] + dp[i]) % MOD;
  }
}

Int solve(Int n, Int limit) {
  if (n % 2 == 1) return 0;
  if (limit % 2 != 1) exit(1);
  limit = (limit + 1) / 2;
  n /= 2;
  Int res = 0;
  calc(n + 10, limit);
  for (Int i = 1; i <= limit; i++) {
    if (n - i >= 0) res = (res + dp[n - i] * 2 * i) % MOD;
  }
  if (res < 0) exit(1);
  return res % MOD;
}

int main() {
  Int n, m;
  string str;
  vector<Int> vec;
  cin >> n >> m;
  cin >> str;
  bool allsame = true;
  for (int i = 0; i < m; i++) allsame &= (str[i] == str[0]);
  if (allsame) {
    cout << all(n) << endl;
    return 0;
  }
  for (int i = 0; i < m; i++) vec.push_back(str[i] == str[0]);
  // vec.push_back(0);
  Int l = 0;
  while (vec[l] == 1) l++;
  if (l % 2 == 0) l++;
  Int limit = l;
  l = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] == 1)
      l++;
    else {
      if (l % 2 == 1) limit = min(limit, l);
      l = 0;
    }
  }
  cout << solve(n, limit) << endl;
  return 0;
}

Measured memory_bytes: 5364
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int P[M+1];
  int Y[M+1];
  vector<int>Y_num[N+1];
  for(int i=0;i<M;i++){
	cin >> P[i] >> Y[i];
	Y_num[P[i]].push_back(Y[i]);	
  }

  for(int i=0;i<N+1;i++){	
	sort(Y_num[i].begin(),Y_num[i].end());
  }
  
  for(int i=0;i<M;i++){
	cout << setw(6) << setfill('0')<<P[i];
	cout << setw(6) << setfill('0')<<int(lower_bound(Y_num[P[i]].begin(),Y_num[P[i]].end(),Y[i])-Y_num[P[i]].begin())+1;

	cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <cstdlib>

using namespace std;
char c1,c2,c;
int nrcf()
{
    long long nr=1;
    int cf=1;
    while(1)
    {
        cout<<"? "<<nr<<endl;
        cin>>c;
        if(c=='N')return cf-1;
        cf++;
        nr*=10;
    }
}
void particular()
{
    long long nr=1,rez;
    for(int i=1;i<=10;i++)
    {
        cout<<"? "<<nr<<endl;
        cin>>c;
        if(c=='N')return;
        nr*=10;
    }
    nr=9;rez=1;
    for(int i=1;i<=10;i++)
    {
        cout<<"? "<<nr<<endl;
        cin>>c;
        if(c=='Y')
        {
            cout<<"! "<<rez<<endl;exit(0);
        }
        nr=nr*10+9;
        rez=rez*10;
    }
}
int main()
{
    particular();
    int nr=nrcf();
    long long st=1;
    for(int i=1;i<nr;i++)st=10*st;
    long long dr=10*st-1;
    while(st<dr)
    {
        long long mid=(st+dr)/2;
        cout<<"? "<<mid*10+1<<endl;
        cin>>c;
        if(c=='Y')dr=mid;
        else st=mid+1;
    }
    cout<<"! "<<st<<endl;
    return 0;
}


Measured memory_bytes: 684
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int rflg;
    int rnum = ( s[2] - '0' ) * 10 + ( s[3] - '0' );
    int lnum = (s[0] - '0' ) * 10 + ( s[1] - '0' );
    if( rnum == 0 || lnum == 0 ) {
        if( rnum == lnum ) cout << "NA";
        else if( ( rnum == 0 && lnum > 12 ) || ( lnum == 0 && rnum > 12 ) ) cout << "NA";
        else if( rnum == 0 ) cout << "MMYY";
        else cout << "YYMM";

    } else if( lnum > 12 || rnum > 12 ) {
        if( lnum > 12 && rnum > 12 ) cout << "NA";
        else if( lnum > 12 ) cout << "YYMM";
        else cout << "MMYY";

    } else {
        cout << "AMBIGUOUS";

    }
    cout << endl;
    return 0;
}



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

class Main {
  static final Scanner in = new Scanner(System.in);
  static int N, K;

  static int[] h;
  // static int dp[][];
  static int dp[];
  static final int MOD = 1000000007;
  static int[] pre;

  public static void main(String[] args) throws Exception {
    N = in.nextInt();
    K = in.nextInt();
    h = new int[N];
    dp = new int[N];

    // dp = new int[N + 1][K + 1];
    // pre = new int[N];

    int old_sum = 0;
    for (int i = 0; i < N; i++) {
      h[i] = in.nextInt();
      //   pre[i] = old_sum + a[i];
      //   old_sum = pre[i];
      // Arrays.fill(dp[i],-1);
    }
    Arrays.fill(dp, -1);

    System.out.println(F(N - 1));
  }

  // static int F(int i, int k) {
  //   // System.out.println("\tat i == " + i + " k = " + k);
  //   if (i < N && k > pre[i]) return 0;
  //   if (i < N && k == pre[i]) return 1;

  //   if (i == 1) {
  //     // System.out.println("\tat i == 0 k = "+k);
  //     if (k > a[0]) {
  //       // System.out.println("\treturning 0");5
  //       return 0;
  //     }
  //     // System.out.println("\treturning 1");
  //     return 1;
  //   }

  //   if (dp[i][k] != -1) return dp[i][k];

  //   int val = 0;
  //   for (int j = 0; j <= a[i - 1]; j++) {
  //     // System.out.println("\t\tat i == " + i + " k = " + k + " j = " + j);
  //     if (k < j) break;
  //     val += F(i - 1, k - j) % MOD;
  //     val %= MOD;
  //   }
  //   // System.out.println("\t\tat i == " + i + " k = " + k + " val = " + val);
  //   dp[i][k] = val % MOD;
  //   return dp[i][k];
  // }

  static int F(int i) {
    if (i == 0) return 0;

    if (i == 1) return Math.abs(h[0] - h[1]);
    if(dp[i] != -1)
      return dp[i];
    int min_cost = Integer.MAX_VALUE;
    for(int k = 1;k <= K;k++){
      if(k > i)
        break;
      min_cost = Math.min(min_cost,F(i-k) + Math.abs(h[i-k] - h[i]));
    }
    
    dp[i] = min_cost;
    return dp[i];  

  }
  // static int F_topDown(int i) {
  //   for (int i = 0; i < N; i++) {
  //     //..if we have only 1 stone
  //     if (i == 0) {
  //       dp[i] = 0;
  //       continue;
  //     }

  //     //..if we have 2 stones
  //     if (i == 1) {
  //       dp[i] = Math.abs(h[0] - h[1]);
  //       continue;
  //     }

  //     //..if frog jumps from previous stone
  //     int cost1 = F(i - 1) + Math.abs(h[i - 1] - h[i]);

  //     //..if frog jumps from two stones back
  //     int cost2 = F(i - 2) + Math.abs(h[i - 2] - h[i]);

  //     //..store it before returning
  //     dp[i] = Math.min(cost1, cost2);
  //   }
  //   //..if value is already been calculated return directly
  //   if (dp[i] != -1) return dp[i];

  //   //..if frog jumps from previous stone
  //   int cost1 = F(i - 1) + Math.abs(h[i - 1] - h[i]);

  //   //..if frog jumps from two stones back
  //   int cost2 = F(i - 2) + Math.abs(h[i - 2] - h[i]);

  //   //..store it before returning
  //   dp[i] = Math.min(cost1, cost2);
  //   return dp[i];
  // }
}


Measured memory_bytes: 69064
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) { }
    bool unionSet(ll x, ll y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) {
        return root(x) == root(y);
    }
    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(ll x) {
        return -data[root(x)];
    }
};

ll gcd(ll a, ll b)
{
    for (;;)
    {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

ll lcm(ll a, ll b)
{
    ll temp = gcd(a, b);
    
    return temp ? (a / temp * b) : 0;
}

ll a[10000][2];
ll sa[10000][2];

int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        ll a1, b1;
        cin >> a1 >> b1;
        a[i][0] = a1;
        a[i][1] = b1;
    }
    sa[0][0] = a[0][0];
    sa[0][1] = a[0][1];
    for(int i = 1;i < n;i++)
    {
        if(a[i][0] == a[i][1])
        {
            if(sa[i-1][0] == sa[i-1][1])
            {
                sa[i][0] = sa[i-1][0];
                sa[i][1] = sa[i-1][1];
            }
            else
            {
                sa[i][0] = sa[i][1] = max(sa[i-1][0], sa[i-1][1]);
            }
        }
        else
        {
            ll divm = -1;
            for(int j = 0;j < 2;j++)
            {                
                ll div = sa[i-1][j] / a[i][j];
                ll mod = sa[i-1][j] % a[i][j];
                if(mod)
                {
                    div++;
                }
                if(divm < div)
                {
                    divm = div;
                }
            }
            for(int j = 0;j < 2;j++)
            {
                sa[i][j] = a[i][j] * divm;
            }
        }
        //cout << sa[i][0] <<","<< sa[i][1]  <<","<< a[i][0] << "," << a[i][1] << endl;
    }
    ll sum = sa[n-1][0] + sa[n-1][1];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  const double PI = 3.14159265358979;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double kaku, kaku_a, kaku_b;
  kaku_a =
      (long double)2.0 * PI * ((long double)h + ((long double)m / 60.0)) / 12.0;
  kaku_b = (long double)2.0 * PI * m / 60.0;
  kaku = (long double)abs((long double)kaku_a - kaku_b);

  long double ans;
  ans = (long double)a * a + (long double)b * b -
        (long double)2.0 * a * b * cos(kaku);
  ans = (long double)sqrt(ans);
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4160
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  uint64_t n, x;
  cin >> n >> x;
  vector<uint64_t> v;
  for (auto i = 0; i < n; i++) {
    uint64_t a;
    cin >> a;
    v.push_back(a);
  }
  sort(begin(v), end(v));
  uint64_t child = 0;
  for (auto i = 0; i < n; i++) {
    if (v[i] <= x) {
      x -= v[i];
      child++;
    } else {
      break;
    }
  }
  if (x > 0 && child == n) child--;
  cout << child << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    int n, k;
    double ans = 0.0;
    double p = 0.0;

    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        if(i == k) { 
            ans += (double)(n-k+1)/n;    
            //printf("%.10f\n", ans);
            break;
        }
        int power = 0;
        for(int j = i; j < k; j *= 2) {
            power++;
        }
        p += 1.0 / (n*pow(2,power)); 
        //printf("i,%d,p,%.10f\n", i, p);
    }
    ans += p ; 
    printf("%.12f\n", ans); 

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


string s;

int main(){
	cin >> s;
	int a = 0;
	for(int i = 0; i < 4; i++){
		if(s[i] == '+') a++;
		else a--;
	}
	
	cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,m,k = map(int,readline().split())
*a, = map(int,readline().split())
*b, = map(int,readline().split())

from itertools import accumulate

a = list(accumulate(a))
b = list(accumulate([0]+b))

from bisect import bisect_right

ans = 0
for i,bi in enumerate(b):
    if bi > k: break
    r = i + bisect_right(a,k-bi)
    ans = max(ans,r)


print(ans)


Measured memory_bytes: 132524
N = int(input())
Hs = list(map(int, input().split()))

ans = 0
num = 0
for i in range(N-1):
    if Hs[i] >= Hs[i+1]:
        num += 1
        if num > ans:
            ans = num
    else:
        num = 0

print(ans)


Measured memory_bytes: 14252
n,m = map(int,input().split())
L = [0]*n
penalty = [0]*n
ans = 0
out = 0
for i in range(m):
  p,q = input().split()
  if q == 'AC':
    if L[int(p)-1] == 0:
      L[int(p)-1] = 1
      ans += 1
  else:
    if L[int(p)-1] == 0:
      penalty[int(p)-1] += 1
for i in range(n):
  if L[i] == 1:
    out += penalty[i]
print(ans,out)

Measured memory_bytes: 4596
#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 INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    ans = x /(y+z);
    if(x < ans*(y+z)+z) ans--;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;

//* calculate x^n mod something in O(log n) -- recursive version
ll mod_pow(ll x, ll n, ll mod){
    if(n == 0) return 1;
    ll res = mod_pow(x*x % mod, n/2, mod);
    if(n & 1) res = res * x % mod;
    return res;
}

void solve(long long N){
    ll ans = 0;
    ll tmp = mod_pow(10, N, MOD);
    ans = mod_pow(10, N, MOD) + mod_pow(8, N, MOD) - 2* mod_pow(9, N, MOD);
    ans = ans % MOD;
    if(ans < 0 ) ans += MOD;
    cout<<ans<<endl;

}
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main(){
	int n ;
	cin >> n ;
	int p[n] , q[n];
  	for(int i = 0 ; i < n ; ++i)
    	cin >> p[i] , q[p[i]-1] = i;
  	int ans = 1 , cur = 1 ; 
	for(int i = 1 ; i < n ; ++i){
    	if(q[i] > q[i-1]) cur++;
      	else cur = 1;
      	ans = max(ans , cur);
    }
  	cout << n - ans ;
}

Measured memory_bytes: 5184
nm = [int(x) for x in input().split()]
n = nm[0]
m = nm[1]
students = []
checkpoints = []
distances = []
for i in range(n):
  students.append([int(x) for x in input().split()])
for i in range(m):
  checkpoints.append([int(x) for x in input().split()])
  
for i in students:
  for j in checkpoints:
    distances.append(abs(j[0]-i[0])+abs(j[1]-i[1]))
  print(distances.index(min(distances))+1)
  distances = []


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

vector<vector<int>> r;
int n;

int func(int a, vector<int> h) {
  int ret = 0, f = 1;
  for(auto x : r.at(a)) {
    if(!count(h.begin(), h.end(), x)) {
      f = 0;
      auto v = h;
      v.push_back(x);
      ret += func(x, v);
    }
  }
  if(f && h.size() == n)
    return 1;
  return ret;
}

int main() {
  int m, a, b, o = 0;
  cin >> n >> m;
  r = vector<vector<int>>(n);
  for(int i = 0; i < m; i++) {
    cin >> a >> b;
    r.at(--a).push_back(--b);
    r.at(b).push_back(a);
  }
  for(auto x : r.at(0)) {
    vector<int> v = {0, x};
    o += func(x, v);
  }
  cout << o << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int H,N; cin>>H>>N;
  vi A(N),B(N);
  vi dp(H+1);
  rep(i,0,N) cin>>A[i]>>B[i];
  REP(i,1,H){
    dp[i]=dp[max(0ll,i-A[0])]+B[0];
    rep(j,1,N){
      dp[i]=min(dp[max(0ll,i-A[j])]+B[j],dp[i]);
    }
  }
  cout<<dp[H]<<endl;
  }



Measured memory_bytes: 384
using System;

class Program{
    static int Merge(int[] A, int left, int mid, int right){
        var n1=mid-left;
        var n2=right-mid;
        var L=new int[n1+1];
        var R=new int[n2+1];
        for(var i=0; i<n1; i++){
            L[i]=A[left+i];
        }
        for(var i=0; i<n2; i++){
            R[i]=A[mid+i];
        }
        L[n1]=1000*1000*1000+1;
        R[n2]=1000*1000*1000+1;
        var l=0;
        var j=0;
        var cnt=0;
        for(var k=left; k<right; k++){
            if(L[l]<=R[j]){
                A[k]=L[l];
                l++;
            } else{
                A[k]=R[j];
                j++;
            }
            cnt++;
        }
        return cnt;
    }

    static int MergeSort(int[] A, int left, int right){
        if(left+1<right){
            var mid=(left+right)/2;
            var a=MergeSort(A, left, mid);
            var b=MergeSort(A, mid, right);
            var c=Merge(A, left, mid, right);
            return a+b+c;
        } else{
            return 0;
        }
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var s=Console.ReadLine().Split(' ');
        var S=new int[n];
        for(var i=0; i<n; i++){
            S[i]=int.Parse(s[i]);
        }

        var result=MergeSort(S, 0, n);

        for(var i=0; i<n; i++){
            Console.Write(S[i]);
            if(i>=n-1){
                Console.WriteLine();
            } else{
                Console.Write(" ");
            }
        }
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 83612
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    return arr


def nCr(n,r,mod = 10**9+7):
    r = min(n-r,r)
    numer = denom = 1
    for i in range(1,r+1):
        numer = numer * (n+1-i) %mod
        denom = denom * i % mod
    return numer * pow(denom,mod-2,mod) %mod


n, m = map(int, input().split())
factors = factorization(m)
mod = 10**9 + 7

ans = 1
for factor, count in factors:
    pattern = nCr(count+n-1, count)
    ans *= pattern
    ans %= mod

print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] c = new int[n];
        int[] s = new int[n];
        int[] f = new int[n];
        for (int i = 0; i < n - 1; i++) {
            c[i] = scan.nextInt();
            s[i] = scan.nextInt();
            f[i] = scan.nextInt();
        }
        f[n-1] = 1;
        int[] result = new int[n];
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = i; j < n; j++) {
                sum = (sum < s[j]) ? s[j] : sum;
                if (sum % f[j] != 0) {
                    sum += f[j] - sum % f[j];
                }
                sum += c[j];
            }
            System.out.println(sum);
        }
    }


}


Measured memory_bytes: 27764
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, m, k;
vector<vector<long long>> dp;

long long solve();

int main() {
  smodfact();
  cin >> m >> n >> k;
  dp.resize(m);
  for(int i = 0; i < m; ++i) dp[i].assign(n, 0);
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(long long i = 0; i < m; ++i)
    for(long long j = 0; j < n; ++j) {
      ans += ((m - i) * (m - i - 1) / 2 % N * j % N +
              (j + 1) * j / 2 % N * (m - i - 1) % N) %
             N;
      ans %= N;

      ans += ((i + 1) * i / 2 % N * (j + 1) % N +
              (j + 1) * j / 2 % N * (i + 1) % N) %
             N;
      ans %= N;
    }
  while(ans < 0) ans += N;
  ans %= N;
  return ans * calccomb((n * m - 2), k - 2) % N;
}

Measured memory_bytes: 22912
#include <iostream>
#include <vector>
#include <queue>
#include <numeric>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    const ll n = s.size() + 1;
    vector<vector<ll>> net(n);
    vector<ll> indeg(n, 0);
    REP(i, s.size()){
        if(s.at(i) == '<'){
            net.at(i).push_back(i + 1);
            indeg.at(i + 1)++;
        }else{
            net.at(i + 1).push_back(i);
            indeg.at(i)++;
        }
    }
    vector<ll> height(n, -1);
    REP(i, n){
        if(indeg.at(i) > 0){ continue; }
        height.at(i) = 0;
        queue<ll> que;
        que.push(i);
        while(!que.empty()){
            ll j = que.front(); que.pop();
            for(ll k : net.at(j)){
                if(height.at(k) < height.at(j) + 1){
                    height.at(k) = height.at(j) + 1;
                    que.push(k);
                }
            }
        }
    }

    ll ans = accumulate(height.begin(), height.end(), 0LL);
    cout << ans << endl;
    return 0;
}


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

int n;
int main(){
    cin>>n;
    std::vector<int> d(n);
    
    for (int i = 0; i < n; i++) {
        /* code */
        std::cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    int ans=n;
    for (int i = 0; i < n-1; i++) {
        /* code */
        if(d.at(i)==d.at(i+1))ans--;
    }
    std::cout << ans << std::endl;
}

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

using namespace std;

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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


int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector< int > C(N);
  auto A = make_v< int >(N, M);
  for(int i = 0; i < N; i++) {
    cin >> C[i];
    cin >> A[i];
  }
  int ret = inf;
  for(int i = 0; i < (1 << N); i++) {
    vector< int > sum(M);
    int add = 0;
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) {
        add += C[j];
        for(int k = 0; k < M; k++) {
          sum[k] += A[j][k];
        }
      }
    }
    bool ok = true;
    for(int j = 0; j < M; j++) {
      if(sum[j] < X) ok = false;
    }
    if(ok) chmin(ret, add);
  }
  if(ret == inf) ret = -1;
  cout << ret << "\n";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (int)(n); i++)
int main(){
    int H,W,f=0,c=0;
    cin >> H >> W;
    vector<vector<char>> grid(H,vector<char> (W));
    rep(i,H){
        rep(j,W){
            cin >> grid.at(i).at(j);
        }
    }
    rep(i,H){
        f=0;
        rep(j,W){
            if(grid.at(i).at(j)=='#') {
                f=1;
                break;
            }
        }
        if(f==0){
            rep(j,W) grid.at(i).at(j)='-';
        }
    }
    rep(i,W){
        f=0;
        rep(j,H){
            if(grid.at(j).at(i)=='#') {
                f=1;
                break;
            }
        }
        if(f==0){
            rep(j,H) grid.at(j).at(i)='-';
            c++;
        }
    }
    rep(i,H){
        int C=0;
        rep(j,W){
            if(grid.at(i).at(j)=='-') continue;
            C++;
            cout << grid.at(i).at(j);
            if(C==(W-c)) cout << endl;
            //else cout << ' ';

        }
    }
}

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

int main(){
	int n;
	cin>>n;
//	double A[n];
	vector<double>A(n,0);
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
//	double dp[n+1][n+1];
	vector<vector<double>>dp(n+1, vector<double>(n+1, 0.0));
//	memset(dp, 0.0, sizeof(dp));
	dp[0][0]= 1;
//	cout<<"hi";
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0) dp[i][j]= dp[i-1][j]*(1-A[i-1]);
			else {
				dp[i][j]= (dp[i-1][j])*(1.0-A[i-1])+ (dp[i-1][j-1])*(A[i-1]);
			}
//			cout<<dp[i][j]<<" ";
//			dp[i][j+1] += dp[i-1][j]*(A[i-1]);
//      dp[i][j] += dp[i-1][j]*(1.0 - A[i-1]); 
		}
	}
	double ans= 0.0;
	for(int i=n;i>n/2;i--){
		ans= ans+ dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
//	cout<<ans<<endl;
	return 0;
	
}

Measured memory_bytes: 73784
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];

    vector<int> tmp(n);
    for(int i = 0; i < n; i++) {
        tmp[i] = i + 1;
    }

    

    int a = 0;
    int b = 0;

    int cnt = 0;

    
    do{
        cnt++;
        //cout << cnt << endl;
        bool fa = true;
        bool fb = true;

        for(int i = 0; i < n; i++){
            //cout << tmp[i] << " ";
            if(tmp[i] != p[i]){
                
                fa = false;
                break;
            }
            //cout << endl;
        }

        if(fa){
            a = cnt;
        }

        for(int i = 0; i < n; i++){
            if(tmp[i] != q[i]){
                fb = false;
                break;
            }
        }

        if(fb){
            b = cnt;
        }
    } while(next_permutation(tmp.begin(), tmp.end()));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
op = "$"

while op != "?":
	a, op, c = map(str, raw_input().split())
	a = int(a)
	c = int(c)

	if   op == "+":
		print u"%d" % (a+c)
	elif op == "-":
		print u"%d" % (a-c)
	elif op == "*":
		print u"%d" % (a*c)
	elif op == "/":
		print u"%d" % (a/c)
	else:
		break

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n/2) if(s[i] != s[n-1-i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a[3], b[3], c[4] = {0,0,0,0};
	for (int i=0;i<3;i++) {
		cin >> a[i] >> b[i];
		c[a[i]-1]++;
		c[b[i]-1]++;
	}
	for (int i=0;i<4;i++) {
		if (c[i]==0||c[i]==3) {cout << "NO" << endl; return 0;}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(){
	int n;
	int p;
	int count;
	vector<int> v(300000,1);

	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		count = 0;
		for(int i = 0; i <= 2*n; i++){
			v[i] = 1;
			//cout << " testcase1 " << endl;
		}
		v[0] = 0;
		v[1] = 0;

		for(int i = 0; i <= 2*n;i++){	

			if(v[i] == 1){
				for(int j = 2*i; j <= 2*n; j+= i){
					v[j] = 0;
					//cout << " testcase 4" << endl;
				}
			}
			//cout << " testcase2 " << endl;
		}

		for(int i = n+1 ; i <= 2*n ; i++){
			if(v[i] == 1){
				count++;
			}
			//cout << " testcase3 " << endl;
		}
		cout << count << endl;

	}
}



		

 

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1; char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while (isdigit(ch)) {x=x*10+(ch^48); ch=getchar();}
	return x*f;
}

int main() {

	LL n=read(),a=read(),b=read();
	if (n==1&&a!=b) {puts("0"); return 0;}
	if (b<a) {puts("0"); return 0;}
	LL tmp1=a*(n-1)+b;
	LL tmp2=a+(n-1)*b;
	printf("%lld\n",tmp2-tmp1+1);	

	return 0;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>

#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPA(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#if defined(_MSC_VER)||__cplusplus > 199711L
#define AUTO(r,v) auto r = (v)
#else
#define AUTO(r,v) typeof(v) r = (v)
#endif
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(AUTO(it,(c).begin());it != (c).end();++it)
#define LL long  
#define int LL
#define INF  99999999
#define DEV 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
using namespace std;



signed main()
{
	QUICK_CIN;
	//ifstream cin("debug.txt");
	//ofstream cout("result.txt");
	int n;
	while (cin >> n){
		cout << n*n*n << endl;
	}

}

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

int main() {
  int n; cin >> n;
  string str; cin >> str;
  map<char, int> g;
  for (auto &c : str) ++g[c];
  set<char> s;
  int ans = 0, tmp = 0;
  for (auto &c : str) {
    --g[c];
    if (g[c] == 0 && s.count(c)) --tmp;
    if (g[c] > 0 && !s.count(c)) ++tmp;
    s.insert(c);
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;

  int cnt =0;

  for(int i=1; i<=n; ++i){
    if(i%2 == 1) cnt++;
  }
  
  cout << fixed << setprecision(10)<< (double)cnt / n;
}

  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://abc054.contest.atcoder.jp/tasks/abc054_c>
問題文============================================================
 自己ループと二重辺を含まない N 頂点 M 辺の重み無し無向グラフが与えられます。
 i(1≦i≦M) 番目の辺は頂点 ai と頂点 bi を結びます。
 ここで、自己ループは ai=bi(1≦i≦M) となる辺のことを表します。
 また、二重辺は ai=aj かつ bi=bj(1≦i<j≦M) となる辺のことを表します。
 頂点 1 を始点として、全ての頂点を1度だけ訪れるパスは何通りありますか。
 ただし、パスの始点と終点の頂点も訪れたものとみなします。
 
 例として、図1のような無向グラフが与えられたとします。
=================================================================

解説=============================================================
制約が弱いので貪欲
================================================================
*/
int cnt = 0;
vector<vector<int>> G;
void dfs(int n,int rev, vector<int> checked) {
    checked[n] = 1;
    bool f = false;
    for (int i = 0; i < checked.size();i++) {
        if (checked[i] == 0) {
            f = true; break;
        }
    }
    if (!f) { cnt++; return; }
    
    for (auto next : G[n]) {
        if (checked[next] == 1)continue;
        dfs(next,n, checked);
    }
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    G.resize(N);
    for (int i = 0; i < M;i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> checked(N, 0);
    dfs(0,-1, checked);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define BOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

bool used[4];

int main(){

    string s;
    cin>>s;
    REP(i,4)used[i]=false;
    
    REP(i,s.size()){
        if(s[i]=='N')used[0]=true;
        if(s[i]=='W')used[1]=true;
        if(s[i]=='S')used[2]=true;
        if(s[i]=='E')used[3]=true;
    }
    
    if(used[0]!=used[2]||used[1]!=used[3]){
        cout<<"No"<<endl;
        return 0;
    }
    
    cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);


	string s, t;

	while(cin >> s >> t)
	{
		ans = 0;

		for(ll i = 0; i < s.size(); i++) ans += (s[i] != t[i]);

		cout << ans << '\n';
	}

}





Measured memory_bytes: 3916
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int N = scan.nextInt();
		for(int i = 0; i < N; i++){
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();
			if(a * a == b * b + c * c | b * b == a * a + c * c | c * c == a * a + b * b){
				System.out.println("YES");
			} else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 33148
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cstdlib>

using namespace std;

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

template<typename T> inline void chmax(T& t, T f){if(t < f)t = f;}

inline bool inrect(int x, int y){
    return 0 <= x && x < 8 && 0 <= y && y < 8;
}

void solve(vector<string>& s){
    for(bool turn=true, pass=false; ; turn=!turn){
        tuple<int, int, int, vector<string> > best = make_tuple(0, turn? -8: 0, turn? -8: 0, s); // {0, turn? -8: 0, turn? -8: 0, s}
        rep(x, 8)rep(y, 8)if(s[x][y] == '.'){
            char my = turn? 'o': 'x', your = turn? 'x': 'o';
            int cnt = 0;
            vector<string> t = s; t[x][y] = my;
            for(int dx=-1; dx<=1; ++dx){
                for(int dy=-1; dy<=1; ++dy){
                    int nx = x + dx, ny = y + dy;
                    if((dx|dy) == 0 || !inrect(nx, ny) || s[nx][ny] != your)continue;
                    vector<string> tmp = t;
                    while(inrect(nx, ny) && s[nx][ny] == your){
                        tmp[nx][ny] = my; nx += dx; ny += dy;
                    }
                    if(inrect(nx, ny) && s[nx][ny] == my){
                        cnt += max(abs(x - nx) - 1, abs(y - ny) - 1);
                        t.swap(tmp);
                    }
                }
            }
            if(cnt)chmax(best, make_tuple(cnt, turn? -x: x, turn? -y: y, t)); // {cnt, turn? -x: x, turn? -y: y, t};
        }
        if(get<0>(best) == 0){
            if(pass)break; else pass = true;
        }
        else{
            if(pass)pass = false;
            s.swap(get<3>(best));
        }
    }
}

int main(){
    vector<string> s(8);
    rep(i, 8)cin >> s[i];
    solve(s);
    rep(i, 8)cout << s[i] << '\n';
    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    int x = 0,y = 0;
    rep(i,n) {
        if(a[i]%2 != 0) x++;
        if(a[i]%4 == 0) y++;
    }
    Yes(x <= y || x+y == n && x-1 <= y);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void readLong(ll &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
/*================Header Template==============*/
int n,m,bok[26],cnt0,cnt1,cnt2,cnt3;
char s[105][105];
int main() {
	readInt(n);
	readInt(m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
		memset(bok,0,sizeof bok);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			bok[s[i][j]-'a']++;
	for(int i=0;i<26;i++) {
		if(bok[i]%4==0)
			cnt0++;
		else if(bok[i]%4==1)
			cnt1++;
		else if(bok[i]%4==2)
			cnt2++;
		else
			cnt3++;
	}
	if(n%2==1&&m%2==1) {
		if(cnt1+cnt3>1)
			puts("No");
		else {
			int sum2=0,sum4=0;
			for(int i=0;i<26;i++) {
				sum4+=bok[i]/4;
				int tmp=bok[i]%4;
				sum2+=tmp/2;
			}
//			cout<<sum4<<" "<<sum2<<endl;
			int x=(n*m-n-m+1)/4;
			if(x>sum4) {
				puts("No");
				return 0;
			}
			else {
				sum4-=x;
				if(sum4*2+sum2<(n+m-2)/2) {
					puts("No");
					return 0;
				}
			}
			puts("Yes");
		}
	}
	else if(n%2==0&&m%2==1) {
		if(cnt1+cnt3>0)
			puts("No");
		else {
			int sum2=0,sum4=0;
			for(int i=0;i<26;i++) {
				sum4+=bok[i]/4;
				int tmp=bok[i]%4;
				sum2+=tmp/2;
			}
			int x=(n*m-n)/4;
			if(x>sum4) {
				puts("No");
				return 0;
			}
			else {
				sum4-=x;
				if(sum4*2+sum2<n/2) {
					puts("No");
					return 0;
				}
			}
			puts("Yes");
		}
	}
	else if(n%2==1&&m%2==0) {
		if(cnt1+cnt3>0)
			puts("No");
		else {
			int sum2=0,sum4=0;
			for(int i=0;i<26;i++) {
				sum4+=bok[i]/4;
				int tmp=bok[i]%4;
				sum2+=tmp/2;
			}
			int x=(n*m-m)/4;
			if(x>sum4) {
				puts("No");
				return 0;
			}
			else {
				sum4-=x;
				if(sum4*2+sum2<m/2) {
					puts("No");
					return 0;
				}
			}
			puts("Yes");
		}
	}
	else {
		if(cnt1+cnt2+cnt3>0)
			puts("No");
		else
			puts("Yes");
	}
	return 0;
}

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

int main()
{
	int x, y, r;
	int W, H;

	while (1)
	{
		cin >> W >> H >> x >> y >> r;
		if (x >= -100 && x <= 100 && y >= -100 && y <= 100 && W > 0 && W <= 100 && H > 0 && H <= 100 && r > 0 && r <= 100)
			break;
	}

	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1160
let n, a, b = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let cs = Array.make 3 0
let f i = cs.(i) <- cs.(i) + 1
let _ = Array.iter (fun p -> if p <= a then f 0 else if p <= b then f 1 else f 2) ps;
  Array.fold_left min 100 cs |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(void){
	int n;
	string s;
	cin >> n >> s;
	vector<int> a(30, 0);
	for(int i = 0; i < n; ++i){
		a[s[i]-'a']++;
	}
	long long ans = 1;
	for(int i = 0; i < 27; ++i){
		ans *= (a[i]+1);
		ans %= MOD;
	}
	cout << (ans - 1LL + MOD) % MOD<< endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint p(int n, int k) { return fact[n] * ifact[n - k]; }
} c(2020);

signed main() {
    int s;
    cin >> s;
    int n = s / 3;
    mint ans = 0;
    rep(i, 1, n + 1) {  //何個に分けるか
        int ns = s - i * 3;
        ans += c(ns + i - 1, i - 1);
        // cout << ns + i - 1 << " " << i - 1 << " " << ans << "\n";
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3648