akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') P(a + b);
  else P(a - b);

  return 0;
}

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

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

using namespace std;


int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];

    vector<ll> over(n-1);
    rep(i, n-1)   over[i] = a[i]+a[i+1] - x;

    ll res = 0;
    rep(i, n-1){
        if(0 < over[i]){
            if(i < n-1 && 0 < over[i+1]){
                if(over[i] <= a[i+1]){
                    over[i+1] -= over[i];
                    res += over[i];
                    over[i] = 0;
                }
                else{
                    over[i+1] -= a[i+1];
                    res += over[i];
                    over[i] = 0;
                }
            }
            else{
                res += over[i];
                over[i] = 0;
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
#define _(i,a,n) for(int i=a;i<n;i++)
#define zero(a) a[0]=0
int read()
{
    int x=0,flag=1;
    char c=getchar();
    while((c>'9' || c<'0') && c!='-')
        c=getchar();
    if(c=='-')
        flag=0,c=getchar();
    while(c<='9' && c>='0')
    {
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return flag?x:-x;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll p[5001],c[5001];
    _(i,0,n)
    cin>>p[i];
    _(i,0,n)
    cin>>c[i];
    ll ans=-MOD;
    _(i,0,n)
    {
        ll s=c[i];
        vector<ll>t;
        t.push_back(s);
     
        for(int j=p[i]; j!=i+1; j=p[j-1])
        {
            //cout<<j<<" "<<i<<endl;
            s+=c[j-1];
            t.push_back(s);

        }
        int len=t.size();
        _(j,0,len)
        {
            int res=k-j-1;
            if(res<0)
                break;
            ans=max(ans,t[j]+(res/len)*max(s,0LL));
            //cout<<t[j]+(res/len)*max(s,0LL)<<endl;
        }
    }
    cout<<ans<<endl;
}


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

bool f(string s){
	string t = s;
	reverse(t.begin(), t.end());

	return t == s;
}

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

	bool ans = true;
	if(!f(s)) ans = false;
	if(!f(s.substr(0, s.size()/2))) ans = false;

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

tasks = []

for i in range(n):
    tasks.append(list(map(int, input().split())))

dp = [[0 for i in range(3)] for j in range(n)]
dp[0] = tasks[0]

for i in range(1,n):
    for j in range(3):
        temp = []
        for k in range(3):
            if j != k:
                temp.append(dp[i-1][k] + tasks[i][j])
        dp[i][j] = max(temp)

print(max(dp[n-1]))



Measured memory_bytes: 47364
#include<iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int P[200010];
  int i;
  for(i=0;i<N;i++)cin >> P[i];
  int ans=0,mi=P[0];
  for(i=0;i<N;i++) {
    if(mi >= P[i]) {
      ans++;
      mi = P[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

# 尺取法
l = r = ans = 0
sm = xor = 0
# 外ループで左を動かす
while l < N:
    # 内ループは条件を満たす限り右を動かす
    while r < N and sm + A[r] == xor ^ A[r]:
        sm += A[r]
        xor ^= A[r]
        r += 1
    # 和とXORが一致する区間の分、合計に足す
    ans += r - l
    if l == r:
        # 左が右に追いついたら、右も左に合わせて+1する
        r += 1
    else:
        # 左を動かす分、合計から引く
        sm -= A[l]
        xor ^= A[l]
    l += 1
print(ans)


Measured memory_bytes: 24836
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    s,t=input().split()
    for i in range(n):
        u=s[i]+t[i]
        print(u,end='')
    # このままだと最後の改行がないから最後の改行をさせるために
    # print関数はデフォルトで改行になってるから()の中はいらない
    print()
resolve()


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << -1 << '\n';
		return 0;
	}
	cout << a * b << '\n';
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;
int main() {
ll N, M;cin >> N;
vector<ll> V(5);

rep(i, 0, 5)cin >> V[i];

M = *min_element(ALL(V));

if(N%M == 0)cout << N / *min_element(ALL(V)) + 4;

else cout << N / *min_element(ALL(V)) + 5;

} 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x;
  rep(i, 5) {
    cin >> x;
    if (x == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}

/*
*/


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

using namespace std;

struct Interval {
    int start, score;
};

class SegmentTree {
  public:
    SegmentTree(int size):
        m_size(size),
        m_add(size * 2, 0),
        m_max(size * 2, 0) {}

    void add(int from, int to, int64_t value) {
        for (int l = from + m_size, r = to + m_size; l < r; l /= 2, r /= 2) {
            if (l & 1) {
                m_max[l] += value;
                m_add[l++] += value;
            }
            if (r & 1) {
                m_add[--r] += value;
                m_max[r] += value;
            }
        }
        build(from + m_size);
        build(to + m_size - 1);
    }

    int64_t query() const {
        return m_max[1];
    }

  private:
    void build(int position) {
        while (position > 1) {
            position /= 2;
            m_max[position] = max(m_max[position * 2], m_max[position * 2 + 1]) + m_add[position];
        }
    }

    int m_size;
    vector<int64_t> m_add, m_max;
};

int main() {
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;

    vector< vector<Interval> > intervals(N);
    for (int i = 0; i < M; ++i) {
        int L, R, W; cin >> L >> R >> W;
        --L; --R;
        intervals[R].emplace_back(Interval{L, W});
    }

    vector<int64_t> dp(N, 0);
    SegmentTree S(N);
    for (int i = 0; i < N; ++i) {
        dp[i] = S.query();

        S.add(i, i + 1, dp[i]);
        for (auto &interval : intervals[i])
            S.add(interval.start, i + 1, interval.score);
    }

    cout << max(S.query(), int64_t(0)) << "\n";
}


Measured memory_bytes: 19072
#include<bits/stdc++.h>
#define mod 998244353
#define M 200007
using namespace std;
struct mo{
	int x,y;
}a[M];
int n,X[M],Y[M],c[M];
long long ans,pre[M]={1};
bool Mo(mo x,mo y){
	return x.y<y.y;
}
void add(int x){
	while(x<M)c[x]++,x+=x&-x;
}
int query(int x){
	int res=0;
	while(x)res+=c[x],x-=x&-x;
	return res;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]*2%mod;
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y),X[i]=a[i].x,Y[i]=a[i].y;
	sort(X+1,X+n+1),sort(Y+1,Y+n+1);
	for(int i=1;i<=n;i++){
		a[i].x=lower_bound(X+1,X+n+1,a[i].x)-X;
		a[i].y=lower_bound(Y+1,Y+n+1,a[i].y)-Y;	
	}
	ans=n*(pre[n]-1)%mod;
	for(int i=1;i<=n;i++){
		ans=(ans-pre[i]+2+mod)%mod;
		ans=(ans-pre[n-i+1]+2+mod)%mod;
	}
	sort(a+1,a+n+1,Mo);
	for(int i=1;i<=n;i++){
		int p=query(a[i].x);
		ans=(ans+pre[p]-1)%mod;
		ans=(ans+pre[i-p-1]-1)%mod;
		add(a[i].x);
	}
	memset(c,0,sizeof c);
	for(int i=n;i>=1;i--){
		int p=query(a[i].x);
		ans=(ans+pre[p]-1)%mod;
		ans=(ans+pre[n-i-p]-1)%mod;
		add(a[i].x);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5760
import java.io.*;

class Main
{
    public static void main(String[] args) throws IOException
    {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String  str = br.readLine();

	String[] ar = str.split("");

	int[] num_ar = new int[3];
	for(int i=0; i<3; i++)
	    num_ar[i] = Integer.parseInt(ar[i]);

	if(num_ar[0]<num_ar[1])
	    System.out.println(100*(num_ar[0]+1)+10*(num_ar[0]+1)+num_ar[0]+1);
	else if(num_ar[0]==num_ar[1]){
	    if(num_ar[1]<num_ar[2])
		System.out.println(100*(num_ar[0]+1)+10*(num_ar[0]+1)+num_ar[0]+1);
	    else if(num_ar[1]==num_ar[2])
		System.out.println(100*(num_ar[0])+10*(num_ar[0])+num_ar[0]);
	    else
		System.out.println(100*(num_ar[0])+10*(num_ar[0])+num_ar[0]);
	}
	else
	    System.out.println(100*(num_ar[0])+10*(num_ar[0])+num_ar[0]);
	
    }
}

Measured memory_bytes: 22484
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int n, m, k, s, p, q;
vector<int> v[100001];
int da[100001];
typedef pair<long long int, int> P;
long long int di[100001];
long long int INF = 1e17;

void bfs(){
	queue<P> q;
	q.push(P(0, -1));
	da[0] = -1;
	while(!q.empty()){
		P p = q.front(); q.pop();
		for(int i=0; i<v[p.first].size(); ++i){
			if(p.second+1 < da[v[p.first][i]]){
				da[v[p.first][i]] = p.second+1;
				if(p.second+1 < s) q.push(P(v[p.first][i], p.second+1));
			}
		}
	}
}

int d(int x){
	if(da[x] == 0) return INF;
	else if(da[x] <= s) return q;
	else return p;
}

void dijkstra(){
	fill(di, di+n+1, INF);
	di[1] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));

	while(!q.empty()){
		P p = q.top(); q.pop();
		long long int c = p.first;
		int ve = p.second;
		if(c > di[ve]) continue;
		for(int i=0; i<v[ve].size(); ++i){
			if(di[v[ve][i]] > di[ve] + d(v[ve][i])){
				di[v[ve][i]] = di[ve] + d(v[ve][i]);
				q.push(P(di[v[ve][i]], v[ve][i]));
			}
		}
	}
}

int main(){
	scanf("%d %d %d %d %d %d", &n, &m, &k, &s, &p, &q);
	fill(da, da+n+1, 100100100);
	for(int i=0; i<k; ++i){
		int t;
		scanf("%d", &t);
		v[0].push_back(t);
		v[t].push_back(0);
	}
	for(int i=0; i<m; ++i){
		int a, b;
		scanf("%d %d", &a, &b);
		v[a].push_back(b);
		v[b].push_back(a);
	}

	bfs();
/*
	for(int i=1; i<n+1; ++i){
		printf("%d\n", da[i]);
	}
*/
	dijkstra();
/*
	for(int i=0; i<n; ++i){
		printf("%lld\n", di[i+1]);
	}
*/
	printf("%lld\n", di[n] - d(n));
}

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

const int maxn = 111111;
int a[maxn], b[maxn], c[maxn], dp[maxn][4];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	for (int i = 2; i <= n; i++) {
		dp[i][1] = a[i] + max(dp[i - 1][2], dp[i - 1][3]);
		dp[i][2] = b[i] + max(dp[i - 1][1], dp[i - 1][3]);
		dp[i][3] = c[i] + max(dp[i - 1][1], dp[i - 1][2]);
	}
	cout << max({dp[n][1], dp[n][2], dp[n][3]}) << '\n';
	return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;


class Main {
	public static int n;
	public static int s;
	public static int c;

	public static void dfs(int k, int rest, int x){
		if(k == n){
			c += rest == 0 ? 1 : 0;
			return;
		}
		if(rest<0)return;
		for(int i=Math.min(x, 9); i >= 0; i--){
			dfs(k+1, rest-i, i-1);
		}
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			n = scan.nextInt();
			s = scan.nextInt();
			if(n == 0 && s == 0)break;
			c = 0;
			dfs(0, s, s);
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 26244
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
diff_po = []
diff_ne = []
if sum(a) < sum(b):
    print(-1)
else:
    ans = 0
    for i in range(n):
        if a[i] - b[i] < 0:
            diff_ne.append(a[i]-b[i])
        elif a[i] - b[i] > 0:
            diff_po.append(a[i]-b[i])
    diff_ne.sort(reverse = True)
    diff_po.sort()
    tmp_po = 0
    while len(diff_ne):
        tmp_ne = diff_ne.pop()
        ans += 1
        while tmp_ne < 0:
            if tmp_po <= 0:
                tmp_po = diff_po.pop()
                ans += 1
            #print(tmp_po,tmp_ne)
            if abs(tmp_po) > abs(tmp_ne):
                tmp_po += tmp_ne
                tmp_ne = 0
            else:
                tmp_ne += tmp_po
                tmp_po = 0
    print(ans)


Measured memory_bytes: 84272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

// a(n) = Sum_{k=1..n} k/2 * floor(n/k) * floor(1 + n/k). 

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */

   long int n;
   cin>>n;

   long int ans = 0;
   for(long int i = 1; i <= n; i++)
   		ans += (i * (n / i) * (1 + n / i)) / 2;

   	cout<<ans;
   

   return 0;
}

Measured memory_bytes: 3664
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=1
cnt=0
i=0
while i<n-1 and cnt<2:
    if a[i]==a[i+1]:
        ans*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
if cnt==2:
    print(ans)
else:
    print(0)

Measured memory_bytes: 14172
n = int(input(''))
xs = list(map(int, input('').split(' ')))
ys = list(map(int, input('').split(' ')))

c = 0
i = 0
while i < len(ys):
    c += min(xs[i], ys[i])
    ys[i] -= xs[i]
    if ys[i] > 0:
        c += min(xs[i + 1], ys[i])
        xs[i + 1] -= ys[i]
        if xs[i + 1] < 0:
            xs[i + 1] = 0
    i += 1

print(c)


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

ans = 0
while True:
    flag = True
    for i in range(n):
        if a[i] % 2 != 0:
            flag = False
        a[i] /= 2
    if not flag:
        break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  vector<int> idx(n);
  rep(i,n) idx[a[i]] = i;
  set<int> s;
  ll ans=0;
  for(int x=n-1; x>=0;x--){
    int i = idx[x];
    ll c=0;
    s.insert(i);
    vector<int> l(2,-1);
    vector<int>	r(2,n);

    auto it = s.find(i);
    rep(j,2){
      if(it==s.begin()) break;
      --it;
      l[j]=*it;
      //      cout << *it << endl;
    }
    auto it2 = s.find(i);
    rep(j,2){
      ++it2;
      if(it2==s.end())	break;
      //      ++it2;
      r[j]=*it2;
      //    cout << *it2 << endl;   
    }
    
    vector<int> ls(2);
    ls[0] = i-l[0];
    ls[1] = l[0]-l[1];
    vector<int> rs(2);
    rs[0]=r[0]-i;
    rs[1]=r[1]-r[0];
    //    cout << r[0]-i << " "<<r[1] << " " << r[0] << endl;
    //    cout << ls[0] <<" " << ls[1] <<" " << rs[0] <<" " << rs[1] << endl;
    c =(ll) ls[0]*rs[1] + (ll) ls[1]*rs[0];
    
    ans+=c*(x+1);
  }
  cout << ans << endl;

   
  return 0;
    

}


Measured memory_bytes: 6144
#include <iostream>
#include<vector>
#include<string>
#include<cmath>

using std::vector;
using std::string;
using std::cout;
using std::cin;
typedef long long ll;
/*void input(){
    
}*/
/*void output(){
    
}*/

int main() {
	int test=1;
	//cin>>test;
	while(test-->0)
	{   
	  long int n,x;
	  cin>>n;
	  x=sqrt(n);
	  cout<<x*x;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

struct Edge{
    int to;
    int cost;
};

vector<vector<Edge> > G;
int dis[100005];
int ans[100005];
int V,E;

void dijkstra(int r){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(dis,dis+V,INF);
    dis[r] = 0;
    que.push(P(0,r));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;

        // 最短距離候補が2つ以上queに入る時があって、その時dis[v]は本当の最短距離を表すが、p.firstはそれより大きいことがある
        if (dis[v] < p.first) {
            continue;
        }

        for(auto e : G[v]){
            if(dis[e.to] > dis[v]+e.cost){
                dis[e.to] = dis[v] + e.cost;
                ans[e.to] = v;
                que.push(P(dis[e.to],e.to));
            }
        }
    }
}

int main(){
    cin >> V >> E;
    G.resize(V);
    for(int i=0;i<E;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        struct Edge x1 = { b,1 };
        struct Edge x2 = { a,1 };
        G[a].push_back(x1);
        G[b].push_back(x2);
    }

    dijkstra(0);
    cout << "Yes" << endl;
    for(int i=1;i<V;i++){
        cout << ans[i]+1 << endl;
    }
}




Measured memory_bytes: 14012
while True:
	try:
		point = map(float,raw_input().split())
		z1 = (point[4] - point[2]) * (point[7] - point[3]) - (point[5] - point[3]) * (point[6] - point[2])
		z2 = (point[0] - point[4]) * (point[7] - point[5]) - (point[1] - point[5]) * (point[6] - point[4])
		z3 = (point[2] - point[0]) * (point[7] - point[1]) - (point[3] - point[1]) * (point[6] - point[0])
		
		if z1 > 0 and z2 > 0 and z3 > 0 or z1 < 0 and z2 < 0 and z3 < 0:
			print "YES"
		else:
			print "NO"
			
	except EOFError:
		break

Measured memory_bytes: 6300
from collections import deque
from itertools import product

H, W =map(int,input().split())
C=tuple(map(lambda x: int(x)-1,input().split()))
D=tuple(map(lambda x: int(x)-1,input().split()))
S=[input().strip("¥n") for i in range(H)]

mag=(-2, -1, 0, 1, 2)

dist=[[-1]*W for i in range(H)]

qu=deque([(C[0], C[1])])
dist[C[0]][C[1]]=0

while(len(qu)>0):
  qut=deque()
  while(len(qu)>0):
    v=qu.popleft()
    qut.append(v)
    for h,w in ((-1,0),(1,0),(0,-1),(0,1)):
      nvh=v[0]+h
      nvw=v[1]+w
      if 0<=nvh<H and 0<=nvw<W and dist[nvh][nvw]==-1 and S[nvh][nvw]==".":
        dist[nvh][nvw]=dist[v[0]][v[1]]
        qu.append((nvh,nvw))
  while(len(qut)>0):
    v=qut.popleft()
    for h,w in product(mag,repeat=2):
      if h==0 and w==0:
        continue
      nvh=v[0]+h
      nvw=v[1]+w
      if 0<=nvh<H and 0<=nvw<W and S[nvh][nvw]==".":
        if dist[nvh][nvw]==-1:
          dist[nvh][nvw]=dist[v[0]][v[1]]+1
          qu.append((nvh,nvw))
print(dist[D[0]][D[1]])

Measured memory_bytes: 88352
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class DirectedGraph {
public:
    int V;
    vector<vector<int>> costs;

    DirectedGraph(int v) : V(v), costs(v, vector<int>(v, INF)) {
        for (int i = 0LL; i < V; i++) {
            costs[i][i] = 0LL;
        }
    }

    void add_edge(int u, int v, int cost) {
        costs[u][v] = cost;
    }

    void warshall_floyd() {
        for (int k = 0LL; k < V; k++) {
            for (int i = 0LL; i < V; i++) {
                for (int j = 0LL; j < V; j++) {
                    costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
                }
            }
        }
    }
};

signed main() {
    int N, M, R;
    cin >> N >> M >> R;

    int r[R];
    for (int i = 0LL; i < R; i++) cin >> r[i];
    sort(r, r + R);

    DirectedGraph g = DirectedGraph(N);
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }
    g.warshall_floyd();

    int ret = INF;

    do {
        int dis = 0LL;
        for (int i = 0; i < R - 1; i++) {
            dis += g.costs[r[i] - 1LL][r[i+1LL] - 1LL];
        }

        ret = min(ret, dis);
    } while (next_permutation(r, r + R));

    cout << ret << endl;

    return 0;
}

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

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

    int c1=0,c2=0;

   while(X-500 >= 0){
       X = X-500;
       c1++;
   }

   while(X-5 >= 0){
       X = X-5;
       c2++;
   }

   cout << c1*1000+c2*5 << endl;


}

Measured memory_bytes: 256
import itertools

N,M,Q=[int(i) for i in input().split(" ")]

abcd=[]

for i in range(Q):
    abcd.append([int(j) for j in input().split(" ")])




def score(A):
    retval=0
    for i in range(Q):
        a,b,c,d=abcd[i]
        if A[b-1]-A[a-1]==c:
            retval+=d
    return retval

retval=0
for iter in itertools.combinations_with_replacement([i for i in range(1,M+1)],N):
    retval=max(score(sorted(iter)),retval)

print(retval)


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

int main(){
	
    int a,b,c;
    bool ok = false;

    
	cin >> a>>b>>c;

    if(a==b){ 
        ok = true;
    }
    if(a==c){
        ok = true;
    }
    if(b==c){
        ok = true;
    }
    if(a==b &&b ==c){
    ok = false;

    }
    
    if(ok){
    cout <<"Yes" <<endl;
    }else{
    cout <<"No" <<endl;
        
    }
}
		




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * メインクラス
 *
 */
public class Main {

	/**
	 * メインメソッド
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		// ============================================================
		// 標準入力を変数に設定
		// ============================================================

		// 標準入力を取得
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();

		long N = Long.parseLong(line.split(" ")[0]);

		line = br.readLine();
		String[] str = line.split(" ");
		long[] hana = new long[str.length];

		for (int i = 0; i < str.length; i++) {
			hana[i] = Long.parseLong(str[i]);
		}
		long answer = 0;
		while (true) {

			boolean b = false;
			int start = 0;
			int end = 0;
			for (int i = 0; i < hana.length; i++) {

				if (hana[i] > 0 && !b) {
					b = true;
					start = i;
				}

				if (b && (hana[i] == 0 && end == 0) || i == hana.length - 1) {

					if (i == hana.length - 1 && hana[i] != 0) {
						end = i;
					} else {
						end = i - 1;
					}

					long min = 0;
					for (int j = start; j <= end; j++) {
						if (min == 0 || min > hana[j]) {
							min = hana[j];
						}

					}
					for (int j = start; j <= end; j++) {
						hana[j] = hana[j] - min;
					}
					b = false;
					start = 0;
					end = 0;
					answer += min;
				}
			}

			boolean has = false;
			for (int i = 0; i < hana.length; i++) {
				if (hana[i] > 0) {
					has = true;
					break;
				}
			}

			if (!has) {
				System.out.println(answer);
				return;
			}
		}

	}
}

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

const int S = 10010;
int uf[S];

int find(int a) {
    if(a == uf[a]) return a;
    return find(uf[a]);
}

void unite(int a, int b) {
    int fa = find(a);
    int fb = find(b);
    if(fa == fb) return;
    if(fa < fb) uf[fb] = uf[fa];
    else uf[fa] = uf[fb];
}

int main() {
    rep(i,0,S) uf[i] = i;
    int n, q; cin >> n >> q;
    rep(i,0,q) {
        int c, x, y; cin >> c >> x >> y;
        if(c == 0) unite(x, y);
        else if(c == 1) cout << (find(x) == find(y)) << endl;
    }
    return 0;
}

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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int MAXN = 1050;

int n;
int a[MAXN];
long long sumOdd, sumEven;
int mxOdd, mxEven;

int main() {

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

    mxEven = a[0]; mxOdd = a[1];
    for (int i = 0; i < n; i++) {
        if (i & 1) {
            mxOdd = max(mxOdd, a[i]);
            if (a[i] >= 0) {
                sumOdd += a[i];
            }
        } else {
            mxEven = max(mxEven, a[i]);
            if (a[i] >= 0) {
                sumEven += a[i];
            }
        }
    }

    long long ansOdd = mxOdd;
    if (mxOdd >= 0) ansOdd = sumOdd;
    long long ansEven = mxEven;
    if (mxEven >= 0) ansEven = sumEven;

    vector<int> taken;
    if (ansOdd > ansEven) {
        for (int i = 1; i < n; i += 2) {
            if ((mxOdd >= 0 && a[i] >= 0) || (mxOdd < 0 && a[i] == mxOdd)) {
                taken.push_back(i);
            }
        }
    } else {
        for (int i = 0; i < n; i += 2) {
            if ((mxEven >= 0 && a[i] >= 0) || (mxEven < 0 && a[i] == mxEven)) {
                taken.push_back(i);
            }
        }
    }

    vector<int> ops;

    int last = taken.back();
    for (int i = n - 1; i >= last + 1; i--) {
        ops.push_back(i);
    }

    int removed = 0;
    for (int i = 0; i < taken[0]; i++) {
        ops.push_back(0);
        removed++;
    }

    for (int i = 0; i + 1 < sz(taken); i++) {
        for (int j = taken[i] + 2; j < taken[i + 1]; j += 2) {
            ops.push_back(taken[i] + 2 - removed);
        }
        ops.push_back(taken[i] + 1 - removed);
        removed += taken[i + 1] - taken[i];
    }

    cout << max(ansOdd, ansEven) << endl;
    cout << sz(ops) << endl;
    for (auto op : ops)
        printf("%d\n", op + 1);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  cin >> N;
    
  if ((N - N % 10) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl; 
  }  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

using namespace std;

inline bool isAGCT(char c) {
	if (c == 'A' || c == 'T' || c == 'C' || c == 'G') return true;
	return false;
}

int main() {
	char input[11];
	scanf("%s", input);
	int len = strlen(input);

	int max_length = 0;
	for (int ii = 0; ii < len; ii++) {
		if (len < max_length) break;
		int length = 0;
		for (int jj = ii; jj < len; jj++) {
			if (!isAGCT(input[jj])) {
				break;
			}
			length++;
		}
		max_length = max_length < length ? length : max_length;
	}

	printf("%d", max_length);

	return 0;
}

Measured memory_bytes: 128
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


x,a,b = list(map(int, input().split()))
if x<-a+b:
    ans = "dangerous"
elif a>=b:
    ans = "delicious"
else:
    ans = "safe"
print(ans)

Measured memory_bytes: 61784
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n;
  ll a,b;
  cin >> n >> a >> b;
  vector<ll> x(n); rep(i, n) cin >> x[i];

  ll ans = 0;
  rep(i, n-1){
    ans += min(a*(x[i+1]-x[i]), b);
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n,b,a,x,y;
  cin>>n>>a>>b;
  x = n / (a + b);
  y = min(a,n%(a+b));
  cout<< x * a + y<<"\n";
  return(0);
}

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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  string str;
  cin >> str;
  string ss;
  stack<char> s;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] != 'x') {
      ss += str[i];
    }
  }
  string rss = ss;
  reverse(rss.begin(), rss.end());
  if (ss != rss) {
    cout << "-1\n";
    return;
  }
  int ans = 0;
  for (int i = 0; i * 2 < str.size(); i++) {
    if (str[i] != str[str.size() - i - 1]) {
      if (str[i] == 'x') str += 'x';
      else { str = 'x' + str; }
      ans++;
    }
  }
  cout << ans << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        int x,l;
        cin >> x >> l;
        a[i] = {x+l, x-l};
    }
    sort(a.begin(), a.end());
    int cnt = 1;
    int r = a[0].first;
    for (int i = 1; i < n; i++) {
        if (a[i].second < r) continue;
        cnt++;
        r = a[i].first;
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 1024
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    X = parseInt(readline())
    for a in -200:200
        for b in -200:200
            if a ^ 5 - b ^ 5 == X
                return "$a $b"
            end
        end
    end
end


println(main())

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

int main() {
  int x,ans = 1;
  cin >> x;
  for(int i = 2;i <= x;i++){
    int a = i;
    while(a*i <= x){
      a *= i;
      if(a > ans){
        ans = a;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

int f(int a, int b, int c, int d, string s) {
	vector<string> st;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a') s[i] = (char)('0' + a);
		if (s[i] == 'b') s[i] = (char)('0' + b);
		if (s[i] == 'c') s[i] = (char)('0' + c);
		if (s[i] == 'd') s[i] = (char)('0' + d);
	}
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ']') {
			vector<string> t(3);
			int cur = 0;
			while (st.back() != "[") {
				t[cur] = st.back();
				st.pop_back();
				cur++;
			}
			st.pop_back();
			int res = 0;
			if (t[2] == "+") {
				res = stoi(t[0]) | stoi(t[1]);
			}
			if (t[2] == "*") {
				res = stoi(t[0]) & stoi(t[1]);
			}
			if (t[2] == "^") {
				res = stoi(t[0]) ^ stoi(t[1]);
			}
			st.emplace_back(to_string(res));
		}
		else {
			st.emplace_back(string(1, s[i]));
		}
	}
	return stoi(st[0]);
}

void solve() {
	string s; cin >> s; if (s == ".") exit(0);
	int p; cin >> p;
	map<int, int> mp;
	int res = 0;
	vector<int> cnt(20000);
	for (int a = 0; a < 10; a++) for (int b = 0; b < 10; b++) for (int c = 0; c < 10; c++) for (int d = 0; d < 10; d++) {
		int t = a * 1000 + b * 100 + c * 10 + d;
		if (p == t) res = f(a, b, c, d, s);
		cnt[f(a, b, c, d, s)]++;
	}
	cout << res << " " << cnt[res] << "\n";
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int kkt = 89; while (kkt) solve();
}



Measured memory_bytes: 3368
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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



















int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    REP(i, n){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

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

int main(){
	int a,b,c;
	char com;
	int t = 0;
	int h = 0;
	while(cin >> a >> com >> b >> com >> c){
		if(a*a+b*b==c*c) t++;
		else if(a==b) h++;
	}
	cout << t << endl;
cout << h << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x;
    cin >> x;

    ll ans = 2 * (x / 11);
    if (x % 11 != 0) {
        ans++;
        if (x % 11 > 6) {
            ans++;
        }
    }

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

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

int par[15];

int root(int x) {
  if(par[x] == x) {
    return x;
  } else {
    return par[x] = root(par[x]);
  }
}
void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;

  par[x] = y;
}
bool same(int x, int y) {
  return root(x) == root(y);
}

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


  for (int i = 0; i < 15; i++) {
    par[i] = i;
  }
  unite(1, 3);
  unite(1, 5);
  unite(1, 7);
  unite(1, 8);
  unite(1, 10);
  unite(1, 12);

  unite(4, 6);
  unite(4, 9);
  unite(4, 11);

  if (same(x, y)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[62][2][2], mod = 1e9 + 7;
long long n;
long long solve(int idx, int carry, int flag){
    long long &ans = dp[idx][carry][flag];
    if(ans != -1){
        return ans;
    }
    if(idx == 60){
        return ans = (carry == 0 && flag == 0);
    }
    int bit = (n >> idx) & 1;
    ans = 0;
    for(int a = 0; a <= 1; a++){
        for(int b = 0; b <= a; b++){
            int curbit = (a + b + carry) % 2;
            int curcarry = (a + b + carry) / 2;
            int curflag = flag;
            if(curbit > bit){
                curflag = 1;
            }
            if(curbit < bit){
                curflag = 0;
            }
            ans = (ans + solve(idx + 1, curcarry, curflag)) % mod;
        }
    }
    return ans;
}
int main(){
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0, 0);
    return 0;
}

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

int main(){
  int n,m;
  while(cin >> n >> m,n||m){
    vector<int> a(n,0);
    
    for(int i=0;i < n;i++){
      cin >> a[i];
    }
    int maxi=0;
    
    for(int i=0;i < n;i++){
      for(int j=i+1;j < n;j++){
	if(i != j){
	  if(a[i]+a[j] <= m) maxi = max(a[i]+a[j],maxi);
	}
      }
    }
    if(maxi) cout << maxi << endl;
    else cout << "NONE" << endl;
  }
  return 0;
}


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

int main() {
  int s;
  cin >> s;
  
  if(s == 25){
    cout << "Christmas" << endl;
  }
  else if (s == 24){
    cout << "Christmas Eve" << endl;
  }
  else if (s == 23){
    cout << "Christmas Eve Eve" << endl;
  }
  else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//using namespace atcoder;

int main(){
    ll N,K,C;
    string S;
    cin >> N >> K >> C;
    cin >> S;
    ll cnt = 0;
    vector<ll> v(N, -1);
    rep(i,N){
        if(cnt >= K){
            break;
        }
        if(S[i] == 'o'){
            //S[i] = 'a';
            cnt++;
            v[i] = cnt;
            i += C;
            continue;
        }
    }
    if(cnt < K){
        cout << endl;
        return 0;
    }
    //PR(v,N);
    cnt = K;
    vector<ll> ans;
    for(ll i=N-1;i>=0;i--){
        if(cnt <= 0){
            break;
        }
        if(S[i] == 'o'){
            if(v[i] > 0){
                //cout << i << endl;
                if(v[i] == cnt){
                    ans.push_back(i+1);
                }
            }
            //S[i] = 'x';
            i -= (C);
            cnt--;
            continue;
        }
    }
    if(cnt > 0){
        cout << endl;
        return 0;
    }
    sort(ans.begin(), ans.end());
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 6944
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

bool in_range(int x, int W){
    return x >= 0 && x < W;
}

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

int main(){
    int N;
    while(cin >> N && N){
        vector<int> l(N), t(N), r(N), b(N);
        set<int> s;
        REP(i, N){
            cin >> l[i] >> t[i] >> r[i] >> b[i];
            for(int d = -1; d <= 1; d++){
                s.insert(l[i] * 2 + d);
                s.insert(t[i] * 2 + d);
                s.insert(r[i] * 2 + d);
                s.insert(b[i] * 2 + d);
            }
        }
        map<int, int> index;
        for(int si : s){
            int t = index.size();
            index[si] = t;
        }
        bool used[50 * 15][50 * 15] = {};
        REP(i, N) {
            int lx = index[2 * l[i]], rx = index[2 * r[i]];
            int ly = index[2 * b[i]], ry = index[2 * t[i]];
            //printf("[%d, %d] x [%d, %d]\n", lx, rx, ly, ry);
            for(int y = ly; y <= ry; y++){
                used[y][lx] = used[y][rx] = true;
            }
            for(int x = lx; x <= rx; x++){
                used[ly][x] = used[ry][x] = true;
            }
        }
        /*
        REP(y, index.size()) {
            REP(x, index.size()) cout << used[y][x];
            cout << endl;
        }
        */
        int answer = 0;
        for(int sy = 0; sy < index.size(); sy++){
            for(int sx = 0; sx < index.size(); sx++){
                if(!used[sy][sx]){
                    answer++;
                    queue<int> qx, qy;
                    qx.push(sx); qy.push(sy);
                    used[sy][sx] = true;
                    while(!qx.empty()){
                        int x = qx.front(), y = qy.front();
                        qx.pop(); qy.pop();
                        REP(r, 4){
                            int nx = x + dx[r], ny = y + dy[r];
                            if(in_range(nx, index.size()) && in_range(ny, index.size()) && !used[ny][nx]){
                                used[ny][nx] = true;
                                qx.push(nx); qy.push(ny);
                            }
                        }
                    }
                }
            }
        }
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    ll h;
    cin >> h;
    ll ans=0;
    ll n=1;
    while(h>1){
        ans+=n;
        h/=2;
        n*=2;
    }
    cout << n+ans << endl;
    return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,x,y,now=0,whi=0,ai=0,bi=0;
vector <pair <LL,pii> > v;
LL ans[2];

bool cmp(pair <LL,pii> a,pair <LL,pii> b)
{
	return a.fi>b.fi;
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%I64d%I64d",&x,&y);
		v.pb({x+y,{x,y}});
	}
	sort(v.begin(),v.end(),cmp);
	rep(i,n)
	{
		if(i%2==0) ans[0]+=v[i].se.fi;
		else ans[1]+=v[i].se.se;
	}
	cout<<ans[0]-ans[1]<<endl;
	rt0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int a[N]; rep(i,N) cin >> a[i];
  sort(a, a+N, greater<int>());
  int result = 0;
  rep(i, N) result += a[i] * pow(-1,i);
  cout << result << endl;
  return 0;
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll ans=0;
    for(int bit=0; bit<(1<<n-1); ++bit){
        ll sum=0;
        rep(i,n){
            sum+=s[i]-'0';
            if(bit&(1<<i)){
                ans+=sum;
                sum=0;
            }
            else{
                if(i==n-1)ans+=sum;
                else sum*=10;
            }
        }

    }
    cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  if(N==1) {
    cout << "Hello World" << endl;
  }
  else if(N==2) {
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
a, b, k = [int(x) for x in input().split()]
al = set()
bl = set()
for i in range(1, a+1):
    if a%i == 0:
        al.add(i)
for i in range(1, b+1):
    if b%i == 0:
        bl.add(i)
kk = list(al & bl)
kk.sort(reverse=True)
print(kk[k-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;
    cin>>a;
    ll ans=a + a*a +a*a*a;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3636
from collections import Counter
from operator import itemgetter

n = int(input())
v = list(map(int, input().split()))
vodd = []
veven = []


for i in range(n):
    if i%2==0:veven.append(v[i])
    else: vodd.append(v[i])

lstodd = Counter(vodd)
lsteven = Counter(veven)

ans = []
for i, ii in zip(range(2), lstodd.most_common()):
    for j, jj in zip(range(2), lsteven.most_common()):
        if ii[0] == jj[0]:continue
        ans.append(len(vodd) - ii[1] + len(veven) - jj[1])
if ans == []:ans.append(n//2)

print(min(ans))


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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vchar vector<char>
#define vool vector<bool>
#define pb() pushback
#define elif else if
#define all(x) x.begin(),x.end()

main(){
    int N,b,count=0,count2=0,H,W;
    double r,pai=3.141592653589;
    int C='A'-'a';
    char op;
    str S,T;
      while(1){
        cin>>H>>W;
        if(H>0&&W>0){
          vector<vchar> sharp(H,vchar(W));
          rep(0,H){
            REP(0,W){
              if((i+1)%2==1){
                if((j+1)%2==1)cout<<'#';
                else cout<<'.';
              }
              else{
                if((j+1)%2==1)cout<<'.';
                else cout<<'#';
              }
            }
            cout<<endl;
          }
          cout<<endl;
        }
        else break;
      }
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define int long long 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define N 10000005
#define INF 10000000000000

using namespace std;

const int mod=1e9+7;



void need_for_speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


int32_t main(){
	need_for_speed();
    int a,b;
    cin>>a>>b;
    int y;
    if((b-2*a)>=0 and (b-2*a)%2==0 ){
        y=(b-2*a)/2;
        if(a-y>=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
    
    
    return 0;
}
        
	

		
    

        
        
    
 

Measured memory_bytes: 3648