akhauriyash/Code-Regression huggingface dataset:
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

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

bool process(vector<string> &s, char c){
    char cc=(c=='o'?'x':'o');
    int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,1,1,1,0,-1,-1,-1};
    vp mem;
    rep(i,8){
        rep(j,8){
            int ii=i,jj=j;
            if(c=='x')ii=7-ii,jj=7-jj;
            vp tmp;
            tmp.pb({ii,jj});
            if(s[ii][jj]=='.'){
                rep(k,8){
                    vp t;
                    int nx=jj+dx[k],ny=ii+dy[k];
                    while(true){
                        if(!is_valid(nx,ny)||s[ny][nx]=='.'){
                          t.resize(0);
                          break;
                        }
                        else if(s[ny][nx]==cc)t.pb({ny,nx});
                        else if(s[ny][nx]==c)break;
                        nx+=dx[k],ny+=dy[k];
                    }
                    for(pi p:t)tmp.pb(p);
                }
            }
            if(tmp.size()!=1&&mem.size()<tmp.size()){
                mem=tmp;
            }
        }
    }
    if(mem.empty())return false;
    for(pi p:mem){
        int nx=p.se,ny=p.fi;
        s[ny][nx]=c;
    }
    return true;
}

void solve(vector<string> &s){
    bool f=false;
    do{
        f=process(s,'o');
        f|=process(s,'x');
    }while(f);
}

void run(){
    vector<string> s(8);
    rep(i,8)cin>>s[i];
    solve(s);
    rep(i,8)cout<<s[i]<<endl;
}
    


Measured memory_bytes: 3244
// ------------------------------------
// Date:2018/ 4/14
// Problem:/ / / a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "YES" : "NO") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(a, b, x);

  OK(0 <= x - a && x - a <= b);

  return 0;
}




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

using namespace std;
bool visited[(int)(1e5+1)];
int dp[(int)(1e5+1)];
vector<int> adj[(int)(1e5+1)];
#define ll long long int
const int mod = 1e9 + 7;

int answer(int node){
    if(visited[node]){
        return dp[node];
    }
    int ans = 0;
    for(int c:adj[node]){
        ans = max(ans,1+answer(c));
    }
    visited[node] = true;
    dp[node] = ans;
    return ans;
}

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

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(visited[i]==false)
            ans = max(ans,answer(i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair <int,ll> pii;
typedef vector<int> vi;
const int inf=1e9;
const int max_N=1e5+10;
ll n,a,b;
ll ans=0;
vector<int> x(100005);


int main()
{
  cin >> n >> a >> b;
  for(int i=0;i<n;i++)
    {
      cin >> x[i];
    }
  for(int i=0;i<n-1;i++)
    {
      ans+=min((ll)a*(x[i+1]-x[i]),b);
    }
  cout << ans << endl;
  return 0;
}
 


Measured memory_bytes: 640
import sys

A, B, C, D = list(input())

op = ["+", "-"]

for i in range(2):
    for j in range(2):
        for k in range(2):
            f = A + op[i] + B + op[j] + C + op[k] + D
            # print(f)
            if eval(f) == 7:
                print(f, "=7", sep="")
                sys.exit()

Measured memory_bytes: 38256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    int n = s.size();
    ll sum = 0;
    rep(i, n){
        sum += (s[i] - '0');
    }
    //cout << sum << endl;
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3748
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

// unsigned_map<int, int> mp;
std::vector<int> V(100005);
ll N;
ll arr[100005];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		V[arr[i]] = i + 1;
	}
	for(int i = 1; i <= N; i++) {
		cout << V[i] << " "; 
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
    
  if( N % 1000 % 111 == 0)
    cout << "Yes" << endl;
  else if( N / 10 % 111 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  }

Measured memory_bytes: 3484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

using namespace std;

int ans = 0;
int N;
int order;

void FDS(int num_i, int height)
{
    if (height >= order)
    {
        string num_s = to_string(num_i);
        if (num_i <= N && num_s.find("3") != string::npos
         && num_s.find("5") != string::npos 
         && num_s.find("7") != string::npos
         && num_s.find("0") == string::npos 
         )
             ans++;
    } else {
        FDS(num_i*10, height+1);
        FDS(num_i*10 + 3, height+1);
        FDS(num_i*10 + 5, height+1);
        FDS(num_i*10 + 7, height+1);
    }
}

int main()
{   cin >> N;
    order = to_string(N).length();

    FDS(0, 0);

    cout << ans << endl;
}

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

using namespace std;

int main() {
	long long n, x;
	scanf("%lld %lld", &n, &x);
	long long ans = n;
	n -= x;
	while (true) {
		if (n % x == 0) {
			ans += 2 * x * (n / x) - x;
			break;
		} else {
			ans += 2 * x * (n / x);
		}
		long long res = n % x;
		n = x;
		x = res;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>grid(h);
    for (int i = 0; i < h; i++)
    {
        string s;
        cin>>s;
        grid[i]=s;
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(grid[i][j]=='#'){
                bool flag=false;
                for (int dx = -1; dx <=1 ; dx++)
                {   
                    for (int dy = -1; dy <=1 ; dy++)
                    {   
                        if(0<=i+dx && i+dx<h && 0<=j+dy && j+dy<w && dx*dx+dy*dy==1){
                            if(grid[i+dx][j+dy]=='#'){
                              flag=true;  
                            }
                        }
                    }
                    
                }
                if(!flag){
                    cout<<"No"<<endl;
                    return 0;
                }
                
            }
        }
        
    }
    cout<<"Yes"<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')cout << 3 << endl;
  else if(s[0] == 'R' && s[1] == 'R')cout << 2 << endl;
  else if(s[2] == 'R' && s[1] == 'R')cout << 2 << endl;
  else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S')cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3624
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var abc=input.trim().split(" ").map(Number);
var a=abc[0];
var b=abc[1];
var c=abc[2];
var time=1;
var flag=true;
var nokori=a;
for(var i=0;i<60*60;i++){
   if(time%60==c && flag){console.log(time);break;}
   time++;
   nokori--;
   if(nokori==0){flag=!flag;nokori=flag?a:b;}
}
if(i==60*60)console.log(-1);

Measured memory_bytes: 7380
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}

using namespace std;

ll d(ll a)
{
    ll ret = 0;
    while (a > 0)
    {
        a /= 10;
        ret++;
    }
    return ret;
}

// C++ゆるさねえリスト
// accumulate(all(a), 0LL);
// 二分探索

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<vector<vector<int>>> data(n, vector<vector<int>>(n , vector<int>(2)));
    vector<int> uh(n);
    vector<int> a(n);
    int tmp, tmp2;

    rep(i, n)
    {
        cin >> tmp;
        a[i]=tmp;
        rep(j, tmp)
        {
            cin >> tmp2;
            data.at(i).at(j).at(0) = tmp2 - 1;
            cin >>data.at(i).at(j).at(1);
        }
    }

    for (int bit = 0; bit < (1 << n); ++bit)
    {
        rep(i, n)
        {
            uh[i] = 0;
        }

        vector<int> S;
        for (int i = 0; i < n; ++i)
        {
            if (bit & (1 << i))
            {
                S.push_back(i);
            }
        }

        for (int i = 0; i < (int)S.size(); ++i)
        {
            uh[S[i]] = 1;
        }


        int flag = 1;
        rep(i, n)
        {
            if (uh[i] == 1){
                rep(j, a[i])
                {
                    if (uh[data.at(i).at(j).at(0)] != data.at(i).at(j).at(1))
                        flag = 0;
                }
            }

        }

        if(flag==1){
            ans = max(ans, accumulate(all(uh),0));
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int n,a[2][100001],d[2][20][100001],e[2][20][100001];
int query(int parity,int l,int r)
{
	int k=0;l>>=1;r-=parity;r>>=1;
	while((1<<(k+1))<=r-l+1)k++;
	return min(d[parity][k][l],d[parity][k][r-(1<<k)+1]);
}
int pos(int parity,int l,int r)
{
	int k=0;l>>=1;r-=parity;r>>=1;
	while((1<<(k+1))<=r-l+1)k++;
	return d[parity][k][l]>d[parity][k][r-(1<<k)+1]?e[parity][k][r-(1<<k)+1]:e[parity][k][l];
}
struct range
{
	int l,r;
	range(int left,int right):l(left),r(right){}
	bool operator<(const range &b)const{return query(l&1,l,r)>query(b.l&1,b.l,b.r);}
};
int main()
{
	scanf("%d",&n);
	for(int i=0,j=0;i<n;i+=2,j++)scanf("%d%d",a[0]+j,a[1]+j);
	for(int i=0,j=0;i<n;i+=2,j++)
	{
		d[0][0][j]=a[0][j];
		d[1][0][j]=a[1][j];
		e[0][0][j]=i;
		e[1][0][j]=i+1;
	}
	for(int i=1;(1<<i)<=n/2;i++)
		for(int j=0;j+(1<<i)<=n/2;j++)
			for(int k=0;k<2;k++)
				if(d[k][i-1][j]<d[k][i-1][j+(1<<(i-1))])
				{
					d[k][i][j]=d[k][i-1][j];
					e[k][i][j]=e[k][i-1][j];
				}
				else
				{
					d[k][i][j]=d[k][i-1][j+(1<<(i-1))];
					e[k][i][j]=e[k][i-1][j+(1<<(i-1))];
				}
	priority_queue<range> q;
	q.push({0,n-1});
	while(!q.empty())
	{
		range u=q.top();q.pop();
		int p=pos(u.l&1,u.l,u.r-1),r=pos(u.r&1,p+1,u.r);
		printf("%d %d ",query(u.l&1,u.l,u.r-1),query(u.r&1,p+1,u.r));
		if(u.l<=p-1)q.push({u.l,p-1});
		if(p+1<=r-1)q.push({p+1,r-1});
		if(r+1<=u.r)q.push({r+1,u.r});
	}
	putchar('\n');
	return 0;
}


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

typedef long long lint;

int main(){
    lint a[20001],b[20001];
    int p[20001];
    bool chk[20001];
    int N;
    cin >> N;
    for(int i=1;i<=N;i++){
        a[i]=i*30000;
        b[i]=(N-i+1)*30000;
        chk[i]=false;
        cin >> p[i];
    }

    for(int i=1;i<=N;i++){
        for(int j=p[i]+1;j<=N;j++) if(!chk[j]) a[j]++;
        for(int j=p[i]-1;j>=1;j--) if(!chk[j]) b[j]++;
        chk[p[i]]=true;
    }

    for(int i=1;i<=N;i++){
        cout << a[i];
        if(i<N) cout << ' ';
        else cout << endl;
    }
    for(int i=1;i<=N;i++){
        cout << b[i];
        if(i<N) cout << ' ';
        else cout << endl;
    }

    return 0;
}//

Measured memory_bytes: 1024
import sys
#input = sys.stdin.buffer.readline
sys.setrecursionlimit(20000+1)

def main():
    s = "".join(list(reversed(str(input()))))
    b = True
    
    while len(s) != 0:
        if len(s) >= 5:
            use = ["maerd","esare"]
            if s[:5] in use:
                s = s[5:]
            elif (len(s) >= 6 and s[:6] == "resare"):
                s = s[6:]
            elif (len(s) >= 7 and s[:7] == "remaerd"):
                s = s[7:]
            else:
                b = False
                break
        else:
            b = False
            break
            
    if b:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3956
#include <stdio.h>

int main()
{
  int G[100][100],l,m,n,i,j,x;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  G[i][j] = 0;
	}
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d",&m,&l);

      for(j=0;j<l;j++)
	{
	  scanf("%d",&x);
	  G[m-1][x-1] = 1;
	}
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n-1;j++)
	{
	  printf("%d ",G[i][j]);
	}
      printf("%d",G[i][j]);
      printf("\n");
    }
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A + B >= C)cout << "Yes" << endl;
    else cout << "No" << endl;    
}

Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int A,B,M;cin>>A>>B>>M;
    vector<int> a(A),b(B);
    for(int i=0;i<A;i++){
        cin >> a[i];
    }
    for(int i=0;i<B;i++){
        cin >> b[i];
    }
    vector<int> xy(M);
    for(int i=0;i<M;i++){
        int x,y,c;cin>>x>>y>>c;
        xy[i] = a[x-1] + b[y-1] - c;
    }
    sort(xy.begin(),xy.end());
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(a[0]+b[0]<xy[0]){
        cout << a[0] + b[0] << endl;
    }else{
        cout << xy[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N);
  for (ll i = 0; i < N; ++i) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  vector<vector<ll>> dp(N + 1, vector<ll>(K, 0));
  dp.at(0).at(0) = 1;
  for (ll i = 0; i < N; ++i) {
    ll now = a.at(i);
    for (ll j = 0; j < K; ++j) {
      dp.at(i + 1).at(j) += dp.at(i).at(j);
      if (now + j < K) {
        dp.at(i + 1).at(j + now) += dp.at(i).at(j);
      }
    }
  }
  ll ans = N;
  for (ll i = 0; i < N; ++i) {
    vector<ll> last = dp.at(N);
    for (ll j = 0; j < K; ++j) {
      if (j + a.at(i) < K) {
        last.at(j + a.at(i)) -= last.at(j);
      }
      if ((j >= K - a.at(i)) && (last.at(j) != 0)) {
        ans -= 1;
        break;
      }
    }
  }
  cout << ans << "\n";
  // for (ll i = 0; i <= N; ++i) {
  //   for (ll j = 0; j < K; ++j) {
  //     cout << dp.at(i).at(j) << " ";
  //   }
  //   cout << "\n";
  // }
}


Measured memory_bytes: 195840
#include <stdio.h>
int main(){

  int n,m,a[101]={51},h=0,result,i,j,blank;

  scanf("%d %d",&n,&m);
  m *= 2;

  for(i	= 0; i < m; i++) scanf("%d",&a[i]);

  for(i = 0; i < m-1; i++){

    for(j = 0; j < m-1; j++){

      if(a[j] > a[j+1]){

        blank=a[j];
        a[j]=a[j+1];
	a[j+1]=blank;

      }

    }

  }

  //for(i = 0; i < m; i++) printf("%d ",a[i]);                                                                                 
  //printf("%d ",a[m-1]);                                                                                                      

  for(i = 1; i <= n; i++){

    result=0;
    for(j = h; a[j] == i; j++) result++;
    h=j;
    printf("%d\n",result);

  }

  return 0;

}


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

int main() {
	ios_base::sync_with_stdio( false );

	vector<string> S( 3 );
	for( auto& v: S ) { cin >> v; }

	char tn = 'a';

	for( ;; ) {
		auto& x = S.at( tn - 'a' );

		if( x.empty() ) {
			break;
		}

		tn = x.at( 0 );
		x.erase( 0, 1 );
	}

	char result = tn - 'a' + 'A';
	cout << result << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = sum(A)
    if sum(a>=B/4/M for a in A) >= M:
        return 'Yes'
    else:
        return 'No'
        
if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    vector<long long int>v;
    long int n,i;
  unsigned  long long int x,sum=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        sum+=x;
    }
    cout<<sum-n<<endl;
}


Measured memory_bytes: 256
from collections import Counter
seq = list(input().split())
mode_word = ''
cnt = 0
for k, v in Counter(seq).items():
    if cnt < v:
        mode_word = k
        cnt = v
max_count_word = ''
for s in seq:
    if len(max_count_word) < len(s):
        max_count_word = s
print(mode_word, max_count_word)



Measured memory_bytes: 5956
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,1,0,-1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);

    int K;cin>>K;
    deque<ll> a;
    repl(i,1,10)a.push_back(i);
    rep(i,K){
        ll p=a.front();
        if(i==K-1){
            cout<<p<<endl;
            return 0;
        }
        a.pop_front();
        if(p%10>0)a.push_back(p*10+p%10-1);
        a.push_back(p*10+p%10);
        if(p%10<9)a.push_back(p*10+p%10+1);
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//sort(l,l+N,greater<int>());	降順ソート
//sort(l,l+N);	昇順ソート
//string 変数　　変数.size()で数字化


int main(void)
{
	int w, a, b;
	cin >> w >> a >> b;
	if (a > b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int ans = b - (a + w);
	if (ans <= 0)
		cout << 0 << endl;
	else
		cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin>>a[i];
  int ans = 1000000000;
  rep(i,100){
    int sum=0;
    rep(j,n){
      sum+=(a[j]-i-1)*(a[j]-i-1);
    }
    ans = min(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#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<math.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
const long double pi = 3.14159265358979323846264338327950288;
bool a[1000001];
int main() {
	ll a, b;
	cin >> a >> b;
	if (b < 0) {
		if ((b - a + 1) % 2 == 1)cout << "Negative\n";
		else
			cout << "Positive\n";
	}
	else if (a > 0)
		cout << "Positive\n";
	else
		cout << "Zero\n";
	cin >> a;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, sum int
	Fscan(in, &n, &sum)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	dp := make([]int, sum+1)
	dp[0] = 1
	for _, v := range a {
		for s := sum; s >= 0; s-- {
			dp[s] <<= 1
			if s >= v {
				dp[s] += dp[s-v]
			}
			dp[s] %= 998244353
		}
	}
	Fprint(_w, dp[sum])
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 1916
x = []
for i in range(3):
  x.append(list(map(int,input().split())))

n = int(input()) 
b = []
for i in range(n):
  b.append(int(input()))


#横にビンゴ
if (x[0][0] in b) and (x[0][1] in b)and (x[0][2] in b):
  print("Yes")
elif (x[1][0] in b) and (x[1][1] in b)and (x[1][2] in b):
  print("Yes")
elif (x[2][0] in b) and (x[2][1] in b)and (x[2][2] in b):
  print("Yes")
#縦にビンゴ
elif (x[0][0] in b) and (x[1][0] in b)and (x[2][0] in b):
  print("Yes")
elif (x[0][1] in b) and (x[1][1] in b)and (x[2][1] in b):
  print("Yes")
elif (x[0][2] in b) and (x[1][2] in b)and (x[2][2] in b):
  print("Yes")
#斜めにビンゴ
elif (x[0][0] in b) and (x[1][1] in b)and (x[2][2] in b):
  print("Yes")
elif (x[0][2] in b) and (x[1][1] in b)and (x[2][0] in b):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


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

    int n,k; cin >> n >> k;
    std::vector<double> p(n); rep(i,n) cin >> p[i];
    std::vector<double> exp(n); rep(i,n) exp[i] = ((1.0+p[i])*p[i]/2.0)/p[i];

    std::vector<double> rskw(n+1); rep(i,n) rskw[i+1] = rskw[i] + exp[i];

    double m = 0;

    for(int i=k; i<=n; i++){
        m = max(m, rskw[i]-rskw[i-k]);
    }
    
    cout << setprecision(20) << m << endl;


    return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;
    vector<pair<int, int>> v;
    bool mp[n + 1][n + 1] = {};

    if (n % 2 == 0) {
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (j != n - i + 1 && j != i && !mp[i][j] && !mp[j][i])
                    v.push_back({i, j}), mp[i][j] = 1;
    } else
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (j != n - i && j != i && !mp[i][j] && !mp[j][i])
                    v.push_back({i, j}), mp[i][j] = 1;

    cout << v.size() << '\n';
    for (auto x : v)
        cout << x.first << ' ' << x.second << '\n';

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0;
    ll a,b,c,k;
    cin >> a >> b >> c >> k ;
    if(a>=k)
    {
        cout << k ;
        return 0;
    }
    if(a+b>=k)
    {
        cout << a ;
        return 0;
    }
    ll temp = k-(a+b);
    if(c>temp)
    {
        cout << a-temp;
    }
    else 
    {
        cout << a-c ;
    }
    
    return 0;
}

Measured memory_bytes: 3640
from collections import deque 

N,M = map(int, input().split())
root = [[] for _ in range(N)]

for _ in range(M):
	a,b = map(int,input().split())
	root[a - 1].append(b)
	root[b - 1].append(a)

q = deque()
q.append(1)
ans = [0]*N

while len(q) > 0:
	v = q.popleft()
	for ike in root[v - 1]:
		q.append(ike)
		if(ans[ike - 1] == 0):
			ans[ike - 1] = v

	root[v-1].clear()

print('Yes')
for a in ans[1::]:
	print(a)

Measured memory_bytes: 34860
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] b = new int[100000];
		for(int i = 0; i < n; i++) {
			b[sc.nextInt()]++;		
		}
		int max = 0;
		for(int i = 1; i < 99999; i++) {
			if(b[i-1]+b[i]+b[i+1] > max) {
				max = b[i-1]+b[i]+b[i+1];
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 50680
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i <= (n); i++)
#define repb(i, a, n) for (int i = (a); i >= (n); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const double inf = 0x3f3f3f3f3f;
/******* Function ***********************************/
void OutIndent(const vector<int> &X) {
  rep(i, 0, X.size() - 1) {
    co(X[i]);
  }
}
void OutSpace(const vector<int> &X) {
  rep(i, 0, X.size() - 2) {
    cosp(X[i]);
  }
  cout << X.back() << endl;
}
/*****************************************************/
/******* Main ****************************************/
int main() {
  int N, Q;
  cin >> N >> Q;
  queue<pair<string, int>> que;
  rep(i, 0, N - 1) {
    string name;
    int time;
    cin >> name >> time;
    que.push({name, time});
  }
  // ラウンドロビンスケジューリング
  int cur_time = 0;
  while (!que.empty()) {
    auto cur = que.front();
    que.pop();
    // Q秒以上かかるとき、Q秒処理してまたキューに追加
    if (cur.second > Q) {
      cur_time += Q;
      cur.second -= Q;
      que.push(cur);
    } else {
      cur_time += cur.second;
      cout << cur.first << " " << cur_time << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6224
a = int(input())

if a < 10:
  print(a)
elif a < 100:
  print(9)
elif a < 1000:
  print(a - 90)
elif a < 10000:
  print(909)
elif a < 100000:
  print(a - 90 - 9000)
elif a == 100000:
  print(90909)


Measured memory_bytes: 2940
console.log((args=>{
  const [[N],h] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  let o = h[0];
  for ( let i = 1; i < N; i++ ) {
    if ( h[i] > h[i-1] ) o += h[i] - h[i-1];
  }
  return `${o}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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


using namespace std;

int main()
{ int n,k;

  cin>>n;
  cin>>k;
  int ans=0;
  
  
  int a[n];
  for(int i=0;i<n;i++)
  {
  cin>>a[i];
  if(a[i]>=k)ans++;
}
  cout<<ans;
  
  
	
	
	
	return 0;
	
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<set>
#define LL long long
LL N;
LL mod = 1000000000 + 7;
LL R[100010];
LL A[100010];
LL ans = 1;
bool D[100010];
int main() {
	std::cin >> N;
	LL bef = 0;
	for (int i = 1; i <= N; i++) {
		LL tmp;
		std::cin >> tmp;
		if (tmp != bef) {
			D[i] = true;
		}
		R[i] = tmp;
		bef = tmp;
	}
	bef = 0;
	for (int i = 1; i <= N; i++) {
		LL tmp;
		std::cin >> tmp;
		if (i == N&&R[i]<tmp) {
			std::cout << 0 << std::endl;
			return 0;
		}
		if (i == 1 && R[i] > tmp) {
			std::cout << 0 << std::endl;
			return 0;
		}
		if (bef != tmp) {
			if (R[i - 1] < bef) {
				std::cout << 0 << std::endl;
				return 0;
			}
			if (D[i - 1]) {
				if (R[i - 1] != bef) {
					std::cout << 0 << std::endl;
					return 0;
				}
			}
			D[i - 1] = true;
		}
		bef = tmp;
		A[i] = std::min(R[i], tmp);
	}
	D[N] = true;
	for (int i = 1; i <= N; i++) {
		if (!D[i]) {
			ans *= A[i];
			ans %= mod;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1920
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, K, Q = map(int, input().split())
A = [0 for i in range(N)]
for i in range(Q):
    A[int(input())-1] += 1

for i in range(N):
    if A[i] - Q + K > 0:
        print("Yes")
    else:
        print("No")

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

int main()
{
    int N;
    cin >> N;
    char arr[N];
    cin >> arr;
    int cnt = 0;
    for (int i = 0; i < N; ++i)
    {
        if (arr[i] == 'A' && arr[i + 1] == 'B' && arr[i + 2] == 'C')
        {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3108
x,k,d=map(int,input().split())

if x>=0:
  if x>=k*d:
    x-=k*d
    print(x)
  else:
    n=x//d
    k-=n
    if k%2==0:
      print(x-n*d)
    else:
      print(abs(x-n*d-d))
else:
  if abs(x)>=k*d:
    x+=k*d
    print(abs(x))
  else:
    n=abs(x)//d
    k-=n
    if k%2==0:
      print(abs(x+n*d))
    else:
      print(abs(x+n*d+d))

Measured memory_bytes: 61860
N = (input())
acgt = ['A','C','G','T']
ans = 0
for i in range(len(N)+1):
    for j in range(i+1,len(N)+1):
        if len(N[i:j]) == sum([1 for k in N[i:j] if k in acgt]):
            ans = max(ans , len(N[i:j]))
print(ans)

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

double cal(int x1,int x2,int y1,int y2){
    double r;
    r =  sqrt((double)pow(x1-x2,2)+(double)pow(y1-y2,2));
    return r;
}


int main(){

    int N;
    cin >> N;

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

    vector<double> d(N);

    int S=1;
    for (size_t i = N;i>0;i--)
    {
        S*=i;
    }

    double SUM=0;

    vector<int>  v(N);
    for (size_t i = 0; i < N; i++)
    {
        v[i]=i;
    }
     
    do{
        double temp;
        for (size_t i = 0; i < N-1; i++)
        {
            temp =cal(x[v[i]],x[v[i+1]],y[v[i]],y[v[i+1]]);
            SUM+=temp;
        }
    }while(next_permutation(v.begin(),v.end()));


    
    cout << std::fixed << std::setprecision(15)<< SUM/S << endl;
     

    
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define watch(x) cout << "debug : " << #x << " -> " << x << endl; 

//globals
ll const mod = 1e9+7;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE

int main() {
  IOS;

  int n;cin >> n;
  std::vector<int> v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
  }
  bool flag = false;
  for (int i = n-2; i >= 0; i--)
  {
    if(v[i] > v[i+1] + 1)
      flag = true;
    else{
      if(v[i] == v[i+1] + 1)
        v[i] = v[i+1];
      else
        continue;
    }
  }
  if(flag){
    cout << "No" << endl;
  }
  else
    cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 640
N, X = map(int, input().split())

count_p = [1] * (N+1) # パティの数
for i in range(1, N+1):
    count_p[i] += count_p[i-1] * 2

length = [1] * (N+1) # バーガーの長さ
for i in range(1, N+1) :
    length[i] += (length[i-1] + 1) * 2

def F(n, x): # レベルnバーガーの下x層のあるパティの数
    if n == 0:
        return 0 if x <= 0 else 1
    if x == length[n] // 2 + 1:
        return count_p[n-1] + 1
    elif x > length[n] // 2 + 1:
        return count_p[n-1] + 1 + F(n-1, x-(length[n]//2+1))
    else:
        return F(n-1, max(0, x-1))
print(F(N, X))


Measured memory_bytes: 3064
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto S = RD!string;
	string ans;
	foreach (i; 0..S.length)
	{
		auto num = S[i] - 'A';
		ans ~= cast(char)('A'+(num+N)%26);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 380
import sys
import math

N, M = sys.stdin.readline().strip().split()
N = int(N)
M = int(M)
P = M//N # これ以下で最大の、Mの約数を探す
Q = math.floor(math.sqrt(M)) #sqrt。解の探索範囲を絞るのに使う

# Mでないなら高々sqrt(M)


if P <= Q:
  # P=M/Nから1つずつ下がって探索
  for x in range(P, 0, -1):
    # print(x)
    if M % x == 0:
      print(x)
      break
elif P == M: # N=1
  print(M)
else:
  #1からQ=sqrt(M)まで増やす
  res = 1
  flag = 0
  for x in range(1, N, 1):
    # このときM/xはPより大きいことに注意
    if M % x == 0:
      res = x
  for x in range(N, Q+1, 1):
    if M % x == 0:
      print(M//x)
      flag = 1
      break
  if flag == 0:
    print(res)

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

int main() {
  int n;
  cin >> n;
  vector<int> c(n), s(n), f(n);
  for(int i = 0; i < n-1; i++) cin >> c.at(i) >> s.at(i) >> f.at(i);
  
  for(int i = 0; i < n; i++){
    int ans = s.at(i) + c.at(i);
    for(int j = i+1; j < n-1; j++){
      if(ans < s.at(j)) ans = s.at(j) + c.at(j);
      else ans = (ans - s.at(j) + f.at(j) - 1) / f.at(j) * f.at(j) + s.at(j) + c.at(j);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3540
n,d = map(int, input().split())
a = []
ans = 0

for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(n):
    for j in range(i+1,n):
        sum = 0
        for v1, v2 in zip(a[i], a[j]):
            sum += (v1-v2)**2
        sum**=0.5
        #print(sum)
        if sum == int(sum):
            ans += 1

print(ans)

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

using namespace std;
int main(void){
    // Your code here!
    int x;
    int sum = 0;
    
    std::vector<int> a(3);
    
    std::cin >> a[0] >> a[1] >> a[2];
    
    std::sort(a.begin(), a.end());
    
    x = max(a[2] - a[1], a[1] - a[0]);
    
    sum = a[2] - a[1] + a[1] - a[0];
    
    
    std::cout << sum << std::endl;
}


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

int vs(int a1, int a2) {
  int maxa = max(a1, a2);
  int mina = min(a1, a2);
  while (mina > 0) {
    maxa = maxa % mina;
    swap(maxa, mina);
  }
  return maxa;
}

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

  int A;
  cin >> A;
  int ans = A;
  for (int i = 1; i < N; i++) {
    cin >> A;
    ans = vs(ans, A);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//fifer a tak luboin
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define endl "\n"

// using namespace __gnu_pbds;
using namespace std;
// template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

const double eps = 1e-10;                                     
const double pi = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    // freopen("input.in.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    vector <ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    ll sum = a[0];
    for (int i = 1; i < n; i++) sum ^= a[i];

    for (int i = 0; i < n; i++) {
        cout << (sum ^ a[i]) << " ";
    }
    return 0;  
}


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

#define ff first
#define ss second
#define endl '\n'

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

	ll a, b;
	cin >> a>> b;
	cout << (a * b) / __gcd(a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
X = [int(e) for e in input().split()]
ans = 0
for i in range(0,X[0]+1):
    for k in range(0,X[0]+1):
        if(X[1] - (i+k))<=X[0] and X[1] - i - k >= 0:
            ans += 1
print(ans)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    vector<int> a(5);
    rep(i, 5)
    {
        cin >> a[i];
    }
    sort(ALL(a), greater<int>());
    rep(i, 5)
    {
        cout << a[i];
        if (i != 4)
        {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <vector>
#include <iostream>
using namespace std;
#define ll long long
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; i < n; i++)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%I64d", &x)
#define ss(s) scanf("%s", s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1000000007;
template <typename T>
T abs(const T& x) { return x < 0 ? -x : x; }
#include <cmath>
#include <algorithm>

void min_self(int& a, int b) {
	a = min(a, b);
}

const int INF = 1E9;

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> grid(H);
	for (int row = 0; row < H; row++) {
		cin >> grid[row];
	}
	vvi dp(H, vector<int>(W, INF));

	dp[0][0] = (grid[0][0] == '#');
	for (int r = 0; r < H; ++r) {
		for (int c = 0; c < W; ++c) {
			if (r == 0 && c == 0) continue;
			if (r != 0) {
				min_self(dp[r][c], dp[r - 1][c] + (grid[r][c] == '#' && grid[r - 1][c] == '.'));
			}
			if (c != 0) {
				min_self(dp[r][c], dp[r][c - 1] + (grid[r][c] == '#' && grid[r][c - 1] == '.'));

			}
		}
	}
	int answer = dp[H - 1][W - 1];
	cout << answer << endl;
}


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

ans = 0
for i in range(N - 1, -1, -1) :
    left = min(A[i + 1], B[i])
    ans += left
    B[i] -= left
    center = min(A[i], B[i])
    ans += center
    A[i] -= center

print(ans)

Measured memory_bytes: 18624
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{
    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;
}
int main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    ll r,s,p;
    cin>>r>>s>>p;
    ll ans=0;
    string t;
    cin>>t;
    vector<ll>visited(n,-1);
    for(ll i=0; i<k; i++)
    {
        if(visited[i]==-1)
        {
            visited[i]=1;
            if(t[i]=='r')
            {
                ans+=p;
            }
            else if(t[i]=='p')
            {
                ans+=s;
            }
            else if(t[i]=='s')
            {
                ans+=r;
            }
            for(ll j=i+k; j<n; j+=k)
            {
                if(visited[j]==-1)
                {
                    if(t[j]==t[j-k])
                    {
                        if(visited[j-k]==1)
                        {
                            visited[j]=2;
                            continue;
                        }
                        else
                        {
                            if(t[j]=='r')
                            {
                                ans+=p;
                            }
                            else if(t[j]=='p')
                            {
                                ans+=s;
                            }
                            else if(t[j]=='s')
                            {
                                ans+=r;
                            }
                            visited[j]=1;
                        }
                    }else
                    {
                        visited[j]=1;
                        if(t[j]=='r')
                            {
                                ans+=p;
                            }
                            else if(t[j]=='p')
                            {
                                ans+=s;
                            }
                            else if(t[j]=='s')
                            {
                                ans+=r;
                            }

                    }

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


Measured memory_bytes: 1232
S = input()
if len(S) <= 4 or len(S) >= 10:
  print('NO')
elif len(S) == 5:
  if S == 'KIHBR':
    print('YES')
  else:
    print('NO')
elif len(S) == 6:
  L = ['AKIHBR','KIHABR','KIHBAR','KIHBRA']
  if S in L:
    print('YES')
  else:
    print('NO')
elif len(S) == 7:
  M = ['AKIHABR','AKIHBAR','AKIHBRA','KIHABAR','KIHABRA','KIHBARA']
  if S in M:
    print('YES')
  else:
    print('NO')
elif len(S) == 8:
  O = ['AKIHABAR','AKIHABRA','AKIHBARA','KIHABARA']
  if S in O:
    print('YES')
  else:
    print('NO')
else:
  if S == 'AKIHABARA':
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N;
  int tmp; 
  int *a; 
  
  cin >> N; 

  a = new int[N+1];
  
  for(int i=1;i<N+1;i++){
    cin >> tmp;
    a[tmp] = i; 
  }
  
  for(int i=1; i<N+1; i++){    
    cout << a[i];
    cout << " "; 
  }
  
  return 0;
}

Measured memory_bytes: 1152