akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> p(N),A(Q),j(N);
	for (int i = 0; i < Q; i++) {
		cin >> A[i];
		p[A[i] - 1]++;
	}
	for (int i = 0; i < N; i++) {
	
		if (K-(Q-p[i]) > 0) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

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

int main(){
	int list_data[10000], n;

	for (int i = 0; i < 10000; i++){
		cin >> n;
		list_data[i] = n;
		if (n == 0){
			break;
		}
	}

	for (int i = 0; i < 10000; i++){
		if (list_data[i] == 0){
			break;
		}
		cout << "Case " << i+1 << ": " << list_data[i] << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long LL;

LL check(LL l)
{
	return l % 1000000007;
}

int main()
{
	LL count = 1;
	int N;
	string s1, s2;
	vector<short> v;
	cin >> N;
	cin >> s1;
	cin >> s2;
	for (int i = 0; i < N; i ++)
	{
		if (s1[i] == s2[i])
		{
			v.push_back(0);
		}
		else
		{
			v.push_back(1);
			i++;
		}
	}
	
	for (int i = 0; i < v.size(); i++)
	{
		if (i == 0)
		{
			if (v[0] == 1)
			{
				count = 6;
			}
			else
			{
				count = 3;
				v[0] = 0;
			}
		}
		else
		{
			if (v[i] == 0)
			{
				if (v[i - 1] == 0)
				{
					count = check(count * 2);
				}
			}
			else
			{
				if (v[i - 1] == 0)
				{
					count = check(count * 2);
				}
				else
				{
					count = check(count * 3);
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

S = input()
T = input()
q = deque()
while len(S):
    indexes = [i for i, v in enumerate(S) if v == S[0]]
    q.append(indexes)
    S = S.replace(S[0], "")
while len(T):
    indexes = [i for i, v in enumerate(T) if v == T[0]]
    if q.popleft() != indexes:
        print("No")
        sys.exit()
    T = T.replace(T[0], "")
print("Yes")


Measured memory_bytes: 16268
#include <stdio.h>

int main(void) {

  long sum = 0;
  char c;
  while (1) {
    scanf("%c", &c);
    if (c >= '0' && c <= '9') {
      sum += c-'0';
    } else {
      break;
    }
  }
  if (sum%9 == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define ci(n, o) cin >> n >> o
#define co(n) cout << n << endl

int main() {
  int A, B;
  ci(A, B);
  co(max({A + B, A - B, A * B}));
}  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

//  最長共通部分列

int dp[1005][1005];

signed main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    string s1,s2;
    cin>>s1>>s2;
    s1=" "+s1;
    s2=" "+s2;
    int maxl=0;
    for(int i=0; i<=s1.size()-1; i++) for(int j=0; j<=s2.size(); j++) dp[i][j]=0;
    for(int i=1; i<=s1.size()-1; i++){
      for(int j=1; j<=s2.size(); j++){
        if(s1[i]==s2[j]) dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        maxl=max(maxl,dp[i][j]);
      }
    }
    cout<<maxl<<en;
  }
}





Measured memory_bytes: 11060
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

int maxBit(int a){
  int x = 1;
  while(1LL<<(x+1) <= a) x++;
  return x;
}

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

  vector<int> A(n);
  vector<int> B(n);
  cin>>A;
  cin>>B;
  
  const int N = 54;
  int g[N][N];
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) g[i][j] = INF;

  for(int i=0;i<N;i++) g[i][i] = 0;
  
  for(int i=0;i<N;i++)
    for(int k=1;k<N;k++) Min(g[i][i%k], 1LL<<k);

  int ans = 0;
  int cnt = 100;
  while(cnt--){
    for(int k=0;k<N;k++)
      for(int i=0;i<N;i++)
        for(int j=0;j<N;j++) Min(g[i][j],g[i][k] + g[k][j]);

    int x = 0;
    for(int i=0;i<n;i++) x |= g[A[i]][B[i]];
    if(x == 0) break;
    int mx = maxBit(x);
    for(int i=0;i<N;i++) Min(g[i][i%mx],0LL);
    ans += 1LL<<mx;    
  }

  for(int i=0;i<n;i++){
    int a = A[i], b = B[i];
    if(g[a][b] == 0) continue;
    cout<<-1<<endl;
    return 0;
  }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f, mod=1000000007;

void read(int &x)
{
    char ch; bool ok;
    for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
    for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}

int main()
{
    char s[100]; scanf("%s",s);
    for (int i=0; i<3; i++)
    {
        if (s[i]=='1') s[i]='9';
         else if (s[i]=='9') s[i]='1';
    }
    printf("%s\n",s);
    return 0;
}


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

int main() {
    string s;
    std::cin >> s;
    ll n = s.size();
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if(s[n-1-i]-'0'==10){
            s[n-1-i]='0';
            if(i==n-1){
                ans++;   
            }else{
                s[n-1-i-1]++;
            }
        }
        if(s[n-1-i]-'0'>=6){
            ans += 10-(s[n-1-i]-'0');
            if(i==n-1){
                ans++;
            }else{
                s[n-1-i-1] += 1;                
            }
        }else{
            if(i!=n-1 && s[n-1-i-1]-'0'>=5 && s[n-1-i]=='5'){
                ans += 10-(s[n-1-i]-'0');
                s[n-1-i-1] += 1;
            }else{
                ans += s[n-1-i]-'0';                
            }
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1412
n, m = tuple(map(int, input().split()))

L = []
R = []
for i in range(m):
    l, r = tuple(map(int, input().split()))
    L.append(l)
    R.append(r)

ans = min(R) - max(L)+1
if ans >= 0:
    print(ans)
else:
    print(0)


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

string S[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};

int main(){
	string s;
	cin >> s;
	
	rep(i,3){
		if(s == S[i]){
			cout << S[i+1] << endl;
		}
	}
	
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();

		int i = 0;
		while (i < n) {
			if (s.substring(i).equals(t.substring(0, n - i))) {
				System.out.println(n + i);
				return;
			}
			i++;
		}

		System.out.println(n * 2);
		sc.close();
	}

}


Measured memory_bytes: 21844
X, Y = map(int, input().split())
MAX = 10**9+7

# def cmb(n, r):
#     if n - r < r: r = n - r
#     if r == 0: return 1
#     if r == 1: return n

#     numerator = [n - r + k + 1 for k in range(r)]
#     denominator = [k + 1 for k in range(r)]

#     for p in range(2,r+1):
#         pivot = denominator[p - 1]
#         if pivot > 1:
#             offset = (n - r) % p
#             for k in range(p-1,r,p):
#                 numerator[k - offset] /= pivot
#                 denominator[k] /= pivot

#     result = 1
#     for k in range(r):
#         if numerator[k] > 1:
#             result *= int(numerator[k])

#     return result

def cmb(n, r, mod, g1, g2):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod



def main(X, Y):
    _X = 2*X - Y
    _Y = -X + 2*Y
    if _X%3!=0 or _Y%3!=0:
        return 0

    X = _X//3
    Y = _Y//3

    mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, X+Y + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    return cmb(X+Y, X, MAX, g1, g2)

print(main(X, Y)%MAX)

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

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

int main(void)
{
	ll a, b, c; cin >> a >> b >> c;
	
	if (b - a == c - b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,T;
  cin>>n>>T;
  vector<int> cs;
  rep(i,n) {
    int c,t;
    cin>>c>>t;
    if(t<=T) {
      cs.push_back(c);
    }
  }
  sort(cs.begin(),cs.end());
  if(cs.size()>0) {
    cout << cs[0] << endl;
  } else {
    cout << "TLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
#define     PI          3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342
 
 
int main()
{
	ll N;
	cin >> N;

	if(N%1000==0)cout << 0 << endl;
	else
	{
		ll x = N%1000;
		cout << 1000-x << endl;
	}
    


    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define MAXN 200005
#define LL long long
#define sum(l,r) (l<=r?(s[r] - s[l-1]):0)
using namespace std;
 
int N;
LL a[MAXN], s[MAXN];
int nxt[MAXN];

LL dp[MAXN][3];
 
int main(){
	//freopen("1.in", "r", stdin);
	//freopen("1.out", "w", stdout);
	
	cin>>N;
	cin>>a[1];
	
	int N1 = 1;
	char op;
	int x, f = 1; 
	for(int i=1;i<N;i++){
		cin>>op;
		cin>>x;
		if(op=='-') a[++N1] = -x, f = 0;
		else{
			if(f) a[N1] += x;
			else a[++N1] = x, f = 1; 
		}
	}

	N = N1;
	if(N==1){
		cout<<a[1]<<endl;
		return 0;
	}
	
	for(int i=1;i<=N;i++){
		//cout<<a[i]<<" ";
		s[i] = s[i-1] + abs(a[i]);
	}
	//cout<<endl;
	
	memset(dp, 0xf3, sizeof(dp));
	dp[1][0] = a[1];
	
	for(int i=2;i<=N;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(a[i]>=0 && k>=j){
					if(k==1) dp[i][j] = max(dp[i][j], dp[i-1][k] - a[i]);
					else dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i]);
				}
				
				if(a[i]<0){
					if(k>=j){
						if(k==1) dp[i][j] = max(dp[i][j], dp[i-1][k] - a[i]);
						else dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i]);
					}
					else if(k==j-1){
						if(j==2) dp[i][j] = max(dp[i][j], dp[i-1][k] - a[i]);
						else dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i]);
					}
				}
			}
		}
	}
	
	//for(int i=2;i<=N;i++) cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	
	cout<<dp[N][0];
	
	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,sum=0,sumL=0,min=100000,num;
  cin >> N;
  
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }
  
  for(int i=0;i<N;i++){
    sumL += A[i];
    if(min > abs(sumL-(sum-sumL)))
       min = abs(sumL-(sum-sumL));
  }
       cout << min <<endl;
}

Measured memory_bytes: 256
import heapq
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    ans = 0
    d = defaultdict(list)
    for _ in range(N):
        A, B = map(int, input().split())
        d[A].append(-B)
    cand = []
    heapq.heapify(cand)
    for day in range(M-1,-1,-1):
        diff = M - day
        for money in d[diff]:
            heapq.heappush(cand, money)
        if cand:
            ans -= heapq.heappop(cand)

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 96752
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    long long sum=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j)continue;
            sum+=a[i]*a[j];
        }
    }
    cout << (sum/2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
bool ask(int a,int b)
{
	cout<<"? "<<a<<" "<<b<<endl;
	string ret;
	cin>>ret;
	if(ret[0]=='Y') return true;
	return false;
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=b)
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	stack<int> st;
	for(int i=0;i<a+b;i++)
	{
		if(st.empty()) st.push(i);
		else if(ask(st.top(),i))
			st.push(i);
		else st.pop();
	}
	string ans;
	for(int i=0;i<a+b;i++)
	{
		if(ask(st.top(),i))
			ans+='1';
		else ans+='0';
	}
	cout<<"! "<<ans<<endl;

}


Measured memory_bytes: 724
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;

int main()
{
	string s;
	cin >> s;
	if(s[0]==s[1] && s[1]==s[2]) puts("Yes");
	else if(s[2]==s[3] && s[1]==s[2]) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3620
from itertools import accumulate

N, K = map(int, input().split())
p = list(map(int,input().split()))

pc = [0] * N

for i in range(N):
    pc[i] = (1 + p[i]) / 2

L = [0] + list(accumulate(pc))

ans = 0
for i in range(0,N-K+1):
    ans = max(ans, L[i+K] - L[i])

print(ans)

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

int main() {
  int M,N;
  cin >> N>>M;
 vector<int> veca(M),vecb(M);
  vector<int> vecm(N);
for (int i = 0; i < M; i++) { cin >> veca.at(i) >> vecb.at(i);}
  for (int i = 0; i <N; i++){  
  
  
  for (int j= 0; j< M;j++){
    if(veca.at(j)==i+1||vecb.at(j)==i+1) vecm.at(i)++;
  }
    
}
  for (int i = 0; i <N; i++)cout <<vecm.at(i)<<endl;
  
}  


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

long long K, A, B;

int main() {
    cin >> K >> A >> B;
    if (A + 2 >= B || K <= A) {
        cout << K + 1 << endl;
        return 0;
    }
    long long cng = (K - A + 1) / 2;
    long long ans = B + (cng - 1) * (B - A);
    if ((K - A + 1) % 2) {
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
#include <cstdio>
using namespace std;
stack <int> st;
int solve(string);
int main(){
  string str;
  while(cin>>str){
    if(str=="+"||str=="-"||str=="*"||str=="/")
      st.push(solve(str));
    else st.push(atoi(str.c_str()));
    if(getchar()=='\n'){
      cout << st.top() << endl;
      return 0;
    }
  }
}
int solve(string str){
  int b = st.top(); st.pop();
  int a = st.top(); st.pop();
  if(str=="+")return a+b;
  else if(str=="-")return a-b;
  else if(str=="*")return a*b;
  else if(str=="/")return a/b;
}


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

int main(void){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll c=x/d;
    ll ans;
    if(k<c)ans=x-k*d;
    else{
        x-=d*c;
        k-=c;
        if(abs(k%2)==1)ans=abs(x-d);
        else ans=x;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

vector <LL> G[1005];
LL w[1005],z[1005],dp[5005];
LL n,ff;

void dfs(LL u,LL f){
	for(LL i = 0;i < G[u].size();i ++) dfs(G[u][i],u);
	
	for(LL j = 0;j <= w[u];j ++) dp[j] = INF; dp[0] = 0;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = G[u][i];
		for(LL j = w[u];j >= 0;j --){
			LL mi = INF;
			if(j >= w[v]) mi = min(mi,dp[j - w[v]] + z[v]);
			if(j >= z[v]) mi = min(mi,dp[j - z[v]] + w[v]);
			dp[j] = mi;
		}
	}
	for(LL i = w[u];i >= 0;i --) z[u] = min(z[u],dp[i]);
}

int main(){
	memset(z,INF,sizeof(z));
	cin >> n;
	for(LL i = 2;i <= n;i ++){
		cin >> ff;
		G[ff].push_back(i);
	}
	for(LL i = 1;i <= n;i ++) cin >> w[i];
	dfs(1,0);
	cout << (z[1] < INF ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  map<string, int> mp;
  rep(i, N) {
    string S;
    cin >> S;
    mp[S]++;
  }
  int mx = 0;
  for (auto p : mp) mx = max(mx, p.second);
  for (auto p : mp) {
    if (p.second != mx) continue;
    cout << p.first << '\n';
  }
  return 0;
}

Measured memory_bytes: 19200
#include <iostream>

using namespace std;

  int check(int front, int back){
    int point = 0;
    if(front <= back){
      point++;
    }
    return point;
  }


int main(){
  int n;
  int counter = 1;
  cin >> n;
  if(n > 0 && n <= 20){
    int h[n];
    for(int i = 0; i < n; i++){
      cin >> h[i];
    }
    
    for(int i = 1; i < n; i++){
      //山の高さを比べる(再帰処理が必要)
      int j = i;
      int counter2 = 0;
      while(j > 0){
        counter2 += check(h[j-1], h[i]);
        //        cout << "counter2: " << counter2 << endl;
        j--;
      }
      if(counter2 == i){
        counter++;
      }
      //      cout << "counter: " << counter <<endl;
    }
    cout << counter << endl;
  }else{
    return 0;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
vi v, v2;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    v.pb(a);
    v2.pb(a);
  }
  sort(rng(v2));
  int a = v2[n/2-1], a2 = v2[n/2];
  FOR(i, 0, n) printf("%d\n", v[i] > a ? a : a2);
  return 0;
}


Measured memory_bytes: 3948
from collections import defaultdict


def calc_divisors_of_factorial(n):
    ret = defaultdict(int)
    for i in range(1, n+1):
        divisors = calc_prime_divisors(i)
        for d in divisors:
            ret[d] += divisors[d]
    return ret


def calc_prime_divisors(n):  # do not contain 1
    ret = defaultdict(int)
    for i in range(2, n+1):
        if is_prime(i):
            while n % i == 0:
                n = n // i
                ret[i] += 1
            if n == 1:
                break
    return ret


def is_prime(n):
    memo = {}
    def calc(n):
        if n in memo:
            return memo[n]
        if n == 1 or n == 2:
            return True
        if n % 2 == 0:
            return False
        d = 3
        while True:
            if d**2 > n:
                break
            if n % d == 0:
                memo[n] = False
                return False
            d += 2
        memo[n] = True
        return True
    return calc(n)


def get_over(divisors, n):
    ret = 0
    for d in divisors:
        if divisors[d]+1 >= n:
            ret += 1
    return ret


def factorial(n):
    memo = {}
    def calc(n):
        if n in memo:
            return memo[n]
        if n <= 1:
            return 1
        ret = n *factorial(n-1)
        memo[n] = ret
        return ret
    return calc(n)


def combination(n, k):
    if n <= 0:
        return 0
    return factorial(n) // (factorial(k) * factorial(n-k))


def solve(n):
    prime_divisors = calc_divisors_of_factorial(n)
    ret = 0
    over_75 = get_over(prime_divisors, 75)
    over_25 = get_over(prime_divisors, 25)
    over_15 = get_over(prime_divisors, 15)
    over_5 = get_over(prime_divisors, 5)
    over_3 = get_over(prime_divisors, 3)

    if over_75 > 0:
        ret += combination(over_75, 1)
    if over_25 > 0 and over_3-1 > 0:
        ret += combination(over_25, 1) * combination(over_3 - 1, 1)
    if over_15 > 0 and over_5-1 > 0:
        ret += combination(over_15, 1) * combination(over_5 - 1, 1)
    if over_5 > 0 and over_3-2>0:
        ret += combination(over_5, 2) * combination(over_3 - 2, 1)

    return ret


def main():
    N = int(input())
    print(solve(N))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=2000009;
ll  dp[100009]; ///number of way to use i coins
ll  pre[100009];
int main()
{
    ll  n,k;
    cin>>n>>k;
    dp[0]=1;
    for(ll  i=0;i<n;i++)
    {
        ll  x; cin>>x;
        for(ll  used=k;used>=0;used--)
        {
            ll  suru=used+1;
            ll  ses=used+min(x,k-used);
            if(suru<=ses)
            {
                pre[suru]+=dp[used],pre[ses+1]-=dp[used];
                pre[suru]%=mod;
                pre[ses+1]=(pre[ses+1]+mod)%mod;

            }
        }
            for(ll  i=1;i<=k;i++)
            {
                pre[i]+=pre[i-1];
                pre[i]%=mod;
                dp[i]+=pre[i];
                dp[i]%=mod;
            }
            for(ll  i=0;i<=k;i++) pre[i]=0;
    }
    cout<<dp[k]<<endl ;
}


Measured memory_bytes: 1792
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("input failed");
    let splited: Vec<i32> = input.split_whitespace()
                            .map(|s| s.parse().expect("aaaaaaaaa"))
                            .collect();

    let total = splited[0] * splited[1];
    if total % 2 == 0 {
        println!("Even")
    } else {
        println!("Odd")
    }
}


Measured memory_bytes: 2128
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int a[n+1];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int put[n+1];
  int ball;
  int ball_sum = 0;
  for (int i = n; i > 0; i--) {
    ball = 0;
    for (int j = 2; i*j <= n; j++) {
      ball += put[i*j];
    }
    if (a[i]%2 != ball%2) {
      put[i] = 1;
      ball_sum++;
    } else {
      put[i] = 0;
    }
  }
  printf("%d\n", ball_sum);
  for (int i = 1; i <= n; i++) {
    if (put[i] == 1) {
      ball_sum--;
      if (ball_sum > 0) {
        printf("%d ", i);
      } else {
        printf("%d\n", i);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 2432
// 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll k,L,num=1,ans=-1;
    cin>>k;
    if(9*k%7==0) L=9*k/7;
    else L=9*k;
    if(L%2==0 || L%5==0) ans=-1;
    else{
        for(int i=1;i<=L;i++){
            num*=10;
            num%=L;
            if(num==1){
                ans=i;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

int cost[100001];
const int INF = 1e9;

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    Fill(cost, INF);
    queue<int> q;
    q.push(0);
    cost[0] = 0;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 1; i <= 6; i++) {
            int nx = max(0, min(n - 1, v + i));
            int nxc = cost[v] + 1;
            while(a[nx] && cost[nx] > nxc){
                cost[nx] = nxc;
                nx = max(0, min(n - 1, nx + a[nx]));
            }
            if(!a[nx] && cost[nx] > nxc){
                cost[nx] = nxc;
                q.push(nx);
            }
        }
    }
    cout << cost[n - 1] << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ for (int i = 0; i < min(n, c.size()); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }

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

    // eratosthenes
    int P_MAX=100000;
    char p[P_MAX+1];
    memset(p, 1, sizeof p);
    p[0] = p[1] = 0;
    for (int i = 4; i <= P_MAX; i+=2)
        p[i] = 0;
    for (int i = 3; i*i <= P_MAX; i+=2) {
        if (!p[i]) continue;
        for (int j = i*i; j <= P_MAX; j += i)
            p[j] = 0;
    }

    // 2017-like number
    char n2017[P_MAX+1];
    memset(n2017, 0, sizeof n2017);
    for (int i = 2; i <= P_MAX; i++) {
        if (!p[i]) continue;
        int n = 2 * i - 1;
        if (n > P_MAX) break;
        if (p[n]) n2017[n] = 1;
    }

    // cumulative sum
    int s[P_MAX+1];
    s[0] = 0;
    for (int i = 1; i <= P_MAX; i++) {
        s[i] = s[i-1] + n2017[i];
    }

    int Q; cin >>Q;
    rep(i, Q) {
        int l, r; cin >> l >> r;
        cout << (s[r] - s[l-1]) << endl;
    }
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int32_t main()
{

	int k;
	cin >> k;
	string s = "ACL";
	string ans;
	for (int i = 0; i < k; i++)
	{
		ans += s;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    VI p(n);
    REP(i,n)cin>>p[i];
    int res=0;
    int mn=p[0];
    REP(i,n){
        mn=min(p[i],mn);
        if(mn>=p[i]){
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int main() {
  int K;
  int A, B;
  cin >> K;
  cin >> A >> B;

  for (int i = A; i < B + 1; ++i) {
    if (i % K == 0) {
      cout << "OK" << endl;
      break;
    } else if (i == B) {
      cout << "NG" << endl;
    }
  }
}

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

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int i = 0;
  int j = n-1;
  int ans =0;

  while(i<j){
    while(s[j] != 'R' && j >= 0)j--;
    while(s[i] != 'W' && i < n)i++;
    if(i>=j)break;
    i++;
    j--;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3764
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        if(A == B && A== C){
            System.out.println("No");
        }
        else if(A == B || A == C || B == C){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
import sys
INF = 10**9
sys.setrecursionlimit(INF)


def main():
    a, b, c, k = map(int, open(0).read().split())

    if k <= a:
        ans = k
    elif k <= a + b:
        ans = a
    else:
        # ans = a + -1 * (k - a - b)
        ans = 2 * a + b - k

    print(ans)
    return(str(ans))


if __name__ == '__main__':
    main()


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

int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<int> a(m), b(m), c(m);
    map<pair<int, int>, int> color, hd;
    int x = 0, y = 0;
    for (int i = 0; i < m; ++i) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        a[i]--, b[i]--;
        color[make_pair(a[i], b[i])] = c[i];
        if (abs(a[i] - b[i]) >= 3) {
            if (a[i] > b[i]) swap(a[i], b[i]);
            if (hd.find(make_pair(a[i], b[i])) != hd.end()) {
                if (hd[make_pair(a[i], b[i])] != c[i]) {
                    puts("0");
                    return 0;
                }
                x--, y++;
            } else {
                hd[make_pair(a[i], b[i])] = c[i];
                x++;
            }
        }
    }

    vector<int> dp(16);
    constexpr int kMod = 998244353;
    for (int s = 0; s < (1 << 4); ++s) {
        if (__builtin_popcount(s) & 1) continue;
        bool ok = true;
        for (int i = 0; i < 2; ++i) {
            for (int j = 0; j < 2; ++j) {
                if (color.find(make_pair(i, j)) != color.end()) {
                    int c = color[make_pair(i, j)];
                    if (c != (s >> (i * 2 + j) & 1)) ok = false;
                }
            }
        }
        if (ok) dp[s] = 1;
    }

    constexpr int dx[5] = {-2, -1, 0, 0, 0};
    constexpr int dy[5] = {0, 0, 0, -1, -2};

    for (int i = 2; i < n; ++i) {
        vector<int> nxt(16);
        for (int s = 0; s < (1 << 5); ++s) {
            if (__builtin_popcount(s) & 1) continue;
            for (int t = 0; t < (1 << 4); ++t) {
                if (dp[t] == 0) continue;
                assert(__builtin_popcount(t) % 2 == 0);
                int a = t >> 3 & 1;
                int b = s >> 1 & 1;
                int c = s >> 3 & 1;
                int d = s >> 2 & 1;
                if ((a + b + c + d) & 1) continue;
                bool ok = true;
                for (int j = 0; j < 5; ++j) {
                    if (color.find(make_pair(i + dx[j], i + dy[j])) != color.end()) {
                        ok &= color[make_pair(i + dx[j], i + dy[j])] == (s >> j & 1);
                    }
                }
                if (ok) (nxt[a | (b << 1) | (c << 2) | (d << 3)] += dp[t]) %= kMod;
            }
        }
        dp = nxt;
    }
    int ans = 0;
    long long blank = (1LL * n * n - (4 + 5 * (n - 2))) / 2 - x - y;
    for (int s = 0; s < (1 << 4); ++s) (ans += dp[s]) %= kMod;

    auto fpow = [&](int a, long long n) {
        int res = 1;
        while (n > 0) {
            if (n & 1) res = 1LL * res * a % kMod;
            a = 1LL * a * a % kMod;
            n >>= 1;
        }
        return res;
    };
    // printf("blank = %lld\n", blank);

    ans = 1LL * ans * fpow(2, blank) % kMod;
    printf("%d\n", ans);
}


Measured memory_bytes: 7040
n = int(input())
h = list(map(int, input().split()))

dp= [10 ** 9 + 7] * (n + 10)

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n - 1])


Measured memory_bytes: 13980
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
 
int n, m, v[100100];
vector<int> G[100100];
 
int main()
{
	scanf ("%d %d", &n, &m);
	for (int i = 0; i < m; i++){
		int x, y; scanf ("%d %d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
 
	for(int i=1; i <=n; i++) v[i] = -1;

    queue<int> q; q.push(1);
    while(!q.empty()) {
        int x = q.front();
        q.pop();
        for(auto& y: G[x]) {
            if(v[y] == -1){
                v[y] = x;
                q.push(y);
            }
        }
    }
 
	for (int i = 2; i <= n; i++) if (v[i] == -1){
		puts("No");
		return 0;
	}
	puts("Yes");
	for (int i = 2; i <= n; i++) printf ("%d\n", v[i]);
	return 0;
}

Measured memory_bytes: 10128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    
    int a,b,c;
    int count=0;
    cin >> a >> b >> c;
    
    for(int i=a; i<=b; i++){
        if(c%i==0){
            count += 1;
        }
    }
    
    cout << count << endl;
    
    return 0;
}




Measured memory_bytes: 3100
// template version 1.8

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
const int INF=1e18;
const int MOD=1e9+7;
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  vector<int> b(n);
  rep(i, n) {
    cin>>b[i];
  }
  int res=0;
  rep(i, n){
    if (a[i]>b[i]){
      res += a[i]-b[i];
    }
  }
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
object Main extends App {
  def count(str: String, main: Char): Int = {
    var t = str
    var count = 0

    while (!ok(t)) {
      t = t.zip(t.tail).map(_ match {
        case (`main`, _) => main
        case (_, `main`) => main
        case (cur, _) => cur
      }).mkString
      count = count + 1
    }
    count
  }

  def ok(str: String): Boolean = str.distinct.length <= 1

  def calc(str: String): Int = {
    str.map(c => count(str, c)).min
  }

  val sc = new java.util.Scanner(System.in)
  val str = sc.nextLine()
  println(calc(str))
}

Measured memory_bytes: 43468
import Base.readline
function readline(T)
    map(x->parse(T, x), split(readline()))
end

function solve(K, A, B)
    if B <= A + 2 || K < A
        K
    elseif mod(K - A, 2) == 1
        1 + solve(K - 1, A, B)
    else
        A + div(K - A, 2) * (B - A)
    end
end

K,A,B = readline(Int)

println(solve(K+1, A, B))


Measured memory_bytes: 165484
use proconio::input;

fn main() {
    input!{
        n: i32,
        p: [i32; n],
    };

    let mut max = std::i32::MIN;
    let mut sum = 0;
    for &price in p.iter() {
        sum += price;
        max = std::cmp::max(max, price);
    }
    println!("{}", sum - max / 2);
}


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

// 約数列挙
vector<long long> calc_divisor(long long n) {
	vector<long long> res;
	for (long long i = 1LL; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			long long j = n / i;
			if (j != i) res.push_back(j);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

int main() {
	
	ll n, m; cin >> n >> m;
	vector<long long> div = calc_divisor(m);
	ll cnt = div.size();
	ll index = cnt - 1;
	ll ans;
	while (cnt--) {
		if (n * div[index] <= m) {
			ans = div[index];
			break;
		}
		index--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
int N, K;
long long int S;

struct cube {
	vector<long long int>coors;
};

long long int connect(const cube&l, const cube&r) {
	vector<long long int>ds;
	for (int i = 0; i < 3; ++i) {
		if (abs(l.coors[i] - r.coors[i]) >= S)return 0;
		else ds.emplace_back(S-abs(l.coors[i] - r.coors[i]));
	}
	return 2 * (ds[0] * ds[1] + ds[1] * ds[2] + ds[2] * ds[0]);
}
void dfs(const int now, const int from, const vector<vector<pair<int, long long int>>>&edges, vector<int>&used,vector<long long int>&v) {
	for (auto e : edges[now]) {
		if (e.first == from)continue;
		if (used[e.first]) {
			v.push_back(e.second);
		}
		else {
			v.push_back(e.second);
			used[e.first] = true;
			dfs(e.first, now, edges, used, v);
		}
	}
}
int main() {
	while (1) {
		cin >> N >> K >> S;
		if (!N)break;
		long long int total = K*S*S * 6;
		
		vector<cube>cus;
		for (int i = 0; i < N; ++i) {
			int x, y, z; cin >> x >> y >> z;
			cus.push_back(cube{ vector<long long int>{x,y,z} });
		}
		if (K == 1) {
			cout << total << endl;
			continue;
		}
		vector<vector<pair<int, long long int>>>edges(N);
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i == j)continue;
				long long int sa = connect(cus[i], cus[j]);
				if (sa) {
					edges[i].push_back(make_pair(j, sa));
				}
			}
		}
		vector<int>used(N);
		long long int hide_max = -1;
		for (int i = 0; i < N; ++i) {
			if (!used[i]) {
				if (edges[i].size()==1) {
					used[i] = true;
					vector<long long int>v;
					dfs(i, -1, edges, used, v);
					if (v.size() < K-1)continue;
					else {
						long long int sum = 0;
						for (int i = 0; i < K - 1; ++i) {
							sum += v[i];
						}
						for (int i = K - 1; i <=v.size(); ++i) {
							hide_max = max(hide_max, sum);
							sum -= v[(i - K + 1) % v.size()];
							sum += v[i%v.size()];
						}
					}
				}

			}
		}
		for (int i = 0; i < N; ++i) {
			if (!used[i]) {
				used[i] = true;
				if (!edges[i].empty()) {
					vector<long long int>v;
					dfs(i, edges[i][0].first, edges, used, v);
					if (v.size() < K)continue;
					else if (v.size() == K) {
						hide_max = max(hide_max, accumulate(v.begin(), v.end(), 0ll));
					}
					else {
						long long int sum = 0;
						for (int i = 0; i < K-1; ++i) {
							sum += v[i];
						}
						for (int i = K-1; i <= v.size()+K; ++i) {
							hide_max = max(hide_max, sum);
							sum -= v[(i - K+1) % v.size()];
							sum += v[i%v.size()];
						}
					}
				}
				
			}
			
		}
		if (hide_max == -1)cout << -1 << endl;
		else {
			cout << total - hide_max << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3276
import sys
n=int(input())
tmp_t=0
dist=0
for i in range(n):
    a,b,c=map(int,input().split())
    if i==0:
        if (b+c)%2==0 and a%2==0 and a>=(b+c) or (b+c)%2!=0 and a%2!=0 and a>=(b+c):
            tmp_t=a
            dist=b+c
        else:
            print("No")
            sys.exit()
    else:
        if abs((dist-(b+c)))%2==0 and (a-tmp_t)%2==0 and (a-tmp_t)>=(dist-(b+c)) or abs((dist-(b+c)))%2!=0 and (a-tmp_t)%2!=0 and (a-tmp_t)>=(dist-(b+c)):
            tmp_t=a
            dist=b+c
        else:
            print("No")
            sys.exit()
print("Yes")


Measured memory_bytes: 3064