akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>

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

using namespace std;
typedef long long ll;

int isprime(int x) {
    for (int i = 2; i * i <= x; i ++) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    for (int x = N;; x ++) {
        if (isprime(x)) {
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
# Aizu Problem 0021: Parallelism
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
for n in range(N):
    x1, y1, x2, y2, x3, y3, x4, y4 = [float(_) for _ in input().split()]
    det = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3)
    print("YES" if abs(det) < 1e-10  else "NO")

Measured memory_bytes: 7700
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

queue<int> que;
void Search(int n, const vector<list<int>>& mp, vector<int>& d) {
	for (auto i = mp[n].begin(); i != mp[n].end(); i++) {
		if (d[*i] < 0) {
			que.push(*i);
			d[*i] = d[n] + 1;
		}
	}
	if (que.empty())
		return;
	n = que.front();
	que.pop();
	Search(n, mp, d);
	return;
}

int main(void) {
	int num, i, s, t, a, b, ans = 0;
	cin >> num >> s >> t;
	vector<list<int>> mp(num + 1);
	vector<int> x(num + 1, -1), y(num + 1, -1);
	for (i = 1; i < num; i++) {
		cin >> a >> b;
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	x[s] = 0;
	y[t] = 0;
	Search(s, mp, x);
	Search(t, mp, y);
	for (i = 1; i <= num; i++) {
		if (mp[i].size() == 1 && x[i] < y[i]) {
			ans = max(ans, y[i] - 1);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll i = n - 2, j = n - 1;
    while (i >= 0)
    {
        ans += a[j--];
        i--;
        if (i >= 0)
        {
            ans += a[j];
            i--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4776
#include <stdio.h>

#define I 10000000
#define MAX 100

int n, m[MAX][MAX], Q[MAX], head = 0, tail, d[MAX];

void enqueue(int x)
{
  Q[tail] = x;
  tail = (tail+1)%MAX;
}

int dequeue()
{
  int x;

  x = Q[head];
  head = (head+1)%MAX;

  return x;
}

void bfs(int s)
{
  int q, i, u;

  enqueue(s);
  for (i = 0; i < n; i++)
    d[i] = I;
  d[s] = 0;
  while (head != tail){
    u = dequeue();
    for (i = 0; i < n; i++){
      if (m[u][i] == 0)
	continue;
      if (d[i] != I)
	continue;
      d[i] = d[u] + 1;
      enqueue(i);
    }
  }
  for (i = 0; i < n; i++){
    printf("%d ",i+1);
    if (d[i] == I)
      printf("-1\n");
    else
      printf("%d\n",d[i]);
  }
}

int main()
{
  int i, j, a, u, k;

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      m[i][j] = 0;
  for (i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for (j = 0; j < k; j++){
      scanf("%d",&a);
      m[u-1][a-1] = 1;
    }
  }
  tail = n;
  bfs(0);
    
  return 0;
}



Measured memory_bytes: 2084
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
    d=0
    for j in range(m):
        d+=a[i][j]*b[j]
    if d+c>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 9152
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
res = 0
for i in range(n):
	if t[i] == t[i-k] and i >= k:
		t[i] = "X"
	if t[i] == "s":
		res += r
	if t[i] == "p":
		res += s
	if t[i] == "r":
		res += p
print (res)

Measured memory_bytes: 4084
n = int(input())
s = input()

passwd = ["{:03}".format(x) for x in range(1000)]
ans = 0

for p in passwd:
    p = iter(p)
    c = next(p)
    for t in s:
        if c == t:
            try:
                c = next(p)
            except:
                ans += 1
                break

print(ans)


Measured memory_bytes: 42812
/*
                ******
		
        Author: Nguyen Phuc Chuong

                ******
*/

#include <bits/stdc++.h>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> d1(n), d2(n);
	for (int i = 0; i < n; i++) {
		cin >> d1[i] >> d2[i];
	}
	int tmp = 0;
	for (int i = 0; i < n; i++) {
		if (d1[i] == d2[i]) {
			tmp++;
		} else {
			tmp = 0;
		}
		if (tmp == 3) {
			cout << "Yes\n";
			exit(0);
		}
	}
	cout << "No\n";
	return 0;
}


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

bool g[8][8];
int N, M;
int dfs(int v, int n, bool visited[]){
    bool all = true;
    for(int i=0;i<N;i++){
        if(visited[i] == false) all=false;
    }
    if(all) return 1;
    int ret=0;
    for(int i=0;i<N;i++){
        if(g[v][i]==false) continue;
        if(visited[i]) continue;

        visited[i]=true;
        ret+=dfs(i, n, visited);
        visited[i]=false;
    }
    return ret;
}

int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) g[i][j] = false;
    }
    for(int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        g[a-1][b-1] = true;
        g[b-1][a-1] = true;
    }
    bool visited[N];
    for(int i=0;i<N;i++) visited[i] = false;
    visited[0] = true;
    int ans = dfs(0, 0, visited);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std ;
using ll = long long int ;


int main(){
	auto max = [](ll a,ll b){return a>b?a:b;};
	ll n ; cin >> n ;
	vector<vector<ll>> dp(n,vector<ll>(3,0)) ;
	for(int i=0;i<n;i++){
		ll a,b,c ;
		cin >> a >> b >> c ;
		if(i==0){
			dp.at(i).at(0) = a ;
			dp.at(i).at(1) = b ;
			dp.at(i).at(2) = c ;
		}else{
			dp.at(i).at(0) = max(dp.at(i-1).at(1),dp.at(i-1).at(2))+a ;
			dp.at(i).at(1) = max(dp.at(i-1).at(0),dp.at(i-1).at(2))+b ;
			dp.at(i).at(2) = max(dp.at(i-1).at(1),dp.at(i-1).at(0))+c ;
		}
	}
	cout << max(dp.at(n-1).at(0),max(dp.at(n-1).at(1),dp.at(n-1).at(2))) << endl ;
}


Measured memory_bytes: 5760
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  string S;
  cin >> S;
  int ans = 0;

  rep (i, S.size()) {
    if (S[i] == '-') --ans;
    else ++ans;
     }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class suffix_array {
// This is an O(n log^2 n) suffix array algorithm.
// It uses hashing (modulo 2^64) so the hash value may collide.
private:
	int size_;
	std::string s;
	std::vector<unsigned long long> prefix_hash;
	std::vector<unsigned long long> powers;
public:
	suffix_array(std::string s_) : s(s_) {
		size_ = s.size();
		prefix_hash = std::vector<unsigned long long>(size_ + 1);
		powers = std::vector<unsigned long long>(size_ + 1);
		powers[0] = 1;
		for (int i = 0; i < size_; i++) {
			prefix_hash[i + 1] = prefix_hash[i] * 311 + (s[i] - 48);
			powers[i + 1] = powers[i] * 311;
		}
	}
	int hash_value(int l, int r) {
		return prefix_hash[r] - powers[r - l] * prefix_hash[l];
	}
	int lcp(int x, int y) {
		int l = -1, r = std::min(size_ - x, size_ - y) + 1;
		while (r - l > 1) {
			int m = (l + r) >> 1;
			if (hash_value(x, x + m) == hash_value(y, y + m)) l = m;
			else r = m;
		}
		return l;
	}
	vector<int> suffix_arrray() {
		vector<int> ret(size_ + 1);
		for (int i = 0; i <= size_; i++) ret[i] = i;
		sort(ret.begin(), ret.end(), [&](int i, int j) {
			int len = lcp(i, j);
			if (i + len == size_) return true;
			if (j + len == size_) return false;
			return s[i + len] < s[j + len];
		});
		return ret;
	}
};
int main() {
	string s; cin >> s;
	suffix_array sa(s);
	vector<int> v = sa.suffix_arrray(), c(s.size());
	for (int i = 0; i < s.size(); i++) c[sa.lcp(v[i], v[i + 1])]++;
	int sum = 0, ret = 0;
	for (int i = 0; i < s.size(); i++) sum += c[i], ret = max(ret, sum - i);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int now = 1;
  int cnt = 0;
  vector<int> vec;
  for (int i = 0; i < N; i++) {
    if (S[i] == ('0' + now)) {
      cnt++;
    } else {
      vec.push_back(cnt);
      now ^= 1;
      cnt = 1;
    }
  }
  if (cnt > 0) {
    vec.push_back(cnt);
  }
  if (vec.size() % 2 == 0) {
    vec.push_back(0);
  }
  
  ll res = 0;
  int right = 0;
  ll sum = 0;
  for (int left = 0; left < vec.size(); left+=2) {
    while (right < min((int)vec.size(), left + 2 * K + 1)) {
      sum += vec[right];
      ++right;
    }

    res = max(res, sum);

    if (right == left) ++right;
    else if(right >= vec.size()) break;
    else sum -= vec[left] + vec[left + 1];
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>


using namespace std;


int main()
{
  int a, b;

  cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else if ((a > b && b != 1) || a == 1) cout << "Alice" << endl;
  else if ((b > a && a != 1) || b == 1) cout << "Bob" << endl;
  else cout << "You must be wrong ..." << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Test
{
    static void Main()
    {
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int x = n[0];
        int y = n[1];
        int diff = Math.Abs(x - y);

        if (diff != 0)
        {
            List<int> dx = new List<int>();
            List<int> dy = new List<int>();

            for (int i = 1; i <= diff; i++)
            {
                if (x % i == 0) dx.Add(i);
            }

            for (int i = 1; i <= diff; i++)
            {
                if (y % i == 0) dy.Add(i);
            }

            List<int> gcd = dx.Where(dy.Contains).ToList();
            Console.WriteLine(gcd.Max());
        }
        else Console.WriteLine(x);
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N+1);
    a[0] = 0;
    for(int i=1; i<=N; i++) cin >> a[i];

    int cnt = 0;
    for(int i=1; i<=N-1; i++) {
        int like = a[i];
        if(like > i && a[like] == i) cnt++;
    }
    cout << cnt;
}

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

int main() {
  long N, K;
  cin >> N >> K;

  vector<long> v(N);
  for (long i = 0; i < N; i++) {
    long a, b;
    cin >> a >> b;

    v[i] = a * 1000000 + b;
  }

  sort(v.begin(), v.end());
  long k = 0;
  long ans = 0;
  for (long i = 0; i < N; i++) {
    k += v[i] % 1000000;
    ans = v[i] / 1000000;

    if (k >= K) {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
 
int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int l1=s.length(),l2=t.length(),mn=INT_MAX;
	for(int i=0;i<=l1-l2;i++){
		int cnt=0;
		for(int j=0;j<l2;j++){
			if(s[i+j]==t[j]){
				cnt++;
			}
			mn=min(mn,l2-cnt);
		}
	}
	cout<<mn;
	return 0; 
} 


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

int main(void){
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    a = a / d + ((a % d > 0)? 1 : 0);
    c = c / b + ((c % b > 0)? 1 : 0);
    std::cout << ((c <= a)? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<50)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=1000;
static const int MMAX=2000;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int N,M;
typedef struct edge{
    int from,to;
    ll cost;
}Edge;

vector<Edge> V_edge;
ll d[NMAX+2]; //最短距離

//ベルマンフォード法　頂点sからの最短距離を求めるO(NM) エッジの数が多い時はダイクストラ
//後でcheck_nloopで負の閉路が解答に響くか判定
void bellman(int s){
    for(int i=0;i<N;i++) d[i]=INFLL;
    d[s]=0ll;
    
    for(int i=0;i<N-1;i++){ //負の閉路がなければwhile(1)でもN-2回で終わる
        for(int i=0;i<M;i++){
            edge e=V_edge[i];
            
            if(d[e.from]!=INFLL && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
            }
        }
    }
}


//
bool negative[NMAX];
void check_nloop(){
    for(int loop=0;loop<N;loop++){ //全ての頂点の数だけループ
        for(int i=0;i<M;i++){
            edge e=V_edge[i];
            if(d[e.from]==INFLL) continue;  //始点につながってないとこからスタートしてる
            
            if(d[e.to]>d[e.from]+e.cost){ //負の閉路から行けるところはbellmanがおわってもまだ更新できる
                d[e.to]=d[e.from]+e.cost;
                negative[e.to]=true;
            }
        }
        
    }
}

void solve(){
    
    bellman(0);
    
    check_nloop();
    
    if(negative[N-1])cout<<"inf"<<"\n";
    else cout<<(-1)*d[N-1]<<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;
        ll c;
        cin>>a>>b>>c;
        a--; b--;c*=-1; //costの符号を反転し、最小値を求める
        V_edge.push_back((Edge){a,b,c});
    }
    
    solve();
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	string s;
	string odd;
	int ans=0;
	
	cin>>s;
	for(int i=0;i<s.length();i+=2)
	{
		odd+=s[i];
	}
	cout<<odd<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int genkin;
	int happy;

	scanf("%d", &genkin);

	happy = genkin / 500 * 1000;
	genkin = genkin % 500;

	happy = happy + (genkin / 5 * 5);

	printf("%d\n", happy);

	return (0);
}


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

const int mod = 1e9 + 7;
int main() {
	int n, m;
	cin >> n >> m;
	int a[n][m];
	char arr[n][m];
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < m; j++)
			cin >> arr[i][j];
	a[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (arr[i][j] == '.') {
				if (i == 0 && j > 0)
					a[i][j] = (arr[i][j - 1] == '.') ? a[i][j - 1] : 0;
				else if (j == 0 && i > 0)
					a[i][j] = (arr[i - 1][j] == '.') ? a[i - 1][j] : 0;
				else if (i > 0 && j > 0) {
					int x = (arr[i][j - 1] == '.') ? a[i][j - 1] : 0;
					int y = (arr[i - 1][j] == '.') ? a[i - 1][j] : 0;
					a[i][j] = (x + y) % mod;	
				}
			}
		}
	}
	cout << a[n - 1][m - 1] << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
unsigned long long int mod = 1000000000 + 7;
 
vector<vector<unsigned long long int>>  comb(int N){
  vector<vector<unsigned long long int>> vs(N + 1, vector<unsigned long long int>(N + 1, 0));
 
  for(int i = 0 ; i < vs.size() ;i++){
    vs[i][0] = 1;
    vs[i][i] = 1;
  }
  
  for(int i = 1; i < vs.size(); i++){
      for(int j = 1; j < i ; j++){
        vs[i][j] = (vs[i-1][j-1] +vs[i-1][j]) % mod;
      }
  }
 
  return vs;
}
 
int main(){
  unsigned long long int N, K;
  cin >> N >> K;

  vector<vector<unsigned long long int>>  v = comb(N);
  
  for(int i = 1; i <= K ;i++){   
   cout <<( v[K-1][i-1] % mod) * (v[N-K+1][i] % mod) % mod << endl;
  }
  
  return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return;
    }
    int cnt = 0;
    rep3(i, 2, sz(s) - 1) {
        if (s[i] == 'C') ++cnt;
    }
    if (cnt != 1) {
        cout << "WA" << endl;
        return;
    }
    rep(i, sz(s)) {
        if (s[i] != 'A' && s[i] != 'C' && (s[i] < 'a' || s[i] > 'z')) {
            cout << "WA" << endl;
            return;
        }
    }
    cout << "AC" << endl;
}




Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
int A,B,C;
  C=2*B;
  cin>>A>>C;
  if(A<=5){
  cout<<0<<endl;
  }
  else if((6<=A)&&(A<=12)){
  cout<<C/2<<endl;
  }
  else if(13<=A){
  cout<<C<<endl;
  }
  return 0;
}

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

int main() {
    int n, k; scanf("%d%d", &n, &k);
    if (2 * k > n) {
        printf("-1\n");
    } else {
        vector<vector<pair<int, int> > > spaning_trees;
        vector<pair<int, int> > unused_edges;
        REP3 (i, 2, n + 1) {
            int j = 0;
            for (; j < spaning_trees.size(); ++ j) {
                int k = i & 1 ? j : (i - 1) - j - 1;
                spaning_trees[j].emplace_back(k, i - 1);
            }
            if (spaning_trees.size() >= k) continue;
            for (; j < i - 1; ++ j) {
                int k = i & 1 ? j : (i - 1) - j - 1;
                unused_edges.emplace_back(k, i - 1);
            }
            if (i % 2 == 0) {
                spaning_trees.push_back(unused_edges);
                unused_edges.clear();
            }
        }
        for (auto const & spaning_tree : spaning_trees) {
            for (auto edge : spaning_tree) {
                int i, j; tie(i, j) = edge;
                printf("%d %d\n", i + 1, j + 1);
            }
            printf("\n");
        }
    }
    return 0;
}

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

int main() {
    int D, N;
    std::cin >> D >> N;

    if (D == 0) {
        if (N == 100) {
            std::printf("101\n");
        } else {
            std::printf("%d\n", N);
        }
    } 
    else if (D == 1) {
        if (N == 100) {
            std::printf("10100\n");
        } else {
            std::printf("%d\n", N * 100);
        }
    }
    else {
        if (N == 100) {
            std::printf("1010000\n");
        } else {
            std::printf("%d\n", N * 100 * 100);
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
#define QUO(x,y) (x-x%y)/y
 
int main(){

	char a,b;
	cin>>a>>b;

	if(a==b)PRINT("H");
	else PRINT("D");

	
	

	return 0;
}

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

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a;
	string s;
	
	cin >> a;
	syc(a,1,100);
	
	cin >> s;
	for(int i=0;i<s.length();i++){
		syc(s[i],97,122);
	}
	
	if(s.length() != a)exit(1);
	
	if(s.length()%2 != 0){
		cout << "No" << endl;
		return 0;
	}else{
		for(int j=0;j<s.length()/2;j++){
			if(s[j] != s[j+s.length()/2]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
		
	return 0;
}


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

using namespace std;

const int MAX_N = 1e5 + 200;

int n, ai[MAX_N], si[MAX_N];
map<int, int> mp, tmp;

int main()
{
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++)
        scanf("%d", &ai[i]), mp[ai[i]]++;
    if (mp.size() <= 3)
    {
        vector<int> vi;
        for (auto x : mp)
            vi.push_back(x.first);
        bool flag = false;
        do
        {
            int len = vi.size();
            tmp.clear();
            for (int i = 1; i <= 2; i++)
                si[i] = vi[(i - 1) % len];
            for (int i = 3; i <= n; i++)
                si[i] = si[i - 1] ^ si[i - 2];
            for (int i = 1; i <= n; i++)
                tmp[si[i]]++;
            bool cflag = true;
            for (auto x : tmp)
                cflag &= mp[x.first] == x.second;
            flag |= cflag;
        } while (next_permutation(vi.begin(), vi.end()));
        puts(flag ? "Yes" : "No");
    }
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 7600
#include<iostream>
using namespace std;
int main(){
int base;
int first=0;
int temp=0;
cin>>base;
char math[100];
for(int i=0;i<base;i++){
    cin>>math[i];
    if(math[i]=='I'){
        first=first+1;
        if(first>temp){
            temp=first;
        }
    }
    else if(math[i]=='D'){
        first=first-1;
    }
}
cout<<temp<<endl;
}

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

typedef long long ll;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    int N;
    cin >> N;
    ll cnt = 0;
    for (int A = 1; A < N; A++)
    {
        cnt += N % A == 0 ? N / A - 1 : N / A;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    cout << (d[n / 2] - d[n / 2 - 1]) << endl;
}


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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = -1;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k - i; j++) {
      int m = max(k - i - j, 0);
      int tmp = a*pow(2, i) + b*pow(2,j) + c*pow(2,m);
      ans = max(tmp, ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C;
	cin >> K;
	int k = 0;
	while (1) {
		if (B > A)
			break;
		B *= 2;
		k++;
	}
	while (1) {
		if (C > B)
			break;
		C *= 2;
		k++;
	}

	string ans = (K>=k) ? "Yes" : "No";


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import heapq
n,m = map(int,input().split())
lst = [0 for _ in range(m)]
dic = {}
for i in range(n):
    a,b = map(int,input().split())
    if a in dic:
        dic[a].append(-b)
    else:
        dic[a] = [-b]
q = []
heapq.heapify(q)
ans = 0
for i in range(1,m+1):
    if i in dic:
        for j in range(len(dic[i])):
            heapq.heappush(q,dic[i][j])
    if q:
        ans -= heapq.heappop(q)
print(ans)

Measured memory_bytes: 26872
n=input()
a=int(n[:2])
b=int(n[2:])
if 1<=a<13:
	if 1<=b<13:
		print('AMBIGUOUS')
	else:
		print('MMYY')
else:
	if 1<=b<13:
		print('YYMM')
	else:
		print('NA')

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.size()){
   if(s[i] != t[i]){
     ans++;
   } 
  }
  cout << ans << endl;
}


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

using namespace std;
#define NIL -1
#define ll long long
#define MAX 100
#define pb push_back

int main()
{
	int n;
	cin >> n;
	int x = (int)(double)n/1.08;
	int y = (int)ceil((double)n/1.08);
	if((int)(x*1.08) == n) {
		cout << x << endl;
	}
	else if((int)(y*1.08) == n) cout << y << endl;
	else cout << ":(\n";
	return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        String[] s = nsa(3);

        out.println("A" + s[1].charAt(0) + "C");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

d=[]
for x in a:
  s=[1,x]
  d.append(s)
  
for _  in range(m):
  b=list(map(int,input().split()))
  d.append(b)
  
d.sort(key=lambda x:x[1],reverse=True)
  
ch=0
ans=0
for f in d:
  p,q=f[0],f[1]
  if ch==n:
    break
  else:
    if ch+p>=n:
      ans+=q*(n-ch)
      break
    else:
      ans+=p*q
      ch+=p
      
print(ans)

Measured memory_bytes: 117688
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007LL
#define INF 2000000000
#define PI 3.1415926

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

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int N, M, C, b[20], a[20][20];
	cin >> N >> M >> C;
	REP(i, M) cin >> b[i];
	int ans = 0;
	REP(i, N){
		int num = C;
		REP(j, M){
			cin >> a[i][j];
			num += a[i][j] * b[j];
		}
		if(num > 0) ans++;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll INF = (1LL << 60);

int main(){
    ll N, K;
    cin >> N >> K;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    map<int, vector<int>> mp;
    for(int i = 0; i < N; i++) mp[a[i]].push_back(i);

    ll d[N][60];
    for(auto it = mp.begin(); it != mp.end(); it++){
        vector<int> vec = it -> second;
        for(int i = 0; i < (int)vec.size(); i++){
            if(i == (int)vec.size() - 1){
                d[vec[i]][0] = N + vec[0] - vec[i] + 1;
            } else {
                d[vec[i]][0] = vec[i + 1] - vec[i] + 1;
            }
        }
    }

    for(int j = 1; j < 60; j++){
        for(int i = 0; i < N; i++){
            int idx = (i + d[i][j - 1]) % N;
            d[i][j] = d[i][j - 1] + d[idx][j - 1];
            d[i][j] = min(INF, d[i][j]);
        }
    }

    /*
    for(int j = 0; j < 60; j++){
        for(int i = 0; i < N; i++){
            cout << d[i][j] << " ";
        }
        cout << endl;
    }*/

    ll pos = 0;
    while(true){
        int idx = pos % N;
        bool found = false;
        for(int j = 59; j >= 0; j--){
            if(pos + d[idx][j] < N * K){
                found = true;
                pos += d[idx][j];
                break;
            }
        }

        if(found) continue;
        else break;
    }

    pos %= N;

    //pos~Nまでをシミュレート
    map<int, int> mp2;
    stack<int> st;
    for(int i = pos; i < N; i++){
        if(mp2[a[i]] > 0){
            while(mp2[a[i]] > 0){
                int x = st.top();
                mp2[x]--;
                st.pop();
            }
        }
        else {
            st.push(a[i]);
            mp2[a[i]]++;
        }
    }

    vector<int> ans;
    while(!st.empty()){
        ans.push_back(st.top());
        st.pop();
    }

    reverse(ans.begin(), ans.end());

    for(int val : ans){
        cout << val << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 129012
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	int N, D, X, A[105];
	ll ans = 0;

	cin >> N >> D >> X;
	for (int i = 0; i < N; i++) {

		cin >> A[i];
		for (int j = 1; j <= D; j++) {

			if (A[i] > 1 && j%A[i] == 1)ans++;
			if (A[i] == 1)ans++;

		}

	}
	ans += X;

	cout << ans << endl;

	return 0;
}

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

int main() {

    int h, w; cin >> h >> w;
    vector<vector<char>> c(h + 2, vector<char>(w + 2));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> c[i][j];
        }
    }

    bool can = true;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (c[i][j] == '#') {
                if (c[i - 1][j] == '#' || c[i + 1][j] == '#' || c[i][j - 1] == '#' || c[i][j + 1] == '#') {
                }
                else { 
                    can = false;
                }
            }
        }
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long ll;
int main()
{
    int N, A, B, C, D;
    scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);

    ll x = B - A;

    for(int i=0; i<N; i++){
        ll Imin, Imax;
        Imin = (ll)(N - 1 - i) * C - i * (ll)D;
        Imax = (ll)(N - 1 - i) * D - i * (ll)C;
        if(Imin <= x && x <= Imax){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
use std::collections::VecDeque;

fn main() {
    let mut queue: VecDeque<char> = {
        let init = read::<String>();
        init.chars().collect()
    };
    let n = read::<usize>();

    let mut order = 0;
    for _ in 0..n {
        let v = read_vec::<String>();
        if v[0] == "1" {
            // reverse
            order += 1;
        } else {
            // add
            let c: char = {
                let mut queue: VecDeque<char> = v[2].chars().collect();
                queue.pop_back().unwrap()
            };
            if order % 2 == 0 {
                if v[1] == "1" {
                    // front
                    queue.push_front(c);
                } else {
                    // back
                    queue.push_back(c);
                }
            } else {
                if v[1] == "1" {
                    // back
                    queue.push_back(c);
                } else {
                    // front
                    queue.push_front(c);
                }
            }
        }
    }

    let mut ret: Vec<char> = Vec::new();
    if order % 2 == 0 {
        while !queue.is_empty() {
            let c = queue.pop_front().unwrap();
            ret.push(c);
        }
    } else {
        while !queue.is_empty() {
            let c = queue.pop_back().unwrap();
            ret.push(c);
        }
    }

    let s: String = ret.into_iter().collect();
    println!("{}", s);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 10492
#include <stdio.h>
#define MAX 200000

#define max(a, b) a > b ? a : b
#define min(a, b) a < b ? a:b

int main(void)
{
    int n, R[MAX], j;
    
    scanf("%d", &n);
    
    for (j = 0; j < n; j++)
    scanf("%d", &R[j]);

    int maxv = -2000000000;
    int minv = R[0];

    for (j = 1; j < n; j++){
    maxv = max(maxv, R[j]-minv);
    minv = min(minv, R[j]);
    }

    printf("%d\n", maxv);

    return 0;
}


Measured memory_bytes: 2536
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
#pragma GCC optimize ("trapv")

#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define mem(x,y) memset(x,y,sizeof(x))
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;
mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
typedef long double C;

#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}

map<lli,lli> m,date;
set<lli> loc;
int main(){
    lli n; cin>>n;
    if(n%2==1){
        m[0]=1;loc.insert(0);
        for(lli i=2;i<=n-1;i+=2) m[i]=2,loc.insert(i);
    }else{
        for(lli i=1;i<=n-1;i+=2) m[i]=2,loc.insert(i);
    }
    rep(i,0,n){
        int foo; cin>>foo;
        date[foo]++;
    }
    bool chi=true;
    lli ans=1,mod=1e9+7;
    for(auto x : loc){
        if(m[x]!=date[x]) chi=false;
        else{
            if(x==0) continue;
            else ans=(ans*2)%mod;
        }
    }
    if(chi) cout<<ans<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 10880
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a == 1) {
            a += 13;
        }
        if (b == 1) {
            b += 13;
        }
        if (a > b) {
            System.out.println("Alice");
        } else if (a < b) {
           System.out.println("Bob");
        } else {
            System.out.println("Draw");
        }
    }

}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    string s;
    cin >> s;
    if(s[s.length()-1] == '3'){
        puts("bon");
    }else if(s[s.length()-1] == '0' || s[s.length()-1] == '1' || s[s.length()-1] == '6' || s[s.length()-1] == '8'){
        puts("pon");
    }else {
        puts("hon");
    }
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <math.h>
long long int min(long long int a, long long int b)
{
    if (a > b) return b;
    else return a;
}
 
int main(void)
{
    long long int a, b, dist, f = 0;
    scanf("%ld", &a);
    dist=a-1;
    for (long long int i=2; i<=sqrt(a); i++){
        if (a % i == 0){
          b = a/i;
          dist = min(dist, i+b-2);
        }
    }
    printf("%ld", dist);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    int a,odd=0,even=0;
    cin >> a;
    double b;
    for(int i = 1;i <= a ;i++){
      if(i % 2 == 0){
        even++;
      }else{
        odd++;
      }
    }
    b = ((double)odd / (even + odd));
    cout << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)


int main()
{
	map<string, ll> dict;
	ll n;
	cin >> n;
	string s;
	for (ll i = 0; i < n; i++)
	{
		cin >> s;
		dict[s]++;
	}
	
	typename map<string, ll> ::iterator it = begin(dict);
	ll max = 0;
	while (it != end(dict))
	{
		if (max < it->second)
		{
			max = it->second;
		}
		it++;
	}
	typename map<string, ll> ::iterator itr = begin(dict);
	while (itr != end(dict))
	{
		if (itr->second == max)
		{
			cout << itr->first << "\n";
		}
		itr++;
	}

	return 0;
}

Measured memory_bytes: 19216
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int N, M;
	int cnt = 0;
	long sum = 0;

	cin >> N >> M;

	vector<int> A(N);
	rep(i, N) {
		cin >> A.at(i);
		sum = sum + A.at(i);
	}
	sort(A.begin(), A.end(), greater<int>());
	
	rep(i, N) {
		if (A.at(i) * 4 * M < sum)	break;
		cnt = cnt + 1;
	}

	if (cnt >= M) {
		cout << "Yes";
	} else{
		cout << "No";
	}

}

Measured memory_bytes: 256
cities , num = map(int,input().split())
ary = [0 for i in range(num)]
result = [0 for i in range(cities)]
check = 0

for i in range(num):
    ary[i] = list(map(int,input().split()))

for i in range(num):
    check = ary[i][0]
    result[check-1] += 1
    check = ary[i][1]
    result[check-1] += 1

for i in range(cities):
    print(result[i])

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    ll X, Y;
    
    cin >> X >> Y;
    
    cout << X + Y / 2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
char s[3][4];
int main()
{
    scanf("%s%s%s",s[0],s[1],s[2]);
    printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);
    return 0;
}

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin (),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp
//tgamma(i+1) is 1!

const int M=1e9+7;
int n, a, b;
ll iv[200001];
 
ll nck(int n, int k) {
	ll ans=1;
	for(int i=1; i<=k; ++i)
		ans=ans*(n-i+1)%M*iv[i]%M;
	return ans;
}
 
ll powM(ll b, int p) {
	ll r=1;
	for(; p; b=b*b%M, p/=2)
		if(p&1)
		r=r*b%M;
	return r;
}


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

    int MOD = 1e9 + 7;
    int n, a, b;
    cin >> n >> a >> b;
    ll pos = powM(2,n) - 1;
    iv[1] = 1;
    for(int i=2; i<=200000; ++i){
		iv[i]=M-M/i*iv[M%i]%M;
    }
    cout << (pos - nck(n,a)%MOD - nck(n,b)%MOD + 2*MOD)%MOD;
}








Measured memory_bytes: 1792
#!/usr/bin/env python

def choose_t(c_lst, s_lst, last, day):
    scr_max = -float('inf')
    for t in range(26):
        scr = 0
        scr += s_lst[t]
        for typ in range(26):
            if typ != t:
                scr -= c_lst[typ] * (day - last[typ])

        if scr > scr_max:
            scr_max = scr
            ret = t

    return(ret)


def main():
    d = int(input())
    c_lst = list(map(int, input().split()))
    s_mat = [list(map(int, input().split())) for _ in range(d)]

    last = [-1 for _ in range(26)]
    for day in range(d):
        t = choose_t(c_lst, s_mat[day], last, day)
        last[t] = day
        print(t+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9364
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  bool can = true;
  if(N%2==0){
    int j=1;
    for(int i=0; i<N; i+=2){
      if(A[i] != A[i+1] || A[i] != j){
        can = false;
        break;
      }
      j += 2;
    }
  }else{
    int j=2;
    if(A[0] != 0){
      can = false;
    }
    for(int i=1; i<N; i+=2){
      if(A[i] != A[i+1] || A[i] != j){
        can = false;
        break;
      }
      j += 2;
    }
  }
  if(!can){
    cout << 0 << endl;
    return 0;
  }

  ll ans=1;
  for(int i=0; i<N/2; i++){
    ans = (ans*2)%mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string s[a];
    for (int i = 0; i < a; i++)
    {
        cin>>s[i];
    }
    

    sort(s, s+a);
    for (int i = 0; i < a; i++)
    {
        cout<<s[i];
    }
    
    return 0;
}

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

using namespace std;

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

  int n,k,s;
  while(true){
      cin>>n>>k>>s;
      if(n==0) break;
      int res=0;
      for(int i=0;i<(1<<n);i++){
          int tmp=i;
          int sum=0,cnt=0;
          for(int j=0;j<n;j++){
              if(tmp%2){
                  cnt++;
                  sum+=(j+1);
              }
               tmp/=2;
          }
          if(cnt==k && sum==s) res++;
      }
      cout<<res<<endl;
  }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string str;
    int i,j;
    cin >> str;
    vector <string> devide = { "dream", "dreamer", "erase", "eraser" };
    reverse(str.begin(),str.end());
    for(i=0;i<4;i++){
        reverse(devide[i].begin(),devide[i].end());
    }
    bool can = true;
    for(i=0;i<str.size();){
        bool can2 = false;   
         for(j=0;j<4;j++){
             string d = devide[j];
            if(str.substr(i,d.size())==d){
                can2=true;
                i+=d.size();
            }
         }
        if(can2==false){
            can = false ;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512