akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define mii map<int, int>
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
#define fi first
#define se second
#define PB pop_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define repit(st) for (auto it = st.begin(); it != st.end(); it++)
#define sz(x) (int)((x).size())
#define pi 1.0l * acos(-1)
#define iOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define tc     \
    int tc;    \
    cin >> tc; \
    while (tc--)
//const int mod=998244353;
#define M_PI 3.14159265358979323846
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
ull gcd(ull a, ull b) { return (b == 0 ? a : gcd(b, a % b)); }
ull lcm(ull a, ull b) { return (a * (b / gcd(a, b))); }

int main()
{
    iOS
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
       ll a,b;
       cin>>a>>b;
       cout<<a*b<<endl;


    return 0;
}

Measured memory_bytes: 3652
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)2e1
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll i,n,x,j;cin>>n>>x;vi w(n),v(n);vvi d(n+1,vi(x+1,0));
	for(i=0;i<n;i++) cin>>w[i]>>v[i];
	for(i=1;i<=n;i++){
		for(j=0;j<=x;j++){
			d[i][j]=max(d[i-1][j],d[i][j]);
			if(j+w[i-1]<=x) d[i][j+w[i-1]]=max(d[i][j+w[i-1]],d[i-1][j]+v[i-1]);
		}
	}cout<<d[n][x]<<endl;
}


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

n,*a = map(int,read().split())


from collections import deque

q = deque()

flag = 0
for ai in a:
    if flag==0:
        q.append(ai)
    else:
        q.appendleft(ai)
    flag ^= 1

q = list(q)
#print(q)
if flag==0:
    print(*q)
else:
    print(*q[::-1])









Measured memory_bytes: 31188
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL a;
    cin >> a;
    if(a < 1200){
        cout << "ABC" << endl;
    }else if(a < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/


void solve()
{
  ll h,a;
  cin>>h>>a;
  if(h%a)
    cout<<h/a+1;
  else
    cout<<h/a;
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

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

using namespace std;



int main() {
    
    int n;
    cin >> n;
    
    vector<int> a(n);
    FOR(i, 0, n){
        cin >> a[i];
    }
    
    sort(a.begin(),a.end());

    int mid=0;
    
    FOR(i, 0, n-1){
        mid = ((min(a[i],a[n-1]-a[i]) > mid) ? a[i] : mid);
    }
    
    
    cout << a[n-1] << " " << mid << endl;
    return 0;
}



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

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

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;


void solve(int z) {
    int n , k;
    cin >> n >> k;
    vector<int> v(n , 0);
    int j = 0;
    while(k --) {
        int d;
        cin >> d;
        for(int i = 0 , a ; i < d ; i ++) cin >> a , a -- , v[a] ++;
    }
    int  cnt =0 ;
    for(auto x : v) {
        if(x == 0) cnt ++;
    }
    cout << cnt;
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



Measured memory_bytes: 3664
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	while (1) {
		ll n, r;
		cin >> n >> r;
		if (n == 0 && r == 0) break;
		ll a[55], b[55];
		repi(i, 1, n + 1) a[n - i] = b[n - i] = i;
		repi(i, 0, r) {
			ll p, c;
			cin >> p >> c;
			repi(j, 0, p - 1) b[c + j] = a[j];
			repi(j, 0, c) b[j] = a[p - 1 + j];
			repi(j, 0, n) a[j] = b[j];
		}
		wrln(a[0]);
	}
	return 0;
}



Measured memory_bytes: 3032
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,a,b=0,c=0;
vector<int> bff;

void ch()
{
	int bt=0;
	for(int i=0;i<bff.size();i++)
		if(bff[i]>=2&&bff[i]%2==0)bt++;
	if(bt>1)
	{
		c-=bt-1;
	}
}

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&a);
		if(a>=4&&a%4==0)b++;
		else
		{
			bff.push_back(a);
			c++;
		}
	}
	ch();
	if(b>c||abs(b-c)<2)puts("Yes");
	else puts("No");
}


Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 1050;

const int mod = (int) 1e9 + 7;

int addMod(int a, int b) {
  int sum = a + b;
  return sum >= mod ? sum - mod : sum;
}
int subMod(int a, int b) {
  int res = a - b;
  return res < 0 ? res + mod : res;
}

int n, m;
char c[MAXN][MAXN];
int dp[MAXN][MAXN];

int main() { 

  scanf("%d %d\n", &n, &m);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &c[i][j]);
    }
    scanf("\n");
  }

  dp[0][0] = 1;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i][j] == '#') {
        continue;
      }
      if (i) {
        dp[i][j] = addMod(dp[i][j], dp[i - 1][j]);
      }
      if (j) {
        dp[i][j] = addMod(dp[i][j], dp[i][j - 1]);
      }
    }
  }

  cout << dp[n - 1][m - 1] << endl;

  return 0;
}


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

const long long MOD = 1000000007;
using ll = long long;

const int MAX = 2010000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve(long long K, std::string S){
    ll ans = 0;
    COMinit();
    for(int i = 0;i <= K;i++){
        ans += (COM(K - i + (int)S.size() - 1, (int)S.size() - 1) * modpow(26, i, MOD)) % MOD * modpow(25, K - i, MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 52552
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>

int main(){
  
  long long int N, M;
  scanf("%lld%lld", &N, &M);
  
  std::string S;
  std::cin >> S;
  
  std::vector<long long int> field;
  for(long long int i = 0; i <= N; i++){
    if(S[i] == '0'){
      field.push_back(i);
    }
  }
  /*
  std::cerr << "S:" << std::endl;
  std::cerr << S << std::endl;
  std::cerr << "field" << std::endl;
  for(long long int i = 0; i < field.size(); i++){
    std::cerr << field[i] << " ";
  }std::cerr << std::endl;*/
  
  // solve problem
  //long long int current_pos = N;
  long long int current_index = field.size()-1;
  int possible_flag = 1;
  
  long long int l, r, mid;
  std::vector<long long int> dices_reverse;
  while(current_index > 0){
    // go back to initial position
    if(field[current_index] <= M){
      dices_reverse.push_back(field[current_index]);
      //current_pos = 0;
      current_index = 0;
      break;
    }
    // it is impossible to reach goal
    else if(field[current_index] - field[current_index-1] > M){
      possible_flag = 0;
      break;
    }
    // bisection
    l = 0;
    r = current_index-1;
    while(r-l > 1){
      mid = (l+r)/2;
      if(field[current_index]-field[mid]>M)l = mid;
      else r = mid;
    }
    dices_reverse.push_back(field[current_index] - field[r]);
    current_index = r;
  }
  
  std::cerr << "Answer:" << std::endl;
  if(possible_flag == 0){
    std::cout << -1 << std::endl;
  }
  else{
    for(long long int i = dices_reverse.size()-1; i >= 0; i--){
      std::cout << dices_reverse[i] << " ";
    }
  }
  std::cout << std::endl;
  return 0;
}


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

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

  static class DHandstand {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt(), k = in.nextInt();
      char[] s = in.next().toCharArray();
      List<Integer> trans = new ArrayList<>();

      for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1])
          trans.add(i - 1);
      }

      int ans = 0, L = 0, R;

      boolean one = s[0] == '1';
      int rightIdx = 2 * k, m = trans.size();
      if (!one) {
        rightIdx--;
      }
      R = getR(n, trans, rightIdx, m);

      do {
        if (L > 0) {
          one = (s[L] - s[L - 1]) == 1;
          if (one) {
            for (int i = 0; i < 2 && R < n && rightIdx < m; ++i) {
              rightIdx++;
            }
            R = getR(n, trans, rightIdx, m);
          }
        }
        ans = Math.max(ans, R - L + 1);
        L++;
      } while (L < n);
      out.println(ans);
    }

    private int getR(int n, List<Integer> trans, int rightIdx, int m) {
      return rightIdx >= m ? n - 1 : trans.get(Math.min(rightIdx, m - 1));
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

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

    public int nextInt() {
      return Integer.parseInt(next());
    }

  }
}



Measured memory_bytes: 29140
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(void){
  int a, b, c;
  scanf("%d", &a);
  scanf("%d", &b);

  if(a+b==3)
    c = 3;
  else if(a+b == 4)
    c = 2;
  else if(a+b == 5)
    c = 1;

  printf("%d\n", c);
  
  return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
	int in1;
	map <int, int> an;
	for (int i = 0; i < n; i++) {
		cin >> in1;
		an[in1]++;
	}

	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> in1;
		an[in1]--;
		if (an[in1] < 0) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 12976
n,m,q = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(q)]
b = []
for i in range(m):
    b.append(i+1)
import itertools
l = list(itertools.combinations_with_replacement(b,n))
max=0
#print(l)                                                                      

#for _ in range(int(c)):                                                       
for ll in l:
    m=0
#    print(ll)                                                                 
    for aa in a:
#        print(ll[aa[1]-1],ll[aa[0]-1],aa[2])                                  
        if ll[aa[1]-1]-ll[aa[0]-1]==aa[2]:
 #           print(aa[3])                                                      
            m+=aa[3]
    if max < m:
        max=m
  #  print(m,max)                                                              
print(max)


Measured memory_bytes: 21532
/*
Kaushal Jalan
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}
 
signed main()
{
    crap;
    int n,k;
    cin>>n>>k;
    n=n%k;
    cout<<min(n,k-n)<<endl;
}

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

using namespace std;

int main() {
	int N;//くじ引きの回数

	cin >> N;

	std::vector<string> vec_keihin;//景品の文字列

	string strCin;
	for (int i = 0; i < N; i++) {
		cin >> strCin;
		vec_keihin.push_back(strCin);
	}

	std::sort(vec_keihin.begin(), vec_keihin.end());
	vec_keihin.erase(std::unique(vec_keihin.begin(), vec_keihin.end()), vec_keihin.end());

	cout << vec_keihin.size() << endl;

}

Measured memory_bytes: 11624
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

H, W = list(map(int, input().split()))
s = []
for i in range(H):
	s.append(input())

que = deque()
dist = [[-1 for i in range(W)] for j in range(H)]
que.append([0,0])
dist[0][0] = 0
while len(que) > 0:
	loc = que.popleft()
	if loc[0] < H - 1 and s[loc[0] + 1][loc[1]] == '.' and dist[loc[0] + 1][loc[1]] == -1:
		dist[loc[0] + 1][loc[1]] = dist[loc[0]][loc[1]] + 1
		que.append([loc[0] + 1, loc[1]])
	if loc[0] > 0 and s[loc[0] - 1][loc[1]] == '.' and dist[loc[0] - 1][loc[1]] == -1:
		dist[loc[0] - 1][loc[1]] = dist[loc[0]][loc[1]] + 1
		que.append([loc[0] - 1, loc[1]])
	if loc[1] < W - 1 and s[loc[0]][loc[1] + 1] == '.' and dist[loc[0]][loc[1] + 1] == -1:
		dist[loc[0]][loc[1] + 1] = dist[loc[0]][loc[1]] + 1
		que.append([loc[0], loc[1] + 1])
	if loc[1] > 0 and s[loc[0]][loc[1] - 1] == '.' and dist[loc[0]][loc[1] - 1] == -1:
		dist[loc[0]][loc[1] - 1] = dist[loc[0]][loc[1]] + 1
		que.append([loc[0], loc[1] - 1])


distance = dist[H - 1][W - 1]
if distance == -1:
	print(-1)
	exit()
num = H*W
for i in range(H):
	for j in range(W):
		if s[i][j] == '#':
			num -= 1
num -= 1 + distance
print(num)

Measured memory_bytes: 40492
import math as np
k = int(input())
D = {}
for a in range(1, k + 1):
    for b in range(1, k + 1):
        try:
            D[np.gcd(a, b)] += 1
        except:
            D[np.gcd(a, b)] = 1
ans = 0
for c in range(1, k + 1):
    for key, cnt in D.items():
        ans += cnt * np.gcd(c, key)
print(ans)


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

#define pr pair<int, int>

using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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 a[10010][10010], b[1000];
// int dp[10010][3];

int main() {
    ll N; cin >> N;
    set<string> s;
    rep(i,N){
        string S; cin >> S;
        s.insert(S);
    }
    
    cout << s.size() << endl; 

return 0;
}


Measured memory_bytes: 19076
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ll Mod = 1000000007;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, m;
	cin >> n >> m;
	int s = m * 1900 + (n - m) * 100;
	cout << s*pow(2, m) << endl;
	getchar(); getchar();
}

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

const int N = 2002;
                               
int main(){
  int n;
  cin >> n;
  vector<int>ar(n);
  for (int i = 1; i <= n; i++){
    cin >> ar[i];
  }
  vector< vector<int> > dp(n + 1, vector<int>(10, -1e5));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++){
    for (int j = 0; j < 10; j++){
      dp[i][j] = max(dp[i - 1][j], dp[i - 1][(j - (ar[i] % 10) + 10) % 10] + ar[i]);
    }
  }
  int ans = 0;
  for (int i = 1; i < 10; i++) {
    ans = max(ans, dp[n][i]);
    //cout << dp[n][i] << "\n";
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 
public class abcC
{
	
	
	public static void Main()
	{
	
		int sum = 0;
		int N = int.Parse(Console.ReadLine()); 
		
		int[] score = new int[N];
		string line;
		int i = 0;
		while ((line = Console.ReadLine()) != null) {
			int x = int.Parse(line);
			score[i] = x;
			sum += x;
			i++;
		}
		
		if (sum % 10 != 0) {
			Console.Write(sum);
		} else {
			Array.Sort(score);
			foreach (int j in score) {
				if (j % 10 != 0) {
					Console.Write(sum - j);
					return;
				}
			}
			Console.Write(0);
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

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

    vec c(k+1);

    lint res = 0;

    for (int x = k; x > 0; x--) {
        lint t = k / x;
        t = modpow(t, n);
        lint x2 = x + x;
        while (x2 <= k) {
            t -= c[x2];
            x2 += x;
        }
        t = ((t % MOD) + MOD) % MOD;
        c[x] = t;
        res += t * x;
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4056
n,a,b = map(int,input().split())
L = list(map(int,input().split()))

diff = []
for i in range(n-1):
    diff.append(a*(L[i+1]-L[i]))
#print(diff)
cnt = 0
for i in range(n-1):
    if diff[i] > b:
        cnt +=1
diff.sort()

print(sum(diff[:n-1-cnt]) + b*cnt)

Measured memory_bytes: 19924
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    Int k;
    cin >> k;

    Int ans = 0;
    for (Int i = 1; i <= k; i++) {
        for (Int j = 1; j <= k; j++) {
            for (Int l = 1; l <= k; l++) {
                Int t = gcd(i, j);
                t = gcd(t, l);
                ans += t;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
using namespace std;

struct Data{
	int A,B;
	bool operator<(const Data &a)const{
		if(B!=a.B) return B>a.B;
		else return A<a.A;
	}
};

int main(){
	int N;
	Data H[20];
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>H[i].A>>H[i].B;
	}
	sort(H,H+N);
	printf("%d %d\n",H[0].A,H[0].B);
	return 0;
}

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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	sort(p.begin(), p.end());
	p[n - 1] /= 2;
	int ans = 0;
	rep(i, n) ans += p[i];
	cout << ans << endl;
	return 0;
}

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

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

int main()
{
    int N, res;
    cin >> N >> res;
    for (int i = 1; i < N; i++)
    {
        int a;
        cin >> a;
        res = gcd(a, res);
    }
    cout << res << '\n';
    return(0);
}

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

using namespace std;

int main()
{
    map<string,int>m;
    map<string,int>::iterator it,low,up;
    string s,p;
    string l,r;
    int i,t,j,n;
    long long int z;
    cin>>t;
    for (i=1;i<=t;++i){

        cin>>n;
        if (n==0){

            cin>>s>>z;
            m[s]=z;


        }
        else if(n==1){

            cin>>s;
            cout<<m[s]<<'\n';

        }
        else if(n==2){

            cin>>s;
            m[s]=0;

        }
        else{

           cin>>l>>r;
           low=m.lower_bound(l);
           up=m.upper_bound(r);
           for (it=low;it!=up;++it) {

                p=it->first;
                if (p>=l && p<=r && m[p]!=0){

                    cout<<p<<' '<<m[p]<<'\n';


                }

           }

        }

    }

    return 0;
}



Measured memory_bytes: 27648
N=int(input())
C=input()
s=0
e=N-1
ans=0
while(s<e):
  while(C[s]=="R" and s<e):
    s+=1
  while(C[e]=="W" and s<e):
    e-=1
  if s<e:
    s+=1
    e-=1
    ans+=1
print(ans)

Measured memory_bytes: 9488
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    // t=s;
    ll i=0,c=0;
    vi temp;
    while(i<n){
        while(i<n && s[i]=='R') c++,i++;
        if(c) temp.pb(c);
        c=0;
        while(i<n && s[i]=='L') c++,i++;
        if(c) temp.pb(c);
        c=0;
    }
    // rep(i,0,sz(temp)-1) cout<<temp[i]<<" \n"[i==sz(temp)-1];
    ll ans=0;
    for(auto i:temp) ans+=i-1;
    ans+=min(sz(temp)-1,k)*2;
    cout<<min(ans,n-1);
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repm(i, n) for (int i = n; i >= 0; --i)
typedef long long ll;
template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  vector<vector<ll>> dp(100, vector<ll>(2, -1));
  dp[0][0] = 0;
  rep(i, 50) {
    ll mask = 1LL << (50 - i - 1);
    int cnt = 0;
    rep(j, N) if (A[j] & mask) cnt++;
    if (dp[i][1] != -1)
      chmax(dp[i + 1][1], dp[i][1] + max(cnt, N - cnt) * mask);
    if (dp[i][0] != -1 && K & mask)
      chmax(dp[i + 1][1], dp[i][0] + cnt * mask);
    if (dp[i][0] != -1) {
      if (K & mask)
        chmax(dp[i + 1][0], dp[i][0] + (N - cnt) * mask);
      else
        chmax(dp[i + 1][0], dp[i][0] + cnt * mask);
    }
  }
  cout << max(dp[50][0], dp[50][1]) << endl;
  return 0;
}


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


int main() {
    int n;
    cin >> n;
    string s="MARCH";
    long long c[5]={0};
    for (int i = 0; i < n; ++i){
        string t;
        cin >> t;
        for (int j = 0; j < 5; ++j){
            if(t[0]==s[j])
                c[j]++;
        }
    }

    long long ans=0;
    for (int i = 0; i < 5; ++i){
        for (int j = i+1; j < 5; ++j){
            for (int k = j+1; k < 5; ++k){
                ans+=c[i]*c[j]*c[k];
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::min;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (h, w) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1])
    };

    let mut ans = std::usize::MAX;
    // 縦hに沿って1個目を分割
    for wid in 1..w {
        let mut squares = vec![h * wid];
        if h % 2 == 0 || (w-wid) % 2 == 0 {
            let rest = (h * (w-wid)) / 2;
            squares.push(rest);
            squares.push(rest);
        } else {
            // hを２つに分割
            if h > (w-wid) {
               squares.push((w-wid)*(h/2));
               squares.push((w-wid)*(h/2 + 1));
            } else {
                squares.push(h*((w-wid)/2));
                squares.push(h*((w-wid)/2 + 1));
            }
        }
        squares.sort();
        let M = squares[2];
        let m = squares[0];

        ans = min(ans, M - m);
    }

    // 横wに沿って1個目を分割
    for hig in 1..h {
        let mut squares = vec![hig * w];
        if w % 2 == 0 || (h-hig) % 2 == 0 {
            let rest = ((h-hig) * w) / 2;
            squares.push(rest);
            squares.push(rest);
        } else {
            // wを２つに分割
            if w > (h-hig) {
               squares.push((w/2)*(h-hig));
               squares.push((w/2 + 1)*(h-hig));
            } else {
                squares.push(w*((h-hig)/2));
                squares.push(w*((h-hig)/2 + 1));
            }
        }
        squares.sort();
        let M = squares[2];
        let m = squares[0];

        ans = min(ans, M - m);
    }

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


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include <stdlib.h>

#define MAX 7777777

#define NF 100
#define INF 1000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, A[NF][NF], d[NF];
void ax(void) {
  int i, v, head, tail, q[NF*NF], z[NF];

	head = -1;
	tail = 1;
	for (i = 0; i < n; i++) {
		d[i] = INF;
		z[i] = WHITE;
	}
	z[0] = GRAY;
	q[++head] = 0;
	d[0] = 0;

	while (head != tail) {
		v = q[head++];
		for (i = 0; i < n; i++) {
			if (A[v][i] == 1 && z[i] == WHITE) {
				z[i] = GRAY;
				q[tail++] = i;
				d[i] = d[v] + 1;
			}
		}
		z[v] = BLACK;
	}
}
void cl(void) {
	int i, j;

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			A[i][j] = 0;
		}
	}
	return ;
}
void print(void) {
	int i;
	for (i = 0; i < n; i++) {
		printf("%d ", i + 1);
		if (d[i] == INF) printf("-1\n");
		else			 printf("%d\n", d[i]);
	}
	return ;
}




int main() {
	int i, j, l, m, dt;

	cl();

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
	  
		scanf("%d%d", &l, &m);
		for (j = 0; j < m; j++) {
			scanf("%d", &dt);
			
			A[l - 1][dt - 1] = 1;
		}
	}

	ax();
	print();

	return 0;
}



Measured memory_bytes: 2124
li = list(map(int,input().split()))
count5 = 0
count7 = 0

for number in li :
  if number == 5 :
    count5 += 1
  elif number == 7:
    count7 += 1

if count5 == 2 and count7 == 1 :
  print('YES')
else:
  print('NO')

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    long n;
    cin >> n;
    vector<long> a(n);
    for(long i = 0;i < n;i++){
          cin >> a[i];
    }
    for(long i = 0;i < n;i++){
          if(a[i] == 0){
                cout << 0 << endl;
                return 0;
          }
    }
    long t = 1;
    long limit = 1e18;
    for(long i = 0;i < n;i++){
          if(a[i] <= limit / t){
                t *= a[i];
          }else{
                cout << - 1 << endl;
                return 0;
          }
    }
    cout << t << endl;
}


Measured memory_bytes: 4040
Program main
  implicit none
  character(len=3) :: S
  integer :: i
  read(*,*) S
  if ( S== "AAA") then
     write(*,'(a)') 'No'
  else if ( S== "BBB") then
     write(*,'(a)') 'No'
  else 
     write(*,'(a)') 'Yes'
  end if
end program main


Measured memory_bytes: 768
#include<iostream>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, 0, 3) {
        if (S[i] == T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MIN(x, y) ((x) < (y) ? (x) : (y))

int asc(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int upper_bound(int sup, int *y, int n){
  int r = 0, l = n;
  while(l - r > 1){
    if(y[(r + l)/2] > sup) l = (r + l)/2;
    else r = (r + l)/2;
  }
  return y[r];
}

int
main(int argc, char *argv[])
{
  int a, b, c, d, e, f;
  scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

  int y[500000];
  int k;

  k = 0;
  for(int i = 0; i <= (f - 100*a)/c; i++){
    for(int j = 0; j <= (f - 100*a - c*i)/d; j++){
      y[k++] = c*i + d*j;
    }
  }

  qsort(y, k, sizeof(int), asc);

  int sup; int z; double max = 0; double cons; int ans1 = 100*a, ans2 = 0;

  for(int i = 0; i <= f/(100*a); i++){
    for(int j = 0; j <= (f - 100*a*i)/(100*b); j++){
      sup = MIN(f - 100*a*i - 100*b*j, e*(a*i + b*j));
      z = upper_bound(sup, y, k);
      cons = (double)z/((double)(100*a*i+100*b*j+z));
      if(cons > max){
	max = cons;
	ans1 = 100*a*i + 100*b*j + z;
	ans2 = z;
      }
    }
  }

  printf("%d %d\n", ans1, ans2);

  return 0;
}
      


Measured memory_bytes: 1788
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int ans=0;
        int[] p=new int[n];
        for(int i=0;i<n;i++){
            p[i]=sc.nextInt();
            ans+=p[i];
        }
        Arrays.sort(p);
        out.println(ans-p[n-1]/2);
    }
}


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

using namespace std;

int main(){
        double a;
        while(cin >> a){ 
                double s = a;
                for(int i = 2; i <= 10; i++){
                        if(i%2) a /= 3;
                        else a *= 2;
                        s += a;
                }   
                printf("%06f\n",s);
        }   
}

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

int main() {

    int X, Y;
    cin >> X >> Y;

    int ans = 0;
    if (X == 1 && Y == 1) {
        ans += 4e5;
    }
    if (X <= 3) {
        ans += ((4 - X) * 1e5);
    }
    if (Y <= 3) {
        ans += ((4 - Y) * 1e5);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 1e3 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll n, m;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n >> m;

  cout << (n - m) + 1;
}


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

int main(){
  string s;
  long long int k;
  cin >> s >> k;
  long long int x=0;
  for(long long int i=0;i<s.size();i++){
    if(s.at(x)=='1'){
    x++;
    }else{
      break;
    }
  }
  if(x>=k){
    cout << '1' << endl;
  }else{
    cout << s.at(x) << endl;
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	vector<int> vec(3);
	rep(i, 3) cin >> vec[i];
	sort(vec.begin(), vec.end());
	//a <= b <= c
	int a = vec[0], b = vec[1], c = vec[2];
	//a,bをcにできないか考える。
	int ans = 0;
	//c-b回だけa,bを+1する
	ans += (c - b);
	a += (c - b);
	b = c;
	while (a < c) {
		a += 2;
		ans++;
	}
	if (a > c) cout << ans + 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())

csflist=[]
for i in range(N-1):
  c,s,f=map(int,input().split())
  csflist.append((c,s,f))
#print(csflist)

for i in range(N-1):
  sec=0
  for j in range(i,N-1):
    c,s,f=csflist[j]
    if sec<=s:
      sec=s
    else:
      sec=f*((sec-s-1)//f+1)+s
    sec+=c
    #print(i,j,sec)
  print(sec)
  
print(0)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    string s;
    cin>>s;
    ll ans=0;
    rep(i,0,3)if(s[i]=='1')ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
   // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=-10000001;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){
        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

        for(int i=0;i<l;i++){
            sum+=v[i];
            if(v[i]<0) {
                te.push_back(v[i]);
            }
        }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }

            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());
            for(int tt=0;tt<min(a,b);tt++){
             if(te[tt]<0){

                 sum-=te[tt];

                 if(ans<sum){
                     ans=sum;
                 }
                 
             }else{break;}
             //cout<<l<<" "<<r<<" "<<sum<<endl;

            }
            if(ans<sum){
                ans=sum;
            }




        }
    }

    cout<<ans<<endl;



    return 0;
}


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

vector<int> g[200010];
ll cnt[200010];

void dfs(int cur, int par, ll cost){
    cnt[cur] += cost;
    for (int to : g[cur]) {
        if (to == par) continue;
        dfs(to, cur, cnt[cur]);
    }
}

int main(void){
    int n, q;
    cin >> n >> q;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    dfs(0, -1, 0);
    rep(i,n){
        cout << cnt[i] << (i < n-1 ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 24320
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        
        int ans = 0;
        for(int i=0; i<=K; i++){
            for(int j=0; j<=K; j++){
                int z = S - i - j;
                if(0 <= z && z <= K){
                    ans++;
                }
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import numpy as np
N = int(input())

# get primes
primes = np.arange(55556)
primes[:2] = 0
for i in range(2, int(55555 ** 0.5)):
    if primes[i]:
        primes[2 * i::i] = 0

for j in range(1, 5):
    ans = primes[j::5]
    ans = ans[ans > 0]
    if len(ans) >= N:
        ans = ans[:N]
        break

print(*ans)

Measured memory_bytes: 12852
X,Y,A,B,C = map(int,input().split())
Pi=list(map(int,input().split()))
Qi=list(map(int,input().split()))
Ri=list(map(int,input().split()))

Pi.sort()
Qi.sort()
Ri.sort(reverse=True)


#Ri
#for i in range(X,)
r=0
p=A-X
q=B-Y
while(r<C):
  if(p>=A and q>=B):
    break
  elif(p>=A):
    #qi
    if(Qi[q]>=Ri[r]):
      break;
    else:
      Qi[q]=Ri[r]
      q+=1
  elif(q>=B):
    #pi
    if(Pi[p]>=Ri[r]):
      break;
    else:
      Pi[p]=Ri[r]
      p+=1
  elif(Pi[p]>=Qi[q]):
    #qi
    if(Qi[q]>=Ri[r]):
      break;
    else:
      Qi[q]=Ri[r]
      q+=1
  elif(Pi[p]<Qi[q]):
    #pi
    if(Pi[p]>=Ri[r]):
      break;
    else:
      Pi[p]=Ri[r]
      p+=1
  elif(Pi[p]>=Ri[r] and Qi[q]>=Ri[r]):
    break
  
  r+=1

psum=sum(Pi[A-X:A])
qsum=sum(Qi[B-Y:B])


happy = psum + qsum

print(happy)

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define TMP 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	char s[100];
	scanf("AtCoder %s Contest", s);
	printf("A%cC", s[0]);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define p pair<int, int>
#define ll long long
using namespace std;

int main(){

  ll n, k, a, b;
  vector<p> v;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    v.push_back(p(a, b));
  }
  sort(v.begin(), v.end());
  ll i, cnt;
  i = cnt = 0;
  while(1){
    cnt += v[i].second;
    if(cnt >= k){
      cout << v[i].first << endl;
      return 0;
    }
    i++;
  }
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 100123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

int n, m, h[N];
set<ii> adj[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        cin >> h[i];
    }
    int u, v;
    for(int i = 0; i < m; ++i){
        cin >> u >> v;
        adj[u].insert(ii(h[v], v));
        adj[v].insert(ii(h[u], u));
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(sz(adj[i]) == 0) ans++;
        else {
            auto it = adj[i].end();
            it--;
            ii t = *it;
            if(t.fs < h[i]) ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


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

vector<int> g[200002];
bool vis[200002];
int n;
long long ans = 0;
void dfs(int u, int p){
    for(int i=0;i<(int)g[u].size();i++){
        int v = g[u][i];
        if(v != p) dfs(v, u);
    }
    if(p != 0){
        int L = min(u, p);
        int R = max(u, p);
        if(u < p) ans += L*1ll*(R-L);
        else{
            ans += (u-p)*1ll*(n-u+1);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs(1, 0);
    printf("%lld\n", ans+n);
}

Measured memory_bytes: 24076