akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, M;
int A[100010], S[100010];


signed main(){
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];

    sort(A, A+N);

    int l = 1, r = 2e5+1;
    while(r-l > 1){
        int m = l+(r-l)/2;
        int c = 0;
        rep(i, 0, N) c += A+N-lb(A, A+N, m, [i](int x, int v){ return A[i]+x < v; });
        if(M < c) l = m;
        else r = m;
    }

    int ans = 0;
    rep(i, 0, N) S[i+1] = S[i]+A[i];
    int c = 0;
    rep(i, 0, N){
        int j = lb(A, A+N, r, [i](int x, int v){ return A[i]+x < v; })-A;
        c += N-j;
        if(j < N) ans += (N-j)*A[i]+S[N]-S[j];
    }

    cout << ans+(M-c)*l << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+77;
int in[N];
signed main()
{
#ifdef home
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int n, l;
    cin>>n>>l;
    for(int i=1;i<=n;i++){
        cin>>in[i];
    }
    vector<int> ans;
    for(int i=1;i<n;i++){
        if(in[i]+in[i+1]>=l){
            ans.push_back(i);
            break;
        }
    }
    if(ans.empty()){
        cout<<"Impossible";
        return 0;
    }
    for(int i=ans[0]+1;i<n;i++)ans.push_back(i);
    for(int i=ans[0]-1;i>0;i--)ans.push_back(i);
    reverse(ans.begin(), ans.end());
    cout<<"Possible\n";
    for(int i:ans)cout<<i<<'\n';
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int res = 0;
    for(int i=1;i<=n;i++){
        int ar;
        cin >> ar;
        if(ar&1 && i&1){
            res++;
        }
    }
    cout << res << '\n';
}

Measured memory_bytes: 3636
import sys
l = sys.stdin.readline().strip()
N = int(l)
l = sys.stdin.readline().strip()
nums = map(int, l.split())
nums = sorted(nums)
start = nums[0]
end = nums[-1] + 1
mi = float("INF")
def compute_dist(p):
  dist = 0
  for n in nums:
    dist += (n-p) ** 2
  return dist
for i in range(start, end):
  d = compute_dist(i)
  if d < mi:
    mi = d
print(mi)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        sb.append(s, 0, 4);
        sb.append(' ');
        sb.append(s, 4, s.length());
        System.out.println(sb);
    }

}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string s;
  cin >> s;

  s[3] = '8';
  cout << s << endl;
  return 0;
} 

Measured memory_bytes: 3592
N = gets.to_i
S = gets.chomp

whites = []
blacks = []

if S[0] == '.'
  whites << 1
  blacks << 0
else
  whites << 0
  blacks << 1
end

(1...(S.length)).each do |i|
  if S[i] == '.'
    whites << whites[i-1] + 1
    blacks << blacks[i-1]
  else
    whites << whites[i-1]
    blacks << blacks[i-1] + 1
  end
end

res = [whites[N-1], blacks[N-1]].min

(1...(N)).each do |i|
  res2 = blacks[i-1] + whites[N-1] - whites[i-1]
  res = [res, res2].min
end

p res


Measured memory_bytes: 5392
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
inline ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }



int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if(i + 1 == k)
            cout << (char)(s[i] - 'A' + 'a');
        else
            cout << s[i];
    }
    
    
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <numeric>
#include <functional>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	auto v = vector<int>(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	int avg = round(accumulate(v.begin(), v.end(), 0, plus<int>()) / (double)n);
	cout << accumulate(v.begin(), v.end(), 0, [avg](auto acc, auto x) {
		return acc + (avg - x) * (avg - x);
	}) << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt(),x=sc.nextInt();
		int left=0,right=0;

		for(int i=0;i<m;i++) {
			int a=sc.nextInt();
			if(a<x) {
				left++;
			}else {
				right++;
			}
		}

		System.out.println(left<right?left:right);



	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;

//D

//C

//B
int main() {
	ll N;
	scanf("%lld", &N);
	char S[220];
	scanf("%s", &S);

	bool result = true;

	if (N % 2 == 0) {
		ll half = N / 2;
		for (ll i = 0; i < half; i++) {
			if (S[i] != S[i + half]) {
				result = false;
				break;
			}
		}
	}
	else {
		result = false;
	}

	if (result) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}

//A
/*
int main() {
	ll r;
	scanf("%lld", &r);

	ll result = r * r;

	printf("%lld\n", result);
}
*/



Measured memory_bytes: 256
fun main() {
    val (n,k)= readLine()!!.split(" ").map { it.toInt() }
    val hs= readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    var ans:Int=0
    for (h in hs){
        if (h>=k){ans++}
    }
    println(ans)
}

Measured memory_bytes: 49620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, h; cin >> n >> h;
    vint a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    sort(rall(b));
    sort(rall(a));
    int ct = 0;
    rep(i,n) {
        if (a[0] <= b[i]) {
            h -= b[i];
            ct++;
            if (h <= 0) {cout << ct << endl; return 0;}
        }
        else break;
    }
    if (h > 0) ct += (h+a[0]-1)/a[0];
    cout << ct << endl;
}

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

int main(){
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long long MIN=min({A,B,C,D,E});
  cout << (N+MIN-1)/MIN+4 << endl;
}
  

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

const int NMAX = 300000;
bool ISPRIME[NMAX];
vector<int> PRIMES;
vector<int> FACTORS[NMAX];

int main() {
  fill(ISPRIME, ISPRIME + NMAX, true);
  REP(n, 6) {
    ISPRIME[n] = false;
  }
  for (int n = 6; n < NMAX; n++) {
    int modulo = n % 7;
    if (!((modulo == 1 || modulo == 6) && ISPRIME[n])) continue;
    PRIMES.push_back(n);
    for (int kn = n; kn < NMAX; kn+=n) {
      ISPRIME[kn] = false;
      FACTORS[kn].push_back(n);
    }
  }

  int n;
  while (cin >> n && n != 1) {
    cout << n << ":";
    for (int factor : FACTORS[n]) {
      cout << " " << factor;
    }
    cout << endl;
  }
}

Measured memory_bytes: 16972
//#####   #####   #####   #####   #####   #       #####   #   #//
//#   #   #   #   #       #       #   #   #       #   #   ## ##//
//#####   #####   #####   #       #####   #       #####   # # #//
//##      #   #       #   #       #   #   #       #   #   #   #//
//# #     #   #       #   #       #   #   #       #   #   #   #//
//#  #    #   #       #   #       #   #   #       #   #   #   #//
//#   #   #   #   #####   #####   #   #   #####   #   #   #   #//


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb(x) cout << #x << " " << x << endl;
ll bin(ll a, ll b, ll mod)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2 , mod) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2 , mod) % mod)) % mod;
}
void solve()
{
	string s;
	cin >> s;
	ll sum = 0;
	rep(i, 0, s.size()) {
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	int t;
	t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int N, K, R, S, P;
	string T;
	int pt = 0;
	vector<char> v;

	cin >> N >> K >> R >> S >> P >> T;

	for (int i = 0; i < T.size(); i++) {
		int j = i;
		if (v.size() == K) {
			j = i % K;
		}
		if (T[i] == 'r') {
			if (v.size() == K) {
				if (v[i % K] == 'p') {
					if (i + K < T.size()) {
						if (T[i + K] == 'p') {
							v[i % K] = 'r';
						} else if (T[i + K] == 's') {
							v[i % K] = 's';
						} else {
							v[i % K] = 'r';
						}
					} else {
						v[i % K] = 'r';
					}
				} else {
					v[i % K] = 'p';
					pt += P;
				}
			} else {
				pt += P;
				v.push_back('p');
			}
		} else if (T[i] == 's') {
			if (v.size() == K) {
				if (v[i % K] == 'r') {
					if (i + K < T.size()) {
						if (T[i + K] == 'r') {
							v[i % K] = 's';
						} else if (T[i + K] == 'p') {
							v[i % K] = 'p';
						} else {
							v[i % K] = 's';
						}
					} else {
						v[i % K] = 's';
					}
				} else {
					v[i % K] = 'r';
					pt += R;
				}
			} else {
				pt += R;
				v.push_back('r');
			}
		} else {
			if (v.size() == K) {
				if (v[i % K] == 's') {
					if (i + K < T.size()) {
						if (T[i + K] == 's') {
							v[i % K] = 'p';
						} else if (T[i + K] == 'r') {
							v[i % K] = 'r';
						} else {
							v[i % K] = 'p';
						}
					} else {
						v[i % K] = 'p';
					}
				} else {
					v[i % K] = 's';
					pt += S;
				}
			} else {
				pt += S;
				v.push_back('s');
			}
		}
	}
	
	cout << pt << endl;

	return 0;
}

Measured memory_bytes: 640
#define DEBUG 0

/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-6-1 21:01:48
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

void Yes()
{
  cout << "YES" << endl;
  exit(0);
}

void No()
{
  cout << "NO" << endl;
  exit(0);
}

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

// const ll MOD = 1000000007;

string S;

int main()
{
  cin >> S;
  while (S.size() < 15)
  {
    S = S + "o";
  }
  int cnt = 0;
  for (auto x : S)
  {
    if (x == 'o')
    {
      cnt++;
    }
  }
  if (cnt >= 8)
  {
    Yes();
  }
  else
  {
    No();
  }
}

Measured memory_bytes: 256
//2016/11/2

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


int main(void)
{
	int i;
	int n, a[101] = {0}, flag = 1, count = 0, temp;

	scanf("%d", &n);

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

	while(flag)
	{
		flag = 0;

		for(i = n-1; i > 0; i--)
		{
			if (a[i] < a[i-1])
			{
				temp = a[i];
				a[i] = a[i-1];
				a[i-1] = temp;
				flag = 1;
				count++;
			}
		}
	}

	for(i = 0; i < n; i++)
	{
		if (i == n-1)
		{
			printf("%d\n", a[i]);
		}else
		{
			printf("%d ", a[i]);
		}
	}

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

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
int main () {
	int N,L;
	cin >> N >> L;
	std::vector<string> S(N);
	for (int i = 0; i < N; ++i)
	{
		/* code */
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for (int i = 0; i < N; ++i)
	{
		/* code */
		cout << S[i];
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<ll> p(n);
  vector<ll> q(n);
  vector<pair<ll,ll>> r(n);
  rep(i,n){
    cin>>p[i]>>q[i];
    r[i]={p[i]+q[i],p[i]};
  }

  sort(all(r));
  reverse(all(r));

  ll ans=0;
  rep(i,n){
    if(i%2==0) ans+=r[i].se;
    else ans-=r[i].fi-r[i].se;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main{
	public static void main(String ...ar){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a*n<b)
			System.out.println((a*n));
		else 
			System.out.println(b);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){
  ll ans = -1;
  ll N;
  cin >> N;
  vector< pair<ll, ll> > v;
  ll temp;
  pair<ll, ll> p;
  REP(i, 0, N) {
    cin >> temp;
    p = make_pair(temp, i+1); // distance, edge num
    v.push_back(p);
  }

  sort(v.begin(), v.end()); // 0, 1, 2, ...

  // REP(i, 0, N)
  //   cout << v[i].first << ", " << v[i].second << endl;

  ll before = 0;
  REP(i, 0, N) {
    if ( (v[i].first == before) || v[i].first == before+1 ) { // ok case
      before = v[i].first;
    }
    else {
      ans = 0;
      break;
    }
  }
  if ( (v[0].first != 0) || v[1].first == 0 ){
    ans = 0;
  }
  if (v[0].second != 1 )
    ans = 0;

  if (ans == -1){ // namely, ans is not decided yet
    ll max_ = before;
    ll m[max_+1];
    REP(i, 0, max_+1){
      m[i] = 0;
    }
    REP(i, 0, N) {
      m[v[i].first]++; // m[distance]++
    }
    ans = 1;
    ll before_num = 1;
    REP(i, 1, max_+1){
      // cout << "before_num, m[i]: " << before_num << ", " << m[i] << endl;
      REP(j, 0, m[i]){
        ans = ans * before_num;
        ans = ans % 998244353;
      }
      before_num = m[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2672
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
  ll N, tmp;
  cin >> N;
  vector<ll> A;
  for (int i=0; i<=N; i++){
    cin >> tmp;
    A.push_back(tmp);
  }
  ll ans = 0;
  for (int i=0; i<N; i++){
    cin >> tmp;
    if (A[i] + A[i + 1] <= tmp){
      ans += A[i] + A[i + 1];
      A[i] = 0;
      A[i + 1] = 0;
    }
    else if (A[i] <= tmp){
      ans += tmp;
      A[i + 1] -= tmp - A[i];
      A[i] = 0;
    }
    else{
      ans += tmp;
      A[i] -= tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    Graph<int> G(N);

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            char c;
            cin >> c;
            if (c == '1') {
                G[i].push_back(j);
                G[j].push_back(i);
            }
        }
    }

    auto bfs = [&](int s) {
        vector<int> dist(N, -1);
        queue<int> que;
        dist[s] = 1;
        que.push(s);

        int recent = s;
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (auto nv : G[v]) {
                if (dist[nv] >= 0) {
                    if (abs(dist[nv] - dist[v]) != 1)
                        return -1;
                    continue;
                }
                dist[nv] = dist[v] + 1;
                que.push(nv);
                recent = nv;
            }
        }
        return dist[recent];
    };

    int ans = -1;
    for (int i = 0; i < N; ++i)
        ans = max(ans, bfs(i));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    string N;
    cin >> N;
    int t = N.size();
    int K;
    cin >> K;
    int nonzero = 0;
    if(t < K) {
        cout << 0 << endl;
        return 0;
    } else if(t == K) {
        int NN = stoi(N);
        if(K == 2 && NN < 11) {
            cout << 0 << endl;
            return 0;
        } else if(K == 3 && NN < 111) {
            cout << 0 << endl;
            return 0;
        }
    }
    long ans = 1;
    REP(i, K) {
        ans *= (t-i);
        ans *= 9;
    }
    REP(i, K) {
        ans /= i+1;
    }
    int cnt = 0;
    int s = 0;
    REP(i, t) {
        //cout << ans << endl;
        if(t-i < K-cnt) break;
        int x = N[i] - '0';
        if(x != -1) {
            long tmp = 9-x;
            cnt++;
            REP(j, K-cnt) {
                tmp *= t-i-1-j;
                tmp *= 9;
            }
            REP(j, K-cnt) {
                tmp /= j+1;
            }
            //cout << tmp << endl;
            ans -= tmp;
            if(x == 0) cnt--;
            if(K == cnt) break;
        }
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
class C{
 public:
  constexpr C():xs(){
    for(int i=0;i<=999;++i)xs[i]=i;
    for(int i=1;i<=999;++i)xs[i]+=xs[i-1];
  }
  int xs[1000];
};
int a,b;
main(){
  C c;
  cin>>a>>b;
  for(int i=1;i<=999;++i){
    if(c.xs[i]-c.xs[i-1]==b-a){
      cout<<(c.xs[i]-b)<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 514
 
string S;
int memo[MAX][MAX];
 
bool rec(int L,int R){
    int &res = memo[L][R];
    if(res != -1) return res;
    if(L > R) return 1;
    if(S[L] != 'm' || S[R] != 'w') return (res = 0);
    res = 0;
    for(int i = L+1 ; i < R ; i++){
        if(S[i] == 'e'){
            res = max(res,rec(L+1,i-1)&rec(i+1,R-1));
        }
    }
    return res;
}
 
int main(){
    cin >> S;
    memset(memo,-1,sizeof(memo));
    cout << (rec(0,S.size()-1) ? "Cat" : "Rabbit") << endl;
    return 0;
}

Measured memory_bytes: 4192
use std::io;
use std::cmp;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut ab = Vec::new();

    for _ in 0..m {
        let (a, b) = {
            let i = read::<usize>();
            (i[0], i[1])
        };
        ab.push((a - 1, b - 1));
    }

    ab.reverse();

    let mut cost = Vec::new();

    let mut uf = UnionFind::new(n);
    for &(a, b) in ab.iter() {
        let before_a = uf.find(a);
        let before_b = uf.find(b);
        let c = uf.siz[before_a] * uf.siz[before_b];
        uf.unite(a, b);
        let after_a = uf.find(a);
        let after_b = uf.find(b);

        let c = if before_a != after_a || before_b != after_b {
            c
        } else {
            0
        };
        cost.push(c);
    }
    cost.reverse();

    let mut ans: usize = 0;
    for i in 0..cost.len() {
        ans += cost[i];
        println!("{}", ans);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

#[derive(Debug)]
pub struct UnionFind {
    pub par: Vec<usize>,
    pub rank: Vec<usize>,
    pub siz: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind {
            par: (0..n).collect(),
            rank: vec![0; n],
            siz: vec![1; n],
        }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x { x }
        else {
            let p = self.par[x];
            let pp = self.find(p);
            self.par[x] = pp;
            pp
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let x = self.find(x);
        let y = self.find(y);

        if x == y { return; }

        let prev_x = self.siz[x];
        let prev_y = self.siz[y];
        self.siz[x] += prev_y;
        self.siz[y] += prev_x;

        match self.rank[x].cmp(&self.rank[y]) {
            cmp::Ordering::Equal => {
                self.par[y] = x;
                self.rank[x] += 1;
            },
            cmp::Ordering::Less => {
                self.par[x] = y;
            },
            cmp::Ordering::Greater => {
                self.par[y] = x;
            }
        }

    }
}

Measured memory_bytes: 11516
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int most = max(max(a, b), c);
	int sum = a + b + c - most;
	most *= (1 << k);
	
	cout << sum + most << "\n";

	return 0;

}

Measured memory_bytes: 256
a,b,c = map(int,input().split())

def search(a,b,c):
    lst = [0,0,0]
    if a%2 == b%2:
        lst = [1,1,0]
        if a%2==c%2:
            lst = [1,1,1]
    elif a%2 == c%2:
        lst = [1,0,1]
    else:
        lst = [0,1,1]
    return lst


def make(a,b,c):
    lst = [a,b,c]
    lst.sort()
    lst[0] += 2
    return lst[0],lst[1],lst[2]

if __name__ == "__main__":
    ans = 0
    l = search(a,b,c)
    if sum(l) == 3:
        pass
    else:
        ans += 1
        a += l[0]
        b += l[1]
        c += l[2]
    while a != b or a != c:
        a,b,c = make(a,b,c)
        ans += 1
    print(ans)

Measured memory_bytes: 38384
//................ DON'T WISH IT WERE EASIER, WISH YOU WERE BETTER........................
//............ WHEN LIFE PUTS YOU IN TOUGH SITUATIONS, DONT SAY "WHY ME" SAY "TRY ME".......

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define endl "\n"
#define f first
#define mp make_pair
#define s second
#define int long long
#define delrep(v)  (v).erase(unique((v).begin(),(v).end()),(v).end());
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define sz(x)   (int)x.size()
#define lll __int64
const int N=1e6+10; const int M=1e6+20;
const int mod=1e9+7;
using namespace std;
typedef long long ll;
const long long MAX_SIZE = 3000003;
vector<pair<int,int>>v[N]; map<int,int>hashx;
vector<int>a(N); vector<int>b(N); int pref[N]; int suff[N]; int sum[N];
// vector<ll>dp(N);
ll n,k;
ll dp[1005][1005];
int32_t main()
{
   int n,m; cin>>n>>m; string s[n+1];
   for(int i=1;i<=n;i++) cin>>s[i];  dp[1][0]=1;
   for(int i=1;i<=n;i++) for(int j=0;j<=m;j++)
    {
        if(i==1 && j==0) continue;
        if(s[i][j]=='.') dp[i][j]=dp[i-1][j]+dp[i][j-1];
        dp[i][j]%=mod;
    }
   cout<<dp[n][m-1]; return 0;
}
 
 

Measured memory_bytes: 49152
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm> //???????????¨

using namespace std;

int main(){
	//ifstream fin("in.txt");

	vector<int> v;

	int average = 0;

	int n = 0;
	while (true){

		cin >> n;
		if (n == 0)break;

		//?????????
		average = 0;
		if (!v.empty())v.clear();

		for (int i = 0; i < n; i++){
			int tmp = 0;
			cin >> tmp;
			v.push_back(tmp);
		}
		sort(v.begin(), v.end());
		v.pop_back();
		v.erase(v.begin());

		for (int i = 0; i < v.size(); i++)
			average += v[i];

		average /= v.size();

		cout << average << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    cin>>k>>x>>y;
    for(i=x;i<=y;i++){
        if(i%k == 0){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
}    
    

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define MOD 1000000007
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define dforn(a, n) for(int a = (n)-1; a>=0; --a)
#define forall(a, all) for(__typeof(all.begin()) a = all.begin(); a != all.end(); ++a)
#define EPS 0.000000000001
using namespace std;
typedef long long tint;
typedef pair<tint, tint> pii;
typedef vector<tint> vi;
typedef vector<vi> vvi;

tint solve(tint n, tint a, tint b, tint c, tint d, map<tint, tint>& memo) {
	if(n==0) return 0;
	if(memo.find(n) != memo.end()) {
		return memo[n];
	}
	tint r2 = n%2, r3 = n%3, r5 = n%5;
	tint ans = 1000000000000000000LL;
	if(log(n)+log(d) < 60*log(2)) ans = n*d; 
	ans = min(ans, solve(n/2, a,b,c,d, memo) + a + d*r2);
	if(n/2+1 < n)
	ans = min(ans, solve(n/2+1, a,b,c,d, memo) + a + d*(2-r2));
	ans = min(ans, solve(n/3, a,b,c,d, memo) + b + d*r3);
	if(n/3+1 < n)
	ans = min(ans, solve(n/3+1, a,b,c,d, memo) + b + d*(3-r3));
	ans = min(ans, solve(n/5, a,b,c,d, memo) + c + d*r5);
	if(n/5+1 < n)
	ans = min(ans, solve(n/5+1, a,b,c,d, memo) + c + d*(5-r5));
	memo[n] = ans;
	return ans;
}

int main()
{
	int n;
	cin >> n;
	
	vvi dists(n, vi(n, 0));
	vvi occup(n, vi(n, 1));
	forn(i, n) forn(j, n) {
		dists[i][j] = min(i+1, min(j+1, min(n-i, n-j)))-1;	 
	}
	
	vi dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
	tint ans = 0;
	forn(Pi, n*n) {
		int p;
		cin >> p;
		p--;
		int i = p/n, j = p%n;
		occup[i][j] = 0;
		ans += dists[i][j];
		queue<pair<int, int>> updates;
		updates.push({i,j});
		while(!updates.empty()) {
			int ai = updates.front().first, aj = updates.front().second;
			updates.pop();
			forn(d, 4) {
				int ni = ai+dx[d], nj = aj+dy[d];
				if(ni < 0 || nj < 0 || ni >= n || nj >= n) continue;
				if(dists[ni][nj] > dists[ai][aj]+occup[ai][aj]) {
					dists[ni][nj] = dists[ai][aj]+occup[ai][aj];
					updates.push({ni, nj});
				}
			}
		}
		//forn(i, n) {forn(j, n) cout << dists[i][j] << " "; cout << ans << endl;}
		//cout << endl;
	}
	cout << ans << endl;
}


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

queue<pair<string,int> > que;
int main(){
    int n,q;
    cin>>n>>q;
    string s;
    int t;
    rep(i,n){
        cin>>s>>t;
        que.push({s,t});
    }
    int ans=0;
    while(!que.empty()){
        pair<string,int> p=que.front();que.pop();
        if(p.second>q) p.second-=q,ans+=q,que.push(p);
        else{
            ans+=p.second;
            cout<<p.first<<" "<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n; cin>>n;
	ll ans=(n/11)*2;
	if(0<n%11 && n%11<=6)ans++;
	else if(n%11!=0)ans+=2;
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  string S, T;
  cin >> S >> T;
  int ans = INF;
  rep(i, S.size() - T.size() + 1) {
    int cnt = 0;
    rep(j, T.size()) {
      if (S[i + j] != T[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;
import java.util.Arrays;

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

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int num3 = sc.nextInt();

        if(num1 + num2 + num3 >= 22) {
            System.out.print("bust");
        } else {
            System.out.print("win");
        }


    }
}

Measured memory_bytes: 21844
#include <stdio.h>
    int main (void) {
     int a, b;
     char op;
     while (1) {
      scanf ("%d %c %d", &a, &op, &b);
      if (op=='+') {
       printf ("%d\n", a+b);
      }else if (op=='-') {
       printf ("%d\n", a-b);
      }else if (op=='*') {
       printf ("%d\n", a*b);
      }else if (op=='/') {
       printf ("%d\n", a/b);
      }else if (op=='\?') {
       break;
      }
     }
     return (0);
    } 


Measured memory_bytes: 2060
#include <iostream>		 // cout, endl, cin
#include <string>		 // string, to_string, stoi
#include <vector>		 // vector
#include <algorithm>	 // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>		 // pair, make_pair
#include <tuple>		 // tuple, make_tuple
#include <cstdint>		 // int64_t, int*_t
#include <cstdio>		 // printf
#include <map>			 // map
#include <queue>		 // queue, priority_queue
#include <set>			 // set
#include <stack>		 // stack
#include <deque>		 // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>		 // bitset
#include <cctype>		 // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2)
	{
		int cnt = 0;
		for (int j = 1; j <= i; j++)
		{
			if (i % j == 0)
			{
				cnt += 1;
			}
		}
		if (cnt == 8)
		{
			ans += 1;
		}
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
#define MOD 1000000007

void Main(){
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(u==s){
    cout<<a-1<<" "<<b<<endl;
  }else{
    cout<<a<<" "<<b-1<<endl;
  }


} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
q = int(input())
total = sum(lis)

nlis = [0] * 100002

for i in lis:
    nlis[i-1] += 1

for i in range(q):
    b, c = map(int,input().split())
    total = total -(b*nlis[b-1]) + (c*nlis[b-1])
    nlis[c-1] += nlis[b-1]
    nlis[b-1] = 0
    print(total)

Measured memory_bytes: 20880
n = int(input())

if n < 105:
    print(0)
elif 105 <= n < 135:
    print(1)
elif 135 <= n < 165:
    print(2)
elif 165 <= n < 189:
    print(3)
elif 189 <= n < 195:
    print(4)
else:
    print(5)


Measured memory_bytes: 2940
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
using namespace std;

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

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

    int h[N];

    REP(i, N)
        cin >> h[i];

    sort(h, h+N);

    int min = h[N-1];

    REP(index, N-K+1)
    {
        //cout << "index : " << index;
        int h_min = h[index]; //cout << " h_min: " << h_min;
        int h_max = h[index+K-1]; //cout << " h_max: " << h_max;
        int temp = h_max - h_min; //cout << " temp: " << temp << endl;;

        if (temp < min)
        {
            min = temp;
        }
    }

    cout << min << endl;
}

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

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

  if (X >= 30){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(void){
	int k,i;
	ll a[123456],mx=2ll,mn=2ll;
	cin >> k;
	for(i=0; i<k; i++){
		cin >> a[k-i];
	}
	a[0] = 1;
	for(i=1; i<=k; i++){
		if(mx < a[i]){
			cout << "-1" << endl;
			return 0;
		}
		mx = ((mx/a[i])+1)*a[i]-1;
		mn = (((mn-1)/a[i])+1)*a[i];
		if(mn > mx){
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << mn << " " << mx << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(x<a && x<b && a<b)cout<<"A";
  else if(x<a && x<b && b<a)cout<<"B";
  else if(a<x && x<b && b-x<x-a)cout<<"B";
  else if(a<x && x<b && x-a<b-x)cout<<"A";
  else if(b<x && x<a && a-x<x-b)cout<<"A";
  else if(b<x && x<a && x-b<a-x)cout<<"B";
  else if(b<x && a<x && x-a<x-b)cout<<"A";
  else cout<<"B";
  
}

Measured memory_bytes: 256
open System

let f (a: float) (b: float) (h: float) (m: float): float =
   let large =
       let minutes = 60. * h + m 
       let rate = minutes / (60. * 12.) 
       let rad = 2. * Math.PI * rate 
       let x = a * cos rad
       let y = a * sin rad 
       (x, y)
   let small = 
       let rate = m / 60.
       let rad = 2.0 * Math.PI * rate 
       let x = b * cos rad 
       let y = b * sin rad 
       (x, y)
   let x = fst large - fst small |> abs 
   let y = snd large - snd small |> abs 
   pown x 2 + pown y 2
   |> sqrt

let l = Console.ReadLine().Split()|> Array.map float 
f l.[0] l.[1] l.[2] l.[3]
|> printfn "%.15f"

Measured memory_bytes: 30548
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

enum MOD = 10 ^^ 9 + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    auto dp = new long[][](N + 1, 2);
    dp[0][] = dp[1][] = long.min / 2;
    dp[0][0] = 0;
    // writeln(dp[0]);
    foreach (i; 0 .. N)
    {
        dp[i + 1][0] = dp[i + 1][0].max(dp[i][0] + A[i]);
        dp[i + 1][0] = dp[i + 1][0].max(dp[i][1] - A[i]);

        dp[i + 1][1] = dp[i + 1][1].max(dp[i][0] - A[i]);
        dp[i + 1][1] = dp[i + 1][1].max(dp[i][1] + A[i]);
    }
    writeln(dp[N][0]);
}


Measured memory_bytes: 11416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a, b, c;
		char al, bf, bl, cf;
		
		a = sc.next();
		al = a.charAt(a.length() - 1);
		b = sc.next();
		bf = b.charAt(0);
		bl = b.charAt(b.length() - 1);
		c = sc.next();
		cf = c.charAt(0);
		sc.close();
		
		
		if(al == bf && bl == cf)System.out.println("YES");
		else System.out.println("NO");
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
	int tab[26] = {0};
	string s;
	cin >> s;
	for(int i = 0; i < (int)s.size(); i++){
        tab[s[i] - 'a']++;
	}
	char curr = '0';
	for(int i = 0; i < 26; i++){
        if(tab[i] == 0){
            curr = (char)i+'a';
            break;
        }
	}
	if(curr == '0') cout << "None" << endl;
	else cout << curr << endl;
}


Measured memory_bytes: 512
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int h[N];
int mem[N];

int go(int idx){
    if(idx >= n)
        return 0;
    if(mem[idx] != -1)
        return mem[idx];
    int best = 1e9;
    if(idx + 1 <= n)
        best = go(idx + 1) + abs(h[idx] - h[idx + 1]);
    if(idx + 2 <= n)
        best = min(best , go(idx + 2)  + abs(h[idx] - h[idx + 2]));
    return mem[idx] = best;
}

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &h[i]);
    }
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , go(1));
}
//1 2 3


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, x; cin >> N >> x;
	if (x == 1 || x == 2 * N - 1)cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		if (N == 2) {
			cout << 1 << endl << 2 << endl << 3 << endl;
		}
		else {

			for (int i = 1; i <= 2 * N - 1; i++) {
				cout << (x + N - i + 2 * N - 1 - 1) % (2 * N - 1) + 1 << endl;
			}

		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
typedef long long int ll;


int main() {
    fast
    //test
    {
        int i,j,n;
        cin >> n;
      	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
          cout<<"hon";
     	else if(n%10==0||n%10==1||n%10==6||n%10==8)
          cout<<"pon";
      	else cout<<"bon";
    }
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
    int A, B;

    scanf("%d %d", &A, &B);

    if (A <= 16 && A >= 1 && B <= 16 && B >= 1)
    {
        if ((A + B <= 16))
        {
            if (A > 8 || B > 8)
            {
                printf(":(\n");
            }
            else
            {
                printf("Yay!\n");
            }
        }
        else
        {
            printf(":(\n");
        }
    }
    else
    {
        printf(":(\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

bool isOp(string& s){
	return s.size() == 1 and not isalpha(s[0]) and not isdigit(s[0]);
}

set<int> getNumbers(map<string, pair<int,int>>& var, string& a){
	set<int> res;
	range(i, var[a].first, var[a].second + 1){
		res.emplace(i);
	}
	return res;
}

bool f;
set<int> cul(set<int>& a, set<int>& b, string op){
	set<int> res;
	for(auto i : a){
		for(auto j : b){
			//cout << i << ' ' << j << endl;
			if(op == "+") res.emplace((i + j) % 256);
			else if(op == "-") res.emplace((i - j + 256) % 256);
			else if(op == "*") res.emplace((i * j) % 256);
			else if(op == "/"){
				if(j == 0) f = false;
				else res.emplace((i / j) % 256);
			}
		}
	}
	return res;
}

int main(){

	int m;
	cin >> m;

	map<string, pair<int, int>> var;
	rep(i,m){
		string name;
		int l, r;
		cin >> name >> l >> r;
		var[name] = make_pair(l, r);
	}

	int n;
	cin >> n;

	stack<set<int>> st;
	f = true;
	rep(i,n){
		string s;
		cin >> s;

		if(isOp(s)){
			set<int> b = st.top(); st.pop();
			set<int> a = st.top(); st.pop();
			st.emplace(cul(a, b, s));
		}else{
			if(var.count(s)){
				st.emplace(getNumbers(var, s));
			}else{
				st.emplace(set<int>{stoi(s)});
			}
		}
	}

	cout << (f ? "correct" : "error") << endl;
}



Measured memory_bytes: 3272