akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;
    unordered_map<char, int> mp;
    repall (c, s) { mp[c]++; }

    int cnt = 0;
    bool ok = true;
    repall (e, mp) {
        if (e.second != 2) ok = false;
    }
    yn(ok);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	int  A,B;
	cin >> A >> B;
	if (A == 1)A = 14;
	if (B == 1)B = 14;
	if (A>B) cout << "Alice" << endl;
	else if (B>A) cout << "Bob" << endl;
	else cout << "Draw" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
int main()
{
	ll a,b;
	cin>>a>>b;
	printf("%lld",lcm(a,b));
    return 0;
}

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

int main(){
	int D,N;
	cin>>D>>N;
	int ans=0;
	int i=0;
	while(true){
		if (i%100==0){
			ans=ans;
			i=i+1;
		}else{
			ans=ans+1;
			i=i+1;
		}
		if(ans==N){
			break;
		}
	}
	int I;
	I=(i-1)*pow(100,D);
	cout<<I<<endl;
	return 0;
}


Measured memory_bytes: 384
N = int(input())

a = 0
b = 1
c = 1
d = 8

mod = 10**9 + 7

for _ in range(N-1):
    a = (a * 10 + b + c) % mod
    b = (b * 9 + d) % mod
    c = (c * 9 + d) % mod
    d = (d * 8) % mod
print(a)

Measured memory_bytes: 63628
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int ans = 1;
	int X;
	cin>>X;
	for(int i=2;i<=X;++i){
		int ter = i;
		for(int j=i*i;j<=X;j*=i){
			ans = max(ans,j);
		}
	}
	cout<<ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,j,s,n1,n2,n3,n4,i,max;

  while(1){
    max=0;
    scanf("%d%d%d",&x,&y,&s);
    if(x==0&&y==0&&s==0)break;
    for(i=1;i<s;i++){
      n1=i;
      for(j=1;j<s;j++){
	n2=j;
	n3=(double)n1*(100+x)/100;
	n4=(double)n2*(100+x)/100;
	if(n3+n4!=s)continue;
	n3=(double)n1*(100+y)/100;
	n4=(double)n2*(100+y)/100;
	//  printf("%d %d %d\n",n1,n2,n1+n2);
	if(n3+n4>max)max=n3+n4;
      }
    }
    printf("%d\n",max);
    
  }
  return 0;
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

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

	int n; cin >> n;
	int a;
	string str = "APPROVED";
	rep(i, n) {
		cin >> a;
		if (a % 2) continue;
		if (a % 5 && a % 3) str = "DENIED";
	}
	cout << str << endl;


	return 0;
}


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

using namespace std;
using ll = long long;
int main() {
    int n,m;
    cin >> n >> m;
    int start = pow(10, n-1);
    int end = pow(10, n) - 1;
    if(n == 1)
        start--;
    int cond[m][2];    
    int i;
    for(i=0;i<m;i++)
    {
        cin >> cond[i][0] >> cond[i][1];
    }
    for(i=start;i<=end;i++)
    {
        int j;
        for(j=0;j<m;j++)
        {
            int pos = cond[j][0];
            pos = n - pos;
            int divi = pow(10, pos);
            int dig = i/divi;
            if(dig%10 != cond[j][1])
                break;
        }
        if(j == m)
        {
            cout << i << '\n';
            break;
        }
    }
    if(i == end+1)
        cout << -1 << '\n';
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));


int n; 

int main() {
    #define file "in"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    int cOdd = 0; 
    cin >> n; 
    for (int i = 1; i <= n; i++) {
    	int x; 
    	cin >> x; 
    	if (x % 2 == 1) cOdd++; 
    }
    if (cOdd % 2 == 0) {
    	cout << "YES"; 
    } else {
    	cout << "NO"; 
    }
    return 0;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, m;

int main() {
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1 << endl;
    } else if (n == 1) {
        cout << m-2 << endl;
    } else if (m == 1) {
        cout << n-2 << endl;
    } else {
        cout << (n-2)*(m-2) << endl;
    }
}
































Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
  int n;
  string odr;
  while( cin >> n,n )
    {
      int di[6] = {5,4,1,3,6,2};
      int top_sum = 1; 
      while(n--){
	cin >> odr;
	if(odr == "North"){
	  swap(di[0],di[2]);
	  swap(di[2],di[5]);
	  swap(di[4],di[5]);
	  top_sum+=di[2];
	}else if(odr == "East"){
	  swap(di[1],di[2]);
	  swap(di[1],di[3]);
	  swap(di[1],di[4]);
	  top_sum+=di[2];
	}else if(odr == "West"){
	  swap(di[2],di[3]);
	  swap(di[1],di[3]);
	  swap(di[3],di[4]);
	  top_sum+=di[2];
	}else if(odr == "South"){
	  swap(di[0],di[2]);
	  swap(di[0],di[5]);
	  swap(di[0],di[4]);
	  top_sum+=di[2];
	}else if(odr == "Right"){
	  swap(di[0],di[1]);
	  swap(di[1],di[5]);
	  swap(di[3],di[5]);
	  top_sum+=di[2];
	}else if(odr == "Left" ){
	  swap(di[0],di[3]);
	  swap(di[3],di[5]);
	  swap(di[5],di[1]);
	  top_sum+=di[2];
	}
    }
   cout << top_sum << endl;
    }
}

Measured memory_bytes: 1208
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;



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

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

ll n, m;

int main() {
	cin >> n >> m;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] /= 2;
	}

	ll l = 1;
	for (int i = 0; i < n; i++) {
		l = lcm(a[i], l);
		if (l > m) {
			cout << "0" << endl;
			return 0;
		}
	}
	ll ans = (m / l + 1) / 2;
	int two = 1;
	while (!(l & 1)) {
		l >>= 1;
		two <<= 1;
	}
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (a[i] % two) {
			ok = false;
		}
	}
	if (ok) {
		cout << ans << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}


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

map<string, int> p;
map<string, int> k;
map<string, string*> q;

int min(string item) {
  int buy = p[item];
  if (q.find(item) != q.end()) {
    int trn = 0;
    for (int j=0; j<k[item]; j++) {
      trn += min(q[item][j]);
    }
    if (trn < buy) {
      return trn;
    }
  }
  return buy;
}

int main(void) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int j=0; j<n; j++) {
      string i;
      cin >> i;
      cin >> p[i];
    }
    int m;
    cin >> m;
    for (int j=0; j<m; j++) {
      string o;
      cin >> o;
      cin >> k[o];
      q[o] = new string[k[o]];
      for (int l=0; l<k[o]; l++) {
	cin >> q[o][l];
      }
    }
    string item;
    cin >> item;
    cout << min(item) << endl;
    if (!q.empty()) {
      for (map<string, string*>::iterator j=q.begin(); j!=q.end(); j++) {
	delete[] j->second;
      }
      q.clear();
    }
  }
  return 0;
}

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

int main(){
sp;
ll a,b,c;
cin>>a>>b>>c;
ll canhear=b/a;
canhear=min(canhear,c);
cout<<canhear;
return 0;}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] num =new int[w];
		for(int i=0;i<w;i++){
			num[i]=i+1;
		}

		String [][] scombo =new String[n][2];
		int [][] combo =new int[n][2];

		//??\?????????????????¨????????\?????????????????§????????????
		for(int i=0;i<n;i++){
			String str =sc.next();
			scombo[i]=str.split(",");
		}



		//????????????????????°??????????????????
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++){
				combo[i][j]=Integer.parseInt(scombo[i][j]);
			}
		}
		//????????????
		for(int i=0;i<n;i++){
			int x = num[combo[i][0]-1];
			num[combo[i][0]-1]=num[combo[i][1]-1];
			num[combo[i][1]-1]=x;
		}
		//??????
		for(int i=0;i<w;i++){
			System.out.println(num[i]);
		}


	}

}

Measured memory_bytes: 25808
import numpy as np
[x, N] = list(map(int, input().split()))
if N != 0:
  P = list(map(int, input().split()))
  P_max = max(P) + 2
  P_mini = min(P) - 1
  if P_mini <= x <= P_max:
    A = list(range(P_mini, P_max))
    for p in P:
      A.remove(p)
    delta = [np.abs(x - a) for a in A]
    ind = delta.index(min(delta))
    ans = A[ind]
  else:
    ans = x
else:
  ans = x
    
print(ans)

Measured memory_bytes: 27048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t;cin >> n >> t;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<int>> dp(100001,vector<int>(t+1,-1));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        vector<vector<int>> tp(100001,vector<int>(t+1,-1));
        for(int j=0;j<=10000;j++){
            for(int k=0;k<=t;k++){
                if(dp[j][k]==-1){
                    continue;
                }
                chmax(tp[j][k],dp[j][k]);
                if(k+c[i]<=t){
                    int u=dp[j][k],v=dp[j][k]-j;
                    int p=max(u+a[i],v+b[i]),q=min(u+a[i],v+b[i]);
                    chmax(tp[p-q][k+c[i]],p);
                    p=max(u+b[i],v+a[i]),q=min(u+b[i],v+a[i]);
                    chmax(tp[p-q][k+c[i]],p);
                }
            }
        }
        for(int j=0;j<=10000;j++){
            for(int k=0;k<=t;k++){
                dp[j][k]=tp[j][k];
            }
        }
    }
    int ans=0;
    for(int i=0;i<=10000;i++){
        for(int j=0;j<=t;j++){
            chmax(ans,dp[i][j]-i);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 88956
n=int(input())
#ab=[list(map(int,input().split())) for i in range(n)]
d=[]
for i in range(n):
  x,y=map(int,input().split())
  d.append([y,x])
d.sort()
time=0
flag=True
for i in range(n):
  time+=d[i][1]
  if time>d[i][0]:
    flag=False
    break
if flag==True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 36668
def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        # y = n // i
        # y = (y+1)*y*i//2
        ans += ((n//i)+1) * (n//i) * i // 2
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1],ans=0;
	map<ll,ll> mp;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		mp[ar[i]]++;
	}

	for(auto it:mp){
		k=it.sc;
		ans+=(k*(k-1))/2;
	}

	for(i=1;i<=n;i++){
		k=mp[ar[i]];
		l=ans-(k*(k-1))/2;
		k--;
		l+=(k*(k-1))/2;
		cout<<l<<endl;
	}
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int gauss_jordan(vector<ll>& mat){
    int n = mat.size();
    int ret = 0;
	REP(i,n) if(mat[i]) {
		ret++;
		int x=0;
		while((1LL<<(x+1))<=mat[i]) x++;
		for(int y = i+1; y<n; y++) if(mat[y] & (1LL<<x)) mat[y] ^= mat[i];
	}
    return ret;
}

int main(void)
{
    int T;
    cin >> T;
    while(T--){
        [](){
            int N;
            cin >> N;
            vector<ll> A(N);
            for (int i = 0; i < N; i++) {
                cin >> A[i];
            }
            string S;
            cin >> S;
            vector<ll> M;
            int pre_rank = 0;
            RREP(i, N){
                M.pb(A[i]);
                int rank = gauss_jordan(M);
                if(S[i]=='1'&&pre_rank!=rank){
                    pr(1);
                    return;
                }
                pre_rank = rank;
            }
            pr(0);
        }();
    }
}

Measured memory_bytes: 3556
import math

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

x, y = map(int,input().split())

'''
(1, 2)をn回、(2, 1)をm回
'''

if 2*x-y >= 0 and 2*y-x >= 0 and (2*x-y) % 3 == 0 and (2*y-x) % 3 == 0:
    n = int((2*y-x)/3)
    m = int((2*x-y)/3)

    p = 10 ** 9 + 7
    N = n + m  # N は必要分だけ用意する
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]

    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

    ans = cmb(N, m, p)

    print(ans)
else:
    print(0)


Measured memory_bytes: 82288
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)n;i++)

int n,A[50];

bool solve(int i,int m){
    if(m==0) return true;
    if(i>=n) return false;
    return solve(i+1,m) || solve(i+1,m-A[i]);
}

int main(){
    int q,m;
    cin>>n;
    Rep(i,n) cin>>A[i];
    cin>>q;
    Rep(i,q) {
        cin>>m;
        if(solve(0,m)){
            cout<<"yes"<<endl;
        }
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
constexpr int MAXN = 1e5 + 5;
#define pii pair<int, int>
typedef long long LL;
typedef unsigned long long uLL;
using namespace std;
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while(isdigit(ch)) x = (x << 3) + (x << 1) + ch -48, ch = getchar();
    return x * f;
}
int n, r, ans;
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> r;
	if (n >= 10) ans = r;
	else ans = r + 100 * (10 - n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=998244353;
const llint moe=998999971;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,n;cin>>n;
	llint ans=0;
	string str;cin>>str;
	/*
	ローリングハッシュ
	+ ha+=P
	- hs-=P
	> P*=100;
	< P/=100;
	*/
	llint gya=1,gyb=1,bb=100;
	for(int h=0;h<30;h++){
		if((mod-2)&(1<<h)){gya*=bb;gya%=mod;}
		bb*=bb;bb%=mod;
	}
	bb=100;
	for(int h=0;h<30;h++){
		if((moe-2)&(1<<h)){gyb*=bb;gyb%=moe;}
		bb*=bb;bb%=moe;
	}
	vector<llint>cd(n+1);
	vector<llint>ce(n+1);
	llint cp=1,cq=1;
	for(i=0;i<n;i++){
		if(str[i]=='>'){cp*=100;cq*=100;cp%=mod;cq%=moe;}
		if(str[i]=='<'){cp*=gya;cq*=gyb;cp%=mod;cq%=moe;}
		if(str[i]=='+'){cd[i]=cp;ce[i]=cq;}
		if(str[i]=='-'){cd[i]=mod-cp;ce[i]=moe-cq;}
	}
	for(i=n-1;i>=0;i--){cd[i]+=cd[i+1];cd[i]%=mod;ce[i]+=ce[i+1];ce[i]%=moe;}
	map<pair<llint,llint>,int>ma;
	for(i=0;i<=n;i++){ma[mp(cd[i],ce[i])]++;}
	llint apd=1,ahd=0,ape=1,ahe=0;
	llint Sd=cd[0];//全体のローリングハッシュ
	llint Se=ce[0];
	for(i=0;i<n;i++){
		ma[mp(cd[i],ce[i])]--;
		llint tdr=(Sd-ahd-apd*Sd)%mod;
		llint ter=(Se-ahe-ape*Se)%moe;
		if(tdr<0){tdr+=mod;}
		if(ter<0){ter+=moe;}
		ans+=ma[mp(tdr,ter)];
		if(str[i]=='>'){apd*=100;ape*=100;apd%=mod;ape%=moe;}
		if(str[i]=='<'){apd*=gya;ape*=gyb;apd%=mod;ape%=moe;}
		if(str[i]=='+'){ahd+=apd;ahe+=ape;ahd%=mod;ahe%=moe;}
		if(str[i]=='-'){ahd+=mod-apd;ahe+=moe-ape;ahd%=mod;ahe%=moe;}
	}
	cout<<ans<<endl;
	//ハッシュ衝突?
	return 0;
}

Measured memory_bytes: 35732
s = input()
q = int(input())

cnt = 0
left = ''
right = ''
for i in range(q):
    q_very = input()

    #print(q_very)
    if q_very[0] == '1':
        #print('t is 1')
        cnt += 1
    else:
        instruction = q_very.split()
        # 反転していない
        if cnt % 2 == 0:
            if instruction[1] == '1':
                left = instruction[2] + left
            else:
                right = right + instruction[2]
        else: # 反転している
            if instruction[1] == '1':
                right = right + instruction[2]
            else:
                left = instruction[2] + left

s = left + s + right

if cnt % 2 != 0:
    s = s[::-1]
print(s)

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    //2次元累積和  
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin,coutの高速化
    int n,m,q;
    cin>>n>>m>>q;
    vector<int> l(m),r(m),p1(q),p2(q);
    vector< vector<int>> score(n,vector<int> (n,0));
    map<pair<int,int>,int> p;
    rep(i,m){
        cin>>l[i]>>r[i];
        l[i]--,r[i]--;
        p[{l[i],r[i]}]++;
    }
    for(auto c:p){
        int start = c.first.first;
        int goal = c.first.second;
        int point = c.second;
        for(int i=start;i>=0;i--){
            score[i][goal] += point;
        }
    }
    rep(i,n){
        for(int j=1;j<n;j++){
            score[i][j] +=score[i][j-1];
        }
    }
    /*
    rep(i,n){
        rep(j,n){
            cout<<score[i][j]<<" ";
        }
        cout<<endl;
    }*/
    rep(i,q){
        cin>>p1[i]>>p2[i];
        p1[i]--,p2[i]--;
        cout<<score[p1[i]][p2[i]]<<endl;

    }
}

Measured memory_bytes: 12912
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>
namespace std {
	template<>
	struct hash<typename std::pair<int, int>> {
		size_t operator()(const std::pair<int, int>& pair) const {
			return (pair.first << 16) | (pair.second);
		}
	};
}
std::pair<int, int> pair(int a, int b) {
	if (a > b) std::swap(a, b);
	return std::make_pair(a, b);
}
struct Query {
	int a, b, c;
	bool operator<(const Query& query) const {
		return a == query.a ? (c == 0 && query.c == 1) : a < query.a;
	}
};
int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n, m, t; std::cin >> n >> m >> t;
	std::vector<int> in_time(n);
	std::unordered_set<int> room; room.reserve(100);
	std::unordered_map<std::pair<int, int>, int> history; history.reserve(m * 100);
	std::vector<Query> query(m); 
	for (auto& q : query) {
		std::cin >> q.a >> q.b >> q.c; --q.b;
	}
	std::sort(query.begin(), query.end());
	for (const auto q:query) {
		if (q.c == 0) {
			room.erase(q.b);
			for (const auto other : room) {
				history[pair(other, q.b)] += q.a - std::max(in_time[other], in_time[q.b]);
			}
		}
		else {
			room.insert(q.b);
			in_time[q.b] = q.a;
		}
	}
	for (const auto self : room) {
		for (const auto other : room) if (self < other) {
			history[pair(self, other)] += t - std::max(in_time[self], in_time[other]);
		}
	}
	std::vector<std::pair<int, int>> friends(n, std::make_pair(0, -1)); friends[0].first = 1;
	for (const auto p : history) {
		if (p.second == 0) continue;
		if (friends[p.first.first].second < p.second) {
			friends[p.first.first] = std::make_pair(p.first.second, p.second);
		}
		else if (friends[p.first.first].second == p.second && friends[p.first.first].first > p.first.second) {
			friends[p.first.first] = std::make_pair(p.first.second, p.second);
		}
		if (friends[p.first.second].second < p.second) {
			friends[p.first.second] = std::make_pair(p.first.first, p.second);
		}
		else if (friends[p.first.second].second == p.second && friends[p.first.second].first > p.first.first) {
			friends[p.first.second] = std::make_pair(p.first.first, p.second);
		}
	}
	for (const auto f : friends) {
		std::cout << f.first + 1 << '\n';
	}
}



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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, _ = readnums()
    d = set(readstrs())
    for i in range(N, 100000):
        for digit in tuple(str(i)):
            if digit in d:
                break
        else:
            print(i)
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int x,y,flag=0,cnt=0;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        cnt=i*2+(x-i)*4;
        if(cnt==y){
            flag=1;
        }
        cnt=0;
    }
    if(flag==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
import java.math.*;
import java.util.*;
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			long h2 = h;
			int num = 0;
			long sum = 0;
			
			
			while(h2 >0 ) {
				h2 = h2/2;
				num++;
			}
			
			for(int i=0;i<num;i++) {
				sum += Math.pow(2, i);
			}
			
			System.out.println(sum);
			
		}
				
	}

Measured memory_bytes: 23124
import java.util.*;

class Main{
	public static void main(String args[]){
		final int hTos = 3600, mTos = 60;
		Scanner sc = new Scanner(System.in);
		int S, h, m, s;
		
		S = sc.nextInt();
		
		h = S / hTos;
		int a = S % hTos;
		
		m = a / mTos;
		s = a % mTos;
		
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26232
import java.io.*;
import java.util.*;

public class Main { //Runnableを実装する
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] s = {a, b, c};
        Arrays.sort(s);
        System.out.println(s[2] * 10 + s[1] + s[0]);
    }

}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(void){
	int a, b, c;
	
	cin >> a>> b >> c ;
	int min = a + b;
	if(min > b + c){
		min = b + c;
	}
	if(min > a + c){
		min = a + c;
	}

	cout << min;

	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<ll> A;
  for(int i=0; i<N; i++){
    ll a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end(),greater<int>());
  vector<ll> x(2,0);
  int j=0;
  for(int i=0; i<N-1; i++){
    if(A[i] == A[i+1]){
      x[j] = A[i];
      i++;
      j++;
      if(j >= 2){
        break;
      }
    }
  }
  ll ans;
  ans = x[0]*x[1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  REP(i, n - 1) {
    if(s[i] != s[i + 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define size_of(a) (int)(a).size()
#define minit(a,b) memset(a,b,sizeof(a))

typedef pair< int, int > pii;

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

int R, C, M, eunit[55][55], eon[55][55], eoff[55][55];
string grid[55];

int sx, sy, gx, gy;
bool vis[55][55];
vector< int > tv[55][55];

bool dfs(int x, int y, vector< pii >& path) {
	if (x == gx && y == gy) return true;
	
	path.push_back(pii(x, y));
	
	vis[y][x] = true;
	
	for_(d,0,4) {
		int nx = x + dx[d], ny = y + dy[d];
		if (nx < 0 || C <= nx || ny < 0 || R <= ny) continue;
		if (grid[ny][nx] == '#') continue;
		if (vis[ny][nx]) continue;
		if (dfs(nx, ny, path)) return true;
	}
	
	path.pop_back();
	
	return false;
}

int main() {
	cin >> R >> C >> M;
	for_(i,0,R) cin >> grid[i];
	
	for_(i,0,R) for_(j,0,C) cin >> eunit[i][j];
	for_(i,0,R) for_(j,0,C) cin >> eon[i][j];
	for_(i,0,R) for_(j,0,C) cin >> eoff[i][j];
	
	vector< pii > euler;
	
	cin >> sy >> sx;
	
	for_(i,1,M) {
		cin >> gy >> gx;
		vector< pii > path;
		
		minit(vis, 0);
		
		dfs(sx, sy, path);
		
		int m = size_of(path);
		for_(j,0,m) euler.push_back(path[j]);
		sx = gx; sy = gy;
	}
	
	euler.push_back(pii(gx, gy));
	int m = size_of(euler), ans = 0;
	
	for_(i,0,m) {
		pii p = euler[i];
		int x = p.first, y = p.second;
		tv[y][x].push_back(i);
	}
	
	for_(y,0,R) for_(x,0,C) {
		int m = tv[y][x].size();
		
		if (m > 0) {
			for_(i,0,m-1) ans += min((tv[y][x][i + 1] - tv[y][x][i]) * eunit[y][x], eoff[y][x] + eon[y][x]);
			ans += eon[y][x] + eoff[y][x];
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 19488
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007


using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}

int main()
{

    string s,t;
    cin>>s>>t;
    lg l = s.length();
    lg ans=0;
    for(lg i=0;i<l;i++)
        if(s[i]!=t[i]) ans++;

    cout<<ans<<endl;

}


Measured memory_bytes: 3908
import heapq
import math
n,m = map(int,input().split())
lst = [int(x) * (-1) for x in input().split()]
heapq.heapify(lst)
for use_cnt in range(m):
    num = heapq.heappop(lst) * -1
    nxt_num = math.floor(num / 2)
    heapq.heappush(lst,nxt_num * -1)
print(sum(lst) * (-1))

Measured memory_bytes: 14532
N = int(input())
A = list(map(int, input().split()))
max_A = 10**6+1

dp = [0] * (max_A)
for i in range(N):
    dp[A[i]] += 1

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

pairwise = True

for i in primes(max_A):
    cnt = 0
    # 素数の倍数がdp配列に存在するか。自分以外にあれば2以上になる
    for j in range(i, max_A, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False

if pairwise:
    print("pairwise coprime")
    exit()

from math import gcd

g = 0
for i in range(N):
    g = gcd(g, A[i])
if g == 1:
    print("setwise coprime")
else:
    print("not coprime")



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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
        long K = scan.nextLong();
        long [] A = new long [100001];
        Arrays.fill(A, 0);
        long sum = 0;
        for(int i=0;i<N;i++){
        	int a = scan.nextInt();
        	long B = scan.nextLong();
        	A[a] += B; 
        }
        for(int i=0;i<100001;i++){
        	sum +=A[i];
        	if(sum>=K){
        		System.out.println(i);
        		break;
        	}
        }
	}

}

Measured memory_bytes: 65256
let rec size = function
    | 0 -> 1
    | n -> 3 + 2 * size (n - 1) 

let rec full = function
    | 0 -> 1
    | n -> 1 + 2 * full (n - 1)

let rec f x = function
    | 0 -> if x > 0 then 1 else 0
    | n -> let m = (size n) / 2 + 1 in
        if x < m
        then f (x - 1) (n - 1)
        else (full (n - 1)) + 1 + f (x - m) (n - 1)

let () = Scanf.scanf "%d %d" @@ fun n x ->
    f x n |> Printf.printf "%d"


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

int main() {
  int n,m;
  cin >> n >> m;
  int p[m];
  string s[m];

  for(int i = 0;i < m;i++){
    cin >> p[i] >> s[i];
  }


  int tmp[n+1];
  int tmp1[n+1];
  for(int i = 0;i <= n;i++){
    tmp[i] = 0;
    tmp1[i] = 0;
  }

  
  for(int i = 0;i < m;i++){
    if(s[i] == "AC"){
      tmp[p[i]] = 1;
    }
    if(s[i] == "WA" && tmp[p[i]] == 0){
      (tmp1[p[i]])++;
    }
  }

  int tt=0;
  int ttt=0;

  for(int i = 1;i <= n;i++){
    tt += tmp[i];
    if(tmp[i] != 0)
      ttt += tmp1[i];
  }


  cout << tt << " " << ttt << endl;
}


Measured memory_bytes: 6912
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::string s, std::string t, long long a, long long b, std::string u){
    if(s == u)
        --a;
    if(u == t)
        --b;
    cout << a << " " << b << endl;
}


signed main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n,k; cin >> n >> k;

    cout << n-k+1 << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int dis[205][205];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, r; cin >> n >> m >> r;
    rep(i,n) rep(j,n) dis[i][j] = INF;
    vector<int> R(r);
    rep(i,r) {
        cin >> R[i];
        R[i]--;
    }
    rep(i,m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        dis[a][b] = min(dis[a][b],c);
        dis[b][a] = min(dis[b][a],c);
    }
    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    sort(ALL(R));
    int ans = INF;
    do {
        int cost = 0;
        rep(i,R.size()-1) {
            cost += dis[R[i]][R[i+1]];
        }
        ans = min(ans, cost);
    }while(next_permutation(ALL(R)));

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

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	ll X, Y; cin >> X >> Y;

	ll tmp = X;
	ll ans = 0;
	while(tmp <= Y){
		ans++;
		tmp *= 2;
	}
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll b = 1; b * b <= n; b++) {
        if (n % b == 0) {
            ll m = n / b;
            if (m - 1 > b) {
                ans += m - 1;
                // cout << m - 1 << "\n";
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var x = new int[n];
		var y = new int[n];
		for (var i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();

		var min1 = Integer.MAX_VALUE;
		var max1 = Integer.MIN_VALUE;
		for (var i = 0; i < n; i++) {
			min1 = Math.min(min1, x[i] + y[i]);
			max1 = Math.max(max1, x[i] + y[i]);
		}
		var min2 = Integer.MAX_VALUE;
		var max2 = Integer.MIN_VALUE;
		for (var i = 0; i < n; i++) {
			min2 = Math.min(min2, x[i] - y[i]);
			max2 = Math.max(max2, x[i] - y[i]);
		}

		var max = Math.max(max1 - min1, max2 - min2);
		System.out.println(max);
	}
}


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

#define ll long long
#define ld long double
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update > ost;
// name.find_by_order( x ) or name.order_of_key( x )

const int maxn = 2e5 + 10, maxv = 1e6 + 10, maxlog = 20;
const int inf = 1e9 + 1;
const int MOD = 1e9 + 7;
const ll INF = 4e18 + 1;
const double eps = 1e-9;

void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }

void solve() {
	int n, k, K;
	cin >> n >> K;
	vi p( n, 0 );
	vector < ll > c( n, 0 );
	for( int i = 0;i < n;i++ ) { cin >> p[ i ];p[ i ]--; }
	for( int i = 0;i < n;i++ ) cin >> c[ i ];
	
	ll ans = -INF;
	for( int i = 0;i < n;i++ ) {
		k = K - 1;
		vi vis( n, -1 );
		vis[ i ] = 0;
		int x = i;
		vi path;
		path.pb( x );
		
		int start = -1;
		while ( 1 ) {
			x = p[ x ];
			if ( vis[ x ] != -1 ) { start = x;break; }
			path.pb( x );
		}
		
		ll sum = 0;
		ll sol = c[ i ];
		int pl = 0;
		for( int j = 0;j < min( k, pl );j++ ) { 
			if ( path[ j ] == start ) pl = j;
			sum += c[ path[ j ] ];
			sol = max( sol, sum );
		}
		
		k = max( 0, k - pl );
		ll cycle = 0;
		for( int j = pl;j < (int)path.size();j++ ) cycle += c[ path[ j ] ];
		
		if ( cycle <= 0 ) {
			ll sum1 = 0;
			ll maxi = -INF;
			for( int j = pl;j < min( pl + k, (int)path.size() );j++ ) { sum1 += c[ path[ j ] ];maxi = max( maxi, sum1 ); }
			sum += maxi;
			
			sol = max( sol, sum );
			ans = max( ans, sol );
			continue;
		}
		ll sz = path.size() - pl;
		//cout << << "\n";
		sum += cycle * ( k / sz );
		k %= sz;
		ll sum1 = 0;
		ll maxi = 0;
		for( int j = pl;j <= pl + k;j++ ) { sum1 += c[ path[ j ] ];maxi = max( maxi, sum1 ); }
		sum += maxi;
		sol = max( sol, sum );
		ans = max( ans, sol );
	}
	cout << ans << "\n";
}

int main() {
	int t = 1;
	//cin >> t;
	while ( t-- ) solve();
	return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<string>
 
using namespace std;
 
int main()
{
    int n;
    string t_cade,h_cade;
    int t_point=0,h_point=0;
    cin >>n;
 
    for(int i=0;i<n;i++){
        cin>>t_cade>>h_cade;
 
        if(t_cade==h_cade){
            t_point++;
            h_point++;
        }else{
            int index=0;
            while (t_cade[index] == h_cade[index]){
                index++;
            }
 
            if(t_cade[index] > h_cade[index]){
                t_point+= 3;
            }else{
                h_point += 3;
            }
        }
    }
    cout<<t_point<<" "<< h_point<<endl;
 
    return 0;
}

Measured memory_bytes: 1208
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 10000005; 
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll n;
    cin >> n;
    map<ll,ll> vis;
    ll rem = 7%n;
    vis[rem] = 1;
    ll ans = 1;
    for(ll i=2;;i++)
    {
        if(rem==0)  
        {
            cout<<i-1;
            return;
        }
        rem = (rem * 10 + 7)%n;
        if(vis[rem])
        {
            cout<<-1;
            return;
        }
        vis[rem] = 1;
    }
}

int main()
{
    ll t = 1;
 //   cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 66120
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;

vector<ll> value;
ll N;

void update(ll i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = max(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}

ll query(ll a, ll b, ll k, ll l, ll r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
  //  cout<<"a"<<a<<"b"<<b<<"k"<<k<<"l"<<l<<"r"<<r<<endl;
    if (r <= a || b <= l) return 0; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b){
  //    cout<<"k"<<value[k]<<endl;
          return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
      // に完全に含まれる
    }

    else {
        ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
    //    cout<<"c1"<<c1<<"c2"<<c2<<endl;
        return max(c1, c2); // 左右の子の値の min を取る
    }
}

int main() {
  ll n;
  cin>>n;
  vector<ll> h(n);
  vector<ll> a(n);
  rep(i,n)cin>>h[i];
  rep(i,n)cin>>a[i];
  N=1;
  while (N<=n)N*=2;
//  cout<<N<<endl;
  value=vector<ll>(2*N-1,0);

  ll dp1[n+1];

  rep(i,n){
    ll now=query(0,h[i],0,0,N);
    update(h[i],now+a[i]);
  //  cout<<h[i]<<"now"<<now<<"na"<<(now+a[i])<<"i"<<i<<endl;
  }
ll ans=0;
ans=query(0,n+1,0,0,N);
cout<<ans;

}




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

ll n;
ll h[200200], a[200200], bit[200200];

ll maxi(ll i){
    ll res = 0;
    while(i>0){
        res = max(res,bit[i]);
        i -= i & -i;
    }
    return res;
}
void update(ll i, ll x){
    while(i<=n){
        bit[i] = max(bit[i],x);
        i += i & -i;
    }
}

ll main(){
    cin >> n;
    rep(i,n) cin >> h[i];
    rep(i,n) cin >> a[i];

    rep(i,n) update(h[i], a[i] + maxi(h[i]));
    cout << maxi(n) << endl;
    return 0;
}
*/


Measured memory_bytes: 10380
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int k;
    cin >> k;
    ll ans = 0ll;
    ans = k*pow(k-1, n-1);
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int t=(a[n]+1)/2,max=a[n],ans=0;
	for(int i=1;i<=n;i++)
		if(abs(t-a[i])<max)
		{
			max=abs(t-a[i]);
			ans=a[i];
		}
	cout<<a[n]<<" "<<ans<<endl;
}

Measured memory_bytes: 640