akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    int tmp = k;
    while (tmp - 1 < n)
    {
        ans++;
        tmp *= k;
    }
    cout << ans << endl;
    return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll a, b, c;
    cin >> a >> b >> c;

    REP(i, b) {
        if (i == 0) continue;

        if (a * i % b == c) {
            MSG("YES")
            exit(EXIT_SUCCESS);
        }
    }

    MSG("NO")
}




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

int main() {
  int a;
  int b;
  int c;
  cin >> a;
  cin >> b;
  cin >> c;
  if (a < b) {
    if (b < c) {
      cout << a << " " << b << " " << c << endl;
    } else if (c < a) {
      cout << c << " " << a << " " << b << endl;
    } else {
      cout << a << " " << c << " " << b << endl;
    } 
  } else if (b < a) {
    if (a < c) {
      cout << b << " " << a << " " << c << endl;
    } else if (c < b) {
      cout << c << " " << b << " " << a << endl;
    } else {
      cout << b << " " << c << " " << a << endl;
    }
  } else if (c < a){
    if (a < b) {
      cout << c << " " << a << " " << b << endl;
    } else if (b < c) {
      cout << b << " " << c << " " << a << endl;
    } else {
      cout << c << " " << b << " " << a << endl;
    } 
  }
}


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

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

	int fee = 0;
	for (int j = 0; j <= N; j++) {
		fee = fee + abs(A[j] - A[j + 1]);
	}

	for (int k = 1; k <= N; k++) {
		int ans = 0;
		ans = fee - abs(A[k - 1] - A[k]) - abs(A[k] - A[k + 1]) + abs(A[k - 1] - A[k + 1]);
		cout << ans << endl;
	}
}

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

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

int main() {
	init();
	int n, mmax = 0;
	long long ans = 0;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int num;
		cin >> num;
		mmax = max(mmax, num);
		ans += (mmax - num);
	}
	cout << ans;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#define gmi(a,b) a=a<(b)?a:(b)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=1010;
int n,m,f[N][N];
char s[N][N];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	FOR(i,1,n) scanf("%s",s[i]+1);
	f[1][1]=s[1][1]=='#';
	FOR(i,1,n)FOR(j,1,m)if(i>1 || j>1){
		f[i][j]=n+m;
		if(i>1) gmi(f[i][j],f[i-1][j]+(s[i][j]=='#' && s[i-1][j]=='.'));
		if(j>1) gmi(f[i][j],f[i][j-1]+(s[i][j]=='#' && s[i][j-1]=='.'));
	}
	cout<<f[n][m]<<'\n';
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int A, B;
    cin >> A;
    cin >> B;
    cout << 6 - A - B << endl;    

    return 0;
}

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


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        G[a-1].append((b-1, i))
        G[b-1].append((a-1, i))

    V = [[-1, -1] for _ in range(N)]  # 頂点の[親, 親への辺の色]
    ans = [-1]*(N-1)
    stack = [0]  # dfsになるはず（キューだとbfs）
    while stack:
        i = stack.pop()
        color = 0
        for c, ei in G[i]:
            if c == V[i][0]:
                continue
            V[c][0] = i
            color += 1
            if color == V[i][1]:
                color += 1
            V[c][1] = ans[ei] = color
            stack.append(c)
    print(max(ans))
    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int a,b,t; cin>>a>>b>>t;
  int ans = 0;
  int cur=a;
  while (cur<=t) {
    ans += b;
    cur += a;
  }
  cout<<ans;
    
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;
	int N, M, K;
	
	string S;
	cin >> S;
	int ans = 0;
	int num = 0;
	num += (S[0] == 'R');
	rep(i,1, 3) {
		num += (S[i] == 'R');
		if (S[i - 1] == 'R' && S[i] == 'R')ans++;
	}
	cout << ans + (num > 0);
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std ;
#define ll  long long 
#define dl long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second


int main ()
{
   
     char c;
     cin >> c;
     if (c>='A' && c<='Z')
     	cout<<"A"<<endl;
     else
     	cout<<"a"<<endl;




	return 0;

}

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

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

using namespace std;

const int N_MAX=200000;

template<class T>
class Fenwick_tree{
	int n;
	T a[N_MAX];

public:
	void build(int n){
		this->n=n;
		rep(i,n) a[i]=0;
	}

	void add(int i,T v){
		for(;i<n;i|=i+1) a[i]+=v;
	}

	T sum(int i,int j){
		if(i==0){
			T s=0;
			for(;j>=0;j=(j&(j+1))-1) s+=a[j];
			return s;
		}
		return sum(0,j)-sum(0,i-1);
	}
};

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]-=k;

	vector<long long> sum(n);
	sum[0]=a[0];
	rep(i,n-1) sum[i+1]=sum[i]+a[i+1];

	vector<long long> X=sum;
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	int m=X.size();

	vector<int> pos(n);
	rep(i,n) pos[i]=lower_bound(X.begin(),X.end(),sum[i])-X.begin();

	Fenwick_tree<int> F;
	F.build(m);
	rep(i,n) F.add(pos[i],1);

	long long ans=0,thre=0;
	rep(i,n){
		int idx=lower_bound(X.begin(),X.end(),thre)-X.begin();
		ans+=F.sum(idx,m-1);

		F.add(pos[i],-1);
		thre+=a[i];
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 5760
S = gets.chomp.to_i
a = S/100
b = S%100
if 12<a || a==0 then
	if 12>=b && b>=1 then
		print'YYMM'
	else
		print 'NA'
	end
else
	if 12<b || b==0 then
		print 'MMYY'
	else
		print 'AMBIGUOUS'
	end
end

Measured memory_bytes: 1788
#include <stdio.h>
   
int main(){
   
    int a[3] = {0};
    int b[3] = {0};
   
    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    if (a[0] < a[1]){
        b[0] = 0;
        b[1] = 1;
    }else{
        b[0] = 1;
        b[1] = 0;
    }

    if (a[2] < a[b[0]]){
        b[2] = b[1];
        b[1] = b[0];
        b[0] = 2;
    }else if (a[2] < a[b[1]]){
        b[2] = b[1];
        b[1] = 2;
    }else{
        b[2] = 2;
    }
   
 
    printf("%d %d %d\n", a[b[0]], a[b[1]], a[b[2]]);
   
   
    return 0;
   
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){

    int N;
    cin >> N;
    int H[N];
    int border;
    int count = 1;

    for(int i = 0; i < N; i++){
        cin >> H[i];
        if(i == 0){
            border = H[i];
        }else if(H[i] >= border){
            border = H[i];
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	rep (i, n) {
	  cin >> a[i];
	  sum += a[i];
	}
	ll assum = 0;
	ll pre = 0;
	rep (i, n - 1) {
	  assum += a[i] - pre;
	  pre = a[i] - pre;
	}
	assum *= 2;
	ll x = (sum - assum) / 2;
	pre = x;
	rep (i, n) {
	  cout << 2 * pre;
	  pre = a[i] - pre;
	  if (i == n - 1) cout << endl;
	  else cout << " ";
	}
	
    
    return 0;
}



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

n, w = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]

D = [0] * (w+1)

for i in range(n):
    for j in range(w,-1,-1):
        if j-A[i][0] >= 0:
            D[j] = max(D[j], D[j-A[i][0]] + A[i][1])
print(D[-1])

Measured memory_bytes: 70608
#include <stdio.h>
#include <string.h>
int main(void){
char s[100];
int n;
  int max=0;
int count=0;
scanf("%s",s);
for(n=0;s[n]!='\0';n++){
if(s[n]=='A'||s[n]=='C'||s[n]=='G'||s[n]=='T'){count++;}
else {count=0;}
  if(max<=count){max=count;}
}
printf("%d\n",max);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

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

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        if("AAA".equals(s) || "BBB".equals(s)){
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }   
    }
}

Measured memory_bytes: 35492
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=50+10;
int n;
double a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lf",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++)
		a[i+1]=(a[i]+a[i+1])/2.00;
	printf("%.10lf",a[n]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll ;

#define read() freopen("a.in", "r", stdin)

int main()
{
	// read();

	ll res = 1;
	int t, k;
	cin >> t >> k;

	for(int i=0; i<t; ++i){
		res = min((ll)2*res, res+k);
		//cout << res << endl;
	}	

	// cout << t << endl;

	cout << res << endl;


	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    ll k;
    cin >> k;
    vll n(k);
    queue<int> q;
    auto ps = [&](int v, ll p) {
        if (n[v] != 0) return;
        n[v] = p;
        q.push(v);
    };
    int i = 0;
    while (i < 9) {
        ps(i, i+1);
        ++i;
    }
    while (i < k) {
        int pv = q.front(); q.pop();
        ll pp = n[pv];
        int pp1 = pp % 10;
        if (pp1 > 0) {
            ps(i, pp * 10 + (pp1-1));
            ++i;
        }
        ps(i, pp * 10 + pp1); ++i;
        if (pp1 < 9) {
            ps(i, pp * 10 + (pp1+1));
            ++i;
        }
    }
    cout << n[k-1] << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  
  int sum = 0;
  
  for (int i = 0; i < (n - 1); i++) {
    for (int j = 1 + i; j < n; j++) sum += (d[i] * d[j]);
  }
  
  cout << sum << endl;
}


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

using namespace std;

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

int main(){
  uint64_t a, b, n;
  cin >> a >> b >> n;
  cout << a * min(n, b - 1) / b << endl;
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define m 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i,sum=0;
	cin>>n;
	for(i=1;i<=n;++i)
	{
		if(i%3 && i%5)
		{
			sum+=i;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3656
//https://algospot.com/judge/problem/read/CLOCKSYNC
#include <iostream>
#include <cstdio>
#include <functional>
#include <algorithm>
#include <climits>
#include <utility>
#include <string>
#include <stack>
#include <vector>
#include <queue>
#include <map>

#define LF '\n';

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

int main(void)
{
	ios::sync_with_stdio(false);
	
	int n, a, b;
	cin >> n >> a >> b;

	cout << (n * a > b ? b : n * a);
	return 0;
}	

Measured memory_bytes: 256
n,k=map(int,input().split())
A=[]
for i in range(k):
	d=int(input())
	a=list(map(int,input().split()))
	A+=a
A=set(A)
ans=0
for i in range(n):
	if (i+1) not in A:
		ans+=1
print(ans)
	

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int k,s;
  cin >> k >> s;
  
  int ans = 0;
  
  int z = 0;
  REP(x,k+1){
    REP(y,k+1){
      z = s - x - y;
      if(x + y + z == s && z >= 0 && z <= k){
        ans++;
      }
     
    }
  }
        
  
  cout << ans << endl;

}

Measured memory_bytes: 3508
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll a,b,n;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>a>>b>>n;
    ll ans = 0;
    if(b<=n){
        ans = a*(b-1)/b - a*((b-1)/b);
    }else{
        ans = (a*n)/b - a*(n/b);
    }
    print(ans);
    return 0;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

//return x^y mod p
ll power(ll x,ll y, ll p)
{
    ll res = 1;     
    x = x % p; 
 
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n,k; cin>>n>>k;
    ll res = 0;
    ll cnt[k + 1];
    RFOR(i, k, 1) {
        cnt[i] = power(k / i, n, MOD);
        for(int j = 2*i; j <= k; j += i) {
            cnt[i] = (cnt[i] - cnt[j] + MOD)%MOD;
        }
        res += (cnt[i] * i)%MOD;
        res %= MOD;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 4288
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/pending/disjoint_sets.hpp>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, M;
  bst::disjoint_sets_with_storage<> s(N+1);

  REP(i, M) {
    ll A, B;
    cin>>A>>B;
    s.union_set(A, B);
  }
  
  vector<ll> pars(N+1, 0);
  
  for (int i = 1; i <= N; i++) {
    pars[s.find_set(i)]++;
  }


  return *bst::max_element(pars);
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}




Measured memory_bytes: 6684
#include <iostream>
#define MAX 500010
using namespace std;

int count = 0;

void Merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];
	for (int i = 0;i < n1;i++)
	{
		L[i] = A[left+i];
	}
	for (int i = 0;i < n2;i++)
	{
		R[i] = A[mid+i];
	}
	L[n1] = 1e+9;
	R[n2] = 1e+9;
	int i = 0, j = 0;
	
	for (int k = left;k < right;k++)
	{
		if (L[i] <= R[j] && i < n1)
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			j++;
		}
		count++;
	}
	
}

void Merge_Sort(int A[], int left, int right)
{
	int mid = 0;
	if (left+1 < right)
	{
		mid = (left + right) / 2;
		Merge_Sort(A, left, mid);
		Merge_Sort(A, mid, right);
		Merge(A, left, mid, right);
	}
	return;
}

int main ()
{
	int n, S[MAX];
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> S[i];
	}
	
	Merge_Sort(S, 0, n);
	
	cout << S[0];
	for (int i = 1;i < n;i++)
	{
		cout << " " << S[i];
	}
	cout << endl;
	cout << count << endl;
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 096 A / Link: http://abc096.contest.atcoder.jp/tasks/abc096_a  ----- */


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

	LL a, b; cin >> a >> b;
	LL ans = 0LL;
	if (a <= b) {
		ans = a;
	}
	else {
		ans = a - 1;
	}
	
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  if ((a==c&&c==e)||(a==c&&c==f)||(a==d&&d==e)||(a==d&&d==f)||(b==c&&c==e)||(b==c&&c==f)||(b==d&&d==e)||(b==d&&d==f)){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class DStringFormation {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string S;
	    in >> S;
	    int Q;
	    in >> Q;
        bool order = true;
        string pre = "";
        string suf = "";
        REP(i, Q) {
	        int T;
	        in >> T;
	        if (T == 1) {
	            order ^= true;
	        } else {
	            int F; char C;
	            in >> F >> C;
	            if ((F == 1) ^ order) {
	                suf = suf + C;
	            } else {
	                pre = C + pre;
	            }
	        }
	    }
	    string ans;
	    if (!order) {
	        reverse(ALL(S));
	        reverse(ALL(pre));
	        reverse(ALL(suf));
	        ans = suf + S + pre;
	    } else {
	        ans = pre + S + suf;
	    }

	    out << ans << '\n';
	}
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	DStringFormation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1420
use std::io::*;
use std::str::FromStr;
use std::iter::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: String = sc.read();
    let mut s: Vec<char> = s.chars().collect();
    let n = sc.read();
    for _ in 0..n {
        let com: String = sc.read();
        let (a, b): (usize, usize) = (sc.read(), sc.read());
        let b = b + 1;
        match com.as_str() {
            "print" => {
                println!("{}", String::from_iter(s[a..b].iter()));
            },
            "reverse" => {
                let (q, _) = s.split_at_mut(b);
                let (_, q) = q.split_at_mut(a);
                q.reverse();
            },
            "replace" => {
                let t: Vec<_> = sc.read::<String>().chars().collect();
                let u = s.split_off(b);
                let _ = s.split_off(a);
                s.extend_from_slice(&t);
                s.extend_from_slice(&u);
            },
            _ => panic!(),
        }
    }
}



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    ll k, n;
    cin >> k >> n;
    vector<ll> a(n);
    cin >> a[0];
    ll gokei = 0; 
    ll max_ = 0;
    REP(i, n-1) {
        cin >> a[i+1];
        max_ = max(max_, a[i+1] - a[i]);
    }
    max_ = max(max_, a[0] + k-a[n-1]);
    cout << k-max_ << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define vd vector<double>
#define all(a) a.begin(),a.end()
using namespace std;
ll inf =1e10;

int main(){
  int n;
  cin>>n;
  vd v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(all(v));
  reverse(all(v));
  for(int i=n-1;i>0;i--){
    v[i-1]=(v[i]+v[i-1])/2;
  }
  cout<<v[0]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		N = N%10;
		switch(N){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
		case 3:
			System.out.println("bon");
			break;
		default:
			System.out.println("pon");
		}
	}

}


Measured memory_bytes: 35668
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    string s;
    cin>>s;
    ll ans=0;
    int n=s.size()-1;
    for(int i=0;i<(1<<n);i++){
        ll sum=0;
        ll tmp=s[0]-'0';
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                sum+=tmp;
                tmp=0;
            }
            tmp=10*tmp+s[j+1]-'0';
        }
        sum+=tmp;
        ans+=sum;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
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 kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    a,b,c=map(int,input().split())
    seisubu=c-a-b
    ab=a*b
    s2=seisubu**2
    ab4=ab*4
    ans=s2-ab4
    if ans>0 and seisubu>0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<iostream>
#include<cmath>//1000000000000
using namespace std;
int main()
{
	long long N,k=0;
	cin>>N;
	double n=sqrt(N);
	for(long long i=1;i<n;i++)
		if(N%i==0)
		{
			if((i+1)<N/i)
				k+=N/i-1;
		}
		cout<<k;
		return 0;
}

Measured memory_bytes: 256
S = input().split("/")
S = [int(e) for e in S]
if S[0] > 2019:
    print("TBD")
    exit()
if S[1] > 4:
    print("TBD")
    exit()
if S[2] > 30:
    print("TBD")
    exit()
print("Heisei")

Measured memory_bytes: 3060
fun main(args:Array<String>){
    val N = readLine()!!.split("").filter { it != "" }.map{it.toInt()}
    val c = listOf<Int>(2,4,5,7,9)
    val d = listOf<Int>(0,1, 6, 8)
    

    if(c.contains(N.last())){
        println("hon")
    }else if(d.contains(N.last())){
        println("pon")
    }else if(N.last() == 3){
        println("bon")
    }
}

Measured memory_bytes: 39656
n=int(input())
A=[0.0]+[float(i) for i in input().split()]
B=[float(i) for i in input().split()]
W={}
E={}
for i in range(1,n+2):
    W[i,i-1] = B[i-1]
    E[i,i-1] = B[i-1],i
for i in range(1,n+1):
    for j in range(i,n+1):
        W[i,j] = W[i,j-1]+A[j]+B[j]
for i in range(1,n+1):
    E[i,i] = E[i,i-1][0] + E[i+1,i][0] + W[i,i],i
for h in range(1,n):
    for i in range(1,n-h+1):
        e = 1001,None
        j = i + h
        k0 = E[i,j-1][1]
        k1 = E[i+1,j][1]
        for r in range(k0,k1+1):
            tmp = E[i,r-1][0] + E[r+1,j][0] + W[i,j]
            if tmp < e[0]:
                e = tmp,r
        E[i,j] = e
print(E[1,n][0])


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

 #define PI 3.14159265358979323846264338327950L 
 int main(void) {
 int a, b, h, m;
 cin >>a >> b>> h >> m;

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);


 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq)); 
 return 0;
 }

Measured memory_bytes: 4020
x=int(input())
if(x>=400 and x<=599):
    print(8)
elif (x>=600 and x<=799):
    print(7)
elif (x>=800 and x<=999):
    print(6)
elif (x>=1000 and x<=1199):
    print(5)
elif (x>=1200 and x<=1399):
    print(4)

elif (x>=1400 and x<=1599):
    print(3)
elif (x>=1600 and x<=1799):
    print(2)

else:
    print(1)

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

#define SZ(x) (((int)x.size()))

typedef long long ll;
typedef long double ld;

using namespace std;

ll s, y2, y3;

int main()
{
	cin >> s;
	y3 = (s + 999999999) / 1000000000;
	y2 = y3 * 1000000000 - s;
	cout << 0 << " " << 0 << " " << 1000000000 << " " << y2 << " " << 1 << " " << y3;
	return 0;
}


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

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

  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }

  int ans = -1;
  int num = 0;
  rep(i, N) {
    if (a[num] == 2) {
      ans = i + 1;
      break;
    }
    num = a[num] - 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
  }

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
  }

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
  }

// 最大公約数
fn gcd(a: i64, b: i64) -> i64 {
    let mut aa: i64 = if a > b { a } else { b };
    let mut bb: i64 = if a > b { b } else { a };
    while bb != 0 {
        let tmp = bb;
        bb = aa % tmp;
        aa = tmp;
    }
    return aa;
}

// 最小公倍数
fn lcm(a: i64, b: i64) -> i64 {
    a / gcd(a, b) * b
}

const LARGE_PRIME: usize = 1000000007;

fn main() {
    input! {
        x: usize
    }

    let mut find_prime = false;
    let mut number = x;
    while !find_prime {
        let root = (number as f64).sqrt() as usize;

        let mut is_prime = true;
        for i in 2..root {
            if (number % i == 0) {
                is_prime = false;
            }
        }
        if (is_prime) {
            break;
        }

        number += 1;
    }

    println!("{}", number);
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
V<ll>m[11];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    ll k;cin>>k;
    V<ll>need;
    for(ll i=0;i<k;i++){
        ll b;cin>>b;
        need.pb(b);
    }
    ll cnt=0;
    for(int bit=0;bit < (1<<n); bit++)
    {
        bool abc=1;
        for(ll i=0;i<need.size();i++){
            if(!(bit & (1<<need[i]))){
                abc=0;
                break;
            }
        }
        if(abc==0){cnt++;continue;}
        cout<<cnt++<<":";
        for(int i=0;i<n;i++)
            if(bit & (1<<i))
            {
                cout<<" ";
                cout<<i;
            }
        cout<<endl;
        
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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


int main(){

  int N,K;
  int x;
  int sum = 0;
  int i;

  cin >> N >> K;

  for(i=0;i<N;++i){
    cin >> x;
    if(x < K - x){
      sum += 2 * x;
    }else{
      sum += 2 * (K-x);
    }
  }

  cout << sum;
  
}

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

int main () {
  string A,B,C;
  cin >> A >> B >> C;
  
  if(A.back()==B.front() && B.back()==C.front()){
    cout <<"YES"<<endl;
  }
  else {
    cout << "NO" << endl;
  }
}
  
  

Measured memory_bytes: 256
n = int(input())
travel = [[0, 0, 0]]

for i in range(n):
    array = list(map(int, input().strip().split()))
    travel.append(array)


def func(num, query):
    for j in range(num):
        time_temp = query[j+1][0] - query[j][0]
        x_temp = abs(query[j+1][1] - query[j][1])
        y_temp = abs(query[j+1][2] - query[j][2])

        if not (x_temp + y_temp) % 2 == time_temp % 2:
            print('No')
            return
        if x_temp + y_temp > time_temp:
            print('No')
            return

    print('Yes')


func(num=n, query=travel)


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

const int MAXN = 1e5 + 5;
int dp[MAXN][3];
int val[MAXN][3];

int N;

int compute(int pos, int prev)
{
    if (pos == N)
        return 0;

    if (prev != 4 and dp[pos][prev] != -1)
        return dp[pos][prev];

    int max_val = 0;

    for (int i = 0; i < 3; ++i)
    {
        if (prev != i)
        {
            max_val = max(max_val, compute(pos + 1, i) + val[pos][i]);
        }
    }

    return dp[pos][prev] = max_val;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    cin >> N;

    memset(dp, -1, sizeof dp);

    for (int i = 0; i < N; ++i)
        cin >> val[i][0] >> val[i][1] >> val[i][2];

    cout << compute(0, 4) << '\n';

    return 0;
}


Measured memory_bytes: 8832
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

print("ABC" if S == "ARC" else "ARC")


Measured memory_bytes: 9912
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <stack>
#include <string>
using namespace std;
#define ll long long
const int maxn = 1e2 + 9;
const ll mod = 1e9 + 7;
int main() {
    int n[3];
    scanf("%d%d%d", &n[0], &n[1], &n[2]);
    sort(n, n + 3);
    if (n[1] == n[0] && n[0] != n[2])
        printf("Yes\n");
    else if (n[1] == n[2] && n[1] != n[0])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

int main(){

    int n,a,b;
    cin >> n >> a >> b;
    int tmp = n;
    while(tmp <= 1000){
        if(tmp >= a && tmp <= b){
            cout << "OK" << endl;
            return 0;
        }
        tmp += n;
    }
    
    cout << "NG" << endl;
    return 0;
}




Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int N,x,y;
void input()
{
    cin>>N>>x>>y;
}

void solve()
{
    Graph G(N+1);
    for (int i=1;i<N;++i) {
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    vi d; queue<int> q;
    map<int,int> M;
    for(int i=1;i<=N;++i){
        d.assign(N+1,-1);
        d[i]=0;
        q.push(i);
        while(!q.empty()){
            int v=q.front(); q.pop();
            for(auto nv:G[v]){
                if(d[nv]!=-1) continue;
                d[nv]=d[v]+1;
                M[d[nv]]++;
                q.push(nv);
            }
        }
    }
    for(int k=1;k<N;++k){
        cout<<M[k]/2<<"\n";
    }
}

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

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


void solve();

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

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  sort(all(a));
  ll ans = a.back();
  a.pop_back();
  rep(i, n - 2) {
    ans += a.back();
    if (i % 2) a.pop_back();
  }
  cout << ans << endl;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	ll k;
	cin >> k;
	for( int i = 0; i < k; ++i ){
		if( s.at(i) != '1' ){
			cout << s.at(i) << endl;
			return 0;
		}
	}
	cout << '1' << endl;
	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int n, now = 1, a;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    if (a == now)
      now++;
  }
  cout << (now == 1 ? -1 : n - now + 1) << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>
#define max	1000000000000000000
int main()
{
	long long n,i,sz,sf;
	long long a[10001],b[10001];
	sz=sf=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
		scanf("%lld",a+i);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",b+i);
		if((a[i]-b[i])<0)
			sf+=(a[i]-b[i])/2*2;
		else
			sz+=a[i]-b[i];
	}
	if((sf*(-1))/2>=sz)
		printf("Yes\n");
	else 
		printf("No\n");
	return 0;
}
//x*z这个数%y！=0 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22)cout << "bust" << endl;
  else cout << "win" << endl;
}


Measured memory_bytes: 256
def solve(n, s, p):
    ids = list(range(1,n+1))
    for _, _, id in sorted(zip(s, p, ids), key=lambda _: "%s-%03d" % (_[0], 100-_[1])):
        print(id)

n = int(input())
s, p = [], []
for i in range(n):
    _s, _p = input().split()
    s.append(_s)
    p.append(int(_p))
solve(n, s, p)

Measured memory_bytes: 3064