akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
#define double long double
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int T[110];
int V[110];

template<typename... Args>
void debug(Args... args) {
    for (auto arg:{args...})cerr << arg << " ";
    cerr << endl;
}

pair<double, int> f(int t, int v, int vf, int vm) {
    vf = min(vf, vm);
    if (v + t < vf) {
        double ans = (v + v + t) * t / 2.;
        return make_pair(ans, v + t);
    }

    double ka = 0, ge = 0;
    if (v > vf)ge = v - vf;
    else ka = vf - v;
    t -= ge + ka;
    ka += t / 2.;
    ge += t / 2.;
    double to = 0;
    if (v + ka > vm) {
        //v+ka=vm
        to = (v + ka - vm);
        ka -= to;
        ge -= to;
        to *= 2;
    }
    double ans = (v + v + ka) * ka / 2. + (v + ka) * to + (v + ka + vf) * ge / 2.;
    return make_pair(ans, vf);
}

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> T[i + 1];
    }
    rep(i, N) {
        cin >> V[i + 1];
    }
    for (int i = N; i >= 0; --i) {
        V[i] = min(V[i], V[i + 1] + T[i]);
    }
    double ans = 0;
    int v_prev = 0;
    for (int i = 0; i <= N; ++i) {
        auto p = f(T[i + 1], v_prev, V[i + 2], V[i + 1]);
        v_prev = p.second;
        ans += p.first;
    }
    printf("%.20Lf", ans);
    return 0;
}


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

class UnionFind {
public:
	vector<int>par;

	void init(int size_) {
		par.resize(size_, -1);
	}
	int root(int pos) {
		if (par[pos] == -1) return pos;
		par[pos] = root(par[pos]);
		return par[pos];
	}
	bool same(int u, int v) {
		if (root(u) == root(v)) return true;
		return false;
	}
	void unite(int u, int v) {
		u = root(u); v = root(v);
		par[u] = v;
	}
};

int N, M, A[50009], B[50009], C[50009], cnts, col[509];
vector<int>X[509]; vector<tuple<int, int, int>>tup, Z;

void dfs(int pos) {
	if (col[pos] >= 1) return;
	col[pos] = cnts;
	for (int i = 0; i < X[pos].size(); i++) dfs(X[pos][i]);
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i] >> C[i];
		tup.push_back(make_tuple(C[i], A[i], B[i]));
	}
	sort(tup.begin(), tup.end());

	int sum = 0; UnionFind UF; UF.init(N + 2);
	for (int i = 0; i < tup.size(); i++) {
		if (UF.same(get<1>(tup[i]), get<2>(tup[i])) == false) {
			UF.unite(get<1>(tup[i]), get<2>(tup[i]));
			Z.push_back(tup[i]);
		}
	}
	int ans = 0;
	for (int i = 0; i < Z.size(); i++) {
		for (int j = 1; j <= N; j++) { X[j].clear(); col[j] = 0; }
		for (int j = 0; j < Z.size(); j++) {
			if (i == j) continue;
			int to1 = get<1>(Z[j]), to2 = get<2>(Z[j]);
			X[to1].push_back(to2);
			X[to2].push_back(to1);
		}
		cnts++; dfs(get<1>(Z[i]));
		cnts++; dfs(get<2>(Z[i]));

		int cntu = 0;
		for (int j = 1; j <= M; j++) {
			if (col[A[j]] != col[B[j]] && get<0>(Z[i]) == C[j]) cntu++;
		}
		if (cntu == 1) { ans++; sum += get<0>(Z[i]); }
	}
	cout << ans << " " << sum << endl;
	return 0;
}


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

int main()
{
	int n,m,A,B;
	scanf("%d %d %d %d",&n,&m,&A,&B);
	for(int i=0;i<B;i++)
	{
		for(int j=0;j<m;j++) printf("%c",j<A?'0':'1');
		puts("");
		for(int j=0;j<m;j++) printf("%c",j<A?'1':'0');
		puts("");
	}
	for(int i=0;i<n-2*B;i++)
	{
		for(int j=0;j<m;j++) printf("%c",j<A?'0':'1');
		puts("");
	}
}

Measured memory_bytes: 1280
import java.util.*;
import java.math.BigInteger;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
        System.out.println(lucas(n));
      }
      static BigInteger lucas(int n){
          ArrayList<BigInteger> a = new ArrayList<>();
          a.add(new BigInteger("2"));
          a.add(new BigInteger("1"));
          for(int i = 2 ;i <=n ; i++){
              a.add(a.get(i-2).add(a.get(i-1)));
          }
          return a.get(n);
      }
}

Measured memory_bytes: 22484
/*
 * Author: apikdech
 * Time: 19:07:30 15-06-2019
 * Last Modified: 19:09:02 15-06-2019
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, k, ans;
	cin >> n >> k;
	if (k == 1) ans = 0;
	else ans = n-k;
	cout << ans << "\n";
	// cerr << "time = " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << " ms\n";
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > red_points(n), blue_points(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    red_points[i] = make_pair(a, b);
  }
  for (int i = 0; i < n; ++i) {
    int c, d;
    scanf("%d %d", &c, &d);
    blue_points[i] = make_pair(c, d);
  }
  sort(blue_points.begin(), blue_points.end());
  sort(red_points.begin(), red_points.end(),
       [](pair<int, int>& lhs, pair<int, int>& rhs) {
         return lhs.second > rhs.second;
       });

  int ans = 0;
  vector<int> used(n, 0);
  for (int i = 0; i < n; ++i) {
    int bx = blue_points[i].first, by = blue_points[i].second;
    for (int j = 0; j < n; ++j) {
      int rx = red_points[j].first, ry = red_points[j].second;
      if (used[j]) { continue; }
      if (rx < bx && ry < by) {
        used[j] = 1;
        ++ans;
        break;
      }
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e8+5;
char s[N],t[N];
int n,m,xx,yy,nex[N];
void kmp_init()
{
    int i=1,k=0;
    while(i<=xx*m)
        if(k==0||t[i]==t[k]) nex[++i]=++k;
    else k=nex[k];
}
int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1);m=strlen(t+1);
    xx=2200000/m;
    for(int j=1;j<xx;j++)
    for(int i=1;i<=m;i++)
        t[i+m*j]=t[i];
    kmp_init();
    int ans=0,p=m*xx/n;
    int now=0,pos=0;
    m*=xx;
    for(int l=1;l<=p;l++)
    {
        for(int i=1;i<=n;i++)
        {
            pos++;
            while(pos&&t[pos]!=s[i])
                pos=nex[pos];
            ans=max(ans,pos);
        }
    }
    m/=xx;
    if(ans>=n*(p-1)) printf("-1\n");
    else printf("%d\n",ans/m);
}

Measured memory_bytes: 18688
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for (int i = 0; i < N; i++)cin >> a[i];
    sort(a.begin(), a.end());
    
    int ans = 0;
    if (find_if(a.begin(), a.end(), [](int x) { return (1 <= x&&x <= 399); }) != a.end())ans++;
    if (find_if(a.begin(), a.end(), [](int x) { return (400 <= x&&x <= 799); }) != a.end())ans++;
    if (find_if(a.begin(), a.end(), [](int x) { return (800 <= x&&x <= 1199); }) != a.end())ans++;
    if (find_if(a.begin(), a.end(), [](int x) { return (1200 <= x&&x <= 1599); }) != a.end())ans++;
    if (find_if(a.begin(), a.end(), [](int x) { return (1600 <= x&&x <= 1999); }) != a.end())ans++;
    if (find_if(a.begin(), a.end(), [](int x) { return (2000 <= x&&x <= 2399); }) != a.end())ans++;
    if (find_if(a.begin(), a.end(), [](int x) { return (2400 <= x&&x <= 2799); }) != a.end())ans++;
    if (find_if(a.begin(), a.end(), [](int x) { return (2800 <= x&&x <= 3199); }) != a.end())ans++;
    int min, max;
    min = (ans == 0) ? 1 : ans;
    int c = count_if(a.begin(), a.end(), [](int x) { return 3200 <= x; });
    if (c != 0)ans += c;
    max = ans;

    cout << min << " " << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));

    if(a[n-1]-a[0] >= 2) {
        cout << "No" << endl;
    } else if(a[n-1]-a[0] == 1) {
        ll cnt0 = 0, cnt1 = 0;
        REP(i, n) {
            if(a[i]==a[0]) cnt0++;
            else cnt1++;
        }
        if(cnt0 <= a[0] && (a[0]-cnt0+1)*2 <= cnt1) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else if(a[n-1]-a[0] == 0) {
        if(n == a[0]+1 || n >= a[0]*2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
from sys import stdin


def main():
    H, W = [int(x) for x in stdin.readline().rstrip().split()]
    s = [list(stdin.readline().rstrip()) for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if s[h][w] == '.':
                continue
            idxs = [(h - 1, w), (h, w - 1), (h, w + 1), (h + 1, w)]
            for i, j in idxs:
                if (0 <= i < H) and (0 <= j < W) and (s[i][j] == '#'):
                    break
            else:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

string s[12];
bool visit[12][12];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, -1, 0, 1};

void dfs(int y, int x) {
  visit[y][x] = true;
  REP(i, 4) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (0 <= ny && ny < 12 && 0 <= nx && nx < 12) {
      if (s[ny][nx] == '1' && !visit[ny][nx]) dfs(ny, nx);
    }
  }
}

int main() {
  while (true) {
    REP(i, 12) {
      if (!(cin >> s[i])) return 0;
    }
    REP(i, 12) REP(j, 12) visit[i][j] = false;
    int ans = 0;
    REP(i, 12) REP(j, 12) {
      if (s[i][j] == '1' && !visit[i][j]) {
        dfs(i, j);
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3168
n=int(input())
s=[]
cnt=0
c=[0,0,0]
for i in range(n):
  a=input()
  if a[0]=="B":
    c[0]+=1
  if a[-1]=="A":
    c[1]+=1
  if a[0]=="B" and a[-1]=="A":
    c[2]+=1
  for j in range(len(a)-1):
    if a[j]=="A" and a[j+1]=="B":
      cnt+=1
      #print("cnt",cnt)
if c[0]==0 and c[1]==0:
  plus=0
elif c[0]==c[1] and c[1]==c[2]:
  plus=c[2]-1
else:
  plus=min(c[0],c[1])
print(cnt+plus)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] " << endl;
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
vector<int> bfs(vector<int> v, vector<int> now, int last)
{

    if (v.empty())
    {
        return now;
    }
    int i = v.size();
    for (auto itr = v.end() - 1; itr != v.begin() - 1; itr--)
    {
        auto _v = v;
        if (i == *itr)
        {
            _v.erase(_v.begin() + i - 1);
            now.push_back(i);

            vector<int> res = bfs(_v, now, i - 1);
            if (res[0] != -1)
                return res;
            now.pop_back();
        }
        i--;
    }

    vector<int> ret = {-1};
    return ret;
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> b;
    rep(i, n)
    {
        int t;
        cin >> t;
        b.push_back(t);
    }
    rep(i, n)
    {
        if (b[i] > i + 1)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    auto res = bfs(b, {}, 0);
    reverse(res.begin(), res.end());
    for (int ans : res)
    {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{    
    i64 n,d,a;
    cin >> n >> d >> a;
    vector<pair<i64,i64>> xh(n);
    rep(i,n) cin >> xh[i].first >> xh[i].second;

    sort(xh.begin(),xh.end());

    vector<i64> y;
    vector<i64> cs(1, 0);
    
    rep(i,n)
    {
        i64 xi = xh[i].first;
        i64 hi = xh[i].second;
        
        if(i>0 && y.back()>=xi-d)
        {
            auto itr_l = lower_bound(y.begin(), y.end(), xi-d);
            int dl = distance(y.begin(),itr_l);
            i64 tmp = cs.back() - cs[dl];
            hi -= tmp * a;
        }

        if(hi > 0)
        {
            y.push_back(xi+d);
            cs.push_back(cs.back()+hi/a+int(hi%a!=0));
        }
    }

    cout << cs.back() << endl;
    return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

vi dx = {0,1,0,-1};
vi dy = {1,0,-1,0};

signed main(){
  int h, w; cin >> h >> w;
  vs a(h);
  vvi check(h,vi(w));
  vvi dist(h,vi(w,-1));
  queue<pii> q;
  rep(i,h){
    cin >> a[i];
    rep(j,w){
      if(a[i][j] == '#'){
	dist[i][j] = 0;
	check[i][j] = 1;
	q.push(pii(i,j));
      }
    }
  }
  while(not q.empty()){
    int x = q.front().first, y = q.front().second;
    q.pop();
    
    rep(k, 4){
      int nx = x + dx[k], ny = y + dy[k];
      if(0 <= nx and nx < h and 0 <= ny and ny < w){
	if(dist[nx][ny] == -1){
	  dist[nx][ny] = dist[x][y] + 1;
	  q.push(pii(nx,ny));
	}
      }
    }
  }

  int ans = -inf;
  rep(i,h){
    rep(j,w){
      ans = max(ans,dist[i][j]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 33460
n = gets.to_i
as = Array.new(n)
bs = Array.new(n)
n.times do |i|
  as[i], bs[i] = gets.split.map(&:to_i)
end

add_v = 0
(n-1).downto(0) do |i|
  a = as[i] + add_v
  b = bs[i]
  add_v += (b - (a%b)) % b
end
puts add_v

Measured memory_bytes: 5372
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b,c;
   cin>>a>>b>>c;
   int k;
   cin>>k;
   while(k>0 && b<=a)
   {
       k--;
       b*=2;
   }
   while(k>0 && c<=b)
   {
       k--;
       c*=2;
   }
   if(b>a && c>b)
   {
       cout<<"Yes"<<endl;
   }
   else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int n=s.size(),ct=0;
   for(int i=0;i<n/2;i++)
   {
        if(s[i]!=s[n-i-1])
           ct++;
   }
   cout<<ct<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
int a[100005];

int partition(int p,int r)
{
	int x,i,j,t;
	x=a[r];
	i=p-1;
	for(j=p;j<r;j++)
	{
		if(a[j]<=x)
		{
			i++;
			swap(a[i],a[j]);
		}
	}
	swap(a[r],a[i+1]);
	return i+1; 
}


int main()
{
   int n,q;
   cin>>n;
   for(int i=0;i<n;i++)
   cin>>a[i];
   q=partition(0,n-1);
   for(int i=0;i<n;i++)
   {
   	if(i)
   	cout<<" ";
   	if(i==q)
   	cout<<"[";
   	cout<<a[i];
   	if(i==q)
   	cout<<"]";
   	
   }
   cout<<endl;
return 0;
 } 


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

int main(){

  
  ll n,co=0;
  cin >> n;
  
  vector <ll> a(n);

  vector <ll> c(n+1);

  
  rep(i,n)
    cin >> a.at(i);
  
  rep(i,n+1){
    if(i!=0 && i!=n)
      c.at(i)=abs(a.at(i-1)-a.at(i));
    else if(i==0)
      c.at(i)=abs(a.at(i));
    else
      c.at(i)=abs(a.at(i-1));
    
    co+=c.at(i);
    //cout << i << endl;
  }
  
  rep(i,n){
     if(i!=0 && i!=n-1)
     	 cout << co-c.at(i)-c.at(i+1)+abs(a.at(i+1)-a.at(i-1)) << endl;
    else if (i==0)
         cout << co-c.at(i)-c.at(i+1)+abs(a.at(1)) << endl;
    else if(i==n-1)
      cout << co-c.at(i)-c.at(i+1)+abs(a.at(n-2)) << endl;
    
  }
  
  
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    char c = 'a';
    string s;
    cin >> s;
    vll alpha(26);
    rep(i,26)alpha[i]=0;
    rep(i,26){
        rep(j,SIZE(s)){
            if(s[j] == c)alpha[i]++;
        }
        c++;
    }
    rep(i,26){
        if(alpha[i]%2 !=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
    return 0;
}

Measured memory_bytes: 256
s = list(input())

key = list("keyence")

for i in range(len(s)):
    if s[i] == key[i]:
        continue
    else:
        check = i
        break
else:
    print("YES")
    exit()
    
if key[check:] == s[check-7:]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>

int main() {

     ll n;
     cin>>n;
     ll ans=0;
     ll arr[n];
     forn(i,n){
       cin>>arr[i];
       ans=ans^arr[i];
     }
     forn(i,n){
        ll temp=arr[i]^ans;
        cout<<temp<<" ";
     }
     cout<<endl;

}


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

int main(){

	  int a,b,c ;
	  cin >> a >> b >> c;


	  int x=c;
	  int t=0;
	  set<int> s;
	  while( c % (a+b) > a ) {
			c = c%(a+b);
			c += 60; t++;
			if( s.count(c) != 0){
				  cout << -1 << endl; return 0;
			}
			s.insert(c);
	  }
	  cout << x+(60*t) << endl;
	  return 0;

}

Measured memory_bytes: 1192
from collections import defaultdict
n = int(input())
nums = []
for i in range(n):
  num = int(input())
  nums.append(num)
d = defaultdict(int)
for j in nums:
  d[j] += 1
count = 0
for k in d.values():
  if k % 2 == 1:
    count += 1
print(count)

Measured memory_bytes: 16632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
// #include <stack>
// #include <vector>
#include <cstring>
// #include <algorithm>
using namespace std;

struct Node {
    int key = 0;
    Node *parent, *left, *right;
};

Node *NIL;

struct Tree {
    Node *root;
};

void insert(Tree *T, int key) {
    Node *n = (Node *)malloc(sizeof(Node));
    n->key = key;
    n->parent = NIL;
    n->left = NIL;
    n->right = NIL;
    
    if (T->root == NIL) {
        T->root = n;
        return;
    }
    
    Node *x;
    x = T->root;
    bool continued = true;
    while (continued) {
        if (x->key >= key) {
            if (x->left != NIL) {
                x = x->left;
                continue;
            }
            
            n->parent = x;
            x->left = n;
            continued = false;
            return;
        }
        
        if (x->key <= key) {
            if (x->right != NIL) {
                x = x->right;
                continue;
            }
            
            n->parent = x;
            x->right = n;
            continued = false;
            return;
        }
    }
};

void inorder(Node *N) {
    if (N == NIL) {
        return;
    }

    inorder(N->left);
    cout << " " << N->key;
    inorder(N->right);
}

void preorder(Node *N) {
    if (N == NIL) {
        return;
    }
    
    cout << " " << N->key;
    preorder(N->left);
    preorder(N->right);
}

int main() {
    int N;
    scanf("%d", &N);
    Tree *T = (Tree *)malloc(sizeof(Tree));
    T->root = NIL;

    char command[10];
    int key;
    
    for (int i = 0; i < N; i++) {
        scanf("%s %d", command, &key);
        
        if (!strcmp(command, "insert")) {
            insert(T, key);
        }
        
        if (!strcmp(command, "print")) {
            inorder(T->root);
            cout << endl;
            preorder(T->root);
            cout << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 26500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var originStr = Console.ReadLine();
            var n = int.Parse(Console.ReadLine());

            var tmpStr = originStr;
            for (int i = 0; i < n; i++)
            {
                var cmdStr = Console.ReadLine().Split(' ').ToList();
                if (cmdStr[0] == "replace")
                {
                    tmpStr = tmpStr.Substring(0, int.Parse(cmdStr[1])) + cmdStr[3] + tmpStr.Substring(int.Parse(cmdStr[2]) + 1);
                }
                else if (cmdStr[0] == "reverse")
                {
                    var beforeStr = tmpStr.Substring(0, int.Parse(cmdStr[1]));
                    var reverseStr = string.Join("", tmpStr.Substring(int.Parse(cmdStr[1]), int.Parse(cmdStr[2]) - int.Parse(cmdStr[1]) + 1).Reverse().ToArray());
                    var afterStr = tmpStr.Substring(int.Parse(cmdStr[2]) + 1);
                    tmpStr = beforeStr +  reverseStr + afterStr;
                }
                else if (cmdStr[0] == "print")
                {
                    Console.WriteLine(tmpStr.Substring(int.Parse(cmdStr[1]), int.Parse(cmdStr[2]) + 1 - int.Parse(cmdStr[1])));
                }

            }
        }
    }
}



Measured memory_bytes: 18352
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+')
    {
        cout << a +b << endl;
    }
    else
    {
        cout << a - b <<endl;
    }
    
}

Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll A;
ll B;
ll N;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> A;
    cin >> B;
    cin >> N;
    solve();
}

// 1 ≤ A ≤ 10^{6}
// 1 ≤ B ≤ 10^{12}
// 1 ≤ N ≤ 10^{12}
// 入力は全て整数

// ll A, ll B, ll N
// N 以下の非負整数 x に対する floor(Ax/B) - A × floor(x/B) の最大値を整数として出力せよ。
void solve(){
    if(N<B-1){
        cout<<(A*N/B-A*(N/B))<<endl;
    }else{
        cout<<(A*(B-1)/B)<<endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;

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

  // たたき続けた方が良い場合
  if (b-a <= 2) {
    cout << 1+k << endl;
    return 0;
  }

  // 交換までたどり着けない場合
  if (k <= a) {
    cout << 1+k << endl;
    return 0;
  }

  ll ans = 0;
  ans = a;
  ans += max(0,(int)((k-(a-1))/2))*(b-a);
  if ((k-(a-1)) % 2 != 0) ans += 1;
  cout << ans << endl;
}


Measured memory_bytes: 3536
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }



int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while (t--) {
		string s;
		cin >> s;
		int mx = 0, cnt = 0;
		lop(i, 3) {
			if (s[i] == 'R') cnt++;
			else ckmax(mx, cnt), cnt = 0;
		}
		ckmax(mx, cnt);
		cout << mx << endl;
	}


	return 0;
}


Measured memory_bytes: 3632
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i], ans += a[i];
  int ok = 1;
  sort(a, a + n);
  if (ans % 10 == 0) {
    rep(i, n) {
      if (a[i] % 10 != 0) {
        ans -= a[i];
        ok = 0;
        break;
      }
    }
    if (ok) ans = 0;
  }
  Cout(ans);
  return 0;
}

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

using namespace std;
int sumdigit(int n) {
    int ret = 0;
    while(n) {
        ret += n%10;
        n/=10;
    }
    return ret;
}
int main(void) {
    int N,A,B;
    int sum,total = 0;
    cin >> N >> A >> B;
    for(int i=1;i<=(int)N;i++) {
        sum = sumdigit(i);
        if(A <= sum && sum <= B) {
//            printf("sum:%d\n", sum);
            total += i;
        }
    }

    cout << total << endl;    
}

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

#define all(n) n.begin(),n.end()
#define ll long long
#define ull  unsigned long long
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll maxn=3e6+120;
const ll maxx=1e16;
const ll mod1=1e9+7;
const ll mod=998244353;
vector<ll> adj[maxn];

ll a[maxn];
ll cnt[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
    ll n ;
     cin>>n;
     ll ans=0;
     for (int i=1;i<=n;i++)
     {

         cin>>a[i];
         cnt[a[i]]++;
         ans+=a[i];
     }
     ll p;
     cin>> p;
   //  cout <<ans<<endl;
     while (p--)
     {
         ll b, c;
          cin>>b>>c;
          ll h= cnt[b];
          ans=ans-h*b+h*c;
          cnt[b]=0;
          cnt[c]+=h;
          cout <<ans<<endl;
     }




}


Measured memory_bytes: 75484
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    a,b,c=inpm()
    x=a+b+c
    if x>=22:
        print('bust')
    else:
        print('win')

if __name__ == "__main__":
    main()

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

unsigned getdigit(unsigned NUM){
    return log10(NUM) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n;
    cin >> n;
    int ans = 0;
    ll mn = INF;
    for (int i = 0;i < n;i++){
        ll P;
        cin >> P;
        if (i == 0){
            ans++;
            mn = min(mn,P);
        }
        else {
            if (P < mn) ans++;
            mn = min(mn,P);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
ll dp[1001][1001];
ll fact[1001];
ll ppow(ll a) {
	ll b=MOD-2;
	ll res = 1;
	while (b) {
		if (b & 1)res = (res*a) % MOD;
		a = (a*a) % MOD;
		b >>= 1;
	}
	return res;
}
ll comb(ll a, ll b) {
	return (((fact[a] * ppow(fact[a - b])) % MOD)*ppow(fact[b])) % MOD;
}
int main() {
	fact[0] = 1;
	int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	for (int i = 1; i <= n; i++)fact[i] = (fact[i - 1] * i) % MOD;
	rep(i, n)dp[i][0] = 1;
	for (int i = a - 1; i < b; i++) {
		for (int j = 0; j <= n; j++) {
			if (j)(dp[i + 1][j] += dp[i][j]) %= MOD;
			if (j - c*(i + 1) < 0)continue;
			ll y = 1, t = n - j;
			for (int k = 1; j - k*(i + 1) >= 0 && k <= d; k++) {
				(y *= comb(t + i + 1, t)) %= MOD;
				t += i + 1;
				if(k<c)continue;
				ll o = y;
				(o *= ppow(fact[k])) %= MOD;
				(dp[i + 1][j] += dp[i][j - k*(i + 1)] * o) %= MOD;
			}
		}
	}
	cout << dp[b][n] << endl;
}


Measured memory_bytes: 8064
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int sum = 0;
    int count = 0;
    int[] pop = new int[n];
    for(int i = 0; i < n; i++){
      pop[i] = scan.nextInt();
    }
    for(int i = 0; i < n; i++){
      sum += pop[i];
    }
    int M = 4*m;
    //double border = sum/M;
    for(int i = 0; i<n; i++){
      if(pop[i]*M >= sum){
        count++;
      }
    }
     if(count >= m){
       System.out.println("Yes");
     }else{
       System.out.println("No");
     }
  }
}


Measured memory_bytes: 21972
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=1e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

vector<ll> adj[M];
ll vis[M];
ll indeg[M];
ll dis[M];
ll n,m;

void dfs(ll v){
	vis[v]=1;
	for(auto u: adj[v]){
		dis[u]=max(dis[u],dis[v]+1);
		indeg[u]--;
		if(!indeg[u]) dfs(u);
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	rep(i,0,m){
		ll x,y;
		cin >> x >> y;
		adj[x].push_back(y);
		indeg[y]++;
	}
	for(ll i=1; i<=n; i++){
		if(!vis[i] && indeg[i]==0) dfs(i);
	}
	ll maxi=0;
	for(ll i=1; i<=n; i++) maxi=max(maxi,dis[i]);
	cout << maxi;
	return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  int i,n;
  cin >> s;
  n = s.size();
  for(i=0;i<n;i++){
    if(i%2==0 && s[i]=='L'){
      cout << "No" << endl;
      return 0;
    }else if(i%2==1 && s[i]=='R'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3592
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length; i < len; i++){
    console.log(primeNumbers[parseInt(input[i], 10)]);
  }
}
   
function calcPrimeNumbers(){
  var max = 999999;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  // for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
  for(var i = 2; i <= 1000; i++){
  if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(max + 1);
   for(var i = 1; i <= max; i++){
    primeNums[i] += primeNums[i-1] + 1 - primeNumbers[i];
  }
     
  return primeNums;
}

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using ll = long long;
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
int main(void) {
  int k;cin>>k;
  int ans=0;
  for (int i=1;i<=k;i++){
    for (int j=1;j<=k;j++){
      for (int l=1;l<=k;l++){
        ans+=gcd(i,gcd(j,l));
      }
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3732
r, g, b, n = map(int, input().split())
 
count = 0
for i_r in range(0,int(n)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int(n)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):
 
            count +=1
 
print(count)

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

int main() {
	long long N, K;
	cin >> N >> K;
	long long ans = 0;
	if (0 == K%2) {
		ans = (N / K)*(N / K)*(N / K);
		ans += ((N + K / 2) / K)*((N + K / 2) / K)*((N + K / 2) / K);
	}
	else {
		ans = (N / K)*(N / K)*(N / K);
		
	}
	cout << ans <<  endl;
	return 0;
}

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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    int N,r=0,t=0;
    cin >> N;
    vector<vector<int>> v(N-1,vector<int> (3,0));

    for (int i=0;i<N-1;++i){
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }

    for (int i=0;i<N-1;++i){
        r=v[i][1];
        for (int j=i;j<N-1;++j){
            if (r>=v[j][1]){
                r += (v[j][2] - (r-v[j][1])%v[j][2])%v[j][2] + v[j][0];
            }
            else r = v[j][1] + v[j][0];
        }
        cout << r << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A, B;
  cin>>A>>B;
	int i = 0;
	int flag = 0;
	for (i = 1; i <= 3; i++) {
		if (A*B*i % 2 == 1) flag = 1;
	}
	if (flag) cout << "Yes" << endl;
	else	cout << "No" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
using namespace std;
#define len(n) (int)n.length()
#define dump cout
#define pb push_back
#define ll long long
#define make_pair mkp
typedef pair<ll, ll> LLARR;

bool firstsort_less(const LLARR& left,const LLARR& right){
    return left.first > right.first;
}

bool secondsort_less(const LLARR& left,const LLARR& right){
    return left.second > right.second;
}

int main()
{
	ios::sync_with_stdio(false);
	
	string str;
	cin >> str;
	string ans;
	for (int i = 0; i < len(str); i++) {
	    if (str[i] != 'B')
		{
			ans += str[i];
				}
		else
		{	
			if (len(ans) >= 1)
				ans.erase(ans.begin() + len(ans) - 1);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

double toDeg(double rad)
{
    return (rad * 180.0 / M_PI);
}
int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    if (a * a * b / 2.0 < x)
    {
        printf("%.10lf\n", toDeg(atan(2 * (a * a * b - x) / (double)(a * a * a))));
    }
    else
    {
        printf("%.10lf\n", toDeg(atan(a * b * b / (double)(2 * x))));
    }

    return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    int cunt=0,num=1;

    for(cunt=0;cunt<N;cunt++){
        if(num>=K)break;
        num*=2;
    }
    for(cunt;cunt<N;cunt++){
        num+=K;
    }
    cout<<num<<"\n";
    return 0;
}



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

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

	std::vector<int> a(n);
	for (auto&& e : a)
		std::cin >> e;

	int count = 0;
	while (true) {
		bool hasOdd = false;
		for (auto&& e : a)
			hasOdd = hasOdd || (e % 2 == 1);

		if (hasOdd)
			break;

		for (auto&& e : a)
			e /= 2;

		++count;
	}

	std::cout << count << std::endl;
}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrW = [input() for _ in range(N)]
# arrA = np.array(input().split(),dtype=np.int64)

lis = []
ans = "Yes"
for i,w in enumerate(arrW):
    # print(lis , w)
    if i == 0:
        lis.append(w)
    else:
        if arrW[i-1][-1] != arrW[i][0]:
            ans = "No"
            break
        if arrW[i] in lis:
            ans = "No"
            break
        lis.append(w)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

#define MAX 1000000000

int main(){
  int X, Y;

  cin >> X >> Y;
  if((X % Y) == 0){
    cout << "-1" << endl;
  }else{
    for (int i = 0; i < MAX; i++){
      if((X * i) % Y != 0){
        cout << X * i << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256