akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<<(i+1==n?'\n':' '); }
template<class T>void pp(T v){ EACH(it,v) cout<<(it==v.begin()?"":" ")<<*it; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

inline void write_bool(bool b, const string &tval, const string &fval) {
  cout << (b ? tval : fval) << endl;
} 
inline void YESNO(bool b) { return write_bool(b, "YES", "NO"); }
inline void YesNo(bool b) { return write_bool(b, "Yes", "No"); }
inline void yesno(bool b) { return write_bool(b, "yes", "no"); }

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  int n;
  while (cin >> n) {
    double result = 0;
    REP(i,n) {
      double t; cin >> t;
      result += 1.0 / t;
    }
    printf("%.12lf\n", 1.0 / result);
  }
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;
const int Mx = 100010;
ll Dp[110][300010];

int main()
{

    SPEED;

    int n,a[100010][2],W;
    cin >> n >> W;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=Mx;j++)
            Dp[i][j]= OO;
        cin >> a[i][0] >> a[i][1];
    }
    for(int j=0;j<=Mx;j++)
            Dp[n][j]= OO;
    Dp[0][0]=0;

    for(int i=0;i<n;i++)
    {
        int w = a[i][0], cost = a[i][1];
        for(int j=0;j<Mx;j++)
        {
            Dp[i+1][j] = Dp[i][j];
        }
        for(int j=0;j<Mx;j++)
        {
            Dp[i+1][j+cost] = min(Dp[i+1][j+cost],Dp[i][j]+w);
        }
    }

    for(int i=Mx;i>=0;i--)
       if(Dp[n][i] <= W)
       {
            cout  << i << endl;
            break;
       }
    R 0;
}


Measured memory_bytes: 234496
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

struct edge {
	int to, cost, cam;
	edge(int _to, int _cam, int _cost) : to(_to), cost(_cost), cam(_cam) {

	}
};

inline bool operator<(const edge& left, const edge& right) {
	if (left.to == right.to) return left.cam < right.cam;
	return left.to < right.to;
}
typedef pair<int, pii> pe;

map<int,set<edge>> es[100010];

void solv() {

	ll n,m;
	cin >> n >> m;
	map<int,int> d[100010];
	for (size_t i = 0; i < m; i++)
	{
		int p, q, c;
		cin >> p >> q >> c;
		es[p][c].insert(edge(q, c, 0));
		es[q][c].insert(edge(p, c, 0));
		es[p][c].insert(edge(p, -1,0));
		es[q][c].insert(edge(q, -1, 0));
		es[p][-1].insert(edge(p, c, 1));
		es[q][-1].insert(edge(q, c, 1));
	}

	priority_queue<pe, vector<pe>, greater<pe>> q;
	q.push(pe(0, pii(1,-1)));
	while (!q.empty())
	{
		pe p = q.top();
		q.pop();
		pii v = p.second;
		if (d[v.first][v.second] == 0) {
			d[v.first][v.second] = p.first;
		}
		if (d[v.first][v.second] < p.first) continue;
		
		for (auto item : es[v.first][v.second]) {

			if (d[item.to][item.cam] == 0) {
				d[item.to][item.cam] = INF;
			}

			if (d[item.to][item.cam] > p.first + item.cost) {
				d[item.to][item.cam] = p.first + item.cost;
				q.push(pe(p.first + item.cost,pii(item.to,item.cam)));
			}
		}
	}
	cout << (d[n][-1] == 0 ? -1 : d[n][-1]) << endl;
}




int main() {
	solv();

	return 0;
}


Measured memory_bytes: 156464
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0

mod = 10 ** 9 + 7
for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] = dp[i] % mod

print(dp[n])

Measured memory_bytes: 50904
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll arr[4];
	arr[0]=a*c;
	arr[1]=a*d;
	arr[2]=b*c;
	arr[3]=b*d;
	sort(arr,arr+4);
	cout<<arr[3]<<"\n";
	return 0;
}
	

Measured memory_bytes: 3636
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())
if V <= W:
  print('NO')
elif (A >= 0 and B <= 0) or (B >= 0 and A <= 0):
  if abs(A)+abs(B)-((V*T)-(W*T))>0:
    print('NO')
  else:
    print('YES')
else:
  if abs(A-B)-((V*T)-(W*T))>0:
    print('NO')
  else:
    print('YES')

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

const int N = 105;
int n;
char s[N];

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    int res = 1e9;
    rep(c, 'a', 'z') {
        bool ff = 0;
        int ans = 1e9, lst;
        for (int j = n; j; --j) {
            if (s[j] == c) {
                if (!ff) {
                    ans = n - j, ff = 1;
                } else {
                    ans = max(ans, lst - 1 - j);
                }
                lst = j;
            }
        }
        ans = max(ans, lst - 1);
        res = min(res, ans);
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3816
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	
	String[] day=new String[]{
			"Sunday",
			"Monday",
			"Tuesday",
			"Wednesday",
			"Thursday",
			"Friday",
			"Saturday",
	};
	public void run() {
		while (true) {
			int m=sc.nextInt(),d=sc.nextInt();
			if(m==0 && d==0)break;
			Calendar cl=Calendar.getInstance();
			cl.set(2004,m-1,d);
			ln(day[cl.get(Calendar.DAY_OF_WEEK)-1]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> vc;
    for(int i = 0;i < n; i++){
        int a;
        cin >> a;
        vc.push_back(a);
    }
    sort(vc.begin(), vc.end());
    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += vc[i];
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3664
n,m,k=map(int,input().split())
relfr={i:set() for i in range(n)}
relbl={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  relfr[a-1].add(b-1)
  relfr[b-1].add(a-1)
for i in range(k):
  a,b=map(int,input().split())
  relbl[a-1].add(b-1)
  relbl[b-1].add(a-1)
blsiz=[0 for i in range(n)]
ans=[0]*n
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
uf=UnionFind(n)
for i in range(n):
  for j in relfr[i]:
    uf.Unite(i,j)
for i in range(n):
  for j in relbl[i]:
    if uf.isSameGroup(i,j):
      blsiz[i]+=1
for i in range(n):
  ans[i]=uf.Count(i)-len(relfr[i])-blsiz[i]-1

print(' '.join(map(str,ans)))

Measured memory_bytes: 99560
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;

  ll x = 1, y = 1;
  for (int i = 0; i < N; i++) {
    int t, a;
    cin >> t >> a;
    ll f = max(x / t + (x % t ? 1 : 0), y / a + (y % a ? 1 : 0));
    x = f * t;
    y = f * a;
  }

  cout << x + y << endl;
  return 0;
}


Measured memory_bytes: 256
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int n; cin >> n;
    int a[2][n];

    vector<vector<int>> asum(2,vector<int>(n+1,0));

    rep(i,2) rep(j,n){
        cin >> a[i][j];
        asum[i][j+1] = asum[i][j] + a[i][j];
    }
    int ans = 0;
    rep(i,n) ans = max(ans, asum[0][i+1] + asum[1][n] - asum[1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)
ll md=1000000007;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll mx1=max(b*d,max(a*d,max(b*c,a*c)));
    cout<<mx1;
    return 0;
}

Measured memory_bytes: 3664
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	flag := false
	for i := 1; i <= 9; i++ {
		for j := i; j <= 9; j++ {
			if n == i * j {
				flag = true
			}
		}
	}
	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
route = [[] for i in range(4)]
for i in range(3):
    a, b = map(int, input().split())
    route[a-1].append(b-1)
    route[b-1].append(a-1)
#print(route)

maxlen = 0
for i in range(4):
    maxlen = max(maxlen, len(route[i]))
#print(maxlen)
if(maxlen >= 3): print("NO")
else: print("YES")

Measured memory_bytes: 3060
// AOJ 0146: Lupin The 4th
// 2017.9.28 bal4u@uu
// 2017.11.21

#include <stdio.h>
#include <string.h>

#define INF 1e10
#define ABS(a) ((a)>=0?(a):-(a))
#define MAX 32768

int s[16], d[16], v[16];	// ????????±?????????????????¢???????????±?????°
double dp[16][MAX];			// DP????????¨?????????
int w[16][MAX];				// ????????±????????°
short prev[16][MAX][2];		// ???????????????????????????
int ord[16];				// ???????????????????????????????????????????????´???

int main()
{
	int n, i, j, k, t, ii, lim;
	double x, y;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d%d%d", s+i, d+i, v+i);

	memset(prev, -1, sizeof(prev));
	for (ii = 1, i = 0; i < n; i++, ii <<= 1) w[i][ii] = v[i];

	lim = 1 << n;
	for (k = 0; k < lim; k++) {
		for (ii = 1, i = 0; i < n; i++, ii <<= 1) {		// ??´????????????
			if (k & ii) continue;
			t = k | ii;
			for (j = 0; j < n; j++) {	// ??´?????????
				if (i == j || w[j][k] == 0) continue;
				int dd = d[i] - d[j];
				if (dd < 0) dd = -dd;
				x = dp[j][k] + (dd*(7+2*w[j][k]))/200.0;
				if (dp[i][t] == 0 || x < dp[i][t]) {
					dp[i][t] = x, w[i][t] = w[j][k] + v[i];
					prev[i][t][0] = j;
					prev[i][t][1] = k;
				}
			}
		}
	}

	// ???????§???????????????????
	for (x = INF, ii = 0, i = 0; i < n; i++) {
		y = dp[i][lim-1];
		if (y == 0) continue;
		if (y < x) x = y, ii = i;
	}

	// ?????£???????????????
	for (ord[0] = ii, i = ii, j = lim-1, k = 1; k < n; k++) {
		ord[k] = prev[i][j][0];
		     j = prev[i][j][1];
		     i = ord[k];
	}

	// ??????
	printf("%d", s[ord[n-1]]);
	for (i = 1; i < n; i++) printf(" %d", s[ord[n-i-1]]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 8792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}

class UnionFind{
  vector<int> par,siz;
  //0-indexed
  void init(int n){
    component = n;
    par.resize(n);
    for(int i=0;i<n;++i)par[i]=i;
    siz.resize(n,1);
    msiz = 1;
  }
public:
  int msiz,component;
  UnionFind(int n_){init(n_);}
  int root(int x){
    if(par[x]==x)return x;
    return par[x] = root(par[x]);
  }
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y)return;
    siz[y] += siz[x];
    siz[x] = 0;
    par[x] = y;
    msiz = max(msiz,siz[y]);
    component--;
  }
  int size(int x){
    return siz[root(x)];
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};

int main(){

  ll N,M;
  cin >> N >> M;
  vector<ll> H(N);
  FOR(i,0,N)cin >> H[i];
  vector<ll> is_max(N,1);
  FOR(i,0,M){
    ll a,b;
    cin >> a >> b;
    a--;b--;
    
    if(H[a] > H[b]){
      is_max[b] = 0;
    }else if(H[a] < H[b]){
      is_max[a] = 0;
    }else{
      is_max[a] = 0;
      is_max[b] = 0;
    }
  }

  ll ans = 0;
  FOR(i,0,N){
    ans += is_max[i];
  }

  cout << ans << endl;

}


Measured memory_bytes: 4840
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 119：A - Still TBD


def main():
    S = raw_input().strip()
    # 2019/04/30

    d = [int(n) for n in S.split('/')]
    if d[1] >= 5:
        print 'TBD'
    else:
        print 'Heisei'


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include <iostream>
#include <iterator>
#include <set>

using namespace std;

int main() {
  string s;
  int K;
  cin >> s >> K;
  set<string> S;
  for (int i = 0, n = s.size(); i != n; ++i) {
    for (int j = 1; j <= 5; ++j) {
      if (i + j > n) break;
      string subs = s.substr(i, j);
      S.insert(subs);
    }
  }

  auto it = S.begin();
  advance(it, K - 1);
  cout << *it << endl;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
using namespace std;

void dfs(int node, vi v[], int dp[], bool visited[]){
	visited[node] = true;
	rep(i, 0, v[node].size())
	{
		if(!visited[v[node][i]]) dfs(v[node][i], v, dp, visited);
		dp[node] = max(dp[node], 1 + dp[v[node][i]]);
	}
}

int helper(vi v[], int dp[], bool visited[], int n){
	
	rep(i, 1, n+1) 
	{
		if(!visited[i]) dfs(i, v, dp, visited);
	}
	
	int ans = 0;
	rep(i, 1, n+1) ans = max(ans, dp[i]);
	return ans;
}

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	in(n);
	in(m);
	vi v[n+1];
	int x, y;
	rep(i, 0, m)
	{
		cin>>x>>y;
		v[x].pb(y);
	}
	
	int dp[n+1];
	mem(dp);
	bool visited[n+1];
	mem(visited);
	
	cout<<helper(v, dp, visited, n);
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 1000000007
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,m;
ld arr[10000];
ld dp[2999+9][2999+9];
ld solve(int ind,int h){
    if(ind == n){
        if(h > n-h){
            return 1;
        } else{
            return 0;
        }
    }
    if(dp[ind][h] != -1){
        return dp[ind][h];
    }
    return dp[ind][h] =  solve(ind+1,h+1)*arr[ind] + solve(ind+1,h)*(1-arr[ind]);
}
int main() {
    cin>>n>>m;
    for(int i = 0;i<2999+9;i++){
        for(int j = 0;j<2999+9;j++){
            dp[i][j] = -1;
        }
    }
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    cout<<setprecision(12)<<solve(0,0);
    return 0;
}


Measured memory_bytes: 71168
use std::collections::BTreeSet;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let p: Vec<usize> = (0..n).map(|_| sc.read::<usize>() - 1).collect();
    let mut graph = vec![vec![]; n];
    for (i, &p) in p.iter().enumerate() {
        graph[p].push(i);
    }

    let mut vis = vec![false; n];
    let mut cur = 0;
    while !vis[cur] {
        vis[cur] = true;
        cur = p[cur];
    }

    let mut in_cycle = vec![false; n];
    while !in_cycle[cur] {
        in_cycle[cur] = true;
        cur = p[cur];
    }

    let mut grundy = vec![n; n];
    for i in in_cycle.iter().enumerate().filter(|&(_, &in_cycle)| in_cycle).map(|(i, _)| i) {
        for &child in graph[i].iter() {
            if !in_cycle[child] {
                dfs(child, &graph, &mut grundy);
            }
        }
    }

    let check = |first: usize, grundy: &mut Vec<usize>| -> bool{
        let mut cur = p[first];
        loop {
            let set = graph[cur].iter().map(|&next| grundy[next]).collect::<BTreeSet<usize>>();
            let g = (0..).filter(|i| !set.contains(i)).next().unwrap();

            if cur == first {
                if g == grundy[first] {
                    return true;
                } else {
                    return false;
                }
            } else {
                grundy[cur] = g;
                cur = p[cur];
            }
        }
    };

    let first = cur;
    let set = graph[first].iter().map(|&next| grundy[next]).collect::<BTreeSet<usize>>();
    let mut iter = (0..).filter(|i| !set.contains(i));
    let candidate1 = iter.next().unwrap();
    grundy[first] = candidate1;
    if check(first, &mut grundy) {
        println!("POSSIBLE");
        return;
    }


    let candidate2 = iter.next().unwrap();
    grundy[first] = candidate2;
    if check(first, &mut grundy) {
        println!("POSSIBLE");
        return;
    }
    println!("IMPOSSIBLE");
}

fn dfs(v: usize, graph: &Vec<Vec<usize>>, grundy: &mut Vec<usize>) -> usize {
    let set = graph[v].iter().map(|&child| dfs(child, graph, grundy)).collect::<BTreeSet<usize>>();
    grundy[v] = (0..).filter(|i| !set.contains(i)).next().unwrap();
    grundy[v]
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	ll div = n/(a+b);
	ll rest = n- n/(a+b)*(a+b);
	ll ans=div*a+min(rest,a);
	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define EPS 1e-8
#define EQ(a) (-EPS<a && a<EPS)
#define MP make_pair

bool operator<(P l,P r){
  if(l.real()!=r.real())return l.real()<r.real();
  return l.imag()<r.imag();
}

struct line{P a,b;};

bool operator<(line l,line r){
  if(l.a!=r.a)return l.a<r.a;
  return l.b<r.b;
}

double dot(P a,P b){
  return (conj(a)*b).real();
}
double cross(P a,P b){
  return (conj(a)*b).imag();
}
double po(P a){
  return a.real()*a.real() + a.imag()*a.imag();
}

// http://www.deqnotes.net/acmicpc/2d_geometry/lines
double distance(line a,P b){
  if ( dot(a.b-a.a, b-a.a) < EPS ) return po(b-a.a);
  if ( dot(a.a-a.b, b-a.b) < EPS ) return po(b-a.b);
  double t = abs( cross(a.b-a.a, b-a.a) );
  return t*t / po(a.b-a.a);
}

// http://www5d.biglobe.ne.jp/~tomoya03/shtml/algorithm/Intersection.htm
bool intersect(line a,line b){
  double x,y;
  x = cross(a.b-a.a, b.a-a.a);
  y = cross(a.b-a.a, b.b-a.a);
  if(EQ(x)&&EQ(y))return false;
  if(x*y>EPS)return false;
  x = cross(b.b-b.a, a.a-b.a);
  y = cross(b.b-b.a, a.b-b.a);
  if(EQ(x)&&EQ(y))return false;
  if(x*y>EPS)return false;
  return true;
}

int main(){
  int n;
  scanf("%d",&n);
  if(n>5100){ // (101*101-1)/2 = 10200/2 = 5100
    // law of "su of hato"
    cout << "0.0000000" << endl;
    return 0;
  }
  assert(n <= 5100);
  // O(N^2) ~ O(1e8)
  line lines[n];
  double result = 114514.0;
  REP(i,n){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a<c) lines[i] = (line){P(a,b),P(c,d)};
    else    lines[i] = (line){P(c,d),P(a,b)};
  }
  sort(lines,lines+n);
  REP(i,n){
    line a = lines[i];
    FOR(j,i+1,n){
      line b = lines[j];
      if(a.b.real()+result < b.a.real())break;
      if(intersect(a,b)){
        cout << "0.0000000" << endl;
        return 0;
      }
      result = min(result,
        min(min(distance(a,b.a), distance(a,b.b)),
            min(distance(b,a.a), distance(b,a.b))) );
    }
  }
  cout.precision(10);
  cout << fixed << sqrt(result) << endl;
  return 0;
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
int main() {
	int K,N;
	int mans,ans;
	ans = 1001001;
	cin >> K >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];
	if (N == 2) ans = min(K - (A[1] - A[0]), A[1] - A[0]);
	else {
		rep(i, N) {
			if (i == 0) {
				mans = min(A[N - 1] - A[0], K - (A[1] - A[0]));
				ans = min(ans, mans);
			}
			else if (i == N - 1) {

				mans = min(A[N - 1] - A[0], K - (A[N - 1] - A[N - 2]));
				ans = min(ans, mans);
			}
			else {
				mans = min(K - A[i + 1] + A[i], K - (A[i] - A[i - 1]));
				ans = min(ans, mans);
			}
		}
	}

	cout << ans;
}

Measured memory_bytes: 1024
a,b=gets.split.map(&:to_i)
h=Hash.new
(1..a).each {|i|h[i]=0}
b.times do
  n,m=gets.split.map(&:to_i)
  h[n]+=1
  h[m]+=1
end
h.each {|a,b| puts b}


Measured memory_bytes: 14288
from collections import Counter

def main():

    N = int(input(""))
    A = list(map(int,input().split()))
    X = 0
     
    A_e = list(set(A))
     
    x = Counter(A)
     
    for i in A_e:
        if x[i] >= 2:
            xc2 = x[i]*(x[i]-1)/2
            X = X + xc2
     
    for k in A:
        print(int(X-x[k]+1))

if __name__ == "__main__":
    main() 


Measured memory_bytes: 89292
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	if (A >= K) cout << K;
	else if (A + B >= K) cout << A;
	else cout << A - (K - A - B);

	return 0;
}

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

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

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

signed main() {
  int H, W;
  cin >> H >> W;
  ;

  //ワーシャル-フロイド
  int N = 10;

  //d[from][to] は、fromとtoの間のコスト。初期値はMAX。
  vector<vector<ll>> d(N, vector<ll>(N, INF_LL));
  //自分自身への移動はコストなし
  rep(i, N) { d[i][i] = 0; }


  rep(i, N) {
    rep(j, N) {
      cin >> d[i][j];
    }
  }

  rep(i, N) {
    rep(j, N) {
      rep(k, N) { chmin(d[j][k], d[j][i] + d[i][k]); }
    }
  }

  int cost = 0;
  rep(i, H) {
    rep(j, W) {
      int buf;
      cin >> buf;
      if(buf == -1) continue;
      cost += d[buf][1];
      PRINT(cost)
    }
  }

  cout << cost << endl;
}


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

#define INF (1 << 29)
#define INF_COME (1 << 28)

using namespace std;

struct State{
    int pos;
    int cost;
    bool operator > (const State &other ) const
    {
        return this->cost > other.cost;
    }
    bool operator < (const State &other ) const
    {
        return !(*this > other);
    }
};

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

    vector<int> map(n);
    vector<int> ans(n, INF);    

    for(auto& m : map)
    {
        cin >> m;
    }

    ans[0] = 0;

    priority_queue< State, vector<State>, greater<State> > que;
    que.push(State{0, 0});


    while(!que.empty())
    {
        State now = que.top();
        que.pop();

        ans[now.pos] = min(ans[now.pos], now.cost);
        if(now.pos == n - 1)break;

        for(int i = 1; i <= 6; i++)
        {
            int next = now.pos + i;
            if(next > n - 1)next = n - 1;

            //???????????¨???????????§??????
            while(map[next] != 0 && map[next] != INF)
            {
                //??????????????´??????INF?????\??????
                int tmp = map[next];
                map[next] = INF;
                next += tmp;
            }

            //??????????????????????????£??????
            if(map[next] != INF)
            {
                map[next] = INF;
                que.push(State{next, now.cost + 1});
            }

            /*
            for(int i = 0; i < n; i++)
            {
                cout << ans[i] << " ";
            }
            cout << endl;
            //*/
        }
    }

    cout << ans[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#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>
 
 
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)
 
//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;

int main(void){
  int H,W;
  int h,w;
  cin>>H>>W;
  cin>>h>>w;
  cout<<(H-h)*(W-w)<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
d = defaultdict(list)
for i in range(1, n + 1):
    city, point = input().split()
    p = int(point)
    d[city].append((p, i))

for city in sorted(d):
    l = d[city]
    l.sort(reverse=True)
    for p, i in l:
        print(i)


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

int main(void){
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  int ans[n+1] = {}, a, b;

  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    ans[a]++;
    ans[b]++;
  }

  for (int i = 1; i < n + 1; i++) {
    printf("%d\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cerr<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll MAX=1e16;
const ll MM=1e18;
const ll mod=1e9+7;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}


void solve()
{
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   if(k<=(a+b))
    cout<<min(a,k)<<endl;
   else
   {
      k-=(a+b);
      cout<<(a)-k<<endl;
   }
}


int main()
{
  boost;
  int t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3652
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int A = one.get(0);
      int B = one.get(1);
      int C = one.get(2);
      if((A + B == C) || (A + C == B) || (B + C == A)){
        myout("Yes");
      }else{
        myout("No");
      }
	}
	//Method addition frame start


  
	//Method addition frame end
}


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

A.sort()

A = A[::-1]

B = []
F = False

for i in range(N-1):
    if F == True:
        F = False
        continue
    elif A[i+1] == A[i]:
        B.append(A[i])
        F = True

if len(B) >= 2:
    print(B[0] * B[1])
else:
    print(0)


Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int main(){
	int n,T,c,t,f=0,m=0x7fffffff;
	cin>>n>>T;
	for(int i=0;i<n;i++){
		cin>>c>>t;
		if(t<=T&&c<m){
			m=c;
			f=1;
		}
	}
	if(f)printf("%d",m);
	else cout<<"TLE";
	return 0;
}


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

int main() {
  string O, E;
  cin >> O >> E;

  char C;
  int F = 0;

  if (O.size() > E.size()) {
    C = O.back();
    O.pop_back();
    F = 1;
  }

  for (int i = 0; i < O.size(); i++) {
    cout << O.at(i) << E.at(i);
  }

  if (F) cout << C << endl;
  else cout << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let p = get!([usize]);

    let mut mn = std::usize::MAX;
    let mut sum = 0usize;
    for i in 0..n {
        if p[i] <= mn {
            sum += 1;
        }
        mn = min!(mn,p[i]);
    }
    println!("{}", sum);
}


Measured memory_bytes: 14588
#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
i64 N,Len;
string ans;
inline void pre(){
    i64 l=1,Bas=26,Ans=26;
    while(Ans<N){
        Ans+=(Bas*=26);
        l++;
    }
    ans=string(l,'a');
    N-=Ans-Bas;
    Len=l;
}
inline void work(){
    pre();
    N--;
    i64 Bas=1,Cur=0;
    for(int i=1;i<Len;i++) Bas*=26;
    while(Cur<ans.size()){
        while(N>=Bas) N-=Bas,ans[Cur]++;
        Cur++;
        Bas/=26;
    }
    cout<<ans;
}
int main(){
    cin>>N;
    work();
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define int long long
#define il inline 
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int maxn = 2333, mod = 1000000007;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
string s,t,p;
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, dp[maxn][4][2];
char c[maxn];
il int dfs(int u, int use, int li) 
{
	if(use > m) return 0;
	if(u > n) return use == m;
	if(dp[u][use][li] != -1) return dp[u][use][li];
	int p = li == 1 ? c[u] - '0' : 9, ans = 0;
	rep(i, 0, p) ans += dfs(u + 1, use + (i != 0), li && i == p);
	return dp[u][use][li] = ans;
} 
signed main() 
{
	scanf("%s", c + 1), n = strlen(c + 1), m = read(), memset(dp, -1, sizeof(dp));
	cout << dfs(1, 0, 1);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
  char s[100000];
  scanf("%s", s);
  int start=-1, end=-1;
  for(int i=0;i<strlen(s);i++){
    if(s[i] == s[i+1]){
      start = i+1;
      end = i+2;
    }
    else if(s[i] == s[i+2]){
      start = i+1;
      end = i+3;
    }
  }
  printf("%d %d", start, end);
  return 0;
}

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

int main() {
    ll N,x;
    cin >> N >> x;
    ll last = 0;
    ll ans = 0;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        if(last + a > x){
            ans += (last+a-x);
            a = x-last;
        }
        last = a;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {n: usize, s:[String;n]};

    let mut judge = HashMap::new();

    judge.insert(String::from("AC"), 0);
    judge.insert(String::from("WA"), 0);
    judge.insert(String::from("TLE"), 0);
    judge.insert(String::from("RE"), 0);

    for item in s {
        let count = judge.entry(item).or_insert(0);
        *count += 1;
    }

    println!("AC x {:?}", judge["AC"]);
    println!("WA x {:?}", judge["WA"]);
    println!("TLE x {:?}", judge["TLE"]);
    println!("RE x {:?}", judge["RE"]);
}


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

void solve(long long N, std::vector<long long> d)
{
    set<int> A;
    long long index = 0;
    for (int i = 0; i < N; i++)
    {
        //index = d[i];
        A.insert(d[i]);
    }

    //sort(A.begin(), A.end());
    cout << A.size() << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> d(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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


int main(void){
  string  o,e;
  cin>>o>>e;
  int num;
  for(int j=0;j<e.size();j++){
    cout<<o.at(j)<<e.at(j);
    num=j;
  }

  if((o.size()+e.size())%2==0){cout<<endl;}
    else {cout<<o.at(num+1)<<endl;}


  return 0;
}


Measured memory_bytes: 256
S = input()
num_length = len(S)
counter_0 = 0
counter_1 = 0
for i in range(num_length):
    if S[i] == '0':
        counter_0 += 1
    if S[i] == '1':
        counter_1 += 1
if counter_0 <= counter_1:
    print(2*counter_0)
else:
    print(2*counter_1)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, A, B; cin >> N >> A >> B;
  int max_n = min(A, B);
  int min_n = 0;
  if(N > A + B) {
    min_n = 0;
  } else if(N <= A + B) {
    min_n = (A + B) - N;
  }

  cout << max_n << " " << min_n << endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    set<int> a;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.insert(t);
    }
    if (a.size() == n) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 9600
n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
s1 = [0]
s2 = [0]
mx = 0
for i in range(n):
  s1.append(s1[i]+a1[i])
for p in range(n):
  s2.append(s2[p]+a2[p])
for i in range(1,n+1):
  if s1[i] + s2[n] -s2[i-1] > mx:
    mx = s1[i] + s2[n] -s2[i-1]
print(mx)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int ans=0;
	int t=n;
	while (t!=0)
	{
		if (t%10==2)
		{
			ans++;
		}
		t/=10;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[201];
int main(){
    int n;
    cin>>n;
    n*=2;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<=n;i+=2){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
    cin>>s;
    map<char,int>mp;
    for(int i=0;i<s.length();i++){
        if(!mp.count(s[i]))
            mp[s[i]]=1;
        else
            mp[s[i]]++;
    }
    if(mp.size()==2){
        bool flag=true;
        for(auto it = mp.begin();it!=mp.end();++it){
            if(it->second!=2)
                flag=false;
        }
        if(flag)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
        cout<<"No";
return 0;
}

Measured memory_bytes: 256