akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows: g++ p1.cpp -op1
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)


int main()
{
   
        io;
        //////////////////////////////////
        cs1{
             ll i,j,k,l,s=0,p=INT_MAX,n,m,q=0,e;
             cin>>n;
             vll v(n),dp(n);
             for(i=0;i<n;i++){cin>>v[i];dp[i]=s;s=s+v[i];}
             for(i=0;i<n;i++){
                 q=(q+((dp[i])%mod)*(v[i]%mod))%mod;
             }
             cout<<q nl;
        }
        //////////////////////////////////
 
}

Measured memory_bytes: 6364
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n, d;
    cin >> n >> d;

    vi arr(n);
    for (auto &it : arr) {
        cin >> it;
    }

    vi pre(n);
    pre[0] = d;

    for (int i = 1; i < n; i++) {
        pre[i] = min(pre[i - 1], llabs(pre[i - 1] - arr[i - 1]));
    }

    vi mini(n);
    mini[n - 1] = 1;

    for (int i = n - 2; i >= 0; i--) {
        if (llabs(mini[i + 1] - arr[i + 1]) >= mini[i + 1]) {
            mini[i] = mini[i + 1];
        } else {
            mini[i] = mini[i + 1] + arr[i + 1];
        }
    }

    ll q;
    cin >> q;
    while (q--) {
        ll x;
        cin >> x;
        x--;

        if (pre[x] >= mini[x]) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }
    }
}


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

int main() {
	int n;
	set<string> s;
	cin >> n;
	rep(i, n) {
		string si;
		cin >> si;
		s.insert(si);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 19228
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    string s; int K;
    cin >> s >> K;

    priority_queue<string, vector<string>, greater<string> > res;

    set<string> sss;

    REP(i, s.size()){
        REP(j, 6){
            string tmp = s.substr(i, j);
            if( tmp.size() == 0 ) continue;
            sss.insert(tmp);
        }
    }

    for(auto i : sss)
    res.push(i);

    int k = 1;
    while (!res.empty()){
        string a = res.top(); res.pop();
//        cout << k << " " << a << endl;
        if (k == K){
            cout << a << endl;
            break;
        }
        k++;
    }

    return 0;
}


Measured memory_bytes: 1920
import std.stdio;
import std.ascii;

void main() {
    int sum = 0;

    foreach (string input; stdin.lines) {
        auto num = 0;

        foreach (c; input) {
            if (c.isDigit) {
                num = (num * 10) + (c - '0');
            } else {
                sum += num;
                num = 0;
            }
        }
    }

    writeln(sum);
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
bool compare_by_b(pair<unsigned, long long> a, pair<unsigned, long long> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main()
{
	vector<pair<unsigned long long, unsigned long long>> work;
	unsigned long long N, time = 0;
	cin >> N;
	bool check = true;
	unsigned long long a, b;
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		work.push_back(make_pair(a, b));
	}
	sort(work.begin(), work.end());
	sort(work.begin(), work.end(), compare_by_b);

	for (int t = 0; t < N; t++) {
		time += work[t].first;
		if (time > work[t].second){
			check = false;
		}
	}

	if (check) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


Measured memory_bytes: 6512
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    string a;
    int i, j, o;

    cin >> a;
    for(i = o = 0, j = (signed)a.size() - 1; i < j; i ++, j --)
        o += a[i] != a[j];
    cout << o << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VLL A(N);
    ll maxi=0;
    rep(i,N){
        cin >> A[i];
        maxi=max(maxi, A[i]);
    }
    ll ni=maxi/2;
    ll mini=INF;
    ll key=0;
    rep(i,N){
        if(mini>=abs(ni-A[i])){
            if(abs(maxi-A[i]*2)<=abs(maxi-(key*2))){
                mini=abs(ni-A[i]);
                key=A[i];
            }
        }
    }
    cout << maxi << " " << key << endl;
}

Measured memory_bytes: 3948
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m, p, x;
		int[] t = new int[100];
		n = sc.nextInt();
		int[] xdiff = new int[100];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			p = sc.nextInt();
			x = sc.nextInt();
			xdiff[i] = t[p-1] - x;
			//System.out.println(t[p-1] + "-" + x);
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += t[i];
		}
		for (int i = 0; i < m; i++) {
			int result = sum - xdiff[i];
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 23124
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=998244353,N=405;
int n,fac[N],inv[N],pw[N][N],sa,sb,ans,a[N],b[N],f[N][N];

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod;
	return res;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i],b[i]),sa+=a[i],sb+=b[i];
	fac[0]=1;for(int i=1;i<=sb;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[sb]=fpow(fac[sb],mod-2);for(int i=sb-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(int i=1;i<=n;i++){
		pw[i][0]=1;
		for(int j=1;j<=b[i];j++) pw[i][j]=1ll*pw[i][j-1]*a[i]%mod;
	}
	f[0][0]=mod-1;
	for(int i=1;i<=n;i++)
		for(int j=sa;j>=a[i];j--) for(int k=sb;~k;k--)
			for(int l=0;l<=k&&l<b[i];l++)
				f[j][k]=(f[j][k]+1ll*(mod-f[j-a[i]][k-l])*pw[i][l]%mod*inv[l]%mod+mod)%mod;
	for(int i=1;i<=sa;i++) for(int j=0;j<=sb;j++) ans=(ans+1ll*f[i][j]*fac[j]%mod*fpow(i,1ll*(j+1)*(mod-2)%(mod-1))%mod)%mod;
	write(1ll*ans*sa%mod);
}

Measured memory_bytes: 4852
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

D = {}

for a in A:
    if not a in D:
        D[a] = 1
    else:
        D[a] += 1

list = list(D.items())

list = sorted(list, key=lambda x: x[1])

count = 0

l = len(list) - K
i = 0
while (l >= 1):
    count += list[i][1]
    i += 1
    l -= 1

print(count)

Measured memory_bytes: 41600
/*input
5 3 7
1
3
6
9
12
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 100005
// const int INF = 1e18;
const int mod = 1e9 + 7;
#define c(x) ((x)&1)
int n, A, B;
int a[N];
vector<int> updx, updy;
int Tx = 0, Ty = 0;

struct BITsum {
	int tree[N];
	int cur[N];
	BITsum() {
		memset(tree, 0, sizeof(tree));
	}
	void upd(int p, int val) {
		p++; val %= mod;
		int org = cur[p];
		for (int i = p; i <= N - 2; i += i & -i) tree[i] -= org, tree[i] = ((tree[i] % mod) + mod) % mod;
		cur[p] = val;
		for (int i = p; i <= N - 2; i += i & -i) tree[i] += val, tree[i] %= mod;
	}
	void plus(int i, int val) {
		i++;
		cur[i] += val; cur[i] %= mod;
		for (; i <= N - 2; i += i & -i) tree[i] += val, tree[i] %= mod;
	}
	int get(int i) {
		i++;
		int ret = 0;
		for (; i; i -= i & -i) ret += tree[i], ret %= mod;
		return ret;
	}
} dpx, dpy;

void solve1(int i) {
	int l = 0, r = i - 1;
	while (l != r) {
		int mid = (l + r + 1) / 2;
		if (a[i + 1] - a[mid] < B) r = mid - 1;
		else l = mid;
	}
	Ty = dpx.get(l),
	updy.push_back(i);
	if (a[i + 1] - a[i] < A) {
		for (int i = 0; i < updx.size(); i++) dpx.upd(updx[i], 0);
		updx.clear();
	}
}

void solve2(int i) {
	int l = 0, r = i - 1;
	while (l != r) {
		int mid = (l + r + 1) / 2;
		if (a[i + 1] - a[mid] < A) r = mid - 1;
		else l = mid;
	}
	Tx = dpy.get(l);
	updx.push_back(i);
	if (a[i + 1] - a[i] < B) {
		for (int i = 0; i < updy.size(); i++) dpy.upd(updy[i], 0);
		updy.clear();
	}
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0] = -1e18 - 5;
	updx.push_back(0); updy.push_back(0);
	dpx.upd(0, 1);
	dpy.upd(0, 1);
	for (int i = 1; i < n; i++) {
		solve1(i);
		solve2(i);
		dpx.upd(i, Tx);
		dpy.upd(i, Ty);
		Tx = 0; Ty = 0;
		updy.push_back(i); updx.push_back(i);
	}
	int ans = dpx.get(N - 2) + dpy.get(N - 2);
	ans %= mod;
	cout << ans << endl;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n;
    int c4 = 0, c2 = 0, c = 0;
    cin >> n;
    rep(i, 0, n) {
        int x;
        cin >> x;
        if (x % 4 == 0) {++c4; continue;}
        if (x % 2 == 0) {++c2; continue;}
        ++c;
    }
    int d = min(c4, c);
    c4 -= d;
    c -= d;
    if (c > 1) {cout << "No\n"; return 0;}
    if (c == 1 && c2 > 0) {cout << "No\n"; return 0;}
    cout << "Yes\n";
}

Measured memory_bytes: 256
import java.io.*;
 
class Main {
    public static void main(String[] arg)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] div = str.split(" ");
        int s =  Integer.parseInt(div[0]);
        int l =  Integer.parseInt(div[1]);
        System.out.println(s*l + " "+ 2*(s+l));
    }   
}

Measured memory_bytes: 24196
#!/usr/bin/env python3
from collections import deque


def main():
    H, W = map(int, input().split())
    S = [None for _ in range(H)]
    for i in range(H):
        S[i] = input()

    adj = [[] for _ in range(H * W)]
    dx = [1, -1, 0, 0]
    dy = [0, 0, 1, -1]

    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                for k in range(4):
                    y = i + dy[k]
                    x = j + dx[k]
                    if 0 <= y < H and 0 <= x < W:
                        if S[y][x] == '.':
                            adj[W*i + j].append(W*y + x)

    # スタート
    ans = 0
    for i in range(H*W):
        queue = deque([i])
        visit = [-1] * (H * W)
        visit[i] = 0

        while queue:
            now = queue.popleft()
            for u in adj[now]:
                if visit[u] < 0:
                    queue.append(u)
                    visit[u] = visit[now] + 1
        ans = max(ans, max(visit))
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
int N,L;
int sum;
cin >> N >> L;
for(int i = 1; i <= N; i++){
  sum += L-1+i;
}
if(L <= 0 && L >=1-N){
  
  cout << sum << endl;
}else if(L > 0){
  
  cout << sum -L << endl;
}else if(L < 1-N){
  
  cout << sum-L-N+1 << endl;
}

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++)
  {
    cin >> X[i];
  }

  if (N >= M)
  {
    cout << 0 << endl;
    return 0;
  }
  
  sort(X.begin(), X.end());
  vector<int> dist(M - 1);
  for (int i = 0; i < M - 1; i++)
  {
    dist[i] = X[i + 1] - X[i];
    // cerr << dist[i] << endl;
  }
  sort(dist.rbegin(), dist.rend());

  
  int ans = X[M - 1] - X[0];
  // cerr << "ans=" << ans << endl;
  for (int i = 0; i < N - 1; i++)
  {
    // cerr << "dist[" << i << "]=" << dist[i] << endl;
    ans -= dist[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 2e5 + 100;
int v[MX], mn[MX], nxt[MX], ptr[MX], pass[MX];
void dfs(int p, int t, int k, int n) {
    if(pass[p] and t < k) {
        t += (k - t) / (t - pass[p]) * (t - pass[p]);
        memset(pass, 0, sizeof(pass));
    }
    pass[p] = t;
    if(t > k) return;
    if(t == k) {
        vector<int> que; set<int> s;
        for(int i = p; i < n; i ++) {
            if(s.count(v[i])) {
                while(s.count(v[i])) {
                    s.erase(que.back());
                    que.pop_back();
                }
            }
            else {
                que.push_back(v[i]);
                s.insert(v[i]);
            }
        }
        for(auto it: que) cout << it << ' ';
        return;
    }
    if(ptr[p] == p and p == n - 1) dfs((ptr[p] + 1) % n, t + 2, k, n);
    else                           dfs((ptr[p] + 1) % n, t + 1, k, n);
}
main() {
    for(int i = 0; i < MX; i ++) mn[i] = MX;
    int n, k; cin >> n >> k;
    for(int i = 0; i < n; i ++) cin >> v[i];
    for(int i = 0; i < n; i ++) mn[v[i]] = min(mn[v[i]], i);
    for(int i = n - 1; i >= 0; i --) {
        if(nxt[v[i]]) ptr[i] = nxt[v[i]];
        else          ptr[i] = mn [v[i]];
        nxt[v[i]] = i;
    }
    for(int i = n - 1; i >= 0; i --) {
        if((ptr[i] + 1) % n > i and ptr[i] != i) {
            ptr[i] = ptr[(ptr[i] + 1) % n];
        }
    }
    dfs(0, 1, k, n);
}

Measured memory_bytes: 66676
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}



int main(){
    LL X,Y;
    cin >> X >> Y;
    LL count=1;
    LL res=X;
    while(res*2<=Y){
        res=res*2;
        ++count;
    }
    cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int n;
    cin >> n;
    vector<ll> L(n);
    for(int i = 0; i < n; i++){
        cin >> L[i];
    }

    int ans = 0;
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            for(int k = j + 1; k < n; k++){
                if(L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
                    if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[i] + L[k] > L[j]){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    ll x;
    cin>>x;

    ll ans=0;
    ll tmp=100;
    while(1){
        tmp+=tmp*0.01;
        ans++;
        if(tmp>=x){
            cout<<ans<<endl;
            return 0;
        }

    }
    
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX_N 102

int a[MAX_N];

void dump(int n)
{
	int i;

	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;

	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}


Measured memory_bytes: 2080
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int N = Integer.parseInt(sc.next());
    	int K = Integer.parseInt(sc.next());
    	int[] NG = new int[10];
    	int d;
    	for (int i = 0; i < K; i++) {
        	d = Integer.parseInt(sc.next());
			NG[d] = 1;
		}
    	int ans = 999999, wk, sv1, sv2, sv3, sv4, sv5;
    	for (int i1 = 0; i1 < 10; i1++) {
    		if(NG[i1] == 1)	continue;
    		wk = i1;
    		if(wk >= N && wk < ans)	{ ans = wk; break; }
    		sv2 = wk;
    		for (int i2 = 0; i2 < 10; i2++) {
    			wk = sv2;
        		if(NG[i2] == 1)	continue;
        		wk += i2*10;
        		if(wk >= N && wk < ans)	{ ans = wk; break; };
        		sv3 = wk;
            	for (int i3 = 0; i3 < 10; i3++) {
        			wk = sv3;
            		if(NG[i3] == 1)	continue;
            		wk += i3*100;
            		if(wk >= N && wk < ans)	{ ans = wk; break; }
            		sv4 = wk;
                	for (int i4 = 0; i4 < 10; i4++) {
            			wk = sv4;
                		if(NG[i4] == 1)	continue;
                		wk += i4*1000;
                		if(wk >= N && wk < ans)	{ ans = wk; break; }
                		sv5 = wk;
                    	for (int i5 = 0; i5 < 10; i5++) {
                			wk = sv5;
                    		if(NG[i5] == 1)	continue;
                    		wk += i5*10000;
                    		if(wk >= N && wk < ans)	{ ans = wk; break; }
                    	}
                	}
            	}
    		}
    	}
    	out.println(ans);
    }
}



Measured memory_bytes: 21844
loop {
	n, k = gets.split.map &:to_i
	break if n == 0
	a = (1..k).map { gets.to_i }.sort
	wild_card = false
	if a[0] == 0
		wild_card = true
		a.shift
	end
	chunks = [[a[0], 1]]
	a[1..-1].each{|x|
		if x == chunks[-1][0] + chunks[-1][1]
			chunks[-1][1] += 1
		else
			chunks << [x, 1]
		end
	}
	if wild_card
		max = chunks.map(&:last).max + 1
		chunks.each_cons(2){|c1, c2|
			if c1[0] + c1[1] + 1 == c2[0]
				m = c1[1] + c2[1] + 1
				max = m if m > max
			end
		}
		p max
	else
		p chunks.map(&:last).max
	end
}

Measured memory_bytes: 7996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

int h1, m1, h2, m2, k;
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int x = (h2 - h1) * 60 + m2 - m1;
    cout << x - k;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
  public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	String s = sc.next();
    	if(a < 3200)
    		System.out.println("red");
    	else 
    		System.out.println(s);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;


typedef vector<vector<int>> Graph;

Graph G;
unordered_map<int, unordered_map<int, int>> W;
vector<int> d;

void dfs(int node, int parent) {
    if (parent < 0) {
        d[node] = 0;
    }
    else if (W[parent][node] % 2 == 0) {
        d[node] = d[parent];
    }
    else {
        d[node] = 1 - d[parent];
    }

    for (int to: G[node]) {
        if (to == parent) continue;
        dfs(to, node);
    }
}

void Main()
{
    ll n;
    cin >> n;

    vector<ll> u(n-1), v(n-1), w(n-1);
    rep(i, n-1) cin >> u[i] >> v[i] >> w[i];
    
    G.assign(n, vector<int>());
    rep(i, n) W[i] = unordered_map<int, int>();
    d.assign(n, 0);
    rep(i, n - 1) {
        G[u[i] - 1].push_back(v[i] - 1);
        G[v[i] - 1].push_back(u[i] - 1);
        W[u[i] - 1][v[i] - 1] = w[i];
        W[v[i] - 1][u[i] - 1] = w[i];
    }

    dfs(0, -1);

    rep(i, n) {
        put(d[i]);
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 31636
<?php

while (true) {
    fscanf(STDIN, '%d %d', $n, $x);
    if (isEnd($n, $x)) { break; };

    $count = 0;
    for ($i = 1; $i < ($x / 3); $i++) {
        for ($j = $i + 1; $j < (($x - $i) / 2); $j++) {
            $remainder = $x - ($i + $j);
            if ($n < $remainder || $remainder <= $j) { continue; }

            $count++;
        }
    }
    $result[] = $count;
}

echo implode(PHP_EOL, $result), PHP_EOL;

function isEnd($n, $x)
{
    return !($n || $x);
}

Measured memory_bytes: 6612
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

void printa(int a){
  printf("%c\n",a+'A');
}

void hand(vector<int>& v,const vector<int>& q,int& i){
  int n=q.size();
  int k=q[i],a1=(k+1)%3,a2=(k+2)%3;
  if(v[a1] < v[a2])swap(a1,a2);  // v[a1] >= v[a2]
  if(not (v[a1]>=v[a2])) while(1) print("TLE19");
  if(i==n-1) v[k]++;
  if(v[k]>0 or v[a1]>=2){
    printa(a2);
    v[a1]--; v[a2]++;
    return;
  }
  // v[k]==0, i!=n-1
  if(not (v[k]==0 and i!=n-1)) while(1) print("TLE27");
  if(q[i]==q[i+1]){
    printa(a1);
    printa(a2);
    i++;
    return;
  }
  int a=3-k-q[i+1];
  printa(a);
  printa(k);
  v[k]++;
  v[q[i+1]]--;
  i++;
  return;
}

int main(){
  vector<int> v(3);
  li n; cin >>n;
  rep(i,3){
    cin >>v[i]; chmin(v[i],2);
  }
  vector<int>  q(n);
  rep(i,n){
    string s; cin >>s;
    q[i]=3-(s[0]-'A')-(s[1]-'A');
  }

  int f=(!v[0])+(!v[1])+(!v[2]);  // 0の数
  if(f==3){  // all 0
    if(not (v[0]==0 and v[1]==0 and v[2] == 0)) while(1) print("TLE57");
    print("No");
    return 0;
  }
  if(f==2 and v[q[0]]>0){
    print("No");
    return 0;
  }
  if(f<2 or v[0]+v[1]+v[2]>=2){
    print("Yes");
    rep(i,n){
      hand(v,q,i);
    }
    return 0;
  }
  
  // 0が2つ v[0]+v[1]+v[2]==1
  if(not (v[0]+v[1]+v[2]==1)) while(1) print("TLE74");
  vector<int> ans;
  rep(i,n){
    int k=q[i],a1=(k+1)%3,a2=(k+2)%3;    
    if(v[a1] < v[a2])swap(a1,a2);  // v[a1] >= v[a2]
    if(v[a1]==0){
      print("No");
      return 0;
    } 
    ans.push_back(a2);
    v[a1]--; v[a2]++;
  }
  print("Yes");
  rep(i,n) printa(ans[i]);
    

}


Measured memory_bytes: 4280
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<queue<int>> Q(N + 1);
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N - 1; j++){
			int A;
			cin >> A;
			A--;
			Q[i].push(A);
		}
		Q[i].push(N);
	}
	Q[N].push(N);
	int ans = 0;
	int cnt = N * (N - 1);
	bool ok = true;
	vector<int> upd;
	for (int i = 0; i < N; i++){
		upd.push_back(i);
	}
	while (cnt > 0){
		ans++;
		vector<int> upd2;	
		for (int i : upd){
			if (Q[Q[i].front()].front() == i && Q[i].front() > i){
				upd2.push_back(i);
				upd2.push_back(Q[i].front());
			}
		}
		for (int i : upd2){
			Q[i].pop();
			cnt--;
		}
		if (upd2.empty()){
			ok = false;
			break;
		}
	}
	if (!ok){
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 8000
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = a;
	if (a%b == 0){
		if (c != 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	while (0 != cnt){
		if (cnt == c){
			cout << "YES" << endl;
			return 0;
		}
		cnt += a;
		cnt %= b;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import product
import math

D, G = [int(_) for _ in input().split()]

P = [0] * D
C = [0] * D
for i in range(D):
    P[i], C[i] = [int(_) for _ in input().split()]

V = []
for i in range(D):
    v = P[i] * (i + 1) * 100 + C[i]
    V.append(v)

max_P = sum(P)


def func(bit_pattern):
    score = 0
    tmp = 0
    for i in range(D):
        if bit_pattern[i]:
            score += V[i]
            tmp += P[i]

    if score >= G:
        return tmp

    res = G - score

    for i in reversed(range(D)):
        if not bit_pattern[i]:
            x = math.ceil(res / ((i + 1) * 100))
            if x < P[i]:
                return tmp + x

    return max_P


ans = max_P
for bit_pattern in product(range(2), repeat=10):

    tmp = func(bit_pattern)
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3064
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define MAXI (1<<32)
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define SIZ 1000005
#define SIZE 200005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair<ll,ll>&a,const pair<ll,ll>&b){
	return a.ss < b.ss;
}

//ll p[20000005]={0};
//vector<ll>ans;
/*void sieve(){
    ll i,j;
    p[0]=p[1]=1;
    for(i=2;i*i<=20000005;i++){
        if(!p[i]){
            for(j=2*i;j<20000005;j+=i){
                p[j]=1;
            }
        }
    }
    fo(i,2,20000005){
        if(!p[i]){
            ans.pb(i);
        }
    }
}*/


signed main(){ 
    IOS
    //io_set();
    ll a, b, c = 0, f = 0;
    string s;
    cin >> a >> b >> s;
    rep(i, sz(s)){
        if(s[i] == '-')c++;
        if(s[i] >='0' && s[i] <= '9' || s[i] == '-');
        else{
            f=1;
        }
    }
    if(f || c > 1){
        cout << "No\n";
    }
    else{
        if(s[a] == '-'){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
    return 0;
}



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int dif = 0;
		String N = sc.next();
		
		for (int i = 0; i < N.length();i+=2)
		{
			char c1 = N.charAt(i);
			if (c1 == '1') {dif++;}
			
			if(i+1 < N.length())
			{
			char c2 = N.charAt(i+1);	
			if (c2 == '0') {dif++;}
			}
			
		}
      
      int ans = Math.min(dif,(N.length()-dif));
		
		System.out.println(ans);
		
	

	}
}

Measured memory_bytes: 39152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int Z = 200100;
const int N = Z * 2;
int n, q;
int a[N];
int b[N];
int c[N];
int ans;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    for (int i = 0; i <= Z; i++)
        c[i] = 1;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        b[a[i]]++;
        int x = Z + a[i] - b[a[i]] + 1;
        c[x]++;
        if (c[x] > 1)
            ans++;
    }
    while(q--) {
        int v, w;
        scanf("%d%d", &v, &w);
        v--;
        b[a[v]]--;
        int x = Z + a[v] - b[a[v]];
        c[x]--;
        if (c[x] >= 1)
            ans--;
        a[v] = w;
        b[a[v]]++;
        x = Z + a[v] - b[a[v]] + 1;
        c[x]++;
        if (c[x] > 1)
            ans++;
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 5504
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static List<String> getStrings(Scanner sc, int num) {
		List<String> stringList = new ArrayList<>();
		while(num>0) {
			String nextInt = sc.next();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<String> array = getStrings(sc, n);
		System.out.println(array.stream().distinct().count());
	}

}


Measured memory_bytes: 73276
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};



int main(){
    int n;cin >> n;
    vector<P> v(n);
    for (int i = 0; i < n; i++) {
        LL x,l;cin >> x >> l;
        v[i] = mp(x+l,x-l);
    }
    sort(ALL(v));
    LL t = -LINF;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(t <= v[i].sc){
            t = v[i].fs;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n, X[200001], Y[200001];
char C[200001];
vector <pair<int,int>> V[400001];

void Rotate()
{
    for (int i = 0; i < n; i++)
    {
        int nx, ny;
        nx = Y[i];
        ny = 200000-X[i];
        Y[i] = ny;
        X[i] = nx;
        if (C[i] == 'D')
            C[i] = 'L';
        else if (C[i] == 'L')
            C[i] = 'U';
        else if (C[i] == 'U')
            C[i] = 'R';
        else if (C[i] == 'R')
            C[i] = 'D';
    }
}

long long Solve()
{
    long long Mi=2000000000;
    for (int i = 0; i < n; i++)
    {
        if (C[i] == 'U')
            V[X[i]].push_back({Y[i],1});
        if (C[i] == 'D')
            V[X[i]].push_back({Y[i],-1});
    }
    for (int i = 0; i <= 200000; i++)
    {
        sort(V[i].begin(),V[i].end());
        int p = -1, I;
        for (int y = 0; y < V[i].size(); y++)
        {
            I = V[i][y].first;
            if (V[i][y].second == 1)
            {
                p = I;
            }
            else if (p != -1)
            {
                Mi = min(Mi, 5ll*(I-p));
            }
        }
        V[i].clear();
    }
    for (int i = 0; i < n; i++)
    {
        if (C[i] == 'R')
            V[X[i]+Y[i]].push_back({X[i],1});
        if (C[i] == 'U')
            V[X[i]+Y[i]].push_back({X[i],-1});
    }
    for (int i = 0; i <= 400000; i++)
    {
        sort(V[i].begin(),V[i].end());
        int p = -1, I;
        for (int y = 0; y < V[i].size(); y++)
        {
            I = V[i][y].first;
            if (V[i][y].second == 1)
            {
                p = I;
            }
            else if (p != -1)
            {
                Mi = min(Mi, 10ll*(I-p));
            }
        }
        V[i].clear();
    }
    return Mi;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    long long Re=2000000000;
    for (int i = 0; i < n; i++)
    {
        cin >> X[i] >> Y[i] >> C[i];
    }
    for (int i = 0; i < 4; i++)
    {
        Re = min(Re, Solve());
        Rotate();
    }
    if (Re == 2000000000)
    {
        cout << "SAFE";
    }
    else
    {
        cout << Re;
    }
    return 0;
}


Measured memory_bytes: 26676
#include<iostream>
#include<queue>
#include<cstdio>
using namespace std;
int main(){
	int i,a;
	priority_queue<int> q1;
	for(i=0;i<5;i++){
		cin>>a;
		q1.push(a);
	}
	for(i=0;i<5;i++){
		a=q1.top();
		q1.pop();
		printf("%d%c",a,i==4?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
	using namespace std ; 
	#define all(a) a.begin(),a.end()
	#define rall(a) a.rbegin(),a.rend()
	#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int long long int
	#define endl "\n"
	#define pb push_back
	#define bs binary_search
	#define lb lower_bound
	#define ub upper_bound
	#define f first
	#define s second
	#define pii pair<int,int> 
	template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

	long long M  = 1e9+7;
	 
	signed main(){
	    fast;
	    int s,w; cin >> s >> w;
	    if(w >= s){
	    	cout << "unsafe" << endl;
	    }
	    else
	    	cout << "safe" << endl;
	}


Measured memory_bytes: 3660
N,M = map(int,input().split())
 
def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    return cmb(n-1,r) + cmb(n-1,r-1)
 
ret = cmb(N,2) + cmb(M,2)
print(ret)

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

int main() {
  int x;
  cin >> x;
  int y = x - (x / 1000) * 1000;
  int z = x / 10;
  if (y % 111 == 0 || z % 111 ==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
flag=True
for k in range(n-1):
    if p[k+1]<p[k]:
        flag=False
if flag:
    print("YES")
    exit()

for i in range(n-1):
    for j in range(i+1,n):
            a=p[i]
            p[i]=p[j]
            p[j]=a
            flag=True
            for k in range(n-1):
                if p[k+1]<p[k]:
                    flag=False
            if flag:
                print("YES")
                exit()
            else:
                a=p[i]
                p[i]=p[j]
                p[j]=a
print("NO")


Measured memory_bytes: 39792
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>
using std::bitset;
using std::cin;
using std::cout;
using std::max;
using std::pair;
using std::size_t;
using std::vector;

int main() {
    // inputs
    size_t N;
    cin >> N;

    vector<int> A(N);
    vector<vector<pair<int, bool>>> xy(N);
    for (size_t i = 0uL; i < N; ++i) {
        cin >> A.at(i);
        for (int j = 0; j < A.at(i); ++j) {
            int x, y;
            cin >> x >> y;
            xy.at(i).push_back({x - 1, (y == 1)});
        }
    }

    // solve 𝑶(N^3)
    size_t ans = 0uL;
    for (int i = 1; i < int(1 << N); ++i) {
        // bit全探索
        bitset<16> bs = i;
        bool possible = true;

        for (size_t j = 0uL; j < N && possible; ++j) {
            // 人jが正直者
            if (!bs[j]) continue;

            for (int k = 0; k < A.at(j); ++k) {
                int xjk  = xy.at(j).at(k).first;
                bool yjk = xy.at(j).at(k).second;
                if (yjk) {  // 正直者j曰く，人xjkは正直者
                    if (!bs[xjk]) {
                        possible = false;
                        break;
                    }
                } else {  // 正直者j曰く，人xjkは不親切
                    if (bs[xjk]) {
                        possible = false;
                        break;
                    }
                }
            }
        }
        if (possible) ans = max(ans, bs.count());
        // if (possible) cout << i << ' ' << ans << '\n';
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;

int main(int argc, char ** argv) {
	string s;
	cin >> s;
	bool vis[26];
	memset(vis, 0, sizeof vis);
	for(ll i=0; i<s.length(); i++) {
		if(vis[s[i]-'a']) {
			cout << "no" << endl;
			return 0;
		} else {
			vis[s[i]-'a'] = true;
		}
	}
	cout << "yes" << endl;
	return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int a, b;
	cin >> a >> b;
	if (a == b)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
int MOD = 1e9+7;
int expo(int a,int b){
    if (b == 1) return a%MOD;
    int temp = expo(a,b/2);
    temp = (temp*temp)%MOD;
    if (b%2 == 0)return temp;
    return (temp*a)%MOD;
}
main(){
    int n,k;
    cin >> n >> k;
    int fac[n+1],arr[n+1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++) cin >> arr[i],fac[i] = (fac[i-1]*i)%MOD;
    int ans = 0;
    sort(arr+1,arr+n+1);
    for (int i = k; i <= n; i++){
        int temp = (fac[i-1]*expo(fac[k-1],MOD-2))%MOD;
        temp = (temp*expo(fac[i-k],MOD-2))%MOD;
        //cout << temp << "\n";
        //cout << arr[i]*temp << " ";
        //cout << arr[n-i+1]*temp << "\n";
        ans = (ans+MOD+arr[i]*temp)%MOD;
        ans = (ans+MOD-arr[n-i+1]*temp)%MOD;
    }
    cout << ans%MOD;
}


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

int change(vector<int>&N,int i){
  if(N.at(i)<=N.at(i+1)&&N.at(i)<9){
    N.at(i)++;
  }else{
    int ma=0;
    for(int j=i+1;j<11;j++){
      ma=max(N.at(j),ma);
    }
    if(ma==0&&N.at(i)<9){
      N.at(i)++;
    }else{
      change(N,i+1);
      N.at(i)=max(N.at(i+1)-1,0);
    }
  }
}

int main() {
  int K;
  int64_t ans=0;
  vector<int>N(11,0);
  N.at(1)=1;
  cin >> K;
  if(K<10){
    cout << K << endl;
  }else{
    for(int i=10;i<K;i++){
      change(N,0);
    }
    for(int i=10;i>=0;i--){
    ans=ans*10+N.at(i);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int arr[n+1] = {0};
    arr[0] = 0;
    
    for (int i = 1; i < n; i++) {
        int temp;
        cin >> temp;
        arr[temp]++;
    }
    
    for (int i = 1; i <= n; i++) {
        cout << arr[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4368
import collections

n = []

while True:
   try:
       N = input()
   
   except EOFError:
       break
   
   N = N.lower() 
    
   N.replace('', ' ')
   
   n.extend(N)
   
c = collections.Counter(n)

for i in range(97, 97+26):
        print("%s : %d" % (chr(i),c[chr(i)]) )



Measured memory_bytes: 5964