akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


N = int(input().rstrip())
str_s = [str(input().rstrip()) for _ in range(N)]

prev_s = [str_s[0]]
for i in range(1, N):
	if prev_s[i-1][-1] != str_s[i][0] or str_s[i] in prev_s:
		print("No")
		exit()
	else:
		prev_s.append(str_s[i])
print("Yes")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAX 100010
#define INF 0x3f3f3f3f

ll dp[MAX];
bool been[MAX];
int n, v[MAX];

ll f(int i){
    if(i >= n) return INF;
    if(i == n-1) return 0;
    if(been[i]) return dp[i];
    been[i] = true;
    return dp[i] = min(f(i+1)+abs(v[i]-v[i+1]),f(i+2)+abs(v[i]-v[i+2])); 
}

int main(){
    
    cin >> n;
    for(int i = 0;i<n;i++) cin >> v[i];
    cout << f(0) << '\n';

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main (){
while (1){
long n,dset[5000],temp=0,max;
cin>>n;
if (n==0)break;
for (int i=0;i<n;i++){
        cin>>dset[i];
}
max=dset[0];
for (int i=0;i<n;i++){
        for (int j=i;j<n;j++){
                temp=temp+dset[j];
                if (max<temp){
                        max=temp;
                }
        }
temp=0;
}
cout<<max<<endl;
}
return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 998244353;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j;
    string s;
    cin >> s;
    s += '0';
    ll k;
    cin >> k;
    ll cnt = 0;
    VI v;
    ll u = 0;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == '0') {
            v.pb(cnt);
            u += cnt;
            cnt = 0;
        } else
            cnt++;
    }
    k = min(k,u);
    ll n = v.size();
    VVVI dp(n + 1, VVI(u + 1, VI(u + 1, 0ll)));
    for (j = v[0]; j <= u; j++) {
        dp[0][j - v[0]][j - v[0]] = 1;
    }
    for (i = 1; i < n; i++) {
        for (ll j2 = 0; j2 <= u; j2++) {
            for (ll l = 0; l <= u; l++) {
                for (ll j1 = max(0ll, j2 - l); j1 <= u; j1++) {
                    if (v[i] + j2 - j1 < 0ll) break;
                    if (j2 >= j1) {
                        dp[i][j2][l] += dp[i - 1][j1][l - (j2 - j1)];
                    } else {
                        dp[i][j2][l] += dp[i - 1][j1][l];
                    }
                    dp[i][j2][l] %= mod;
                }
            }
        }
    }
    ll ans = 0;
    for (ll l = 0; l <= k; l++) {
        ans += dp[n - 1][0][l];
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 35616
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

long double l;

int main() {
  init_ios();
  cin >> l;
  l /= 3;
  cout<<fixed<<setprecision(10)<<l*l*l<<"\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
const int maxn=1e5+2;
int n;
int a[maxn];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	int pos=1;
	while (pos<n&&a[pos+1]>=pos+1) pos++;
	int tmp=pos;
	while (tmp<n&&a[tmp+1]==pos) tmp++;
	if ((tmp-pos&1)||(a[pos]-pos&1)) printf("First");
	else printf("Second");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    string s; cin >> s;

    bool flagN = false;
    bool flagW = false;
    bool flagS = false;
    bool flagE = false;
    for(int i=0; i<s.size(); i++){
        switch(s[i]){
            case 'N': 
            flagN = true;
            break;
            case 'W': 
            flagW = true;
            break;
            case 'S': 
            flagS = true;
            break;
            case 'E': 
            flagE = true;
            break;
        }
    }

    if(flagN == flagS && flagE == flagW){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using in6 = int64_t;
using ind = double;
using vi = vector<in6>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<in6,in6>;
using psi = pair<string,in6>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  string s;
  cin >> s;
  in6 ans = inf;
  in6 n = s.size();
  in6 zero = 0;
  in6 one = 0;
  rep(i,n) {
    if(i % 2 == 0 && s[i]=='0') ++one;
    else if(i % 2 == 1 && s[i] == '1') ++one;
  }
  rep(i,n) {
    if(i % 2 == 0 && s[i]=='1') zero++;
    else if(i % 2 == 1 && s[i] == '0') zero++;
  }
  ans = min(zero,one);
  cout << ans;
  hinata;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

struct Edge {
    int v, d;
    Edge(int v, int d) : v(v), d(d) {}
};

struct Node {
    int u, t, r;
    Node(int u, int t, int r) : u(u), t(t), r(r) {}

    bool operator < (Node o) const {
        if (t == o.t) {
            return r < o.r;
        } else {
            return t > o.t;
        }
    }
};

int N, M, L, Q;
vector<vector<Edge>> adj;
int maxR[305][305];
bool vis[305];
int memo[305][305];

int find(int s, int t) {
    memset(vis, false, sizeof(vis));
    memset(maxR, 0, sizeof(maxR));
    priority_queue<Node> q;
    q.push(Node(s, 0, L));
    while (!q.empty()) {
        Node node = q.top(); q.pop();
        int u = node.u;
        if (u == t) {
            return node.t;
        }

        if (vis[u]) {
            continue;
        }

        memo[s][u] = node.t;
        memo[u][s] = node.t;

        vis[u] = true;
        int m = adj[u].size();
        for (int k = 0; k < m; ++k) {
            int v = adj[u][k].v;
            int d = adj[u][k].d;

            if (vis[v]) {
                continue;
            }

            if (node.r >= d) {
                if (node.r - d >= maxR[node.t][v]) {
                    maxR[node.t][v] = node.r - d;
                    q.push(Node(v, node.t, node.r - d));
                }
            } else {
                if (L - d >= maxR[node.t + 1][v]) {
                    maxR[node.t + 1][v] = L - d;
                    q.push(Node(v, node.t + 1, L - d));
                }
            }
        }
    }
    return -1;
}

int main() {
    scanf("%d %d %d", &N, &M, &L);
    for (int i = 0; i <= N; ++i) {
        adj.push_back(vector<Edge>());
    }

    for (int i = 0; i < M; ++i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        adj[a].push_back(Edge(b, c));
        adj[b].push_back(Edge(a, c));
    }

    scanf("%d", &Q);
    memset(memo, -1, sizeof(memo));
    for (int q = 0; q < Q; ++q) {
        int s, t;
        scanf("%d %d", &s, &t);
        int ans = memo[s][t];
        if (ans == -1) {
            ans = find(s, t);
        }
        printf("%d\n", ans);
    }
    return 0;
}



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

long pow(int n,int m);


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

  cout << pow(n,m) << endl;
}

long pow(int n,int m)
{
  long long  x=m;
  long ans=1;
  
  int m2 =m*m;

  while(n>0){
    if(n & 1) ans = ans*x;
    x = (x*x)%1000000007;
    n >>= 1;
    ans = ans%1000000007;
    //cout << x << endl;
  }
  return ans;
}

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

using namespace std;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	vector<string> valid;
	int n = s.size(), m = t.size();
	rep(i,n-m+1){
		string ret = s;
		bool ok=true;
		rep(j,m){
			if(ret[i+j]=='?'){
				ret[i+j]=t[j];
			}
			else if(ret[i+j]!=t[j]){
				ok=false;
			}
		}
		rep(j,n)if(ret[j]=='?')ret[j]='a';
		if(ok)valid.push_back(ret);
	}
	if(valid.size() == 0) {
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	sort(valid.begin(),valid.end());
	cout<<valid[0]<<endl;
}

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

#define ll long long
#define INF pow(10, 12)

struct Edge {
    int a;
    int b;
    ll c;
};

vector<ll> BellmanFord(int N, int M, vector<Edge> edges){
    vector<ll> dist(N,-INF);
    dist[0] = 0;


    for(int i = 0; i < N; i++) {
        bool changedFlag = false;

        for (int j = 0; j < M; j++){
            int a = edges[j].a;
            int b = edges[j].b;
            ll c = edges[j].c;

            if(dist[a] == -INF)continue;  //aがまだ到達していないノードなら無視

            if(dist[b] < dist[a] + c){
                dist[b] = dist[a] + c;
                if(i == N-1 && b == N-1)changedFlag = true;
                // if(i == N-1){
                //     dist[N-1] = INF;
                //     return dist;
                // }
            }
        }

        if(changedFlag == true){
            dist[N-1] = INF;
            return dist;
        }
    }
    
    return dist;
}

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

    vector<Edge> edges(M);

    int a,b;
    ll c;
    for(int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        edges[i] = Edge{--a, --b, c};
    }

    vector<ll> dist = BellmanFord(N, M, edges);

    // for(int i = 0; i < N; i++) {
    //     cout << dist[i] << endl;
    // }

    if(dist[N-1] == INF){
        cout << "inf" << endl;
    }else{
        cout << dist[N-1] << endl;
    }


    return 0;
}

Measured memory_bytes: 256
x = int(input())
if x<600:
    print(8)
elif 600<=x<800:
    print(7)
elif 800<=x<1000:
    print(6)
elif 1000<=x<1200:
    print(5)
elif 1200<=x<1400:
    print(4)
elif 1400<=x<1600:
    print(3)
elif 1600<=x<1800:
    print(2)
else:
    print(1)


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

int par[10000], cnt;

int find(int x) {
	if (x == par[x])return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y)return;
	cnt--; par[x] = y;
}
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n*n)par[i] = i;
		cnt = n*n;
		rep(i, n)rep(j, n) {
			int x, y; scanf("%d%d", &y, &x);
			unite(i*n + j, x*n + y);
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  char b;
  cin >> b;

  if(b == 'A') cout << 'T' << endl;
  if(b == 'T') cout << 'A' << endl;
  if(b == 'C') cout << 'G' << endl;
  if(b == 'G') cout << 'C' << endl;

  return 0;
}



Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll k;cin>>k;
    vector<ll>a(k+1);
    for(ll i=1;i<=k;i++)cin>>a[i];
    reverse(all(a));
    ll dp[100002][2];
    memset(dp,0,sizeof(dp));
    dp[0][0]=2;dp[0][1]=2;
    for(int i=0;i<k;i++){
        //cout<<a[i]<<endl;
        dp[i+1][0]=INF;
        ll tmp=1;
        //cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
        tmp=dp[i][1]-dp[i][1]%a[i];
        ll tmp1=1;
        tmp1=dp[i][0]-dp[i][0]%a[i];
        if(tmp1<dp[i][0])tmp1+=a[i];
        //cout<<tmp<<endl;
        chmin(dp[i+1][0],max(dp[i][0],tmp1));
        
        chmax(dp[i+1][1],tmp+a[i]-1);
        
     
    }
    ll test=dp[k][0];
    for(int i=k-1;i>=0;i--){
        if(test<a[i]){
            cout<<-1<<endl;
            return 0;
        }
        test-=test%a[i];
        
    }
    if(test!=2){
        cout<<-1<<endl;
        return 0;
    }
    test=dp[k][1];
    for(int i=k-1;i>=0;i--){
        if(test<a[i]){
            cout<<-1<<endl;
            return 0;
        }
        test-=test%a[i];
        
    }
    if(test!=2){
        cout<<-1<<endl;
        return 0;
    }
    cout<<dp[k][0]<<" "<<dp[k][1]<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int x,y,total=0;

    cin>>x>>y;

    total+=400000-min(4,x)*100000;
    total+=400000-min(4,y)*100000;
    if(x==1&&y==1){
        total+=400000;
    }
    cout<<total<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
//#define int long long

void solve() {
	string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(all(t)); reverse(all(t));
    if(s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  int n;
  cin >> n;
  vector<pair<ll, ll>> ab(n);
  REP(i, n) { cin >> ab[i].first >> ab[i].second; }
  sort(ALL(ab), compare_by_b);
  ll count = 0;
  REP(i, n) {
    count += ab[i].first;
    if (count <= ab[i].second) {
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

signed main(){  
    ll n,m,k;
    cin >> n >> m >> k;
    ll a[n],b[m];
    rep(i,0,n){
        cin >> a[i];
        if(i != 0) a[i] += a[i-1];
    }
    rep(i,0,m){
        cin >> b[i];
        if(i != 0) b[i] += b[i-1];
    }
    ll cnt = 0;

    rep(i,0,n){
        if(a[i] > k) break;
        ll ok = -1,ng = m;

        while(abs(ok-ng) > 1){
            ll mid = (ok+ng)/2;

            if(a[i] + b[mid] <= k){
                ok = mid;
            }
            else{
                ng = mid;
            }
        }
        cnt = max(cnt,i + 1 + ok + 1);
    }

    rep(i,0,m){
        if(b[i] > k) break;
        ll ok = -1,ng = n;

        while(abs(ok-ng) > 1){
            ll mid = (ok+ng)/2;

            if(a[mid] + b[i] <= k){
                ok = mid;
            }
            else{
                ng = mid;
            }
        }
        cnt = max(cnt,i + 1 + ok + 1);
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 6692
n = int(input())
l = list(map(int,input().split()))

if n == 1:
    l = list(map(str,l))
    print(" ".join(l))
    exit()
2

ans = []

if n%2 == 0:
    tmp = n
    for j in range(n//2-1):
        ans.append(tmp)
        tmp -= 2
    ans.append(tmp)
    ans.append(1)
    tmp = 1
    for j in range(n//2-1):
        tmp += 2
        ans.append(tmp)
else:
    tmp = n
    for j in range(n//2):
        ans.append(tmp)
        tmp -= 2
    ans.append(tmp)
    tmp = 2
    for j in range(n//2):
        ans.append(tmp)
        tmp += 2

ans2 = [0]*n
cnt = 0
for i in ans:
    ans2[cnt] = str(l[i-1])
    cnt += 1


print(" ".join(ans2))

Measured memory_bytes: 42908
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
X = list(map(int, input().split()))
XX = sorted(X)
a = XX[N // 2]
b = XX[N // 2 - 1]
for i in range(N):
    if X[i] <= b:
        print(a)
    else:
        print(b)

Measured memory_bytes: 29132
int a[200010];
 int ans[200010];
 int main(){
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)scanf("%d",&a[i]);
 for(int i=2;i<=n;i++)ans[a[i]]++;
 for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 }

Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
vector<pair<ll, ll> > AB;

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second == b.second){
        return a.first < b.first;
    }else{
        return a.second <b.second;
    }
}

int main(void){
    // Your code here!
    cin >> N;
    ll sum = 0;
    ll a, b;
    for(int i = 0; i < N; i++) {
        cin >> a >> b;
        AB.push_back(make_pair(a, b));
    }
    
    bool flag = true;
    sort(AB.begin(), AB.end(), compare_by_b);
    for(int i = 0; i < N; i++){
        sum += AB[i].first;
        if(sum > AB[i].second) flag = false;
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 6384
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char> > c(h,vector<char>(w));
  
  vector<vector<int> > m(h,vector<int>(w));
  rep(i,h)rep(j,w){
    cin>>c[i][j];
    m[i][j] = c[i][j] - '0';
  }
  loop(i,1,w){
    m[0][i] = m[0][i-1] + m[0][i];
  }
  loop(i,1,h){
    m[i][0] = m[i-1][0] + m[i][0];
  }
  
  loop(i,1,h){
    loop(j,1,w){
      m[i][j] = min(m[i-1][j],m[i][j-1]) + m[i][j];
    }
  }
  cout<<m[--h][--w]<<endl;
  

}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010,mod=998244353;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,m,lim,wsum,e[15][15],f[1<<15][15],tot[1<<15];
inline void chkmax(int &x,int y){if(x<y) x=y;}
int main(){
	n=read();m=read();lim=1<<n;
	FOR(i,1,m){
		int u=read()-1,v=read()-1;
		wsum+=e[u][v]=e[v][u]=read();
	}
	FOR(i,0,lim-1) FOR(j,0,n-1) if((i>>j)&1) FOR(k,j+1,n-1) if((i>>k)&1) tot[i]+=e[j][k];
	MEM(f,~0x3f);
	f[1][0]=0;
	FOR(i,1,lim-1) FOR(j,0,n-1) if((i>>j)&1){
		FOR(k,0,n-1) if(!((i>>k)&1) && e[j][k]) chkmax(f[i|(1<<k)][k],f[i][j]+e[j][k]);
		int re=(lim-1)^i;
		for(int k=re;k;k=((k-1)&re)) chkmax(f[i|k][j],f[i][j]+tot[k|(1<<j)]);
	}
	printf("%d\n",wsum-f[lim-1][n-1]);
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b));
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i <= n/4; i++ {
		for j := 0; j <= n/7; j++ {
			if i*4+j*7 == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    string s;cin>>s;
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',ans=0;

    if(a==b){
        if(b>=c){
            ans=a;
        }
        else {
            ans=a+1;
        }
    }
    else if (a<b) {
        ans=a+1;
    }
    else {
        ans=a;
    }

    rep(i,3){
        cout<<ans;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

char t[256];

int main(){
	int n;
	while(cin>>n,n){
		FOR(i,256) t[i] = i;
		FOR(i,n){ 
			char a,b; scanf(" %c %c",&a,&b);
			t[a] = b;
		}
		int m; cin>>m;
		FOR(i,m){
			char c;
			scanf(" %c",&c);
			putchar(t[c]);
		}
		puts("");
	}
    return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int N; cin >> N;
    vector<int> v;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        v.push_back(a);
    }
    int cnt = 0;
    for(int i = 0; i <= N-1; i++){
        int minV = i;
        for(int j = i; j <= N-1; j++){
            if(v[j] < v[minV]){
                minV = j;
            }
        }
        if(v[i] > v[minV]){   
           swap(v[i], v[minV]);
           cnt++;
           }
    }
    for(int i = 0; i < N; i++){
        if(i == N-1){
            cout << v[i] << endl;
            break;
        }
        cout << v[i] << " ";
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include<map>
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
 
using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    string S;
    cin >> S;
    bool flag = true;
    REP(i,S.length()-1){
        if (S[i] == S[i + 1])
        {
            flag = false;break;
        }
    }
    if(flag) fin("Good");
    else fin("Bad");
    return 0;
}

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

int main() {
    string s;
    int K;
    cin >> s >> K;

    int slen = s.length();
    set<string> st;
    for(int i = 0; i < slen; ++i) {
        string tmp;
        for(int j = 0; i + j < slen && j < K; ++j) {
            tmp += s[i + j];
            st.insert(tmp);
            if(st.size() > K) {
                auto itr = st.end();
                itr--;
                st.erase(itr);
            }
        }
    }
    auto itr = st.end();
    itr--;
    cout << *itr << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<vector>
#include<utility>
#define INF 0x3f3f3f3f3f3f3f3f
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'

using namespace std;
typedef long long ll;
const int maxn = 4e3 + 10;
vector<int>R, G, B;

int main() {
	int n;cin >> n;
	string s;cin >> s;
	ll ans = 0;
	for (int i = 0;i < n;++i) {
		if (s[i] == 'R')R.push_back(i);
		else if (s[i] == 'G')G.push_back(i);
		else B.push_back(i);
	}
	int r = R.size();
	int g = G.size();
	int b = B.size();

	for (int i = 0;i < r;++i) {
		for (int j = 0;j < g;++j) {
			ans += b;
			int d = abs(R[i] - G[j]);
			int minn = min(R[i], G[j]);
			int maxx = max(R[i], G[j]);
			
			if (minn - d >= 0 && s[minn - d] == 'B')--ans;
			if (maxx + d < n && s[maxx + d] == 'B')--ans;
			if ((R[i] + G[j]) % 2 == 0 && s[minn + d / 2] == 'B')--ans;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

typedef pair<int,int> PA;
typedef pair<int,PA> PPA;

int po[100010]={};
int sa[100010]={};
priority_queue<PA> pq;
vector<PPA> vec;

int main(){
  
  int n,r,l,d,t,x;
  
  cin >> n >> r >> l;
  
  for(int i=0;i<r;i++){
    cin >> d >> t >> x;  
    vec.push_back(PPA(t,PA(x,d)));
  }
  
  vec.push_back(PPA(l,PA(0,0)));
  sort(vec.begin(),vec.end());
  
  for(int i=1;i<=n;i++){
    pq.push(PA(0,-i));
  }  

  int in;
  PA p;
  
  sa[1] = vec[0].first;

  for(int i=0;i<r;i++){
    
    int dif = abs(vec[i].first - vec[i+1].first);
    
    p = vec[i].second;
    int next_x = p.first;
    int next_d = p.second;
    po[next_d] += next_x;
    pq.push( PA(po[next_d],-next_d) );
    
    while(!pq.empty()){
      p = pq.top();
      if(po[-p.second] != p.first) pq.pop();
      else break;
    }
    
    p = pq.top();
    sa[-p.second] += dif;
    
  }

  int ans = 1;
  for(int i=1;i<=n;i++){
    if(sa[ans] < sa[i]) ans = i;
  }

  cout << ans << endl;

  return(0);
}



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

const double PI = acos(-1);

unsigned long long GetDigit(unsigned long long num){
    return std::to_string(num).length();
}

int main()
{
	int n,a,b; cin >> n >> a >> b;
	int i = 1;
	int tmp1,tmp2,tmp3,tmp4,tmp,ans=0;
	while(i<=n) {

		tmp1 = i/10000;
		tmp2 = (i-tmp1*10000)/1000;
		tmp3 = (i-tmp1*10000-tmp2*1000)/100;
		tmp4 = (i-tmp1*10000-tmp2*1000-tmp3*100)/10;

		tmp = tmp1+tmp2+tmp3+tmp4+ i%10;

		if(tmp>=a && tmp<=b) {
 			ans += i;
		}
		i++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3620
let () =
  let n = read_int () in
  let rec loop mv md = function
      0 -> md
    | i ->
      let v = read_int () in
      let d = v - mv in
      loop (if v < mv then v else mv) (if d > md then d else md) (i-1)
  in
  let x = loop (read_int ()) min_int (n-1) in
  Printf.printf "%d\n" x

Measured memory_bytes: 4396
from bisect import bisect
N = int(input())
S = input()
A = [[] for i in range(10)]
for i in range(N):
    s = S[i]
    A[int(s)].append(i)
for i in range(10):A[i].append(float("inf"))
ans = 0
for i in range(1000):
    s = str(i).zfill(3)
    a = A[int(s[0])][0]
    if a==float("inf"):continue
    b = A[int(s[1])][bisect(A[int(s[1])],a)]
    if b==float("inf"):continue
    c = A[int(s[2])][bisect(A[int(s[2])],b)]
    if c==float("inf"):continue
    ans+=1
print(ans)

Measured memory_bytes: 4456
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define lli unsigned long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define pint pair<int,int>
#define setit set<int>::iterator seti
#define mapit map<int,int> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)
{   int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

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

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    lli t, i, j, n,  x;
    cin >> n;
    lli a[n];
    x = 1;
    for (i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << "0";
            return 0;
        }
    }
    for (i = 0; i < n; i++) {
        //    x = x * a[i];
        if (a[i] <= 1000000000000000000 / x) {
            x = x * a[i];
        }
        else {
            cout << "-1";
            return 0;
        }
    }
    cout << x;
}

Measured memory_bytes: 4440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  ll K;
  cin>>N>>K;
  VI A(N),F(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>F[i];
  sort(all(A));
  sort(all(F));
  ll ok=1ll<<60,ng=-1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll X=1,sum=0;
    rep(i,N) if(A[i]>=mid/F[N-1-i]) sum+=(A[i]-mid/F[N-1-i]);
    if(sum>K) X=0;
    if(X) ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<u32>();
    let b = read::<u32>();
    let c = read::<u32>();
    let ans = if (a != b) && (a != c) && (b != c) {
        "No"
    } else if (a != b) || (a != c) || (b != c) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
typedef long long ll;
ll A[7],B[7];

int main(){
	for(int i=0;i<7;i++){
		cin >> A[i];
		B[i] = A[i];
	}
	ll ans = 0,ans2 = 0;
	if(A[0]>=1 && A[3]>=1 && A[4]>=1){
		ans += 6;
		A[0]--;
		A[3]--;
		A[4]--;
		ans += A[1]*2;
		ans += (A[0]/2)*4;
		ans += (A[3]/2+A[4]/2)*4;
		A[0] -= A[0]/2;
		A[3] -= A[3]/2;
		A[4] -= A[4]/2;
	}
	ans2 += B[1]*2;
	ans2 += (B[0]/2)*4;
	ans2 += (B[3]/2+B[4]/2)*4;
	cout << max(ans,ans2)/2 << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

int tax(int value, int tax){
    double tmp = double(value)*(100+tax)/100;
    return int(floor(tmp));
}

int retax(int price,int tax){
    double tmp = 100*double(price)/(100+tax);
    return int(ceil(tmp));
}

int soleve(int x,int y,int z){
    int tmp = retax(z,x);
    vector<Pii> p;
    for(int i = 1;i<=z;i++){
        int sum = tax(i,x);
        Pii pi(i,retax(z-sum,x));
        if(pi.second <= 0) continue;
        if(tax(pi.first,x)+tax(pi.second,x)!=z) continue;
        p.push_back(pi);
    }

    int maxp=0;
    rep(i,p.size()){
        int cv = tax(p[i].first,y) + tax(p[i].second,y);
        maxp = max(maxp,cv);
        // if(maxp == 26){
        //     cout<< p[i].first << " " << p[i].second << endl; 
        // }
    }
    return maxp;
}


int main() {
    int x=1,y=1,z=1;
    vector<int> a;
    while(x){
        cin >> x >> y >> z;
        if(x==0)return 0;
        cout << soleve(x,y,z) << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
mod=998244353
n,k=map(int,input().split())
l,r=[0]*k,[0]*k
for i in range(k):
  l[i],r[i]=map(int,input().split())
dp=[0]*(n+1)
sumdp=[0]*(n+1)
dp[1]=1
sumdp[1]=1
for i in range(2,n+1):
  for j in range(k):
    lj=max(i-r[j],0)
    rj=max(i-l[j],0)
    dp[i]+=sumdp[rj]-sumdp[lj-1]
    dp[i]%=mod
  sumdp[i]=sumdp[i-1]+dp[i]
  sumdp[i]%=mod
print(dp[n])

Measured memory_bytes: 77092
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


ll n, m;

int main()
{
	cin >> n >> m;
	ll ans = 0;
	ll tmp, tmps, tmpc;

	tmp = 0; tmps = n; tmpc = m;
	tmp += tmpc / 4;
	tmpc %= 4;
	tmp += min(tmps, tmpc / 2);
	chmax(ans, tmp);

	tmp = 0; tmps = n; tmpc = m;
	ll p = min(tmps, tmpc / 2);
	tmp += p;
	tmpc -= p * 2;
	tmp += tmpc / 4;
	chmax(ans, tmp);

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
  ll k; cin >> k;
  ll L = 9*k;
  if(k%7==0) L/=7;

  if(L%2==0 || L%5==0){
      cout << "-1\n";
  }else{
    ll ans=1;
    for(int i=1; i<1e6; i++){
      ans *= 10;
      ans %= L;
      if(ans==1){
          cout << i << "\n";
          break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3552
#include<stdio.h>
int search(int *,int,int);
int main(){
  int i,j,n,q,num=0;
  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    num += search(S,T[i],n);
  }
  printf("%d\n",num);
  return 0;
}

int search(int *S,int key,int n){
  int left=0,right=n,mid;
  while(left<right){
    mid = (left + right)/2;
      if(S[mid] == key){
	return 1;
      }
      else if(key < S[mid]) right = mid;
      else left = mid +1;
  }
  return 0;
}


Measured memory_bytes: 2320
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  long a, b, c, d, x, y;
  long ac, ad, bc, bd;
  cin >> a >> b >> c >> d;
  
  ac = a * c;
  ad = a * d;
  bc = b * c;
  bd = b * d;
  
  if(ac >= ad){
    if(ac >= bc){
      if(ac >= bd){
        cout << ac << endl;
      }else{
        cout << bd << endl;
      }
    }if(ac < bc){
      if(bc >= bd){
        cout << bc << endl;
      }else{
        cout << bd << endl;
      }
    }
  }if(ac < ad){
    if(ad >= bc){
      if(ad >= bd){
        cout << ad << endl;
      }else{
        cout << bd << endl;
      }
    }if(ad < bc){
      if(bc >= bd){
        cout << bc << endl;
      }else{
        cout << bd << endl;
      }
    }
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    string  a,b;
    cin>>a>>b;
  if(a.size()>b.size()){
      cout<<"GREATER"<<endl;
  }
  else if(a.size()<b.size()){
      cout<<"LESS"<<endl;
  }
  else if(a[0]>b[0]){
      cout<<"GREATER"<<endl;
  
  }
  else if(a[0]<b[0]){
      cout<<"LESS"<<endl;
  }
  else cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
line = input().rstrip().split()
import math
a = int(line[0])
b = int(line[1])

t_angle = (int(line[2]) + int(line[3])/60) /12 
m_angle = int(line[3])/60
angle = 2*(t_angle - m_angle) * math.pi


answer = math.sqrt(a**2 + b**2 - 2*a*b*(math.cos(angle)))

print(answer)


Measured memory_bytes: 9464
#include <cstdio>
#include <cstring>
#include <algorithm>
const int MOD = 998244353;
const int MAXN = 5e5 + 10;

int n, m;
namespace {
  inline int add(int x) { return x >= MOD ? x - MOD : x; }
  inline int sub(int x) { return x < 0 ? x + MOD : x; }
  inline int mul(int x, int y) { return 1ll * x * y % MOD; }
  inline int pwr(int x, int y) {
    int ans = 1;
    for (; y; y >>= 1, x = mul(x, x)) {
      if (y & 1) ans = mul(ans, x);
    }
    return ans;
  }
}
int fact[MAXN << 1], invf[MAXN << 1];
int choose(int x, int y) {
  return x < y ? 0 : mul(fact[x], mul(invf[y], invf[x - y]));
}
int main() {
  scanf("%d%d", &n, &m);
  fact[0] = 1, invf[0] = 1;
  if (n < m) std::swap(n, m);
  for (int i = 1; i <= 2 * n; i++) {
    fact[i] = mul(fact[i - 1], i);
    invf[i] = pwr(fact[i], MOD - 2);
  }

  int ans = 0;
  for (int i = 1; i <= m; i++) {
    ans = add(ans + mul(choose(2 * i - 1, i), choose(n + m - 2 * i, n - i)));
  }
  printf("%d\n", add(n + mul(ans, pwr(choose(n + m, n), MOD - 2))));
}


Measured memory_bytes: 7936
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <ctime>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;

int mod = 1000000007;

int a[100100];

int main() {
    ios::sync_with_stdio(false);
    long long x, y;
    cin >> x >> y;
    int ans = 0;
    while (x <= y) {
        x *= 2;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) cout << c << endl;
  else if (a == c) cout << b << endl;
  else cout << a << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

struct point{
  double x,y;
};


void koch(int n,struct point a,struct point b){
  struct point s,t,u;
  double th=M_PI*60.0/180.0;
    
  if(n==0)return;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  struct point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}
  



Measured memory_bytes: 2108
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;


int main() {
	int k;
	cin >> k;
	rep(i, 0, k)cout << "ACL";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>

int main(void)  {
  int n;
  scanf("%d",&n);
  int N = n;
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  if (N % sum == 0) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

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

int main(){
    int N,a[100000],b[100000],ans;
    cin >> N;
    for (int i=0; i<N; ++i) cin >> a[i];
    b[0]=1;
    bool X =false;
    for (int i=0; i<N; ++i){
        b[i+1]=a[b[i]-1];
        if (b[i]==2){
             ans=i;
             X=true;
             break;
        }
    }
    if (X) cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 1024