akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int num[100000+1];
int main() {
	int N, M; cin >> N >> M;
	vector<P> v(M), b(M);
	rep(i, M) {
		cin >> v[i].first >> v[i].second;
		b[i] = v[i];
		num[v[i].first]++;
	}
	rep(i, 100000+1) {
		if (i == 0) continue;
		num[i] += num[i-1];
	}
	sort(v.begin(), v.end());
	rep(i, M) {
		auto it = lower_bound(v.begin(), v.end(), b[i]);
		int idx = distance(v.begin(), it) + 1;
		idx -= num[b[i].first - 1];
		char s[7];
		sprintf(s, "%d", b[i].first);
		for (int i = 0; i < 6 - strlen(s); i++) {
			cout << "0";
		}
		cout << b[i].first;
		sprintf(s, "%d", idx);
		for (int i = 0; i < 6 - strlen(s); i++) {
			cout << "0";
		}
		cout << idx << endl;
	}
}

Measured memory_bytes: 5428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s;
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy" << endl;
	else if (s == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
}

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

	solve();
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N, Q = map(int, input().split())
c = list(map(int, input().split()))

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r, i])

lr.sort(key=lambda x: x[1])
# print("lr", lr)
rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]] + 1, -1)
    rightest[c[i]] = i
    bit.add(i + 1, 1)
    # print(bit.tree)

    while current_q < Q and lr[current_q][1] == i + 1:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1]) - bit.sum(lr[current_q][0] - 1)
        current_q += 1

for i in range(Q):
    print(ans[i])


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

typedef long long ll;

ll mod=1e9+7;

bool is_prime(ll n){
  if(n==1) return false;
  else{
    bool ans=true;
    for(ll i=2;i*i<=n;i++){
      if(n%i==0) ans=false;
    }
    return ans;
  }
}

 
ll modinv(ll a){
  ll b=mod,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=mod;
  if(u<0) u+=mod;
  return u;
}
 
ll fac[300010];
 
void modfac(){
  fac[0]=1;
  for(ll i=1;i<300010;i++){
    fac[i]=(fac[i-1]*i)%mod;
  }
}
 
ll modcomb(ll n,ll k){
  if(n<k) return 0;
  else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

int main(){
  ll n,m;
  cin >> n >> m;
  modfac();
  ll pr[40000];
  ll k=0;
  for(ll i=1;i<=40000;i++){
    if(is_prime(i)){
      pr[k]=i;
      k++;
    }
  }
  ll cnt[k];
  for(ll i=0;i<k;i++) cnt[i]=0;
  for(ll i=0;i<k;i++){
    while(m%pr[i]==0){
      cnt[i]++;
      m/=pr[i];
    }
  }
  ll ans=1;
  for(ll i=0;i<k;i++){
    ans=(ans*modcomb(n+cnt[i]-1,cnt[i]))%mod;
  }
  if(m!=1){
    ans=(ans*n)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

int main() {
    int N; cin >> N; // 1日あたりに到着する乗客の数
    int C; cin >> C; // バスの定員
    int K; cin >> K; // 経過時間のリミット
    vector<int> T(N); rep(i, N) cin >> T[i];  // 乗客の到着時刻
    sort(T.begin(), T.end());

    int ans = 0;

    for (int i = 0; i < N;) {
        ++ans;
        int start = i;
        while (i < N && T[i] - T[start] <= K && i - start < C) ++i;
    }

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


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int T[35];

int main()
{
    int N, M;
    cin >> N >> M;
    REP(i, M)
    {
        T[i] = 0;
    }
    REP(i, N)
    {
        int k;
        cin >> k;
        REP(j, k)
        {
            int a;
            cin >> a;
            T[--a]++;
        }
    }
    int ans = 0;
    REP(i, M)
    {
        if (T[i] == N)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1 << 30)
using namespace std;

int A[100000];
int dp[100000];
int main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	dp[0] = 0;
	fill(dp + 1, dp + n, INF);
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(i + j < n){
				dp[i + j] = min(dp[i + j], dp[i] + abs(A[i] - A[i + j]));
			}
		}
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    /*int l,r,d;
    cin >> l >> r>> d;
    int ans=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            ans++;
    }
    cout << ans << endl;*/
    int ans=0;
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        if(x%2&&i%2)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3560
#!/usr/bin/env python3
import operator
n, m, c = map(int, input().split())
cnt = 0
b = list(map(int, input().split()))
for _ in range(n):
    a = list(map(int, input().split()))
    cnt += (sum(map(operator.mul, a, b)) + c > 0)
print(cnt)


Measured memory_bytes: 3188
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    reads(s) 

    fori (i , 1, sz(s)) cout << 'x';

    return 0;
}




Measured memory_bytes: 3608
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<pii> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N), B(N);
	PQ Q;
	REP(i, N)cin >> A[i];
	REP(i, N) {
		cin >> B[i];
		Q.push(pii(B[i], i));
	}
	//   i-j-k
	int ans = 0;
	while (!Q.empty()) {
		//REP(a, N)cout << B[a] << " ";
		//cout << endl;
		//ans++;
		int a = Q.top().first, j = Q.top().second;
		Q.pop();
		int i = j - 1, k = j + 1;
		if (j == 0)i = N - 1;
		if (j == N - 1)k = 0;

		if (B[j] == A[j])continue;
		if (B[j] < A[j]) {
			cout << -1 << endl;
			return 0;
		}

		int x = (B[i] + B[k]);
		int K = (B[j] - A[j]) / x;
		
		if (K==0) {
			cout << -1 << endl;
			return 0;
		}
		ans += K;
		B[j] -= x*K;
		
		Q.push(pii(B[j],j));
	}
	bool F = true;
	REP(i, N)if (A[i] != B[i])F = false;
	cout << (F ? ans : -1) << endl;

	return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, M;
ll A[100005];
ll S[100005];

bool check(ll n) {
    ll m = 0;
    REP(i, N) {
        ll ok = i - 1, ng = N;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (A[i] + A[mid] > n)
                ok = mid;
            else
                ng = mid;
        }
        if (ok < i)
            continue;
        ll t = (ok - i) * 2 + 1;
        m += t;
    }
    return m <= M;
}

int main() {

    cin >> N >> M;
    memset(S, 0, sizeof(S));
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N, [](ll a, ll b) { return a > b; });
    REP(i, N) {
        S[i] += A[i];
        S[i + 1] += S[i];
    }

    ll lim = 0;
    {
        ll ok = INF, ng = 0;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (check(mid))
                ok = mid;
            else
                ng = mid;
        }
        lim = ok;
    }

    //! 和がok超であれば、含まれる。
    ll ans = 0;
    REP(i, N) {
        ll ok = i - 1, ng = N;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (A[i] + A[mid] > lim)
                ok = mid;
            else
                ng = mid;
        }
        if (ok < i)
            continue;
        M -= (ok - i) * 2 + 1;
        ans += (S[ok] - S[i]) * 2;
        ans += A[i] * ((ok - i) * 2LL + 2);
    }

    //! lim以下ででかいものから残っているっものだけ取得する
    cout << ans + lim * M << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n); REP (i, n) cin >> a[i];
  vector<int> ans(n);
  for (int i = n; i >= 1; i--) {
    int acc = a[i - 1];
    for (int j = i; j <= n; j += i) {
      acc ^= ans[j - 1];
    }
    ans[i - 1] = acc;
  }
  int cnt = accumulate(ALL(ans), 0LL);
  cout << cnt << endl;
  REP (i, n) {
    if (ans[i]) cout << i + 1 << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3968
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	int[] as = rint(n);

	int x = 0; // iまで見たとき、到達可能な最大
	foreach(a; as){
		if(x + 1 == a) x = a;
	}

	if(x == 0) "-1".writeln;
	else (n - x).writeln;
}

/*
最も長い増加列を作れというのと同じこと
*/

Measured memory_bytes: 10740
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
vector<int> g[212345], rg[212345];
vector<int> sinc[212345];
bool done[212345], cycle[212345];
vector<int> vs;
int an;
int num[212345], tmp[212345];

void dfs(int v) {
	done[v] = true;
	REP(i, g[v].size()) if (!done[g[v][i]]) dfs(g[v][i]);
	vs.push_back(v);
}

void rdfs(int v, int k) {
	done[v] = true;
	sinc[k].push_back(v);
	REP(i, rg[v].size()) if (!done[rg[v][i]]) rdfs(rg[v][i], k);
}

void scc() {
	REP(i, N) if (!done[i]) dfs(i);
	
	memset(done, 0, sizeof(done));
	
	an = 0;
	for (int i = (int)vs.size() - 1; i >= 0; i--) {
		if (!done[vs[i]]) rdfs(vs[i], an++);
	}
}

// 閉路頂点st, a_st = kとする
bool solve(int st, int k) {
	num[st] = k;
	
	queue<int> que;
	que.push(rg[st][0]);
	
	while (!que.empty()) {
		int u = que.front(); que.pop();
		
		set<int> ss;
		REP(i, g[u].size()) ss.insert(num[g[u][i]]);
		int g = 0;
		while (ss.find(g) != ss.end()) g++;
		
		if (num[u] != -1) return num[u] == g;
		
		num[u] = g;
		que.push(rg[u][0]);
	}
	
	return true;
}

int main() {
	cin >> N;
	REP(i, N) {
		int p; scanf("%d", &p);
		p--;
		g[p].push_back(i);
		rg[i].push_back(p);
	}
	
	scc();
	
	REP(i, an) if (sinc[i].size() > 1) {
		REP(j, sinc[i].size()) {
			cycle[sinc[i][j]] = true;
		}
	}
	
	memset(num, -1, sizeof(num));
	
	queue<int> que;
	REP(i, N) if (g[i].size() == 0) {
		num[i] = 0;
		if (!cycle[rg[i][0]]) que.push(rg[i][0]);
	}
	
	while (!que.empty()) {
		int u = que.front(); que.pop();
		
		set<int> ss;
		REP(i, g[u].size()) ss.insert(num[g[u][i]]);
		
		int g = 0;
		while (ss.find(g) != ss.end()) g++;
		
		if (!cycle[rg[u][0]]) que.push(rg[u][0]);
	}
	
	
	int v = -1;
	REP(i, N) if (cycle[i]) { v = i; break; }
	
	set<int> ss;
	REP(i, g[v].size()) {
		int to = g[v][i];
		if (!cycle[to]) ss.insert(num[g[v][i]]);
	}
	
	copy(num, num + N, tmp);
	
	bool ans = false;
	
	int g = 0;
	while (ss.find(g) != ss.end()) g++;
	ans |= solve(v, g);
	
	g++;
	
	copy(tmp, tmp + N, num);
	while (ss.find(g) != ss.end()) g++;
	ans |= solve(v, g);
	
	puts(ans ? "POSSIBLE" : "IMPOSSIBLE");
	
	return 0;
}

Measured memory_bytes: 38768
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,ta,a[101010];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>ta;
		a[ta%2]++;
	}
	if(((a[1]%2)==0))
		cout<<"YES\n";
	else
		cout<<"NO\n";
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))

    counts = [0] * (10**6 + 1)
    for a in A:
        counts[a] += 1

    ans = 1
    for i in range(2, 10**6+1):
        co_primes = 0
        for j in range(i, 10**6+1, i):
            co_primes += counts[j]
        if ans < co_primes:
            ans = co_primes

    if ans == 1:
        print("pairwise coprime")
    elif ans < n:
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == "__main__":
    main()


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

bool binary_search( int* a, int n, int v )
{
    int left = 0, right = n;

    while( left < right )
    {
        int mid = ( left + right ) / 2;

        if( a[mid] > v )
            right = mid;
        else if( a[mid] < v )
            left = mid + 1;
        else
            return true;
    }
    return false;
}

int main()
{
    int n, m;

    cin >> n;

    int a[n];

    for( int i = 0; i < n; i++ )
        cin >> a[i];
    
    cin >> m;

    int b[n];

    for( int i = 0; i < m; i++ )
    {
        cin >> b[i];
        if( binary_search( a, n, b[i] ) == false )
        {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    
    return 0;
}


Measured memory_bytes: 4560
n = int(input())
x = [float(i) for i in input().split()]
y = [float(i) for i in input().split()]

man_x_y = sum(abs(x[i]-y[i]) for i in range(n)) 
euk2_x_y = (sum((x[i]-y[i])**2 for i in range(n)))**(1/2)
euk3_x_y = (sum((abs(x[i]-y[i]))**3 for i in range(n)))**(1/3)

che_x_y = max(abs(x[i]-y[i]) for i in range(n)) 
print(man_x_y)
print(euk2_x_y)
print(euk3_x_y)
print(che_x_y)


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

int main(void){

    int N,A,B; cin>>N>>A>>B;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        int tmp=i;
        int suming=0;
        while(tmp>0){
            suming += tmp%10;
            tmp /= 10;
        }
        if(A<=suming)
            if(B>=suming) ans += i;
    }
    cout<<ans<<endl;
    return 0;
}

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

class unionfind
{
	public:
		//初始化n个元素 
		void init(int n)
		{
			par = new int[n + 1];
			rank = new int[n + 1];
			for(int i = 0;i <= n;i++)
			{
				par[i] = i;
				rank[i] = 0;
			}
		}
		//查询树的根 
		int find(int x)
		{
			if(par[x] == x)
			{
				return x;
			}
			else
			{
				return par[x] = find(par[x]);
			}
		}
		//合并x和y所属的集合
		void unite(int x,int y)
		{
			x = find(x);
			y = find(y);
			if(x == y)
			    return;
			if(rank[x] < rank[y])
			{
				par[x] = y;
			}
			else
			{
				par[y] = x;
				if(rank[x] == rank[y])
				{
					rank[x]++;
				}
			}
		}
		int *par;
		int *rank;
};

struct edge
{
	int u;
	int v;
	double cost;
}; 
bool comp(const edge& e1,const edge& e2)
{
	return e1.cost > e2.cost;
}

int n,m,p,q;
int xi[10010];
int yi[10010];
double all = 0;
edge es[50100050];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i = 0;i < n;i++)
	{
		scanf("%d%d",&xi[i],&yi[i]);
	}
	for(int i = 0;i < m;i++)
	{
		scanf("%d%d",&es[i].u,&es[i].v);
		es[i].u--;
		es[i].v--;
		int dx = xi[es[i].u] - xi[es[i].v];
		int dy = yi[es[i].u] - yi[es[i].v];
		es[i].cost = sqrt(dx * dx + dy * dy);
		all = all + es[i].cost;
	}
	sort(es,es + m,comp);
	unionfind A;
	A.init(n);
	double res = 0;
	for(int i = 0;i < m;i++)
	{
		edge e = es[i];
		if(A.find(es[i].u) != A.find(es[i].v) )
		{
			A.unite(es[i].u,es[i].v);
		}
		else
		{
			res = res + es[i].cost;
		}
	}
	cout.setf(ios::showpoint);
	cout.precision(3);
	cout.setf(ios::fixed);
	cout<<res<<endl;
} 


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

int main()
{
    int n , x , t;
    cin >> n >> x >> t;
   if ( x== 0) {
    cout << 0 << endl;
     return 0;
  }
  n = ((n+x-1)/x)*t;
  	cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**6)

N = int(sys.stdin.readline())
h = tuple(map(int, sys.stdin.readline().split()))
cost = [None]*N

def DP(n):
    if cost[n] != None:
        return cost[n]
    
    if n==0:
        return 0
    elif(n > 1):
        cost[n] = min(DP(n-1) + abs(h[n] - h[n-1]), DP(n-2) + abs(h[n] - h[n-2]))
        return cost[n]
    else:
        cost[n] = DP(n-1) + abs(h[n] - h[n-1])
        return cost[n]


print(DP(N-1))

Measured memory_bytes: 94084
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll N;

int main()
{
	scanf("%lld",&N);
	ll ans=0LL;
	ans=(N/11LL)*2LL;
	N%=11LL;
	if(N!=0LL){ 
		if(N<=6LL) ans++;
		else ans+=2LL;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A, B, C, D; 
 cin >> A >> B >> C >> D;
  
  if (B <= C) cout << 0 << endl;
  else if ( A <= C && C <= B && B <= D ) cout << B - C << endl;
  else if ( A <= C && C <= B && A <= D && B >=D ) cout << D - C << endl;
  else if ( A >= C && A <= D && B >=D ) cout << D - A << endl;
  else if ( C <= A && B <= D ) cout << B- A << endl; 
  else cout << 0 << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	x := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	sort.Ints(aa)

	for i := 0; i < n; i++ {
		x -= aa[i]
		if x < 0 {
			fmt.Println(i)
			return
		}
	}
	if x > 0 {
		n--
	}
	fmt.Println(n)
	writer.Flush()
}


Measured memory_bytes: 640
nums = gets.split(" ").map(&:to_i)
n = nums[0]
k = nums[1]
size = gets.split(" ").map(&:to_i)

i = 0
ctn = 0
while i <= size.length-1  
  if size[i] >= k
    ctn += 1
  end
  i += 1
end

puts ctn

Measured memory_bytes: 7944
#include <bits/stdc++.h>
#include <vector>
#include <map>
#define ll long long
#define h   "\n"
#define ios
using namespace std;

int main()
{
    int a[3];

    cin>>a[0]>>a[1]>>a[2];

    sort(a,a+3);
 int m=0;
    for(int i=1;i<3;i++)
    {
        if(a[i]==a[i-1])
        m++;
    }


    if(m==1)
        cout<<"Yes"<<h;
        else
            cout<<"No"<<h;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define y1 y12312123
#define int ll

using namespace std;

const int N = 3e5 + 3;
const int inf = 1e9 + 3;
int n, a[N], ans[N], l, r;
int nxt[N];

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

    cin >> n;
    for(int i = 1; i <= n; ++i)nxt[i + 1] = i;
    nxt[1] = n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        a[i] *= 2;
    }
    int x = 0;
    for(int i = n; i >= 1; i--){
        if(i & 1)x += a[i];
        else x -= a[i];
    }
    x /= 2;
    ans[n] = x;
    cout << ans[n] << " ";
    for(int i = 1; i < n; ++i){
        ans[i] = (a[i] - ans[nxt[i]]);
        cout << ans[i] << " ";
    }

}


Measured memory_bytes: 6272
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#define endl "\n"
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

#define int long long

const int nmax = 2e5+7;
const int mod = 1e9+7;

template <class T>
T bm(T b, T p, T m ) /// Faster than recursive one
{
    T res = 1 % m, x = b % m;
    while ( p )
    {
        if ( p & 1 )
            res = ( res * x ) % m;
        x = ( x * x ) % m;
        p >>= 1;
    }
    return res;
}

int32_t main()
{
    optimizeIO();

    int tc = 1;

    while(tc--)
    {
        int n;
        cin>>n;

        vector<int>v(n+1);
        for(int i=1;i<=n;i++) cin>>v[i];

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

        bool ok = true;

        for(int i=1;i<=n;i++)
        {
//            if((n%2) == (v[i]%2))
//            {
//                ok = false;
//                continue;
//            }

            int x = (n-v[i]-1)/2;
            int y = (n+v[i]-1)/2;

            cnt[x+1]++;
            cnt[y+1]++;

        }

        for(int i=1;i<=n;i++) if(cnt[i]!=2) ok = false;

        if(ok) cout<<bm(2LL,n/2,mod)<<endl;
        else cout<<0<<endl;
    }

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 4704
from collections import Counter
K, T = [int(x) for x in raw_input().strip().split()]
a = [int(x) for x in raw_input().strip().split()]
amax = max(a)
aothersum = sum([x for x in a if x!=amax])
ac = Counter(a)
aothersum += (ac[amax]-1)*amax

if amax <= aothersum:
  print 0
else:
  print amax - aothersum - 1


Measured memory_bytes: 2812
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int N;
	string s[100];
	cin >> N;
	bool flag = true;
	for(int i = 0; i < N; i++) {
		cin >> s[i];
	}
	for (int i = 1; i < N; i++) {
		if (s[i - 1][s[i - 1].length()-1] != s[i][0]) {
			flag = false;
		}
	}
	
	for (int i = 0; i < N-1; i++) {
		for (int j = i+1; j < N; j++) {
			if (s[i] == s[j]) {
				flag = false;
			}
		}
	}
	if (flag == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int int_cmp(const void *a, const void *b)
{
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib;

}

int main (void) {
int n;
scanf("%d",&n);
int array[n];
for (int i=0;i<n;i++){
    scanf("%d",&array[i]);
}
qsort(array,n,sizeof(array[0]),int_cmp);
for (int j=0;j<n-1;j++){
   if (array[j]==array[j+1]) {printf("NO");
                             return 0;}
  }
printf("YES");

return EXIT_SUCCESS;
}




Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
char a[2][55];

int main()
{
	int n;	
	for(int i=1;i<=52;i++)
	{
		a[1][i]=a[2][i]='!';
	}
	cin>>n;
	cin>>a[1]>>a[2];
	long long ans=0;
	int k=1;
	int f;
	if(a[1][0]==a[1][1])
	{
		ans=6;
		k=2;
		f=0;
	}
	else
	{
		ans=3;
		k=1;
		f=1;
	}
		while(k<n)
		{
			if(f==1)
			{
				ans*=2;
				ans%=MOD;
				if(a[1][k]==a[1][k+1])
				{
					k+=2;
					f=0;
				}
				else
				{
					k+=1;
					f=1;
				}
			}
			else
			{
				if(a[1][k]!=a[1][k+1])
				{
					k+=1;
					f=1;
				}
				else
				{
					ans*=3;
					ans%=MOD;
					k+=2;
					f=0;
				}
			}
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n;
    cin>>n;
    int x=n;
    int a=0;
    string s=to_string(n);
    rep(i,s.size()) {
        a+=n%10;
        n/=10;
    }
    if(x%a==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
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 ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n,m ;
	cin >> n >> m ;
	ll k ; cin >> k ;
	vll a(n+1),b(m+1) ;
	for(int i=0;i<n;i++) cin >> a.at(i+1) ;
	for(int i=0;i<m;i++) cin >> b.at(i+1) ;
	for(int i=1;i<=n;i++) a.at(i) += a.at(i-1) ;
	for(int i=1;i<=m;i++) b.at(i) += b.at(i-1) ;
	ll ans = 0 ;
	for(int i=0;i<=n;i++){
		ll sum = a.at(i) ;
		if(sum>k){
			break ;
		}
		ll l,r,mid ;
		l = 0 ;
		r = m+1 ;
		while(l+1<r){
			mid = (l+r)/2 ;
			if(sum+b.at(mid)<=k) l = mid ;
			else r = mid ;
		}
		chmax(ans,i+l) ;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 6392
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int N;
long long int K;
int P[5050];
long long int C[5050];
int used[5050];

int main(void) {

	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> P[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> C[i];
	}

	long long int ans = -100000000000;

	for (int k = 1; k <= N; k++) {
		long long int sum = 0;
		long long int tmp = 0;
		int cnt = 0;
		for (int i = 1; i <= N; i++) { used[i] = 0; }
		int I = k;

		/*for (long long int i = 1; i <= K; i++) {
			I = P[I];
			tmp += C[I];
			ans = max(ans, tmp);
		}*/
		//cout << "I= " << k << " ans= " << ans << endl;
	
		if (K <= N) {
			for (int j = 1; j <= K; j++) {
				I = P[I];
				tmp += C[I];
				ans = max(ans, tmp);
			}
		}
		else {
			used[I] = 1;
			long long int tmp_K = K;
			while (1) {
				I = P[I]; sum += C[I]; tmp += C[I]; cnt++;  ans = max(ans, tmp); tmp_K--;
				if (used[I] == 1) { break; }
				used[I] = 1;
			}

			tmp = 0;
			for (int i = 1; i <= N; i++) { used[i] = 0; }
			used[I] = 1;
			tmp_K = K;
			while (1) {
				I = P[I];  tmp += C[I]; tmp_K--;  
				long long int num = tmp_K / cnt; 
				//cout << "tmp= " << tmp <<" num= " <<num<< endl;
				ans = max(ans, tmp+num*sum);

				if (used[I] == 1) { break; }
				used[I] = 1;
			}


		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, a * n) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j,h,w;
	scanf("%d %d",&h,&w);
	while((h != 0) || (w != 0)){
		for(i=0;i<h;i++){
			if((i % 2) == 0){
				for(j=0;j<w;j++){
					if((j % 2) == 0){
						printf("#");
					} else {	
						printf(".");
					}					
				}
				printf("\n");
			} else {
				for(j=0;j<w;j++){
					if((j % 2) == 0){
						printf(".");
					} else {	
						printf("#");
					}					
				}
				printf("\n");
			}
		}
		printf("\n");
		scanf("%d %d",&h,&w);
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxx=1010;
const int infinity=1<<30;
int A[maxx][maxx],d[maxx];
bool flag[maxx];
int n,a,b,c;
	
int main (){
	cin>>n;
	for(int i=0;i<n;i++){
		flag[i]=false;
		d[i]=infinity;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			A[i][j]=infinity;
		}
	}
	for(int i=0;i<n;i++){
		cin>>a>>b;
		for(int j=0;j<b;j++){
			cin>>c;
			cin>>A[a][c];
		}
	}
	d[0]=0;
	while(1){
		int minv=infinity,minj=-1;
		for(int i=0;i<n;i++){
			if(flag[i]==false && d[i]<minv){
				minv=d[i];
				minj=i;
			}
		}
		if(minv==infinity) break;
		flag[minj]=true;
		for(int i =0;i<n;i++){
			if(A[minj][i]!=infinity && flag[i]==false && d[i]>=d[minj]+A[minj][i]){
					d[i]=d[minj]+A[minj][i];
			}
		}
	}
	for(int i=0;i<n;i++) cout<<i<<" "<<(d[i]==infinity ? -1 : d[i])<<endl;
	
	return 0;

}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define clean(used) memset(used,false,sizeof(used))
using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

int a[200005];

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,sum = 0,t = 0;
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
        sum += a[i];
    }
    int ans = INF;
    rep(i,0,N-1){
        t +=a[i];
        ans = min(ans,abs((sum - t) -t));
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int loop = 0;
  cin >> loop;
  
  vector<int> buttons(loop);    
  for(int i = 0; i < loop; i++){
    cin >> buttons.at(i);       
    buttons.at(i);
  }   
  
  int next = 0;
  for(int i = 0; i < buttons.size(); i++){    
    if(buttons.at(next) == 2){
      cout << i + 1 << endl;
      return 0;
    }
    next = buttons.at(next) -1;
  }
  
  cout << -1 << endl;
}

Measured memory_bytes: 768
H,W = map(int, input().split())

# 答えの出力

def is_odd(num):
    return num % 2 ==1

if H == 1 or W == 1:
    ans = 1
elif is_odd(H) and is_odd(W):
    ans = ((H * W) + 1)/2
else:
    ans = (H*W) / 2

# 出力

print(int(ans))



Measured memory_bytes: 2940
//AtCoder Group Contest

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    vector<int>a(n*3);
    rep(i,0,n*3)cin>>a[i];
    sort(range(a),greater<int>());
    ll ans=0;
    rep(i,0,n)ans+=a[i*2+1];
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
a,b = map(int,input().split())

if a * b * 1 % 2 == 1:
    print("Yes")
elif a * b * 2 % 2 == 1:
    print("Yes")
elif a * b * 3 % 2 == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int c[5][5], sum = 0;
    for(int i = 1; i <= 3; i++)
    {
        for(int j = 1; j <= 3; j++)
        {
            scanf("%d", &c[i][j]);
            sum += c[i][j];
        }
    }
    int d;
    d = c[2][1] + c[3][1] + c[1][2] + c[1][3];
    if(3 * d == sum + 3 * c[1][1])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <utility>
#include <functional>

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

using ll = long long;
using P = std::pair<int, int>;
using namespace std;

constexpr int INF = 1000000000; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18
constexpr int MAX_N = 201;

// d[i][j]はi->jの最小コスト
int d[MAX_N][MAX_N];
// S->すでに訪れた点の集合, v->現在位置, dp[S][v]: 左の状況での最小コスト
int dp[256][8];
int N, M, R;
vector<int> r;

// dpテーブルを埋める
void solve() {
	for (int s = (1 << R) - 2; s >= 0; --s) {
		REP(v, R) {
			REP(u, R) {
				if (!((s >> u) & 1)) {
					dp[s][v] = min(dp[s][v], dp[s | 1 << u][u] + d[r[v]][r[u]]);
				}
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	// 初期化
	cin >> N >> M >> R;
	r = vector<int>(R);
	REP(i, R) cin >> r[i];
	for (int i = 1; i <= N; ++i) {
		fill(d[i] + 1, d[i] + N + 1, INF);
		d[i][i] = 0;
	}
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
	for (int S = 0; S < (1 << R); ++S) {
		fill(dp[S], dp[S] + R, INF);
	}

	// WF法

	for (int k = 1; k < N + 1; ++k) {
		for (int i = 1; i < N + 1; ++i) {
			for (int j = 1; j < N + 1; ++j) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	// ビットDP

	REP(i, R) dp[(1 << R) - 1][i] = 0; // 全て通った後のコストを0にする

	solve();

	int m = INF;
	REP(i, R) {
		m = min(m, dp[1 << i][i]);
	}

	cout << m << "\n";

	return 0;
}


Measured memory_bytes: 1016
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var ab = lines[0].split(' ');
 var a = Number(ab[0]);
 var b = Number(ab[1]);
 var count = 0;
 
 var s = lines[1].split('');
 if(s[a] !== '-'){
   count++;
 }

 if(s.length !== a+b+1){
   count++;
 }

 for(i=0; i<a; i++){
   s[i] = Number(s[i]);
 
   if(s[i] == 0 || s[i] == 1 || s[i] == 2 || 
      s[i] == 5 || s[i] == 4 || s[i] == 3 ||
      s[i] == 6 || s[i] == 7 || s[i] == 8 || s[i] == 9)
    {}else{
      count++;
    }
 }

 for(i=a+1; i<a+b+1; i++){
   s[i] = Number(s[i]);
   
   if(s[i] == 0 || s[i] == 1 || s[i] == 2 || 
      s[i] == 5 || s[i] == 4 || s[i] == 3 ||
      s[i] == 6 || s[i] == 7 || s[i] == 8 || s[i] == 9)
    {}else{
      count++;
    }
 }

 if(count == 0){
   console.log('Yes');
 }else{
   console.log('No');
 }
});

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

const int N=3003;
int dp[N][N];
string s,t;

int lcs(int n,int m)
{
  if(n<1 or m<1)
    return 0;
  if(dp[n][m]!=-1)
    return dp[n][m];

  if(s[n]==t[m])
  {
    return dp[n][m]=1+lcs(n-1,m-1);
  }
  else
    return dp[n][m]=max(lcs(n-1,m),lcs(n,m-1));
}
int32_t main()
{
 
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  s='!'+s;  
  t='!'+t;

  memset(dp,-1,sizeof(dp));

  int maxlen=lcs(n,m);
 
  int i=n, j=m; 
  string lcsubseq="";
  while (i > 0 && j > 0) 
  { 
    if(s[i]==t[j]) 
    { 
        lcsubseq+=s[i];
        i--; j--; 
    } 
    else if(dp[i-1][j]>dp[i][j-1]) 
       i--; 
    else
       j--; 
  }
   reverse(lcsubseq.begin(), lcsubseq.end());
   cout<<lcsubseq;
  return 0;  
}   

Measured memory_bytes: 35712
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		int[][] f = new int[N][2];
		
		for(int i=0; i<N; i++){
			f[i][0] = sc.nextInt();
			f[i][1] = sc.nextInt();
		}
		Arrays.sort(f, new Comparator<int[]>(){
			public int compare(int[] a, int[] b) {
			    if(a[0] > b[0]) {
			      return 1;
			    }else if (a[0] == b[0]) {
			      return 0;
			    }else {
			      return -1;
			  }}
		});
		
		long sum = 0;
		int ans = 0;
		int p = 0;
		while( sum<K ){
			ans = f[p][0];
			sum += f[p][1];
			p++;
		}
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 89596
#define I[i][j]
#define $;for(i=j=0;i<n;i+=++j/n,j%=n)
#define _(a)$ for(b I=l=0;l<n;)b I+=a[i][l]*p[l++][j]%m $ a I=b I%m;}
long m=1e9+7,p[50][50],a[50][50],b[50][50],k;i,j,l;main(n){scanf("%d%ld",&n,&k)$ a[i][i]=scanf("%d",p[i]+j);for(;k;k/=2){if(k&1){_(a)_(p)$ k+=a I;printf("%d",k%m);}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a1 = parseInt(sc.next());
		int a2 = parseInt(sc.next());
		int a3 = parseInt(sc.next());
		sc.close();
		out.println(a1+a2+a3>=22?"bust":"win");
	}
}


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

int main(){
    string s;
    cin >> s;
    int max=0,count=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')count++;
        else {
            if(max<count)max = count;
            count = 0;
        }
    }
    if(max<count)max = count;
    cout << max << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main(){
    /* code */ 
    int N; 
    cin >> N;
    int n = N%10;
    if (n == 2 || n==4 | n==5 | n == 7 | n==9){
        cout << "hon" << endl;
    }else if (n == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
    return 0;
}

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

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

    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) { // Alice のターン
            Alice += a[i];
        }
        else { // Bob のターン
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

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

using namespace std;

int main()
{
    int N,T;
    cin >> N >> T;
    vector<int> c(N);
    vector<int> t(N);
    for (int i = 0;i < N;i++) {
        cin >> c[i];
        cin >> t[i];
    }
    int co = 1000000;
    for (int i = 0;i < N;i++) {
        if(t[i] <= T){
            if(c[i] <= co){
                co = c[i];
            }

    }
    }
        if(co == 1000000){
            cout<<"TLE"<<endl;
        }else {
            cout<<co<<endl;
        }

    return 0;
}


Measured memory_bytes: 256