akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
using namespace std;
int inf = 1000000000;

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

struct Node{
  int to, from, cost;
};

int main(){
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> dist(n, inf);
  vector<Node> node(m);
  for(int i=0; i<m; i++){
    int s, t, d;
    cin >> s >> t >> d;
    node[i].to = t; node[i].from = s; node[i].cost = d;
  }

  dist[r] = 0;
  int l = 0;
  while( true ){
    if( l > 100000 ){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
    bool f = false;
    for(int i=0; i<node.size(); i++){
      Node d = node[i];
      if( dist[d.from] != inf && dist[d.to] > dist[d.from] + d.cost ){
        dist[d.to] = dist[d.from] + d.cost;
        f = true;
      }
    }
    if( !f ) break;
    l++;
  }

  for(int i=0; i<n; i++){
    if( dist[i] == inf ) cout << "INF" << endl;
    else cout << dist[i] << endl;
  }

  return 0;
}





// EOF

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

def main():
    n = int(input())
    g = [dict() for _ in range(n)]
    for _ in range(n-1):
        u, v, w = list(map(int, input().split()))
        g[u-1][v-1] = w
        g[v-1][u-1] = w
    dist = [-1 for _ in range(n)]
    dist[0] = 0
    q = [0]
    while len(q) > 0:
        f = q.pop()
        for t in g[f]:
            if dist[t] != -1:
                continue
            dist[t] = dist[f] + g[f][t]
            q.append(t)
    for i in range(n):
        if dist[i] % 2 == 0:
            print(0)
        else:
            print(1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49016
#include<iostream>
#include<unistd.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	long long int tmp;
	long long int min=1e18;
	for(int i=0;i<5;i++){
		cin>>tmp;
		min=(tmp>min)?min:tmp;
	}
	if(n%min!=0){
	cout<<(n/min)+5<<endl;
	}else{
	cout<<(n/min)+4<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int n, b, f, r, v;
    vector<vector<vector<int>>> info(
        4, vector<vector<int>>(3, vector<int>(10, 0)));
    cin >> n;
    rep(i, n) {
        cin >> b >> f >> r >> v;
        info[b - 1][f - 1][r - 1] += v;
    }
    rep(i, 4) {
        rep(j, 3) {
            rep(k, 10) {
                cout << " " << info[i][j][k];
                if(k == 9)
                    cout << endl;
            }
        }
        if(i < 3)
            cout << "####################" << endl;
    }
}



Measured memory_bytes: 3152
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc =  new Scanner(System.in);
  int ab = sc.nextInt();
  int bc = sc.nextInt();
  int ca = sc.nextInt();
  int  abc= ab+bc;
  int  bca= bc+ca;
  int  cab= ca+ab;
  int min=0;
  if(abc<bca)min=abc;
  else min=bca;
  if(min>cab) min=cab;
  System.out.println(min);
}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <climits>

using namespace std;

int main(){
	int A,B;
	cin>>A>>B;
	cout<<(A-1)*(B-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
#define pb push_back


int main()
{
	int n, x, y;
	int deg[100010]={}, dag[100010]={};
	vector<int> edge[100010], edge1[100010];
	cin >> n;
	rep(i, n-1)
	{
		cin >> x >> y;
		x--;
		y--;
		edge[x].pb(y);
		edge[y].pb(x);
		deg[x]++;
		deg[y]++;
	}
	int kosu=0;
	rep(i, n)
	{
		if(deg[i]>1) kosu++;
		dag[i]=deg[i];
	}
	if(n==2)
	{
		cout << "1 2" << endl;
		return 0;
	}
	if(n==3)
	{
		cout << "1 2 3" << endl;
		return 0;
	}
	if(kosu==1)
	{
		cout <<  "1 ";
		reps(i, n-3) cout << i+2 << ' ';
		cout << "2 " << n << endl;
		return 0;
	}
	rep(i, n)
	{
		if(deg[i]==1)
		{
			dag[edge[i][0]]--;
			dag[i]=0;
		}
	}
	int kosu1=0, kosu2=0;
	rep(i, n)
	{
		if(dag[i]==1) kosu1++;
		if(dag[i]==2) kosu2++;
	}
	if(kosu1==2 && kosu1+kosu2==kosu)
	{
		int s=-1, t;
		rep(i, n)
		{
			if(dag[i]==1)
			{
				if(s==-1) s=i;
				else t=i;
			}
			if(dag[i]==1 || dag[i]==2)
			{
				rep(j, edge[i].size())
				{
					int k=edge[i][j];
					if(dag[k]==1 || dag[k]==2) edge1[i].pb(k);
				}
			}
		}
		int ss[100010], tt[100010], dones[100010]={}, donet[100010]={};
		ss[0]=s;
		tt[0]=t;
		dones[s]=1;
		donet[t]=1;
		rep(i, kosu-1)
		{
			rep(j, edge1[ss[i]].size())
			{
				int k=edge1[ss[i]][j];
				if(dones[k]==0)
				{
					ss[i+1]=k;
					dones[k]++;
					break;
				}
			}
			rep(j, edge1[tt[i]].size())
			{
				int k=edge1[tt[i]][j];
				if(donet[k]==0)
				{
					tt[i+1]=k;
					donet[k]++;
					break;
				}
			}
		}
		int muri=0;
		rep(i, kosu)
		{
			if(edge[ss[i]].size()>edge[tt[i]].size())
			{
				muri=1;
				break;
			}
			else if(edge[ss[i]].size()<edge[tt[i]].size())
			{
				muri=0;
				break;
			}
		}
		int rui[100010];
		if(muri==0)
		{
			rui[0]=edge[ss[0]].size()-2;
			reps(i, kosu-1)
			{
				rui[i]=edge[ss[i]].size()-2;
			}
		}
		else
		{
			rui[0]=edge[tt[0]].size()-2;
			reps(i, kosu-1)
			{
				rui[i]=edge[tt[i]].size()-2;
			}
		}
		cout << '1';
		int tmp=2;
		rep(i, kosu)
		{
			cout << ' ';
			for(int j=tmp; j<tmp+rui[i]; j++)
			{
				cout << j+1 << ' ';
			}
			cout << tmp;
			tmp+=(rui[i]+1);
		}
		cout << ' ' << n << endl;
	}
	else
	{
		cout << "-1" << endl;
	}





	return 0;
}

Measured memory_bytes: 14464
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	ll N, X;
	cin >> N >> X;

	vector<ll> L(N);
	rep(i, N) cin >> L[i];

	ll tmp = 0, ans = 0;
	for (int i = 0;;i++) {
		if (tmp <= X) {
			ans++;
			if (i >= N) break;
			tmp += L[i];
		}
		else {
			break;
		}
	}

	cout << ans << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for(auto it = v.begin();it != v.end();it++) 
		min = std::min(min,*it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


Measured memory_bytes: 504
N = int(input())
X  = list(map(int, input().split()))

ans1 = 0
ans2 = 0
S = sum(X)//N

for x in X:
    ans1 += (x - S) ** 2
    ans2 += (x - (S + 1)) ** 2

print(min(ans1, ans2))

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

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

int main()
{
	int n;
	scanf("%d ", &n);
	for (int c = 0; c < n; c++){
		string str;
		getline(cin, str);
		
		for (int a = 1; a <= 26; a++){
			if (gcd(a, 26) != 1) continue;
			for (int b = 0; b < 26; b++){
				string cpy(str);
				for (int i = 0; i < str.size(); i++){
					if (cpy[i] == ' ') continue;
					cpy[i] = ((cpy[i] - 'a') * a + b) % 26 + 'a';
				}
				for (int i = 0; i < (int)str.size() - 3; i++){
					string t(cpy, i, 4);
					if (t == "that" || t == "this"){
						cout << cpy << endl;
						goto BREAK;
					}
				}
			}
		}
		
		BREAK:;
	}
	
	return 0;
}

Measured memory_bytes: 1244
n, k = map(int, input().split())
A = [0] * (10 ** 5 + 10)
for _ in range(n):
    a, b = map(int, input().split())
    A[a] += b
cnt = 0
for i in range(10 ** 5 + 10):
    cnt += A[i]
    if cnt >= k:
        print(i)
        exit()

Measured memory_bytes: 11568
#include <stdio.h>

int N, M;
int a[64 * 64], b[64 * 64];

char edge[64][64];
char loop[64][64];

char visited[64];
int trace[64 * 64];

void dfs(int node, int depth, int parent) {
	int i;
	trace[depth] = node;
	if (visited[node]) {
		for (i = depth - 1; i >= 0; i--) {
			loop[trace[i]][trace[i + 1]] = 1;
			if (trace[i] == node) break;
		}
	} else {
		visited[node] = 1;
		for (i = 1; i <= N; i++) {
			if (i != parent && edge[node][i]) {
				dfs(i, depth + 1, node);
			}
		}
		visited[node] = 0;
	}
}

int main(void) {
	int i;
	int sumipe = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d%d", &a[i], &b[i]) != 2) return 1;
		edge[a[i]][b[i]] = edge[b[i]][a[i]] = 1;
	}
	dfs(1, 0, 0);
	for (i = 0; i < M; i++) {
		if (!loop[a[i]][b[i]] && !loop[b[i]][a[i]]) sumipe++;
	}
	printf("%d\n", sumipe);
	return 0;
}


Measured memory_bytes: 128
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from bisect import bisect_right

N,K = LI()
A = LI()

# 各値の場所
d = defaultdict(list)
for i in range(N):
    d[A[i]].append(i)

# 各場所スタートでの，終了時の先頭要素
T = [0]*(N+1)
for i in range(N)[::-1]:
    p = bisect_right(d[A[i]],i)
    if p < len(d[A[i]]):
        T[i] = T[d[A[i]][p]+1]
    else:
        T[i] = A[i]

# 各indexスタートが何週目の操作で起こるか
S = defaultdict(list)
index = 0
roop_flag = False
empty_flag = False
for i in range(1,N+2):
    S[index].append(i)
    if len(S[index]) > 1:
        start = S[index][0]
        end = S[index][1]
        roop_flag = True
        break
    n = T[index]
    if n == 0:
        num = i
        empty_flag = True
        break
    index = d[n][0]+1

def request_s(index):
    ret = []
    while index <= N-1:
        p = bisect_right(d[A[index]],index)
        if p < len(d[A[index]]):
            index = d[A[index]][p]+1
        else:
            ret.append(A[index])
            index += 1
    return ret

if roop_flag:
    if K <= start:
        index = 0
        for i in range(K-1):
            index = d[T[index]][0]+1
        ans = request_s(index)
    else:
        index = 0
        for i in range(start-1):
            index = d[T[index]][0]+1
        left = (K-(start-1)) % (end-start+1)
        if left == 0:
            left = end-start+1
        for i in range(left-1):
            index = d[T[index]][0]+1
        ans = request_s(index)
else:
    K = K%num
    index = 0
    if K == 0:
        ans = []
    else:
        for i in range(K-1):
            index = d[T[index]][0]+1
        ans = request_s(index)

print(*ans)

Measured memory_bytes: 130960
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[][] c = new int[3][3];
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                c[i][j] = sc.nextInt();
            }
        }

        String ans = solve(c);

        System.out.println(ans);
    }

    private static String solve(int[][] c) {
        for (int d=0; d<2; d++) {
            if (!equals(c[0][d+1] - c[0][d], c[1][d+1] - c[1][d], c[2][d+1] - c[2][d])) {
                return "No";
            }
        }

        for (int d=0; d<2; d++) {
            if (!equals(c[d+1][0] - c[d][0], c[d+1][1] - c[d][1], c[d+1][2] - c[d][2])) {
                return "No";
            }
        }

        return "Yes";
    }

    private static boolean equals(int d1, int d2, int d3) {
        if (d1 == d2 && d2 == d3) return true;

        return false;
    }
}

Measured memory_bytes: 25044
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}
 
using namespace std;

void solve(){
  int n,m;
  cin>>n>>m;
  vector<int>s(n),t(m);
  rep(i,n)cin>>s[i];
  rep(i,m)cin>>t[i];
  vector<vector<ll>>dp(n+1,vector<ll>(m+1));
  vector<vector<ll>>sum(n+1,vector<ll>(m+1));
  rep(i,n){
    rep(j,m){
      if(s[i]==t[j]){
        dp[i+1][j+1]+=sum[i][j]+1;
      }
      dp[i+1][j+1]%=mod;
      sum[i+1][j+1]=(sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1]+mod)%mod;
    }
  }
  cout<<(sum[n][m]+1)%mod<<endl;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 62976
#include <iostream>
using namespace std;
int n;
int main() {
	cin >> n;
	for (int i = 1;i <= n;++i) 
	{
		int x = i;
		if (x % 3 == 0) 
		{
			cout << " " << i;
		}
		else 
		{
			while (x>0) {
				if (x % 10 == 3) 
				{
					cout << " " << i;
					break;
				}
				x = x / 10;
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0
#define LIM 1000000007

int main(){
	char s;
	char now;
	string str;
	cin>>str;

	lli cnt=0;
	s = str.at(0);
	for(lli i=1;i<str.size();i++){
		now = str.at(i);
		if(now!=s)cnt++;
		s = now;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  for(ll h=1; h<=3500; h++){
    for(ll n=1; n<=3500; n++){
      ll a = h * n * N;
      ll b = 4LL*h*n - (n * N) - (h * N);

      if(a > b && b > 0 && (a%b==0)){
        ll w = a / b;

        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
    
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,a[100010];
signed main(){
    cin>>n;
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    cout<<sum-((n+1)*n/2)<<endl;
    return 0;
}



Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  int n,ans=0;
  string a,b,c;
  cin>>n>>a>>b>>c;
  for(int i=0;i<n;i++){
    if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i]) ans+=2;
    else if(!(a[i]==b[i] && b[i]==c[i])) ans+=1;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int a,b;
	string s;
	cin >> a >> b >> s;
	bool bb=1;
	REP(i,a+b+1){
		if(i<a){
			if(s[i]<'0'||s[i]>'9') bb=0;
		}else if(i==a){
			if(s[i]!='-') bb=0;
		}else{
			if(s[i]<'0'||s[i]>'9') bb=0;
		}
	}
	cout << (bb ? "Yes" : "No") << endl;
/////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int N;
    cin >> N;
    cout << arr[N-1];
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
d = {}
for e in a:
    if e in d:
        d[e] += 1
    else:
        d[e] = 1

count = 0
for e in d:
    if e < d[e]:
        count += d[e] - e
    elif e > d[e]:
        count +=  d[e]

print(count)

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

int main()
{
string T,S,U;
cin>>S;
cin>>T;
int A,B;
cin>>A>>B;
cin>>U;
if(U==S){
    A-=1;
}else{B-=1;
}


cout<<A<<" "<<B<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iomanip>
#include <stdlib.h>

using namespace std;

#define LL long long
#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)
#define pi pair<int,int>
#define mp make_pair

const int maxN = 1e5 + 11;
const LL oo = 1e17 + 11;

int N,K;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    //
    cin >> N >> K;
    int res = 0;
    FOR(i,1,N){
        int x;
        cin >> x;
        res += (x >= K);
    }

    cout << res;

    return 0;
}

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

int N;
// bit[1]からbit[N]までを使用
int bit[1000010];
// 区間の右端で番号づけ(左の子のみに番号づけ)
// bit[x]が管理する区間の長さは、xの最も下の立っているビット
// 例えば、bit[6]が管理する区間の長さは、6=0110の最も下の立っているビットより0010=2 よって 2
// 最も下の立っているビットを取り出すのは、x & -x でできる。


// 次の更新すべき区間は、番号に区間の長さを足すと求まる
// v[a] += w
void add(int a, int w){
    for(int x=a; x <= N; x += x & -x) bit[x] += w;
}

// 次に足すべき区間は、番号から区間の長さを引くと求まる
// v[1]+...+v[a]
int sum(int a){
    int ret = 0;
    for(int x=a; x>0; x -= x & -x) ret += bit[x];
    return ret;
}

int main() {
    int q;
    cin >> N >> q;
    for(int i=0; i<q; i++){
        int com, x, y;
        cin >> com >> x >> y;
        if(com==0){
            add(x,y);
        }
        else if(com==1){
            cout << sum(y)-sum(x-1) << endl;
        }
    }
}



Measured memory_bytes: 3512
import math
from collections import deque
from collections import defaultdict

import time

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

a,b = readInts()

print(a*b)

Measured memory_bytes: 9592
#include <vector>
#include <stack>
#include <cstddef>
#include <algorithm>

struct strongly_connected_component {
	using size_type = std::size_t;
private :
	size_type num;
	std::vector<std::vector<size_type>> g, scc;
	std::vector<size_type> low, order, index;
	std::vector<bool> instack;
	std::stack<size_type> sta;

	void chmin (size_type &a, const size_type &b) noexcept {
		if (a > b) a = b;
	}

	void dfs (size_type v) noexcept {
		low[v] = order[v] = ++num;
		sta.push(v); instack[v] = true;
		for (const size_type &u : g[v]) {
			if (order[u] == 0) {
				dfs(u);
				chmin(low[v], low[u]);
			} else if (instack[u]) {
				chmin(low[v], order[u]);
			}
		}
		if (low[v] == order[v]) {
			scc.push_back(std::vector<size_type>());
			while (true) {
				const size_type u = sta.top();
				sta.pop(); instack[u] = false;
				scc.back().push_back(u);
				if (u == v) break;
			}
		}
	}

public :
	explicit strongly_connected_component (size_type n)
	: num(0), g(n), scc(), low(n, 0), order(n, 0), index(n), instack(n, false), sta() { }

	void add_edge (size_type v, size_type u) noexcept {
		g[v].push_back(u);
	}

	size_type solve () noexcept {
		for (size_type v = 0; v < g.size(); v++) if (not order[v]) dfs(v);
		std::reverse(scc.begin(), scc.end());
		for (size_type i = 0; i < scc.size(); i++) {
			for (const size_type &v : scc[i]) index[v] = i;
		}
		return scc.size();
	}

	const std::vector<std::vector<size_type>> &get () const noexcept {
		return scc;
	}

	size_type size () const noexcept {
		return scc.size();
	}

	const size_type &operator[] (size_type v) const noexcept {
		return index[v];
	}

};

#include <iostream>
#include <cstddef>

using usize = typename strongly_connected_component::size_type;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	usize n, m;
	std::cin >> n >> m;
	strongly_connected_component g(n);
	for (usize i = 0; i < m; i++) {
		usize a, b;
		std::cin >> a >> b;
		g.add_edge(a, b);
	}
	
	std::cout << g.solve() << '\n';
	for (const auto &vec : g.get()) {
		std::cout << vec.size();
		for (auto &v : vec) std::cout << ' ' << v;
		std::cout << '\n';
	}
	
	return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<int> h(n);
  vector<bool> can(n, true);
  for (int i=0; i<n; i++) {
    cin >> h[i];
  }
  for (int i=0; i<m; i++) {
    int u, v; cin >> u >> v;
    u--, v--;
    if (h[u] <= h[v]) can[u]=0;
    if (h[v] <= h[u]) can[v]=0;
  }
  int ans=0;
  for (bool b : can) ans+=b;
  cout << ans;
  return 0;
}


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

int main(){
  long H, W;
  cin >> H >> W;
  long ans = H*W;
  if(H==1 || W==1){
    cout << "1" << endl;
    return 0;
  }
  if(ans%2==0){
    cout << ans/2 << endl;
    return 0;
  }
  cout << ans/2+1 << endl;
  return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.par = []
        for i in range(n+1):
            self.par.append(i)

    def find(self, x):
        if(self.par[x] == x):
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same(self,x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y) :
            return
        self.par[x] = y




n, m = map(int, input().split())
p = list(map(int, input().split()))

uf = UnionFind(n);

for _ in range(m):
    x, y = map(int, input().split())
    uf.union(x, y)


count = 0
for index in range(n):
    start = index + 1
    to = p[index]
    if uf.same(start, to):
        count += 1
print(count)


Measured memory_bytes: 13812
using System;
using System.Linq;

namespace abc_054_A
{
    class Program
    {
        static void Main(string[] args)
        {
          //  while (true)
            //{
                int[] a = Console.ReadLine().Split().Select(Int32.Parse).ToArray();
                //       long a = Int64.Parse(Console.ReadLine());
                if ((a[0] == 1 && a[1] 
                    >a[0])) { Console.WriteLine("Alice"); }
                else if ((a[1] == 1 && a[0] > a[1])) { Console.WriteLine("Bob"); }
                else if (a[0] == a[1]) { Console.WriteLine("Draw"); }

                else if (a[0] > a[1]) { Console.WriteLine("Alice"); }
                else { Console.WriteLine("Bob"); }
            
        }
    }
}

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

#define DB(a) cerr << __LINE__ << ": " << #a << " = " << (a) << endl;

using namespace std;

typedef pair<int, int> pii;

#define int64 long long int
#define mp make_pair
#define pb push_back
#define MAXN (int)(2e3+5)

int64 slimes[MAXN];
int64 dp[MAXN][MAXN];

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

    int n, x; cin >> n >> x;
	int64 best = 0;
	for (int i = 0; i < n; ++i){
		cin >> slimes[i];
		dp[i][0] = slimes[i];
		best += dp[i][0];
	}

	for (int j = 1; j < n; ++j) {
		int64 resp = 0;
		for (int i = 0; i < n; ++i) {
			dp[i][j] = min(dp[i][j - 1], slimes[(i - j + n) % n]);
			resp += dp[i][j];
		}
		best = min(best, resp + ((int64)j) * x);
	}
	cout << best << '\n';

	return 0;
}


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

int min(int x,int y, int z){
  int m = abs(x-y)+abs(y-z);
  if(m>abs(y-z)+abs(z-x)) m = abs(y-z)+abs(z-x);
  if(m>abs(x-y)+abs(z-x)) m = abs(x-y)+abs(z-x);
  return m;
}

int main(){
  int a[3];
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  printf("%d\n",min(a[0],a[1],a[2]));
  return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
map<int,int> mp;
int main(){
	//freopen("input.txt","r",stdin);
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++)
		mp[min(j-i,abs(i-x)+abs(j-y)+1)]++;
	for(int i=1;i<n;i++) cout<<mp[i]<<endl;
	return 0;
}

Measured memory_bytes: 384
// abc146_a
#include <iostream>
#include <math.h>
#include <cstring>
#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
using namespace std;

int main(int argc, char const *argv[])
{
    UI n;
    char s[10001];
    cin >> n >> s;

    for (UI i = 0; s[i] != '\0'; i++)
    {
        char t = s[i] - 65;
        t += n;
        if (t > 25)
            t -= 26;
        t += 65;
        s[i] = t;
    }

    cout << s << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main(void){
	int n;
	cin >> n;
	vector<int>h(n);
	for (int i = 0;i < n;i++)cin >> h[i];
	int ans = 1;
	for (int i = 1;i < n;i++) {
		bool can = true;
		for (int j = 0;j <= i - 1;j++) {
			if (h[j] > h[i]) {
				can = false;
				break;
			}
		}
		if (can)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int n[9];

int solve(int now, vector<int> m, vector<bool> b){
    if(now == 9){
        if(m[0] + 10*m[1]+m[2] +100*m[3]+10*m[4]+m[5] == 100*m[6]+10*m[7]+m[8]) return 1;
        return 0;
    }
    if(n[now] != -1) return solve(now+1, m, b);

    int re = 0;
    for(int i=0; i<9; i++){
        if(b[i] == true) continue;
        b[i] = true;
        m[now] = i+1;
        re += solve(now+1, m, b);
        b[i] = false;
        m[now] = -1;
    }
    return re;
}

int main(){
    
    vector<int> m;
    vector<bool> b;
    for(int i=0; i<9; i++) b.push_back(false);

    for(int i=0; i<9; i++){
        cin >> n[i];
        m.push_back(n[i]);
        if(n[i] != -1) b[n[i]-1] = true;
    }

    cout << solve(0, m, b) << endl;
    
    return 0;
}


Measured memory_bytes: 3168
class SegmentTreeDual():
    def __init__(self,arr,op=lambda x,y:y if y != -1 else x,ie=-1):
        self.h = (len(arr)-1).bit_length()
        self.n = 2**self.h
        self.ie = ie
        self.op = op
        self.val = [ie for _ in range(self.n)]
        self.laz = [ie for _ in range(2*self.n)]
        for i in range(len(arr)):
            self.val[i] = arr[i]
    def update(self,left,right,f):
        left += self.n
        right += self.n
        while right - left > 0:
            if right & 1:
                right -= 1
                self.laz[right] = self.op(self.laz[right],f)
            if left & 1:
                self.laz[left] = self.op(self.laz[left],f)
                left += 1
            left >>= 1
            right >>= 1
    def get(self,index):
        res = self.val[index]
        index += self.n
        while index>0:
            res = self.op(res,self.laz[index])
            index //= 2
        return res

import sys
input = sys.stdin.readline

import bisect

N,D,A = map(int,input().split())
monster = [list(map(int,input().split())) for _ in range(N)]

monster.sort()
ans = 0
X = []
H = []
for i in range(N):
    X.append(monster[i][0])
    H.append(monster[i][1])

r = [0 for _ in range(N)]
for i in range(N):
    r[i] = bisect.bisect_left(X,X[i]+2*D+1)

sg = SegmentTreeDual(H,lambda x,y:x+y,0)

for i in range(N):
    hp = sg.get(i)
    if hp <= 0:
        continue
    cnt = -(-hp//A)
    sg.update(i,r[i],-A*cnt)
    ans += cnt

print(ans)


Measured memory_bytes: 119648
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<ll> A(4);
  cin>>A;
  ll ans=1e18;
  for(int i=0;i<1<<4;i++){
    if(__builtin_popcount(i)!=2){continue;}
    ll tmp=0;
    for(int j=0;j<4;j++){
      tmp+=(i>>j&1?1:-1)*A[j];
    }
    ans=min(ans,abs(tmp));
  }
  cout<<ans<<endl;
  
  


  return 0;
}



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

int main(){
  int n,m;
  cin >> n >> m;
  int count=0;
  if(n<=1) cout << (m*(m-1))/2 << endl;
  else if(m<=1) cout << (n*(n-1))/2 << endl;
  else{
    count += (n*(n-1))/2+(m*(m-1))/2;
    cout << count << endl;
  }  
  return 0;
}

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

const int MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow( ll x, ll y ){
	ll result = 1;
	ll xx = x % MOD;
	while ( y ){
		if ( y & 1 )
			result = result * xx % MOD;
		xx = xx * xx % MOD;
		y >>= 1;
	}
	return result;
}

ll ncr2( ll n, ll r ){
	ll result = 1;
	for ( ll i = 0; i < r; i++ ){
		result = ((result * (n-i) % MOD) * inv[r-i])%MOD;
	}
	return result;
}

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	
    COMinit();
	cout << (modpow(2,n)-1 - ncr2(n,a) - ncr2(n,b) + MOD*3)%MOD << endl;
	
	
	
	
	return 0;
}



Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define maxx 1000100
using namespace std;
int x,arr[maxx],dp[maxx];

int main() {
	cin >> x;
	for(int i = 0; i < x; i++){
		cin >> arr[i];
		dp[i] = maxx;
	}
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i < x; i++){
		dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]),dp[i-2] + abs(arr[i] - arr[i-2]));
	}
	cout << dp[x-1] << endl;
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

struct Graph
{
std::size_t sz;
std::vector<std::set<int>> elist;
// set avoids duplicates

Graph(int n) : sz(n), elist(n)
{}
void add_edge(int i,int j)
{
	elist[i].insert(j);
	elist[j].insert(i);
}
std::size_t size()
{
	return sz;
}


unsigned connected_components(std::vector<int>& components)
{	unsigned int num = 0;
	std::vector<bool> visited(sz,false);
	for(unsigned v = 0; v < sz; ++v)
	{		
		if(visited.at(v)== false)
		{	
			std::vector<int> nb;
			std::vector<int> nb2;
			components.push_back(0);
			visited.at(v) = true;	
			++components.at(num);
			for(auto & e : elist[v])
			{
				if(visited.at(e)== false)
				{
				nb.push_back(e);
				++components.at(num);
				visited.at(e) = true;			
				}			
			}
			while(!nb.empty())
			{
				for(auto & n : nb)
				{
					for(auto &e : elist.at(n))
					{	if(!visited.at(e))	
						{	nb2.push_back(e);
							++components.at(num);
							visited.at(e) = true;
						}					
					}
				}
				std::swap(nb, nb2);
				nb2.clear();
			}
			++num; 
		}
		
	}
	return num;
}


};





int main()
{
	int n, m;
	std::cin >> n >> m;
	Graph g(n);

	for(int l = 0 ; l < m ; ++l)
	{
		int i, j;
		std::cin >> i >> j;
		g.add_edge(i-1,j-1);
	}
	std::vector<int> components;
	int num = g.connected_components(components);
	if(num == 1)
	{
		std::cout << g.size() ;
		return 0;
	}
	int groups = 0;
	for(auto & m : components)
	{
		if(m > groups)
		groups = m; 
	}
	
	std::cout << groups << std::endl;
}





Measured memory_bytes: 31800
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    string s;cin>>s;
    sort(all(s));
    cout << (s == "abc" ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  
  string s;
  cin >> s;
  
  int counter = 0;
  if(s[0] == '1') ++counter ;
  
  if(s[1] == '1') ++counter ;
  
  if(s[2] == '1') ++counter ;
  
  cout << counter << endl;
  
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
V = list(map(int,input().split()))

V.sort()
ans = V[0]
for i in range(1,N):
    ans = (ans + V[i]) / 2

print(ans)

Measured memory_bytes: 3060
#include <iostream>

int main()
{
	int weeks = 0;
	int amount = 100000;
	std::cin >> weeks;
	for (int i = 0; i < weeks; ++i) {
		amount = amount * 105 / 100;
		amount = (amount + 999) / 1000 * 1000;
	}
	std::cout << amount << std::endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  string s,t;
  cin >> s >> t;

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());

  ll n=s.size();
  vec u,v;
  ll c=1;
  char r=s[0];
  for(ll i=1;i<n;i++){
    if(r==s[i]){
      c++;
    }
    else{
      r=s[i];
      u.push_back(c);
      c=1;
    }
  }
  u.push_back(c);
  c=1;
  r=t[0];
  for(ll i=1;i<n;i++){
    if(r==t[i]){
      c++;
    }
    else{
      r=t[i];
      v.push_back(c);
      c=1;
    }
  }
  v.push_back(c);
  sort(u.begin(),u.end());
  sort(v.begin(),v.end());

  if(u==v)cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3876
from collections import defaultdict
N, K = map(int, input().split())
T = defaultdict(list)
for i in range(N):
    t, d = map(int, input().split())
    T[t].append(d)
S = []; U = []
for k, v in T.items():
    v.sort(reverse=1)
    U.append((v[0], k))
    for w in v[1:]:
        S.append((w, k))
S.sort(reverse=1)
U.sort(reverse=1)
D = defaultdict(int)
t = cnt = 0
res = 0
for w, k in S:
    D[k] += 1
    if D[k] == 1:
        t += 1
    cnt += 1
    res += w
ans = 0
can = 1
for v, k in U:
    D[k] += 1
    if D[k] == 1:
        t += 1
    cnt += 1
    res += v
    while cnt > K:
        if not S:
            can = 0
            break
        cnt -= 1
        w, l = S.pop()
        D[l] -= 1
        if D[l] == 0:
            t -= 1
        res -= w
    if not can:
        break
    ans = max(ans, t*t + res)
print(ans)

Measured memory_bytes: 40224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ma,sum;
  ma=0;
  sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int s;
    cin>>s;
    sum+=s;
    ma=max(ma,s);
  }
  if(2*ma<sum){cout<<"Yes";}
  else{cout<<"No";}
}

Measured memory_bytes: 256
#include <cstdio>

int main(int argc, char const *argv[]) {

    bool decrease_flag = true;
    int n;
    int current, previous;
    int min, max = 0;
    const int DIFF_INIT = 1;
    int diff = DIFF_INIT;

    scanf("%d", &n);
    scanf("%d", &current);
    min = current;
    for(int i=1 ; i<n; i++){
        previous = current;
        scanf("%d", &current);

        if(current < min){
            min = current;
            if(max > 0) max = 0;
        }
        else if(current > max) max = current;

        if(current > previous){
            decrease_flag = false;
            if((max-min) > diff) diff = max - min;
        }
        else if(decrease_flag){
            if((diff == DIFF_INIT) || (current-previous) > diff) diff = current - previous;
        }
    }

    printf("%d\n", diff);
    return 0;
}

Measured memory_bytes: 2736
//****************************************
// 必要なヘッダファイルのインクルード
//****************************************

#include <iostream>
#include <vector>
#include <cstdint>



//****************************************
// 構造体の定義
//****************************************

/**< @brief 素集合森 */
struct disjoint_sets {
    using index_t = std::int32_t;
    using rank_t  = std::int32_t;

    std::vector<index_t> p;
    std::vector<rank_t> rank;

    explicit disjoint_sets(std::size_t size) : p(size, -1), rank(size, -1) {}

    /**
     * @brief xを唯一の要素(従って、代表元)としてもつ新しい集合を生成する.
     * @note  集合は互いに素であるから、xがすでに別の集合に出現していることはない.
     *
     * @param int x 節点x
     */
    void make_set(index_t x) {
        p[x]    = x;
        rank[x] = 0;
    }

    /**
     * @brief     xを含む動的集合Sxとyを含む動的集合Syを合併(統合)し、
     *            これらの和集合である新しい集合を生成する.
     * @attention SxとSyはこの操作を実行する前は互いに素であると仮定する.
     *
     * @param int x   動的集合Sxの元x
     * @param int y   動的集合Syの元y
     */
    void merge(index_t x, index_t y) {
        link(find_set(x), find_set(y));
    }


    /**
     * @brief 手続きmergeの補助関数
     *
     * @param int x 動的集合Sxの代表元x(Sxの根)
     * @param int y 動的集合Syの代表元y(Syの根)
     */
    void link(index_t x, index_t y) {
        // xのランク > yのランクかどうか判定
        if (rank[x] > rank[y]) {  // x.rank > y.rankならば、
            p[y] = x;             // yの親はxを指す
        }
        else {                    // x.rank <= y.rankならば、
            p[x] = y;             // xの親はyを指す

            if (rank[x] == rank[y]) {   // x.rank == y.rankならば、
                rank[y] = rank[y] + 1;  // y.rankをひとつ増やす
            }
        }
    }

    /**
     * @brief  xを含む(唯一の)集合の代表元へのポインタを返す.
     *         手続きfindsetは2パス法に基づく.再帰が進行するのに従って、
     *         find経路を根に向かって上向きに走査して根を発見し、つぎに、
     *         再帰が巻き戻されるにつれて、辿ってきたfind経路を下る2度目の走査を行って、
     *         find経路上の各節点のポインタを直接根を指すように更新する.
     *
     * @param  int x   集合Sxの元x
     * @return int y   集合Sxの代表元(根)
     */
    index_t find_set(index_t x) {
        // find経路を根に向かって上向きに走査
        if (x != p[x]) {
            p[x] = find_set(p[x]);  // 再帰を進行させる
        }
        return p[x];  // 再帰が底をついてから、根を返す
    }
};



//****************************************
// 関数の定義
//****************************************

int main()
{
    using namespace std;
    
    int a, b, q, n, t;

    cin >> n >> q;

    disjoint_sets ds(n);
    for (int i = 0; i < n; i++) { 
        ds.make_set(i);
    }

    for (int i = 0; i < q; i++) {
        cin >> t >> a >> b;

        if (t == 0) {
            ds.merge(a, b);
        }
        else if (t == 1) {
            if (ds.find_set(a) == ds.find_set(b)) {
                cout << 1 << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}





Measured memory_bytes: 3184
#include<stdio.h>
int main(void)
{
	int n,a,b,w,k;
	scanf("%d %d %d",&n,&a,&b);
	w=n-a;
	k=n-b;
	if(w<0){
		w=w*-1;
	}
	if(k<0){
		k=k*-1;
	}
	if(w<k){
		printf("A\n");
	}
	else{
		printf("B\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long int lli;
using namespace std;

int main() {
	int n, k, q;
	int a[100000];
	cin >> n >> k >> q;
	rep(i, q)cin >> a[i];

	int cnt[100010] = {};
	rep(i, q)cnt[a[i]]++;
	rep(i, n)if (k - q + cnt[i + 1] > 0)cout << "Yes" << endl; else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
bonus = 0
for i in  range(N-1):
  if A[i] + 1 == A[i+1]:
    bonus += C[A[i]-1]

    
print(sum(B)+bonus)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  long long int N,K,ans=0;
  scanf("%lld\n",&N);
  scanf("%lld\n",&K);
ans=K;
for (int i = 2; i <= N; i++) {
  ans*=(K-1);
}
printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=1000002;
int a,b,k;

int main()
{
     read(k); read(a); read(b);
    bool flag=false;
    for (int i=a;i<=b;++i)
        if(i%k==0)
        {
            flag=true;
            break;
        }
    printf("%s",flag?"OK":"NG");
    return 0;
}

Measured memory_bytes: 3764