akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define MAGIC0
mt19937 rnd(time(0)); //rnd()

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

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e5 + 7;
const double PI = acos(-1.);
const double EPS = 1e-8;
const int MOD = 998244353;

int main()
{
//	freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;

	if (s == "keyence")
	{
		return cout << "YES", 0;
	}

	for(int len = 0;len <= SZ(s);++len)
	{
		for(int i = 0;i + len - 1 < SZ(s);++i)
		{
			string t;
			bool was[105];
			FILL (was, 0);
			for(int j = i;j < i + len;++j)
			{
				was[j] = 1;
			}
			FOR(i, 0, SZ(s))
			{
				if (!was[i])
				{
					t += s[i];
				}
			}
			if (t == "keyence")
			{
				return cout << "YES", 0;
			}
		}
	}

	cout << "NO";
	return 0;
}
// 2 12 216 5280 190800 9344160


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 205;
const int INF = 0x3f3f3f3f;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

//******************Flow*******************************//

int S, T, level[N], q[N], head, tail;

struct Edge {
	int v, w, nxt;
} e[N * N << 1];
int first[N], used[N], eCnt;

inline void AddEdge(int u, int v, int w) {
	e[++eCnt].v = v;
	e[eCnt].w = w;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

inline void Add(int u, int v, int w) {
	AddEdge(u, v, w);
	AddEdge(v, u, 0);
}

bool BFS() {
	for (int i = 1; i <= T; ++i) {
		level[i] = -1;
		used[i] = first[i];
	}
	level[S] = 0;
	q[head = tail = 1] = S;
	while (head <= tail) {
		int u = q[head++];
		if (u == T) return 1;
		for (int i = first[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (e[i].w && level[v] == -1) {
				level[v] = level[u] + 1;
				q[++tail] = v;
			}
		}
	}
	return 0;
}

int DFS(int u, int flow) {
	if (u == T) return flow;
	int ret = 0;
	for (int i = used[u]; i; i = e[i].nxt, used[u] = i) {
		int v = e[i].v;
		if (e[i].w && level[v] == level[u] + 1) {
			int tmp = DFS(v, min(flow, e[i].w));
			e[i].w -= tmp;
			e[i ^ 1].w += tmp;
			flow -= tmp;
			ret += tmp;
			if (!flow) break;
		}
	}
	return ret;
}

int Dinic() {
	int ret = 0;
	while (BFS()) {
		ret += DFS(S, INF);
	}	
	return ret;
}

//******************Flow*******************************//

int n, m, A[N][N], B[N][N], C[N][N], col[N][N];
int use[N][N], eid[N][N], sor[N];

void Match(int c) {
	mset(first, 0);
	eCnt = 1;
	S = n + n + 1, T = S + 1;
	for (int i = 1; i <= n; ++i) {
		Add(S, i, 1);
		Add(n + i, T, 1);
		for (int j = 1; j <= m; ++j) {
			if (use[i][j]) continue;
			eid[i][j] = eCnt + 1;
			Add(i, n + col[i][j], 1);
		}
	}
	Dinic();
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (use[i][j]) continue;
			if (e[eid[i][j]].w == 0) {
				B[i][c] = A[i][j];
				use[i][j] = 1;
				break;
			}
		}
	}
}

void init() {
	read(n); read(m);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			read(A[i][j]);
			col[i][j] = (A[i][j] - 1) / m + 1;
		}
	}
}

void solve() {
	for (int i = 1; i <= m; ++i) {
		Match(i);
	}
	for (int j = 1; j <= m; ++j) {
		for (int i = 1; i <= n; ++i) {
			sor[i] = B[i][j];
		}
		sort(sor + 1, sor + n + 1);
		for (int i = 1; i <= n; ++i) {
			C[i][j] = sor[i];
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			printf("%d ", B[i][j]);
		}
		puts("");
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			printf("%d ", C[i][j]);
		}
		puts("");
	}
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 4400
N,M=map(int, raw_input().split())

ary = []
f_num = 0

for j in range(M+1):
    ary.append(0)

for i in range(N):
    L = map(int, raw_input().split())
    L.pop(0)
    for vote in L:
        ary[vote] = ary[vote] +1

for k in ary:
    if k == N:
        f_num = f_num + 1

print f_num


Measured memory_bytes: 2568
/*
	
	@Raghul

*/	
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,a,b;
	cin>>n>>a>>b;
	int curr = a+b-n;
	cout<<min(a,b)<<" "<<max(0,curr)<<endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  cout << (n < 1200 ? "ABC" : "ARC") << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
#define long long long

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


int main(){
	int N, M;
	cin >> N >> M;
	vector<int> s(M);
	vector<int> c(M);
	//int s, c;
	rep(i, M) {
		cin >> s.at(i) >> c.at(i);
	}

	// Erase duplicates
	//sort(vec.begin(), s.end());
  	//vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  	//rep(i, M){
  	//	s = 
  	//}
  	int first;
  	if (N>=2){
		first = pow(10, N-1);
	}else{
		first = 0;
	}
	for(int i = first; i<pow(10, N); i++){
		// extract jth digit number
		int value = i;
		int OK = 1;
		//cout << "i: " << i << endl;
		//Check from 1st digit to Mth digit
		for(int j =1; j<=N; j++){
			int jth_num = value%10;
			value /= 10;
			//cout << "j: " << j << endl;
			//cout << "jth_num: " << jth_num<< endl;
			rep(k, M){
				if (s.at(k) == N-j+1){
					int c_ = c.at(k);
					if (c_ != jth_num){
						OK = 0;
						break;
					}
				}
			}
		}
		if (OK){
			cout << i << endl;
			exit(0);
		}
		
	}
	cout << -1 << endl;

}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/
int A, B, C, K;

signed main() {
    cin >> A >> B >> C >> K;
    if (K % 2 == 0) {
        cout << A - B << endl;
    } else {
        cout << B - A << endl;
    }
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string l;
    cin >> l;
    ll n = l.size();
    const ll MOD = 1e9+7;
    ll dp[n][2];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    dp[0][1] = 2;
    for(i = 1;i < n;++i){
        if(l.at(i) == '1'){
            dp[i][0] = 3*dp[i-1][0] + dp[i-1][1];
            dp[i][1] = 2*dp[i-1][1];
        }else{
            dp[i][0] = 3*dp[i-1][0];
            dp[i][1] = dp[i-1][1];
        }
        rep(j,3){
            dp[i][j] %= MOD;
        }
    }
    ll ans = dp[n-1][0] + dp[n-1][1];
    cout << ans%MOD << endl;
    return 0;
}

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

typedef long long ll;
#define mod 1000000007
#define PRINTV(v) for(int z = 0; z < (v).size(); z++){cout<<v[z]<<" ";}cout<<"\n";

template<typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << endl;
}

void solve(){
    ll a, b, c;
    cin>>a>>b>>c;

}

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

    int a, b, c, d, e;
  	cin>>a>>b>>c>>d>>e;
  	cout<<15 - (a + b + c + d + e);
    return 0;
}

Measured memory_bytes: 3596
A=int(input())
B=int(input())
C=int(input())
D=int(input())
if(A<=B):
  if(C<=D):
    print(A+C)
  else:
    print(A+D)
else:
  if(C<=D):
    print(B+C)
  else:
    print(B+D)
  

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

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

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

    for (int i = x - k + 1; i < x + k; i++)
        cout << i << " ";
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a=0,b=0;
  for(int i=0;i<n;i++) if(s[i]=='R') ++a;
  int ans=max(a,b);
  for(int i=0;i<n;i++){
    if(s[i]=='R') --a;
    else ++b;
    int now=max(a,b);
    ans=min(ans,now);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3728
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var s, t string
	fmt.Fscan(r, &s)
	fmt.Fscan(r, &t)

	min := len(t)

	for i := 0; i < len(s)-len(t)+1; i++ {
		diff := 0
		for j := 0; j < len(t); j++ {
			if s[i+j] != t[j] {
				diff++
			}
		}

		if diff < min {
			min = diff
		}
	}

	fmt.Fprintln(w, min)
}


Measured memory_bytes: 1860
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <string>

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

  std::string T;
  int32_t N, K;
  int64_t R, S, P;
  std::cin >> N >> K;
  std::cin >> R >> S >> P;
  std::cin >> T;
  int64_t res = 0;
  for (int i = 0; i < N; i++) {
    if (i < K) {
      if (T[i] == 'r') {
        res += P;
      } else if (T[i] == 's') {
        res += R;
      } else {
        res += S;
      }
    } else {
      if (T[i] == T[i-K]) {
        T[i] = 'x';
        continue;
      } else if (T[i] == 'r') {
        res += P;
      } else if (T[i] == 's') {
        res += R;
      } else {
        res += S;
      }
    }
  }
  std::cout << res << std::endl;

  return 0;
}


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

using namespace std;

const int MAXN = 100005;
const int MOD = (int)1e9 + 7;

int n, a[MAXN], fac[MAXN], inv[MAXN], sum[MAXN];

int fexp(int x, int y) {
  int res = 1;
  for(int i = 1; i <= y; i <<= 1) {
    if(i & y) res = 1LL * res * x % MOD;
    x = 1LL * x * x % MOD;
  }
  return res;
}

int calc(int t) {
  return 1LL * fac[n] * inv[t + 1] % MOD;  
}

void init(int n) {
  fac[0] = inv[0] = 1;
  for(int i = 1; i <= n; i++) {
    fac[i] = 1LL * fac[i - 1] * i % MOD;
    inv[i] = fexp(i, MOD - 2);
  }
  sum[0] = calc(0);
  for(int i = 1; i < n; i++) {
    sum[i] = (sum[i - 1] + calc(i)) % MOD;
  }
}


int main() {
  scanf("%d", &n);
  init(n);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int tot = (sum[i - 1] + sum[n - i] % MOD - sum[0]) % MOD;
    ans = (ans + 1LL * tot * a[i] % MOD) % MOD;
  }
  printf("%d\n", (ans + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 1792
def show(A):
    for i in range(N):
        if i<N-1:
            print(A[i],end=' ')
        else:
            print(A[i])

N=int(input())
A=list(map(int,input().split()))
show(A)
for i in range(1,N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    show(A)


Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	if(n>=64)
	cout<<64<<endl;
	if(n>=32&&n<64)
	cout<<32<<endl;
	if(n>=16&&n<32)
	cout<<16<<endl;
	if(n>=8&&n<16)
	cout<<8<<endl;
	if(n>=4&&n<8)
	cout<<4<<endl;
	if(n>=2&&n<4)
	cout<<2<<endl;
	if(n==1)
	cout<<1<<endl;
	if(n==0)
	cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero\n";
    } else{
        int cnt = max(0, min(-1, b) - a + 1);
        cout << (cnt % 2 == 0 ? "Positive\n" : "Negative\n");
    }

    return 0;
}

Measured memory_bytes: 256
N,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
l.sort()

for n in range(N):
    if n!=N-1:
        if l[n]<x:
            x-=l[n]
            ans+=1
        elif l[n]==x:
            x-=l[n]
            ans+=1
            break
        else:
            break
    else:
        if l[n]==x:
            x-=l[n]
            ans+=1
        else:
            break

print(ans)

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

int main() {
	int nps;
	double dist;
	int npassed;
	int i;

	scanf("%d %lf", &nps, &dist);
	npassed = 0;
	for(i=0; i<nps; i++) {
		double x, y;
		scanf("%lf %lf", &x, &y);
		if(sqrt(x*x + y*y) <= dist) 
			npassed++;
	}

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


Measured memory_bytes: 2216
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] numsA = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[] numsB = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[] numsC = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long answer = 0;

    for(int i = 0; i < n; i++) answer += numsB[i];

    for(int i = 0; i < n-1; i++)
    {
      if(numsA[i+1] == numsA[i]+1)
      {
        answer += numsC[numsA[i]-1];
      }
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11092
n, m = map(int, input().split())
a = list(map(int, input().split()))

sum_a = sum(a)
a = sorted(a)

cnt = 0
for i in a:
    if i >= sum_a / (4*m):
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

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

//bit全探索改
vector<string> bit_all_search(int n){
  vector<string> use(0);
  queue<string> Q;
  Q.push("");
  while(Q.size()){
    string S = Q.front();
    Q.pop();
    string T = S;
    T += '0';
    if(T.size() == n){
      use.push_back(T);
    }
    else{
      Q.push(T);
    }
    T = S;
    T += '1';
    if(T.size() == n){
      use.push_back(T);
    }
    else{
      Q.push(T);
    }
  }
  return use;
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N,vector<int>(0));
  map<P,int> M;
  for(int i=0; i<N-1; i++){
    int a, b;
    cin >> a >> b;
    if(a > b){
      swap(a,b);
    }
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
    P add = {a,b};
    M[add] = i;
  }
  
  
  //条件が満たされないのは、M個の制約について、使う辺の集合全てが白であることをMiとすると、
  //M1 || M2 || ... || Mmとなる
  //よってこれに包除原理を用いるとかつの式に変換できる
  
  int m;
  cin >> m;
  
  vector<set<int>> S(m);
  
  for(int i=0; i<m; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    vector<int> par(N);
    vector<bool> seen(N,false);
    queue<int> Q;
    Q.push(x);
    seen[x] = true;
    while(Q.size()){
      int x = Q.front();
      Q.pop();
      for(int i=0; i<G[x].size(); i++){
        if(!seen[G[x][i]]){
          seen[G[x][i]] = true;
          par[G[x][i]] = x;
          Q.push(G[x][i]);
        }
      }
    }
    while(y != x){
      int x1, y1;
      x1 = par[y];
      y1 = y;
      if(x1 > y1){
        swap(x1,y1);
      }
      P check = {x1,y1};
      int z = M[check];
      S[i].insert(z);
      y = par[y];
    }
  }
  
  /*for(int i=0; i<m; i++){
    for(auto itr = S[i].begin(); itr != S[i].end(); itr++){
      cout << *itr << " ";
    }
    cout << endl;
  }*/
  
  int64_t ans = pow(2,N-1);
  int64_t no = 0;
  
  vector<string> X = bit_all_search(m);
  
  for(int i=0; i<X.size(); i++){
    string T = X[i];
    int cnt = 0;
    set<int> same;
    for(int j=0; j<m; j++){
      if(T[j] == '1'){
        cnt++;
        for(auto itr = S[j].begin(); itr != S[j].end(); itr++){
          same.insert(*itr);
        }
      }
    }
    int SIZE = same.size();
    if(cnt %2 == 1){
      no += pow(2,N-1-SIZE);
    }
    else if(cnt != 0){
      no -= pow(2,N-1-SIZE);
    }  
  }
  cout << ans - no << endl;
}

Measured memory_bytes: 70828
import sys
import pprint

pp = pprint.PrettyPrinter(indent=4)

def main():
    """ Code implementation """
    N, M = map(int, input().split())
    all_love = [True] * M
    for n in range(N):
        arr = list(map(int, input().split()))
        K, A = arr[0], arr[1:]
        this_love = [False] * M
        for k in range(K):
            a = int(A[k])
            this_love[a-1] = True
        for m in range(M):
            if all_love[m] and not this_love[m]:
                all_love[m] = False

    sum_love = 0
    for m in range(M):
        if all_love[m]:
            sum_love += 1
    print(sum_love)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
K = int(input())

from collections import deque
d = deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
  x = d.popleft()
  if x%10!=0:
    d.append(10*x+x%10-1)
  d.append(10*x+x%10)
  if x%10!=9:
    d.append(10*x+x%10+1)

print(x)

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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];
int head[MAXN];

string s;

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

struct edge {
	int to, next;
}e[MAXN * 2];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

int main(){
	int T;
	string s1, s2, s3;
	cin >> s1 >> s2;
	for (int i = 0; i < s2.size() - 1; i++) s3 += s2[i];
	if (s3 == s1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int x, y, z; cin >> x >> y >> z;

	int r = min(y / x, z);

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, m, n) for (int i = m; i <= n; ++i)
using namespace std;

int main() {
	int n, m, C[51]={};
	cin >> n >> m;
	REP(i,m) {
		int a, b; cin >> a >> b;
		++C[a], ++C[b];
	}
	FOR(i,1,n) cout << C[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s1,s2;
cin>>s1>>s2;
if(s1.size()==s2.size()){
    for(int i=0;i<s1.size();i++){
        cout<<s1[i]<<s2[i];
    }
}
else if(s1.size()>s2.size()){
 for(int i=0;i<s2.size();i++){
        cout<<s1[i]<<s2[i];
    }
    cout<<s1[(s1.size())-1];
}
else {
    for(int i=0;i<s1.size();i++){
        cout<<s1[i]<<s2[i];
    }
    cout<<s2[(s2.size())-1];

}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int n;
	vvp g;
	public:
	int DIJ(int s,int t){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(int i=0;i<g[v].size();i++){
				int F=g[v][i].first,S=g[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					q.push({-d[F],F});
				}
			}
		}
		return d[t];
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
	}
};

int n;

int main(){
	cin>>n;
	Graph g(n);
	for(int i=0;i<n;i++) for(int j=0;j<10;j++){
		g.add_edge(i,(i*10+j)%n,j);
	}
	int res=inf;
	for(int i=1;i<min(10,n);i++) res=min(res,g.DIJ(i,0)+i);
	cout<<res<<endl;
}

Measured memory_bytes: 21276
def main():
    p5 = [k**5 for k in range(120)]
    X = int(input())
    for a in range(119, 0, -1):
        bend = max(-54, -a)
        for b in range(a - 1, bend - 1, -1):
            if b >= 0:
                if p5[a] - p5[b] == X:
                    return a, b
            else:
                if p5[a] + p5[-b] == X:
                    return a, b


print(*main())


Measured memory_bytes: 9172
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        v: [i64;n],
        c: [i64;n]
    }

    let mut ret = i64::min_value() >> 4;
    for mask in 0..1<<n {
        let vmask = bit_filter(mask, &v);
        let cmask = bit_filter(mask, &c);
        ret = std::cmp::max(ret, vmask .iter().fold(0, |acc, &x| acc + x) - cmask .iter().fold(0, |acc, &x| acc + x));
    }
    println!("{}", ret);
}

#[allow(dead_code)]
pub fn bit_filter<T: Clone>(mask: usize, v: &[T]) -> Vec<T> {
    let mut ret = vec![];
    for i in 0..v.len() {
        if (mask >> i) & 1 == 1 {
            ret.push(v[i].clone());
        }
    }
    ret
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    if(a == 1 && b == 2){
        cout << 3 << endl;
    }else if(a == 1 && b == 3){
        cout << 2 << endl;
    }else if(a == 2 && b == 1){
        cout << 3 << endl;
    }else if(a == 2 && b == 3){
        cout << 1 << endl;
    }else if(a == 3 && b == 1){
        cout << 2 << endl;
    }else if(a == 3 && b == 2){
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const ll maxn=1e5+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
ll random(ll mn, ll mx){
	return (rand() % (mx - mn + 1)) + mn; 
}
vector<ll> adj[maxn];
vector<ll> deg(maxn, 0);
vector<ll> ans(maxn);

void solve(){
	
	
	ll x;
	cin>>x;
	ll y=x/500;
	ll ans=1000*y;
	ll z=x%500;
	z=z/5;
	ans+=(z*5);
	cout<<ans<<endl;
	
	return ;
	
}

int main(){ 
    
    #ifndef ONLINE_JUDGE
  	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);

	//T{ solve(); }
	solve();
	
	
	
	return 0;
}

Measured memory_bytes: 4224
# include <cstdio>
# include <algorithm>
# include <cmath>
using namespace std;
struct A{
    int value,st,ed;
}a[100005];
bool cmp(A a,A b){
    return a.value <= b.value;
}
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        for(int i = 1;i <= n;++i){
            scanf("%d",&a[i].value);
            a[i].st = i;
        }
        sort(a+1,a+n+1,cmp);
        for(int i = 1;i <= n;++i)
            a[i].ed = i;
        int cnt = 0;
       // printf("**\n");
        for(int i = 1;i <= n;++i)
            if(abs(a[i].st-a[i].ed)&1)
                cnt ++;
           // printf("%d %d %d\n",a[i].value,a[i].st,a[i].ed);
        printf("%d\n",cnt/2);
    }
    return 0;
}

/*
    #include<bits/stdc++.h>
    //#pragma comment(linker, "/STACK:102400000,102400000")
    using namespace std;
    typedef long long LL;
    typedef unsigned long long ULL;
    typedef double db;
    typedef long double ldb;
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define repu(i,a,b) for(i=a;i<=b;i++)
    #define repd(i,a,b) for(i=a;i>=b;i--)
    #define repc(i,a,b,c) for(i=a;i<b;i+=c)
    #define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
    #define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
    #define FIN freopen("input.in","r",stdin)
    #define FOUT freopen("output.out","w",stdout)
    #define CC(a) memset(a,0,sizeof(a))
    #define MST(a,b) memset(a,b,sizeof(a))
    #define PII pair<int,int>
    #define PLL pair<long long,long long>
    #define VI vector<int>
    #define VL vector<long long>
    #define VII vector<PII>
    #define VLL vector<PLL>
    #define all(x) x.begin(),x.end()
    #define mp make_pair
    #define pb push_back
    #define pf push_front
    #define fi first
    #define se second

    template<typename T>inline void gn(T &x){
    	x=0;T f=1;char ch=getchar();
    	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    	x*=f;
    }
    template<typename T>inline void gt(T x){
    	if(!x)return;
    	gt(x/10);putchar(x%10+'0');
    }

    const LL N=100003;
    struct NODE{
    	db o,r,d;
    };
    LL t,n,m,ans;
    LL MOD=1e9+7,inf=0x1f1f1f1f;
    db eps=1e-5;
    LL a[N];

    int main()
    {
    	ios_base::sync_with_stdio(false);cin.tie(0);
    	LL i,j,k,l,ca=0,u,v,d;
    	cin>>n;
    	repu(i,1,n)cin>>a[i];

    	repu(i,1,n){
    		ans+=a[i]/2,a[i]%=2;
    		if(a[i]&&a[i+1]){
    			ans++;
    			a[i]=0;
    			a[i+1]-=1;
    		}
    	}
    	cout<<ans<<endl;
    	return 0;
    }


*/


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<std::string> s(n);
  std::cin >> s;

  std::vector<std::pair<int64_t, int64_t>> c(n);

  for (int64_t i = 0; i < n; i++) {
    int64_t l_req = 0, l_has = 0;

    for (const auto c : s[i]) {
      if (c == '(') {
        l_has++;
      } else {
        if (l_has == 0) {
          l_req++;
        } else {
          l_has--;
        }
      }
    }
    c[i] = {l_req, l_has};
  }

  bool flag = true;
  for (const auto &[req, has] : c) {
    if (req != 0 || has != 0) {
      flag = false;
    }
  }

  if (flag) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  int64_t count = 0;

  for (auto itr = c.begin(); itr != c.end(); itr++) {
    if (itr->first == 0 && itr->second != 0) {
      count = itr->second;
      c.erase(itr);
      break;
    }
  }

  if (count == 0) {
    std::cout << "No" << std::endl;
    return 0;
  }

  std::sort(c.begin(), c.end(), [](const auto &l, const auto &r) {
    bool l_inc = (l.second - l.first > 0);
    bool r_inc = (r.second - r.first > 0);
    if (l_inc && r_inc) {
      return l.first < r.first;
    } else if (!l_inc && r_inc) {
      return false;
    } else if (l_inc && !r_inc) {
      return true;
    } else {
      return l.second > r.second;
    }
  });

  for (const auto &[req, has] : c) {
    count -= req;
    if (count < 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
    count += has;
  }

  if (count != 0) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }
  return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_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())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int H, W, N;
int down(int h, int x){
  h %= 2*W;
  while(h){
	int d = 0;
	if((h+x) % 2 == 1) d = min(h, W - x - 1);
	else d = -min(h, x);
	x += d;
	h -= abs(d);
	if(h) --h;
  }
  return x;
}

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

  cin >> H >> W >> N;
  vector<PII> xs(N);
  REP(i,N){ cin >> xs[i]; xs[i].FF--; xs[i].SS--;}
  SORT(xs);

  VI ans(W); REP(i,W) ans[i] = i;
  REP(i,N){
	swap(ans[down(xs[i].FF, xs[i].SS)], ans[down(xs[i].FF, xs[i].SS+1)]);
  }

  VI ans_(W);
  REP(i,W) ans_[ans[down(H,i)]] = i+1;
  REP(i,W) cout << ans_[i] << endl;
  
  return 0;
}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    for(auto &i:p) cin>>i;
    for(auto &i:q) cin>>i;
    for(auto &i:r) cin>>i;
    sort(p.begin(),p.end(),greater<>());
    sort(q.begin(),q.end(),greater<>());
    priority_queue<ll,vector<ll>,greater<ll>> ppq,qpq;
    priority_queue<ll> rpq;
    for(int i=0; i<x; i++) ppq.push(p[i]);
    for(int i=0; i<y; i++) qpq.push(q[i]);
    for(int i=0; i<c; i++) rpq.push(r[i]);
    for(int i=0; i<c; i++){
        ll pt = ppq.top();
        ll qt = qpq.top();
        ll rt = rpq.top();
        if(rt<pt && rt<qt) break;
        else if(pt<qt){
            ppq.pop();
            rpq.pop();
            ppq.push(rt);
        }else{
            qpq.pop();
            rpq.pop();
            qpq.push(rt);
        }
    }
    ll ans = 0;
    while(!ppq.empty()){
        ans+=ppq.top();
        ppq.pop();
    }
    while(!qpq.empty()){
        ans+=qpq.top();
        qpq.pop();
    }
    cout<<ans<<endl;
    
}

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

void trace(vector<int> a, int n) {
  for (int i = 0; i < n; i ++) {
    if (i > 0) cout << " ";
    cout << a.at(i);
  }
  cout << endl;
}

void insertionSort(vector<int> a, int n) {
  for (int i = 1; i < n; i ++) {
    int v = a.at(i);
    int j = i - 1;
    while (j >= 0 && a.at(j) > v) {
      a.at(j + 1) = a.at(j);
      j --;
    }
    a.at(j + 1) = v;
    trace(a, n);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a.at(i);

  trace(a, n);
  insertionSort(a, n);
}



Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
int main(){
	int n,b,f,r,v,i,j,k;
	int a[4][3][10]={0};
	std::cin>>n;
	for(i=0;i<n;i++){
	std::cin>>b>>f>>r>>v;
	a[b-1][f-1][r-1]+=(v);
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				std::cout<<" "<<a[i][j][k];
			}
			std::cout<<std::endl;
		}
		if(i!=3)
			std::cout<<"####################"<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//tree distfromroot and calcparent
//tenka12016-B
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}

typedef struct{
int val;
int node;
}sd;

int sdsortfnc(const void *a,const void *b){
if(((sd*)a)->val > ((sd*)b)->val){return -1;}
if(((sd*)a)->val < ((sd*)b)->val){return 1;}
return 0;
}

typedef struct{
    long long st;
    long long fi;
    long long kr;
}rs;

typedef struct{
    long long st;
    long long kz;
}mkj;

int sortfnc(const void *a,const void *b){
if(((rs*)a)->st == ((rs*)b)->st){return 0;}
if(((rs*)a)->st < ((rs*)b)->st){return -1;}
return 1;
}

void makemkj(rs g[],mkj x[],long long n){
    long long i,ms=0,nst=g[0].st;
    for(i=1;i<n;i++){
        if(g[i].st!=g[i-1].st){
            x[nst].kz=i-ms;
            x[nst].st=ms;
            nst=g[i].st;ms=i;
        }
    }
    x[nst].kz=n-ms;
    x[nst].st=ms;
}

long long dist[524288],par[524288];
void dfs(long long t,long long l,long long bp,rs g[],mkj x[]){
  long long i;
  if(dist[t]<=l){return;}
  dist[t]=l;
  par[t]=bp;
  for(i=x[t].st;i<x[t].st+x[t].kz;i++){
    dfs(g[i].fi,l+g[i].kr,t,g,x);
  }
}

int main(void){
    long long i,j,n,m,k,a,b,c,h,w,r=0,l,t;
    long long res=0,num[524288];
    long long v[524288],p[524288];
    rs g[524288];
    mkj x[524288];
    sd dat[524288];
    scanf("%lld",&n);
    for(i=0;i<n;i++){
      scanf("%lld%lld%lld",&g[i].st,&g[i].fi,&g[i].kr);
      g[n-1+i].st=g[i].fi;
      g[n-1+i].fi=g[i].st;
      g[n-1+i].kr=g[i].kr;
    }
    qsort(g,2*(n-1),sizeof(g[0]),sortfnc);
    makemkj(g,x,2*(n-1));
    for(i=0;i<=n;i++){
      dist[i]=llinf;
      num[i]=-1;
    }
    dfs(1,0,0,g,x);
    for(i=1;i<=n;i++){
      printf("%lld\n",dist[i]%2);
    }
    return 0;
}


Measured memory_bytes: 14596
#include <iostream>
#include <algorithm>

using namespace std;

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

    int ans = 0;
    int time_log = -1e9 - 1;
    for (int i = 0; i < N; ++i)
    {
        int t;
        cin >> t;
        if (t <= time_log + T && time_log + T <= t + T)
        {
            ans += -time_log + t;
        }
        else
        {
            ans += T;
        }
        time_log = t;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
ans = 0
tmp_len = 0
for i in range(n):
    if a[i] == i + 1:
        tmp_len += 1
    else:
        ans += (1 + tmp_len) // 2
        tmp_len = 0
ans += (1 + tmp_len) // 2
print(ans)


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

int main() {
  int n; cin >> n;
  int tmp=-1, ans=0;
  vector<int> d(n); for(int i = 0; i < n; ++i) cin >> d[i];
  sort(d.begin(), d.end());
  for(auto it = d.begin(); it != d.end(); ++it) {
    if(tmp < *it) {
      tmp = *it;
      ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
	int N, H[20];
	cin >> N ;
	for (int i = 0; i < N; i++) cin >> H[i];

	int ans = 0;
	for (int i = 0; i < N; i++) {
		bool f = true;
		for (int j = 0; j <= i; j++) {
			if (H[i] < H[j]) f = false;
		}
		if (f) ans++;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  	int A[N+1],B[N+1];
  
  	for(int i=1; i<=N; i++){
      cin >> A[i];
    }
  	for(int i=1;i<=N; i++){
      B[A[i]] = i;
    }
  	for(int i=1; i<=N; i++){
      cout << B[i] << " ";
    }
}

Measured memory_bytes: 1536
#include<stdio.h>
#define DATE 10
int main() {

int i,date[DATE],top[3]={0,0,0};

for(i=0;i<DATE;i++){
scanf("%d",&date[i]);
}

for(i=0;i<DATE;i++){
if(date[i]>=top[0]){
top[2]=top[1];
top[1]=top[0];
top[0]=date[i];
} else if(date[i]>=top[1]){
top[2]=top[1];
top[1]=date[i];
} else if(date[i]>=top[2]){
top[2]=date[i];
}
}

printf("%d\n%d\n%d\n",top[0],top[1],top[2]);

return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N,mina=101,maxa=0,ans=INT_MAX;
    cin>>N;
    vector<int> X(N);
    REP(i,N){
        cin>>X[i];
        mina = min(X[i],mina);
        maxa = max(X[i],maxa);
    }

    for(int i=mina;i<=maxa;i++){
        int sum = 0;
        REP(k,N){
            sum += pow((X[k]-i),2);
        }
        ans = min(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int a[5];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i=0;i<5;i++) cin>>a[i];
    int ans=0;
    int temp=4;
    int temp2=11;
    for(int i=0;i<5;i++){
        if(a[i]%10<temp2&&a[i]%10!=0) {
            temp=i;
            temp2=a[i]%10;
        }
    }
    int temp1=a[temp];
    a[temp]=a[4];
    a[4]=temp1;
    for(int i=0;i<5;i++){
        ans+=a[i];
        if(i==4) break;
        if(ans%10!=0){
            ans=ans+10-ans%10;
        }
    }
    cout << ans<< "\n";
}

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

using namespace std;

int n, m, k;
char mat[10][10];

bool row[10], col[10];

bool check_board() {
	int black = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			bool painted_red = row[i] or col[j];
			if(!painted_red) {
				black += mat[i][j] == '#';
			}
		}
	}
	return black == k;
}

int brute_col(int c) {
	bool finished_painting_cols = c == m;
	if(finished_painting_cols) {
		if(check_board()) {
			return 1;
		}
		return 0;
	}
	int ans = 0;
	{ // considere paint the col c
		col[c] = true;
		ans += brute_col(c + 1);
	}
	{ // considere not paint the col c
		col[c] = false;
		ans += brute_col(c + 1);
	}
	return ans;
}

int brute_row(int r) {
	bool finished_painting_rows = r == n;
	if(finished_painting_rows) return brute_col(0);
	int ans = 0;
	{ // considere paint the row r
		row[r] = true;
		ans += brute_row(r + 1);
	}
	{ // considere not paint the row r
		row[r] = false;
		ans += brute_row(r + 1);
	}
	return ans;
}

int main() {
	scanf("%d %d %d", &n, &m, &k);

	for(int i = 0; i < n; i++) {
		scanf("%s", mat[i]);
	}

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


Measured memory_bytes: 3804
#include<iostream>

using namespace std;

void printFrame(int,int);

int main()
{
	int H,W;

	cin >> H >> W;

	while ( H>0 || W>0 )
	{
		printFrame( H, W );
		cout << endl;
		
		cin >> H >> W;
	}

return 0;
}

void printFrame( int H, int W )
{
	int h,w;

	for ( w = 0 ; w < W ; w++ )
		cout << "#";
	cout << endl;

	for ( h = 0+1 ; h < H-1 ; h++ )
	{
		cout << "#";

		for ( w = 0+1 ; w < W-1 ; w++ )
			cout << ".";

		cout << "#";

		cout << endl;
	}

	for ( w = 0 ; w < W ; w++ )
		cout << "#";
	cout << endl;
}



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

const int combination_modulo=1000000007;
const int combination_max=1000000+1000000+2;
vector<int64_t> factorials(combination_max);
vector<int64_t> factorials_inv(combination_max);
vector<int64_t> inverse(combination_max);
int combination_mod(int n, int k);
int prepare_combination_mod();



int main()
{
	int k;
	string s;

	cin >> k >> s;

	vector<int64_t> pow25(1000000+1);
	vector<int64_t> pow26(1000000+1);
	pow25[0]=1;
	pow26[0]=1;
	for (int i=1;i<=1000000;++i)
	{
		pow25[i]=pow25[i-1]*25;
		pow25[i]%=combination_modulo;
		pow26[i]=pow26[i-1]*26;
		pow26[i]%=combination_modulo;
	}
	prepare_combination_mod();

	int l=s.size();
	int64_t combi=0;
	for (int i=l;i<=l+k;++i)
	{
		int64_t c=1;
		c*=pow25[i-l];
		c%=combination_modulo;
		c*=pow26[l+k-i];
		c%=combination_modulo;
		c*=combination_mod(i-1,l-1);
		c%=combination_modulo;
		combi+=c;
		combi%=combination_modulo;
	}
	cout << combi << endl;
}

int prepare_combination_mod()
{
	factorials[0]=1;
	factorials[1]=1;
	factorials_inv[0]=1;
	factorials_inv[1]=1;
	inverse[1]=1;
	for (int i=2;i<combination_max;++i)
	{
		factorials[i]=factorials[i-1]*i%combination_modulo;
		inverse[i]=combination_modulo - inverse[combination_modulo%i]*(combination_modulo/i)%combination_modulo;
		factorials_inv[i]=factorials_inv[i-1]*inverse[i]%combination_modulo;
	}
	return 0;
}

int combination_mod(int n, int k)
{
	return factorials[n]*(factorials_inv[k]*factorials_inv[n-k]%combination_modulo)%combination_modulo;
}






Measured memory_bytes: 66968
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    string S;
    cin >> S;

    if (S[0] == 'A') {
        int cCnt = 0;
        int idx = -1;
        for (int i = 2; (i < S.size()-1); ++i) {
            if (S[i] == 'C') {
                idx = i;
                ++cCnt;
            }
        }
        if (cCnt == 1) {
            bool allLower = true;
            for (int i = 1; (i < S.size()); ++i) {
                if (i == idx) continue;
                if ('a' <= S[i] && S[i] <= 'z') {
                } else{
                    allLower = false;
                }
            }
            if (allLower) {
                cout << "AC" << endl;
                return 0;
            }
        }
    }

    cout << "WA" << endl;
    return 0;
}


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (size_t i = 0; i < n; i++) cin >> v[i];

    sort(v.begin(), v.end());
    double ans = v[0];
    for (size_t i = 1; i < n; i++) {
        ans = (double)(ans + v[i])/2;
    }

    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 3736
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	while(sc.hasNext()){
        	long a = sc.nextInt();
          	long b = sc.nextInt();
          	long c = sc.nextInt();
          	long d = sc.nextInt();
          	long ans = Math.max(Math.max(a*c,a*d), Math.max(b*c, b*d));
          	System.out.println(ans);
        }
    }
}

Measured memory_bytes: 35528
import sys

#+++++

weeks=['SUN','MON','TUE','WED','THU','FRI','SAT']


def main():
	s=input()
	wd = weeks.index(s)
	return 7 - wd
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

ll n;
ll a[100002] = { 0 };
ll b[100002] = { 0 };

int main() {
	cin >> n;
	ll w;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int top = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			b[top++] = a[i];
			i++;
		}
	}
	cout << b[top - 2]*b[top - 1] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    string S;
    cin >> S;
    if (S[0] != S[1] && S[1] != S[2] && S[0] != S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256