akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<stdio.h>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;


struct l{
	int s,t,n,m;
	
	l(){}
	
	l(int _s,int _t,int _n,int _m){
		s=_s;t=_t;n=_n;m=_m;
	}
};



int compute_time(int ts, int te,vector<l> login) {
	int count = 0;
	int time = 0;
	int table[1261];
	fill_n((int *)table,sizeof(table)/sizeof(int),0);
	for (int i=0; i<login.size(); i++) {
		table[login[i].t] += 2*login[i].s-1;
	}
	for (int i=0; i<=1260; i++) {
		count += table[i];
		if (count > 0 && ts <= i && i < te) {
			time++;
		}
	}
	return time;
}

int main(){
	while(1){
		vector<vector<l>> login(10001,vector<l>());
		int n,m,r,q;
		cin >> n >> m;
		if(n==0 && m==0) break;
		cin >> r;
		rep(i,r){
			int t,n,m,s;
			cin >> t >> n >> m >> s;
			login[m].push_back(l(s,t,n,m));
		}
		
		cin >> q;
		rep(i,q){
			int ts,te,m;
			cin >> ts >> te >> m;
			cout << compute_time(ts, te, login[m]) << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()

void solve (int u) {

    int n;
    cin >> n;

    vector<int> d(3, 0);
    
    for (int k = 0; k < n; ++k) {
    
        vector <int> c (3);
        for (int i = 0; i < 3; ++i) {
            cin >> c[i];
        }

        vector <int> nd (3, 0);

       for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i != j) nd[j] = max(nd[j], d[i] + c[j]);
            }
        }
        d = nd;
    }

    cout << max(max(d[0], d[1]), d[2]) << "\n";

//    cout << "Case #" << k << ": " << count << "\n";

}

int main () {

    ios::sync_with_stdio(0);
    cin.tie(0);

    //int t;
    //cin >> t;
    //int k = 1;
    //while (t--) {
    //    solve(k);
    //    k++;
    //}

    solve(0);
}


Measured memory_bytes: 256
#include <stdio.h>
 
double j(double,double,double,double,double,double,double,double);
 
main(){
  double x1, x2, x3, y1, y2, y3, xp, yp;
  double xc, yc;
  int ans;
 
  while(1){
    ans=0;
    if(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)==EOF) break;
    xc=(x1+x2+x3)/3;
    yc=(y1+y2+y3)/3;
    if(j(x1,y1,x2,y2,xp,yp,xc,yc)<0.0){
      ans=1;
    }
    if(j(x1,y1,x3,y3,xp,yp,xc,yc)<0.0){
      ans=1;
    }
    if(j(x2,y2,x3,y3,xp,yp,xc,yc)<0.0){
      ans=1;
    }
    if(ans==1) printf("NO\n");
    else if(ans==0) printf("YES\n");
  }
  return 0;
}
 
double j(double p1x,double p1y,double p2x,double p2y,double p3x,double p3y,double p4x,double p4y){
  double a;
  a=((p1x-p2x)*(p3y-p1y)+(p1y-p2y)*(p1x-p3x))*
    ((p1x-p2x)*(p4y-p1y)+(p1y-p2y)*(p1x-p4x));
 
  return a;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long unsigned int
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

int main()
{
    boost;
    ll tt = 1, n, m, i, j, x, y;
    bool poss = true;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n >> m;

        if(m >= n){
            cout << "unsafe" << nl;
        }
        else cout << "safe" << nl;
    }   
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
void chmax(ll a, ll b) {if(a<b) a=b;}
void chmin(ll a, ll b) {if(a>b) a=b;}
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

ll moP(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) moC(res, *, x);
        moC(x, *, x);
        n>>=1;
    }
    return res;
}

int main(void) {
    ll N;
    cin >> N;
    P p[MAX*2];
    ll i;
    
    ll fa[MAX];
    fa[0]=1;
    for(i=1; i<MAX; i++)
        fa[i]=i*fa[i-1]%MOD;
    
    for(i=0; i<N; i++) {
        cin >> p[i].ft;
        p[i].sc=0;
    }
    for(i=N; i<N*2; i++) {
        cin >> p[i].ft;
        p[i].sc=1;
    }
    sort(p, p+N*2);
    
    
    ll ans=1;
    ll s=0, t=0;
    for(i=0; i<N*2; i++) {
        if(p[i].sc==0) {
            if(t==0) s++;
            else {
                moC(ans, *, t);
                t--;
            }
        }else {
            if(s==0) t++;
            else {
                moC(ans, *, s);
                s--;
            }
        }
    }
    
    pt(ans);
    
}


Measured memory_bytes: 3328
import sys

S = str(input())
T = str(input())
n = 0

if S == T:
    print('Yes')
    sys.exit()

while n <= len(S) - 1:
    S = S[-1] + S[:-1]
    n += 1
    if S == T:
        print('Yes')
        sys.exit()
        
print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX_N=200010;

int N;
vector<int> a(MAX_N),b(MAX_N);

bool lower(int n){
    rep(i,2*N-1){
        if (a[i]<=n) b[i]=1;
        else b[i]=0;
    }
    ll p=INF,q=INF;
    rep(i,2*N-2) if (b[i]==b[i+1]){
        if (b[i]==1){
            if (i<N-1) chmin(p,N-i-2);
            else chmin(p,i-N+1);
        }
        else {
            if (i<N-1) chmin(q,N-i-2);
            else chmin(q,i-N+1);
        }
    }
    if (p==INF&&q==INF) return b[0]==1;
    if (min(p,q)==p) return true;
    else return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,2*N-1) cin >> a[i];
    int lb=0,ub=2*N;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if (lower(mid)) ub=mid;
        else lb=mid;
    }
    cout << ub << endl;
}

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

int n,w;
pii arr[101];
ll dp[101][100005];

ll knap(int i,int n,int sm){
	if(i==n) return 0;
	if(dp[i][sm]!=-1) return dp[i][sm];
	ll ans = 0;
	if(sm+arr[i].first<=w){
		ans = max(ans,arr[i].second+knap(i+1,n,sm+arr[i].first));
		ans = max(ans,knap(i+1,n,sm));
	}
	else {
		ans = max(ans,knap(i+1,n,sm));
	}
	return dp[i][sm]=ans;
}

int main(int argc, char const *argv[])
{
	
	cin>>n>>w;
	for (int i = 0; i <n ; ++i)
	{
		cin>>arr[i].first>>arr[i].second;
	}
	
	memset(dp,-1,sizeof(dp));
	cout<<knap(0,n,0);
	return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=5000002;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	int ans=0,cur=0,curvl=a[0];
	for(int i=1;i<n;i++){
		if(a[i]>curvl){
			ans=max(ans,cur);
			cur=0,curvl=a[i];
		}
		else{
			curvl=a[i];
			cur++;
		}
	}
	ans=max(ans,cur);
	cout<<ans;
			
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int a;
  cin >> n;
  int minus = 0;
  int mn = INTINF;
  ll sm = 0;
  REP(i,n){
    cin >> a;
    if (a<0){
      minus++;
    }
    sm += abs(a);
    mn = min(mn,abs(a));
  }
  
  if (minus%2==0){
    cout << sm << endl;
  }else{
    cout << sm - 2 * mn << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long N,D,x,y;
  int count=0;
  cin >> N >> D;
  for(int i=0; i<N; i++){
    cin >> x >> y;
    if(x*x+y*y<=D*D)count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n){
        cin>>v[i];
    }
    v.push_back(0);
    ll now = 0;
    ll ans = 0;
    rep(i, n+1){
        if(v[i] == 0) {
            ans += now/2;
            now = 0;
        }
        else now += v[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            // 写経
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], Q = l[1];
            var neighbors = Enumerable.Repeat(0, N).Select(_ => new List<int>()).ToArray();

            for (var i = 0; i < N - 1; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                neighbors[tmp[0] - 1].Add(tmp[1] - 1);
                neighbors[tmp[1] - 1].Add(tmp[0] - 1);
            }

            var val = new long[N];
            for (var i = 0; i < Q; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                val[tmp[0] - 1] += tmp[1];
            }

            var arrived = new bool[N];
            var stack = new Stack<int>();
            stack.Push(0);
            arrived[0] = true;

            while (stack.Count > 0)
            {
                var elem = stack.Pop();
                foreach (var neighbor in neighbors[elem])
                {
                    if (arrived[neighbor]) continue;
                    arrived[neighbor] = true;
                    val[neighbor] += val[elem];
                    stack.Push(neighbor);
                }
            }
            Console.WriteLine(string.Join(" ", val));
        }
    }
}


Measured memory_bytes: 54188
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

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

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    
    int cnt = 0;
    int min = INF9;
    rep(i, n){
        if(chmin(min, p[i]))
            ++cnt;
        if(min <= 1) break;
    }

    cout << cnt << endl;

return 0;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
static const int INFTY = (1 << 21);

int func(int a){
    int sum = 0;
    while(a > 0){
        sum += a % 10;
        a /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    int temp, ans = INFTY;
    for(int i = 1; i < N; i++){
        temp = func(i) + func(N - i);
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> A(H);
    int sy,sx;
    rep(i,0,H){
        cin >> A[i];
        rep(j,0,W) if(A[i][j]=='S'){
            sy=i;
            sx=j;
            break;
        }
    }

    vector<vector<int>> dist(H,vector<int>(W,inf));
    queue<pair<int,int>> que;
    vector<int> dy({0,-1,0,1}),dx({1,0,-1,0});
    que.push(make_pair(sy,sx));
    dist[sy][sx]=0;
    while(!que.empty()){
        auto p=que.front();
        que.pop();
        int y=p.first,x=p.second;
        rep(i,0,4){
            int y_=y+dy[i],x_=x+dx[i];
            if(y_<0 or H<=y_ or x_<0 or W<=x_ or A[y_][x_]=='#') continue;
            if(dist[y_][x_]!=inf) continue;
            que.push(make_pair(y_,x_));
            dist[y_][x_]=dist[y][x]+1;
        }
    }

    vector<int> mi1(H,inf),ma1(H,-inf),mi2(W,inf),ma2(W,-inf);
    rep(i,0,H) rep(j,0,W) if(dist[i][j]<=K){
        mi1[i]=min(mi1[i],j);
        ma1[i]=max(ma1[i],j);
    }
    rep(i,0,W) rep(j,0,H) if(dist[j][i]<=K){
        mi2[i]=min(mi2[i],j);
        ma2[i]=max(ma2[i],j);
    }

    int ans=inf;
    rep(i,0,H){
        int y=i,x=0;
        rep(j,0,H){
            if(mi1[j]==inf) continue;
            ans=min(ans,1+(abs(y-j)+abs(x-mi1[j])+K-1)/K);
        }
    }
    rep(i,0,H){
        int y=i,x=W-1;
        rep(j,0,H){
            if(ma1[j]==-inf) continue;
            ans=min(ans,1+(abs(y-j)+abs(x-ma1[j])+K-1)/K);
        }
    }
    rep(i,0,W){
        int y=0,x=i;
        rep(j,0,W){
            if(mi2[j]==inf) continue;
            ans=min(ans,1+(abs(y-mi2[j])+abs(x-j)+K-1)/K);
        }
    }
    rep(i,0,W){
        int y=H-1,x=i;
        rep(j,0,W){
            if(ma2[j]==-inf) continue;
            ans=min(ans,1+(abs(y-ma2[j])+abs(x-j)+K-1)/K);
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>


using namespace std;


int main() {
    int n;
    cin >> n;
    double t;
    bool flag = false;
    for(int i = 1; i <= 9 ; i++){
        t = n / (1.0*i);
        //cout << i << ": " << t << "\n";
        if ((int)t == t*1.0 && 1<=t && t <=9){
            flag = true;
            break;
        }
    }
    if (flag)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
n = int(input())
if n>=400 and n<=599:
  print(8)
elif n>=600 and n<=799:
  print(7)
elif n>=800 and n<=999:
  print(6)
elif n>=1000 and n<=1199:
  print(5)
elif n>=1200 and n<=1399:
  print(4)
elif n>=1400 and n<=1599:
  print(3)
elif n>=1600 and n<=1799:
  print(2)
elif n>=1800 and n<=1999:
  print(1)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;

struct node{
	int x,y;
	node(){}
	node(int x,int y):x(x),y(y){}
} s[N];

bool comp(node a,node b){
	if(a.y == b.y) return a.x > b.x;
	return a.y < b.y;
}

int main()
{
	int n,idx,l;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i){
		scanf("%d%d",&idx,&l);
		s[i] = node(idx-l,idx+l);
	}
	sort(s+1,s+n+1,comp);
	
	int last = -0x3f3f3f3f,ans = 0;
	for(int i = 1;i <= n;++i){
		if(s[i].x < last) continue;
		last = s[i].y;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)	
	{
		c-=b;
		if((c<=0)||(a<=0))
		break;
		a-=d;
		if((c<=0)||(a<=0))
		break;
	}
	if(c<=0)
	cout<<"Yes";
	else
	cout<<"No";	
  return 0;
}


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

int main(){
	long long K;
	cin >> K;
	vector<long long> a(50,K/50);
	for(int i=0;i<50;i++)a[i]+=i;
	K%=50;
	for(int i=0;i<K;i++){
		for(int j=0;j<50;j++){
			if(i==j)a[j]+=50;
			else a[j]--;
		}
	}
	cout << "50" << endl;
	for(int i=0;i<49;i++)cout << a[i] << " ";
	cout << a[49] << endl;
	return 0;
}

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

int main(){
    string x;
    char c;
    deque<char> S;
    cin >> x;
    for (char d : x) S.push_back(d);
    
    int Q;
    cin >> Q;
    int a=0;
    for(int i=0;i<Q;i++){
        int t;
        cin >> t;
        if (t==1){
            a+=1;
        }
        else if(t==2){
            int f;

            cin >> f >> c;
            
            // ushiro
            if(a%2 == 0 && f ==2){ 
                S.push_back(c);
                //s = s + c;
            }
            else if (a%2 == 0 && f ==1){
                S.push_front(c);
                //s = c + s;
            }
            else if (a%2 == 1 && f ==1){
                //s =  s + c;
                S.push_back(c);
            }
            else if (a%2 == 1 && f ==2){
                //s = c + s;
                S.push_front(c);
            }

        }

    }

    if (a%2 == 1){
        reverse(S.begin(), S.end());
    }
    string ans;
    for (char c : S) ans +=c;
    cout << ans;
    
}


Measured memory_bytes: 1412
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderabc153
{
    class Program
    {
        static void Main(string[] args)
        {

            var line1 = Console.ReadLine().Split(' ');
            var monsterCount = int.Parse(line1[0]);
            var attCount = int.Parse(line1[1]);

            var line2 = Console.ReadLine().Split(' ');
            var tmp = new List<long>();
            foreach (var lines in line2) { tmp.Add(int.Parse(lines)); }

            Console.WriteLine(tmp.OrderByDescending(x => x).Skip(attCount).Take(monsterCount).Sum());
        }

    }
}



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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int aa=0,bb=0,cc=0;
    for(int i=0;i<n;i++){
        int p;
        cin >> p;
        if(p<=a) aa++;
        else if(p>=b+1) bb++;
        else cc++;
    }
    cout << min({aa,bb,cc}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int n,t,a; cin>>n>>t>>a;
	double m=INF;
	int index;
	FOR(i,0,n){
		int h; cin>>h;
		if(m>abs((double)t-h*0.006-a)){
			m=abs((double)t-h*0.006-a);
			index=i+1;
		}
	}
	co(index);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n, k;
  cin >> k >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    a[i] = temp;
  }

  vector<int> d(n);
  for(int i = 0; i <= n-2; i++){
    d[i] = a[i+1] - a[i];
  }
  d[n-1] = k +  a[0] - a[n-1];
 
  sort(d.begin(), d.end(), greater<int>());

  cout << k - d[0] << endl;

  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define clr(A, x) memset(A, x, sizeof(A))
#define cpy(A, B) memcpy(A, B, sizeof(B))
#define g(s) getline(cin, s) ///ai grija la fin/cin ///
#define FASTIO ios_base::sync_with_stdio(0)
const long long INFLL = 2 * 1e18 + 100;
const int INFINT = 2 * 1e9 + 100;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//ifstream fin("a2.in");
//ofstream fout("a2.out");
void die()
{
    cout << "-1";
    exit(0);
}
const int NMAX = 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

ll fact[NMAX];


int main()
{
    FASTIO;
    int n, m;
    cin >> n >> m;
    fact[0] = 1;
    for1(i, NMAX - 1) fact[i] = i * fact[i - 1] % MOD;
    if(n == m)
    {
        cout << 2 * fact[n] * fact[n] % MOD;
    }
    else if(abs(n - m) == 1) cout << fact[n] * fact[m] % MOD;
    else cout << 0;


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n = 0;
    cin >> n;
    
    int *a = new int[n + 1];
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    
    int *b = new int[n + 1];
    for(int i=1;i<=n;i++)
    {
        cin >> b[i];
    }
    
    int *c = new int[n];
    for(int i=1;i<=n-1;i++)
    {
        cin >> c[i];
    }
    
    
    int sum = 0;
    int previous = n;
    for(int i = 1;i<=n;i++)
    {
        int target = a[i];
        
        sum += b[target];
        
        if(target == previous + 1) sum += c[previous];
        
        previous = target;
    }
    
    cout << sum << endl;
    
    return 0;
}


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

using namespace std;


struct Zone{
	int originalOrder;
	int area;
	int year;
	int id;
};

vector<Zone> vecArr;

int cmp0(Zone z1,Zone z2)
{
	if(z1.area < z2.area)
	{
		return true;
	}
	else if((z1.area == z2.area) && (z1.year < z2.year))
	{
		return true;
	}
	else
	{
		return false;
	}
}

int cmp1(Zone z1,Zone z2)
{
	if(z1.originalOrder < z2.originalOrder)
		return true;
	else
		return false;
}

string FillString(string str)
{
	int nLen = str.length();

	if(1 == nLen)
	{
		return "00000" + str;
	}
	else if(2 == nLen)
	{
		return "0000" + str;
	}
	else if(3 == nLen)
	{
		return "000" + str;
	}
	else if(4 == nLen)
	{
		return "00" + str;
	}
	else if(5 == nLen)
	{
		return "0" + str;
	}
	else
	{
		return str;
	}
}

void Print(int n1,int n2)
{
	string str1 = FillString(to_string(n1));
	string str2 = FillString(to_string(n2));
	cout << str1 + str2 << endl;
}

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

	vecArr.clear();

	Zone z;
	for(int i = 0; i < M; ++i)
	{
		cin >> z.area >> z.year;
		z.originalOrder = i + 1;
		vecArr.push_back(z);
	}

	sort(vecArr.begin(),vecArr.end(),cmp0);

	int nArea = -1;
	int nCount = 0;
	for(int i = 0; i < M; ++i)
	{
		nCount++;
		if(-1 == nArea)
		{
			nArea = vecArr[i].area;
			vecArr[i].id = nCount;
		}
		else if(vecArr[i].area == nArea)
		{
			vecArr[i].id = nCount;
		}
		else
		{
			nArea = vecArr[i].area;
			vecArr[i].id = 1;
			nCount = 1;
		}
	}

	sort(vecArr.begin(),vecArr.end(),cmp1);

	for(int i = 0; i < M; ++i)
	{
		Print(vecArr[i].area,vecArr[i].id);
	}

	return 0;
}


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


int main(){
	int W,H,N;
	bool width[101]={},height[101]={};
	cin >> W >> H >> N;
	for(int i=1;i<=W;i++){
		width[i] = true;
	}
	for(int i=1;i<=H;i++){
		height[i] = true;
	}
	
	int x[101],y[101],a[101];
	
	for(int i=1;i<=N;i++){
		cin >> x[i] >> y[i] >> a[i];
	}
	
	
	
	for(int i=1;i<=N;i++){
		switch(a[i]){
			case 2:
				for(int j=x[i]+1;j<=100;j++){
					width[j] = false;
				}
				break;
			case 1:
				for(int j=1;j<=x[i];j++){
					width[j] = false;
				}
				break;
			case 4:
				for(int j=y[i]+1;j<=100;j++){
					height[j] = false;
				}
				break;
			case 3:
				for(int j=1;j<=y[i];j++){
					height[j] = false;
				}
				break;
		}
	}
	
	int X=0,Y=0;
	for(int i=1;i<=100;i++){
		if(width[i]){
			X++;
		}
		if(height[i]){
			Y++;
		}
	}
	
	cout << X * Y << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * 0288.cc: Knocker of the Gigas Cedar
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_R = 100;
const int MAX_D = 100;

const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N], es[MAX_N], rs[MAX_N];
int dp[2][MAX_R + 1][MAX_D + 1];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int d, n;
    cin >> d >> n;
    if (d == 0) break;

    int maxr = 0;
    for (int i = 0; i < n; i++) {
      cin >> as[i] >> es[i] >> rs[i];
      if (maxr < rs[i]) maxr = rs[i];
    }

    for (int i = 0; i <= maxr; i++)
      for (int j = 0; j <= d; j++) dp[0][i][j] = dp[1][i][j] = INF;

    int cur = 0, nxt = 1;
    dp[cur][0][0] = 0;

    int mind = INF;
    bool cont = true;

    while (mind >= INF && cont) {
      cont = false;

      memcpy(dp[nxt], dp[cur], sizeof(dp[cur]));
      for (int i = 0; i <= maxr; i++)
	for (int j = 0; j <= d; j++)
	  if (dp[cur][i][j] < INF) {
	    int ndp = dp[cur][i][j] + 1;
	    for (int k = 0; k < n; k++)
	      if (i >= rs[k]) {
		int i0 = i + es[k];
		if (i0 > maxr) i0 = maxr;
		int j0 = j + as[k];
		if (j0 > d) j0 = d;
		if (dp[nxt][i0][j0] > ndp) {
		  dp[nxt][i0][j0] = ndp;
		  if (j0 == d && mind > ndp) mind = ndp;
		  cont = true;
		}
	      }
	  }

      cur ^= 1, nxt ^= 1;
    }

    if (mind >= INF) puts("NA");
    else printf("%d\n", mind);
  }
  return 0;
}

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

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


int main() {

    int n;
    scanf("%d", &n);

    int nums[n];
    REP(i, n) {
        scanf("%d", &nums[i]);
    }
    REP(i, n) {
        printf("%d", nums[n - (i+1)]);
        if(i != n-1) {
            printf(" ");
        }
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 3196
ps = []
time = 0
cnt, q = gets.split.map(&:to_i)

cnt.times do
  n, t = gets.split
  ps << {name: n, time: t.to_i}
end

while !ps.empty?
  p = ps.shift
  if p[:time] <= q
    time += p[:time]
    puts "#{p[:name]} #{time}"
  else
    time += q
    p[:time] -= q
    ps << p
  end
end

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;


    int n;
    cin>>n;
    map<int,int> mp;
    int sum=0;
    rep(i,n){
        int in;
        cin>>in;
        mp[in]++;
        sum+=in;
    }
    int q;
    cin>>q;
    rep(i,q){
        int b,c;
        cin>>b>>c;
        sum-=b*mp[b];
        sum+=c*mp[b];
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 9560
#include <cstdio>
#include <cstdlib>

const int MAX = 44;
int fibo_res[MAX];

void init()
{
    for (int i = 0; i < MAX; i++) {
        fibo_res[i] = -1;
    }
}

int fibonacci(int n)
{
    if (n == 0 || n == 1) {
        return 1;
    }
    if (fibo_res[n-1] != -1 && fibo_res[n-2] != -1) {
        return fibo_res[n-1] + fibo_res[n-2];
    } else {
        int res = fibonacci(n-1) + fibonacci(n-2);
        fibo_res[n] = res;
        return res;
    }
}

int main(int argc, char *argv[])
{
    init();
    int n;
    scanf("%d", &n);
    fprintf(stdout, "%d\n", fibonacci(n));
}


Measured memory_bytes: 2756
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: u64 = read_as_vec()[0];

    let mut divisors = vec![0;(n+1) as usize];

    for i in 1..n+1{
        let mut x = i;
        for i in 2..(x as f64).sqrt().ceil() as u64 + 1{
            while x%i == 0{
                x /= i;
                divisors[i as usize] += 1;
            }
        }
        if x > 1{
            divisors[x as usize] += 1;
        }
    }
    let mut ans: u64 = 1;
    for div in divisors{
        ans = (ans * (div+1))%1_000_000_007;
    }

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


Measured memory_bytes: 4352
def kindfTri(sort_node, node, long_node)
  if sort_node + node <= long_node then
    return -1
  elsif sort_node * sort_node + node * node == long_node * long_node then
    return "tri_right"
  elsif sort_node * sort_node + node * node > long_node * long_node then
    return "tri_acute"
  else
    return "tri_obtuse"
  end
end

tri_right, tri_acute, tri_obtuse = 0,0,0

while (node = gets) do
  node_arr = node.split.map(&:to_i).sort
  tri = kindfTri(node_arr[0], node_arr[1], node_arr[2])

  if tri == -1 then
  	break
  end
  case tri
  when "tri_acute" then
  	tri_acute += 1
  when "tri_right" then
  	tri_right += 1
  when "tri_obtuse" then
  	tri_obtuse += 1
  else
  end
end
puts "#{tri_right + tri_obtuse + tri_acute} #{tri_right} #{tri_acute} #{tri_obtuse}"

Measured memory_bytes: 8668
import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def a_int(): return int(read())


from itertools import product


# 画像でおいた自分の解説見て
N = a_int()
B = []
for _ in ra(N):
    A = read()[:-1]  # floatで扱うと誤差で死ぬ
    if '.' not in A:
        A += '.'
    for _ in range(9 - A[::-1].index('.')):
        A += '0'
    B.append(int(A[:-10] + A[-9:]))

N = []
M = []
for b in B:
    n = 0
    while ~b & 1:  # 偶数である限り
        b >>= 1
        n += 1
    N.append(n)

    m = 0
    while b % 5 == 0:  # 5で割れる限り
        b //= 5
        m += 1
    M.append(m)

cnt = [[0] * 19 for _ in ra(19)]
ans = 0
for n, m in zip(N, M):
    x = max(18 - n, 0)
    y = max(18 - m, 0)
    for i, j in product(range(x, 19), range(y, 19)):
        ans += cnt[i][j]
    # このデータをcntに追加
    cnt[min(n, 18)][min(m, 18)] += 1

print(ans)


Measured memory_bytes: 105048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;
 
  //比較関数（を返す関数）
template<class T>
auto comp_idx(T* ptr){
  return [ptr](int l_idx, int r_idx){
    return ptr[l_idx] < ptr[r_idx];
  };
}

int main(){
  int N, T = 0;
  cin >> N;
  int A[N], B[N], str[N];
  REP(i,N) {
    cin >> A[i] >> B[i];
    str[i] = B[i];
  }

  //インデックスの配列を準備
  int idx[N];
  REP(i,N){
    idx[i] = i;
  }

  //インデックスソート
  sort(idx, idx+N, comp_idx(str));
  sort(B, B+N);
  
  for (int i = 0; i < N; i++) {
    T += A[idx[i]];
    if (T > B[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
  

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

int main() {

  int n;
  scanf("%d", &n);

  std::vector<std::pair<int, int> > coord(n);
  for (auto &elem : coord)
    scanf("%d%d", &elem.first, &elem.second);

  std::vector<int> order(n);
  std::iota(order.begin(), order.end(), 0);

  int fat = 0;
  long double sq = 0;
  do {
    for (int i = 1; i < n; i++) {
      int dx = coord[order[i]].first - coord[order[i-1]].first;
      int dy = coord[order[i]].second - coord[order[i-1]].second;
      sq += hypotl(dx, dy);
    }
    fat++;
  } while (std::next_permutation(order.begin(), order.end()));

  printf("%.20Lf\n", sq / (long double) fat);
}


Measured memory_bytes: 384
unittest
{
	assert( [ "6 2 1001" ].solve == 1369 );
	assert( [ "1000 2 16" ].solve == 6 );
	assert( [ "10000000000 10 99959" ].solve == 492443256176507 );
	
	assert( [ "100 1 1" ].solve == 0 );		// 追加ケース
	assert( [ "100 1 2" ].solve == 100 );		// 追加ケース
	assert( [ "3 2 100" ].solve == 22 );		// 追加ケース
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto x = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s %s"( n, x, m );
	
	if( x == 1 && m == 1 ) return 0L;
	
	// 途中で余りがループするはずなので、ループ長と合計を計算
	auto ts = new long[ 1 + m + 1 ];
	long[ long ] bs;
	auto l = 0L;
	auto r = 0L;
	for( auto i = 0L; i <= m; i++ )
	{
		ts[ i + 1 ] = ts[ i ] + x;
		if( x in bs )
		{
			l = bs[ x ];
			r = i;
			break;
		}
		bs[ x ] = i;
		x = x ^^ 2 % m;
	}
	if( n <= r ) return ts[ n ];
	
	// ループ回数と余りを計算
	auto c = ( n - l ) / ( r - l );
	auto k = ( n - l ) % ( r - l );
	
	// 答えを計算
	return ts[ l ] + ( ts[ r ] - ts[ l ] ) * c + ( ts[ l + k ] - ts[ l ] );
}


Measured memory_bytes: 7116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  set<char> st;
  rep(i, 0, N) {
    VAR(char, si);
    st.insert(si);
  }
  print(st.size() == 3 ? "Three" : "Four");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vector<vi> G(100100);
vector<vl> d(100100);
int color[100100];
int main() {
  fill(color,color+100100,-1);
  int n;
  cin >> n;
  
  rep(i,n-1){
    int u,v,w;
    cin >> u >> v >> w;
    u--;v--;
    G[u].push_back(v);
    G[v].push_back(u);
    d[u].push_back(w);
    d[v].push_back(w);
    
    //d[u][v] = w;
    //d[v][u] = w;
  }
  queue<int> q;
  q.push(0);
  color[0] = 0;
  while(!q.empty()){
    int v = q.front();q.pop();
    rep(i,sz(G[v])){
      int u = G[v][i];
      if(color[u] == -1){
        q.push(u);
        //show(d[v][u]);
        if(d[v][i]%2 == 0)color[u] = color[v];
        else color[u] = 1-color[v];
      }

    }
  }
  rep(i,n)cout<<color[i]<<endl;
  return 0;
}

Measured memory_bytes: 12288
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var ans int
	N, M := nextInt(), nextInt()
	G := make([][]int, N)
	for i := 0; i < M; i++ {
		a, b := nextInt(), nextInt()
		G[a-1] = append(G[a-1], b-1)
		G[b-1] = append(G[b-1], a-1)
	}
	marked := make([]bool, N)
	for g := range G {
		if marked[g] {
			continue
		}
		q := make([]int, 0)
		marked[g] = true
		q = append(q, g)
		sum := 1
		for len(q) != 0 {
			node := q[0]
			q = q[1:]
			for _, newNode := range G[node] {
				if marked[newNode] {
					continue
				}
				marked[newNode] = true
				q = append(q, newNode)
				sum += 1
			}
		}
		if sum > ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 23600
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,A,B;
vector<ll> X;
void input(){
    fast_io();
    cin >> N >> A >> B;
    X = fetch_vec<ll>(N);
}

int solve(){
    ll ans = 0;
    for (int i = 0; i < N-1; i++)
    {
        ans += min(B,A*(X[i+1]-X[i]));
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1024
def main():

    """ ????????? """
    H = int(input().strip())
    hkeys = list(map(int,(input().split())))
    for i in range(H):
        txts = []
        id = i + 1
        txts.append("node {}: key = {},".format(id, hkeys[i]))
        parent = int(id / 2)
        if parent != 0:
            txts.append("parent key = {},".format(hkeys[parent-1]))
        left = id * 2
        if left > 0 and left <= H:
            txts.append("left key = {},".format(hkeys[left-1]))
        right = left + 1
        if right > 0 and right <= H:
            txts.append("right key = {},".format(hkeys[right-1]))
        print("{} ".format(" ".join(txts)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7736
n=int(input())
l=[[] for i in range(n)]
l[0]=[[0]]
for i in range(n-1):
  for j in l[i]:
    for k in range(max(j)+2):
      l[i+1].append(j+[k])

for i in range(len(l[n-1])):
  for j in range(n):
    print(chr(l[n-1][i][j]+97), end="")
  print()

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    pi P[N];
    REP(i, N) {
        int a, b; cin >> a >> b;
        P[i] = mp(b, -a);
    }
    sort(P, P+N);

    string ans = "Yes";
    int t = 0;
    REP(i, N) {
        t += -P[i].second;
        if (t > P[i].first) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define debug(x) cerr << fixed << #x << " is " << x << endl;
#define ii pair<int, int>

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

	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> v_sorted(n);

	for(int i = 0; i < n; i++)
	{
		cin >> v[i];
		v_sorted[i] = v[i];
	}
	int get = (n+1)/2;
	sort(v_sorted.begin(), v_sorted.end());
	for(int i = 0; i < n; i++)
	{
		int find = lower_bound(v_sorted.begin(), v_sorted.end(), v[i])-v_sorted.begin();
		if(find < get)
			cout << v_sorted[get] << endl;
		else
			cout << v_sorted[get-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3840
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,K,Q;
  cin >> N >> K >> Q;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  vector<ll> S = A;
  sort(S.begin(),S.end());
  ll ans = S[Q-1] - S[0];
  S.erase(unique(S.begin(),S.end()),S.end());
  for(int ng: S){
    vector<ll> ok;
    priority_queue<ll,vector<ll>,greater<>> que;
    for(int i=0; i<N; i++){
      if(A[i] <= ng){
        while(que.size()){
          if(que.size() >= K) ok.emplace_back(que.top());
          que.pop();
        }
      }else{
        que.emplace(A[i]);
      }
    }
    while(que.size()){
      if(que.size() >= K) ok.emplace_back(que.top());
      que.pop();
    }
    sort(ok.begin(),ok.end());
    if(ok.size() >= Q){
      chmin(ans,ok[Q-1]-ok[0]);
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
using namespace std;


int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a,b,c = I()
print(a*b//2)

Measured memory_bytes: 76876