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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e9;
const int mod = 1e9 + 7,
N = 2002 + 11;

int n, a[N], low[N], high[N], cnt[N];
vector <int> ke[N], child[N];
bool cmp(int v1, int v2) {
    return low[v1] > low[v2];
}
void Dfs(int u, int p) {
    cnt[u] = a[u];
    low[u] = high[u] = 0;
    child[u].clear();
    for (auto v: ke[u])
        if (v != p) {
            Dfs(v, u);
            if (cnt[v])
                child[u].push_back(v);
            cnt[u] += cnt[v];
            high[v] += cnt[v];
            low[v] += cnt[v];
            high[u] += high[v];
        }
    if (child[u].size() <= 1) {
        for (auto v: child[u])
            low[u] += low[v];
        return;
    }
    sort(child[u].begin(), child[u].end(), cmp);
    int amax = low[child[u][0]];
    low[u] = high[u] % 2;
    int sum = 0;
    for (auto v: child[u])
        sum += min(high[v], amax - abs(amax - low[v]) % 2);
    low[u] = max(low[u], 2 * amax - sum);
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    read(n);
    for (int i = 1; i <= n; i++)
        a[i] = readch() - '0';
    for (int i = 1, u , v; i < n; i++) {
        read(u);
        read(v);
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    int res = INT_MAX;
    for (int root = 1; root <= n; root++) {
        Dfs(root, root);
        if (low[root] == 0)
            res = min(res, high[root] / 2);
    }
    if (res == INT_MAX)
        cout << -1;
    else
        cout << res;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

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

typedef long long ll;

using namespace std;

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

    vector<int> students(N+1);

    REP(i, N)
    {
        int A;
        cin >> A;
        students[A] = i;
    }

    REP(i, N) cout << students[i] << ' ';
    cout << endl;

    return 0;
}

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

using namespace std;

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

int main() {

    int x, y, z;

    cin >> x >> y >> z;

    swap(x, y);
    swap(x, z);

    cout << x << " " << y << " " << z << endl;

    return 0;
}


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

int main() {
	int N, T;
	cin >> N >> T;
	int before;
	cin >> before;
	int sum = 0;
	for (int i = 1; i < N; i++) {
		int now;
		cin >> now;
		sum += min(T, now - before);
		before = now;
	}
	cout << sum + T << endl;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s;cin>>s;
  deque<char> S;
  for(int i = 0; s.size() > i; i++){
    S.push_back(s[i]);
  }
  int q;cin>>q;
  bool rev = false;
  for(int i = 0; q > i; i++){
    int n;cin>>n;
    if(n==1){
      if(rev)rev = false;
      else rev = true;
    }else{
      int z;cin>>z;z=((z+rev)%2);
      char c;cin>>c;
      if(z==1){
        S.push_front(c);
      }else{
        S.push_back(c);
      }
    }
  }
  if(rev){
    for(int i = 0; S.size() > i; i++){
      cout << S[S.size()-i-1];
    }
  }else{
    for(int i = 0; S.size() > i; i++){
      cout << S[i];
    }
  }
  cout << endl;

}

Measured memory_bytes: 976
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include <bits/stdc++.h>
#define YES "Yes"
#define NO "No"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=5*1e5+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;

////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
void init(){
	
}
int A,B,C,D;
LL solve(){
		cin >> A >> B >> C >> D;
		LL gcd=__gcd(B,D);
		//cout << B <<" " <<D << " " << C <<" "<< gcd<<endl; 
		if(A<B) return false;
		if(B>D) return false; 
		if(B==D){
			return A%B<=C;
		}
		A%=B;
		if(A>C) return false;
		if(B<=C+1) return true;
		A+=(C-A)/gcd*gcd+gcd;
		if(A<B) return false;
	
	return true;
}
signed main(){
	int T;
	cin >> T;
	REP(i,T){
		YESNO;
	}
	return 0;
}

Measured memory_bytes: 13184
# import math
# import statistics
a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(i)
#e1,e2 = map(int,input().split())
#f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# zoro = int(a[0]*len(a))
zyun= len(a)*9+int(a[0])
zoro=0
z = zyun//9
af= zyun%9
if af==0:
    if int(a)<=int(str(9)*(z-1)):
        print(int(str(9)*(z-1)))
    else:
            print(str(1)*(z))
else :
    if int(a)<=int(str(af)*(z)):
        print(int(str(af)*(z)))
    else:
        print(int(str(af+1)*(z)))




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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,ans=0;
    cin>>n;
    ll a[n];
    forn(i,n) cin>>a[i];
    multiset<ll> s; s.insert(a[0]);
    for(i=1;i<n;i++){
        auto it=s.lower_bound(a[i]);
        if(it!=s.begin()) {it--; s.erase(it);}
        s.insert(a[i]);
    }
    cout<<sz(s) el;
}

main()
{
//      fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=100500;
string s;
int d;
const int mod=1e9+7;
int dp[N][100][2];
int add(int a, int b){
	a+=b;
	if(a>=mod)a-=mod;
	return a;
}
int f(int i, int r, bool b){
	if(i==SZ(s))return !r;
	int &q=dp[i][r][b];
	if(q!=-1)return q;
	q=0;
	for(int j=(i==0);j<=9;j++){
		if(!b&&j>s[i]-'0')continue;
		q=add(q,f(i+1,(r+j)%d,b|(j<s[i]-'0')));
	}
	return q;
}
int f2(int i, int r, bool b){
	if(i==SZ(s)-1)return !r;
	int &q=dp[i][r][b];
	if(q!=-1)return q;
	q=r==0;
	for(int j=(i==0);j<=9;j++)q=add(q,f2(i+1,(r+j)%d,b));
	return q;
}
int main(){FIN;
	cin>>s>>d;
	memset(dp,-1,sizeof dp);
	int r=f2(0,0,0)-1+mod;r%=mod;
	memset(dp,-1,sizeof dp);
	r=add(r,f(0,0,0));
	cout<<r<<"\n";
}

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

int main(){
    long long n, k,ans=0;
  	cin >> n >> k;
    if(k%2==0){
      ans = pow(n/k, 3)+pow(n/(k/2)-n/k, 3);
    }else{
      ans = pow(n/k, 3);
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

lint mod_pow(lint x,lint n,lint MOD){
  if(n==0)return 1;
  lint res=mod_pow(x*x%MOD,n/2,MOD);
  if(n%2==1)res=res*x%MOD;
  return res;
}

int main(){
  lint n,m;
  cin>>m>>n;
  cout<<mod_pow(m,n,MOD)<<endl;
  return 0;
}



Measured memory_bytes: 3136
h,w,a,b = map(int,input().split())
s = [[0 for i in range(w)] for j in range(h)]
list0 = [[0]*w]*h

#配列チェック用関数
def check(s):
    for i in range(h):
        if min(s[i].count(0),s[i].count(1)) != a:
            return False
    for i in range(w):
        tmp = list([s[j][i] for j in range(h)])
        if min(tmp.count(0),tmp.count(1)) != b:
            return False
    return True

#w-aとh-bを1で埋める
for i in range(b):
    for j in range(a,w):
        s[i][j] = 1
for i in range(b,h):
    for j in range(a):
        s[i][j] = 1
if check(s):
    for i in range(h):
        for j in range(w):
            print(s[i][j],end="")
        print()
else:
    print("No")

Measured memory_bytes: 14324
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int main(){
	int a,b;
	cin>>a>>b;
	if((a*b)%2==0){
		cout<<"Even"<<endl;
	}else{
		cout<<"Odd"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,m;
  cin>>a>>b>>m;
  int aa[a],bb[b];
  int ma=INF,mb=INF;
  rep(i,a){
    cin>>aa[i];
    ma=min(ma,aa[i]);
  }
  rep(i,b){
    cin>>bb[i];
    mb=min(mb,bb[i]);
  }
  int ans=ma+mb;
  rep(i,m){
    int x,y,c;
    cin>>x>>y>>c;
    ans=min(ans,aa[x-1]+bb[y-1]-c);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;
int dp[10005][10005];
char in[10005];

int main(){
    int a,b;
    while(cin>>a>>b){
        cout <<(a+b)%24<<endl;
    }
    return 0;
    
}


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

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  int s, w;
  cin >> s >> w;

  if (w >= s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
	return 0;
}

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

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n,k,res;
vector<ll> g[101010];

ll dfs(ll v,ll pre){
  ll ans=0;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    ll t=dfs(nv,v)+1;
    if(t>=k&&v!=0){
      res++;
      continue;
    }
    maxch(ans,t);
  }
  return ans;
}

int main(){
  cin>>n>>k;
  rep(i,n){
    ll a;
    cin>>a;
    a--;
    if(i==0){
      if(a!=0)res++;
      continue;
    }
    g[a].push_back(i);
    g[i].push_back(a);
  }
  dfs(0,-1);
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve()
{
  int ans = 0;

  bool V[MAX];
  for (int i=0;i<n;i++)
    {
      B[i]=A[i];
      V[i]=false;
    }
  sort(B,B+n);
  for(int i=0;i<n;i++)
    T[B[i]]=i;
  for(int i=0;i<n;i++)
    {
      if(V[i]) continue;
      int cur = i;
      int S = 0;
      int m = VMAX;
      int an = 0;
      while(1)
	{
	  V[cur] = true;
	  an++;
	  int v = A[cur];
	  m=min(m,v);
	  S +=v;
	  cur = T[v];
	  if(V[cur]) break;
	}
      ans += min(S + (an-2)*m,m+S+(an+1)*s);
    }
  return ans;
}

int main()
{
  cin >> n;
  s = VMAX;
  for(int i=0;i<n;i++)
    {
      cin >> A[i];
      s=min(s,A[i]);
    }
  int ans = solve();
  cout << ans <<endl;

  return 0;
}



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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	int A,B,C;
	A=10*a+b+c;
	B=a+10*b+c;
	C=a+b+10*c;
	if(A>=C && A>=B){
		cout<<A;
	}else if(B>=A && B>=C){
		cout<<B;
	}else{
		cout<<C;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        HashSet<Integer> hashSet = new HashSet<>();

        for(int i=0; i<N; i++){
            int d = scanner.nextInt();
            hashSet.add(d);
        }

        System.out.println(hashSet.size());


    }
}


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

void printSequence(int A[], int N)
{
  rep(i, N)
  {
    cout << A[i];
    if (i == N - 1)
    {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

void insertionSort(int A[], int N)
{
  for (int i = 1; i < N; i++)
  {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v)
    {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    printSequence(A, N);
  }
}

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

  int A[N];
  rep(i, N) cin >> A[i];

  printSequence(A, N);
  insertionSort(A, N);

  return 0;
}


Measured memory_bytes: 3092
n=int(input())
l=list(map(int,input().split()))
l.sort()

import bisect

ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ind=bisect.bisect_left(l,l[i]+l[j])
    ans+=ind-j-1
print(ans)

Measured memory_bytes: 42972
#include <stdio.h>

int main(void) {
	int i, a = 0;
	char s[4];
	
	scanf("%s", &s[0]);
	for (i = 0; i < 4; i++) {
		if (s[i] == '+')
			a++;
		else
			a--;
	}
	
	printf("%d\n", a);
	
	return 0;
}

Measured memory_bytes: 128
import collections
import math

def C(n):
    if n-2 < 0:
        return 0
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
#d = {}
d = [-1]*200010
Cf = [C(i) for i in range(200010)]
sm = 0
for k,v in c.most_common():

    d[k] = v
    sm += C(v)

for a in A:
    print (sm - Cf[d[a]] + Cf[d[a]-1])


Measured memory_bytes: 37452
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    int t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

struct unionfind{
  vector<int> par;
  vector<int> size;
  vector<int> rank;
  void begin(int n){
    par.resize(n,-1);
    size.resize(n,1);
    rank.resize(n);
  }
  int find(int x){
    if(par[x]==-1)return x;
    return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y)return;
    if(rank[x]>rank[y])swap(x,y);//[x]<[y]
    par[x]=y;
    size[y]+=size[x];
    if(rank[x]==rank[y])rank[y]++;
  }
};



int main(){
  int n,m,k;scanf("%d %d %d",&n,&m,&k);
  unionfind uf;
  uf.begin(n);
  vector<int> cant(n);
  rep(i,m){
    int a,b;scanf("%d %d",&a,&b);a--;b--;
    uf.unite(a,b);
    cant[a]++;cant[b]++;
  }rep(i,k){
    int a,b;scanf("%d %d",&a,&b);a--;b--;
    if(uf.find(a)==uf.find(b)){cant[a]++;cant[b]++;}
  }
  rep(i,n){
    int x=uf.find(i);
    printf("%d%c",uf.size[x]-cant[i]-1,(n-i-1 ? ' ' : '\n'));
  }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main() {
    ll n,i;
    cin >> n;

    vector<ll> A(n);
    vector<ll> B(n);
  
    ios::sync_with_stdio(false);
  
    for(i=1; i<n; i++){
        cin >> A.at(i);
        B.at(A.at(i)-1)++;
    }

    for(i=0; i<n; i++){
        cout << B.at(i) << endl;
    }
  
    return 0;
}


Measured memory_bytes: 6428
N=int(input())
vlist=list(map(int,input().split()))

vlist.sort(reverse=True)
while(len(vlist)>1):
  v1=vlist.pop()
  v2=vlist.pop()
  v=1.0*(v1+v2)/2
  vlist.append(v)
  vlist.sort(reverse=True)
  
print(vlist[0])

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

ifstream in("test.in");
ofstream out("test.out");

const int SMX = 4000001;

vector<int> sol;

bitset<SMX> bit;

int main(void)
{
    int n; cin >> n;
    
    bit[0] = 1;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        bit |= (bit << x);
    }

    int nr = (int) bit.count(), cnt = 0;
    
    for (int i = 0; i < SMX; ++i) {
        if (bit[i] == 1) ++cnt;
        
        if (cnt == nr / 2 + 1) {
            cout << i;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

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

#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define MAP map<int,int>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

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


void ANS(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Ans(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void ans(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

struct a{
	int to;
	int train;
	int cost;
};

vector<map<int,vector<a>>> edge(100000 + 1);
vector<map<int,int>> node(100000 + 1);

void dijkstra(void) {
	priority_queue<pair<int, PAIR>, vector<pair<int, PAIR>>, greater<pair<int, PAIR>>> pq;
	node[1][-1] = 0;
	pq.push({ 0,{ 1, -1 } });

	while (!pq.empty()) {
		int cost_f = pq.top().first;
		int from = pq.top().second.first;
		int train_f = pq.top().second.second;
		pq.pop();

		REP(i, edge[from][train_f].size()) {
			int to = edge[from][train_f][i].to;
			int train_t = edge[from][train_f][i].train;
			int cost_t = edge[from][train_f][i].cost;

			if (node[to][train_t] > cost_f + cost_t) {
				node[to][train_t] = cost_f + cost_t;
				pq.push({ node[to][train_t], { to , train_t } });
			}
		}
	}
	return;
}

int main() {
	int N, M;
	cin >> N >> M;
	FOR(i, 1, N + 1) node[i][-1] = (int)1e9;

	REP(i, M) {
		int p, q, c;
		cin >> p >> q >> c;
		node[p][c] = (int)1e9;
		node[q][c] = (int)1e9;
		edge[p][c].push_back({ q,c,0 });
		edge[q][c].push_back({ p,c,0 });
		edge[p][c].push_back({ p,-1,0 });
		edge[q][c].push_back({ q,-1,0 });
		edge[p][-1].push_back({ q,c,1 });
		edge[q][-1].push_back({ p,c,1 });

	}

	if (M == 0) {
		cout << -1 << endl;
		return 0;
	}

	dijkstra();
	
	cout << ((node[N][-1] == (int)1e9)?-1:node[N][-1]) << endl;
	// cin >> N >> M;

	return 0;
}


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

using namespace std;

int main(){
  int N, M; cin >> N >> M;
  vector<pair<int,int>> vp(M);
  for(auto& p : vp) cin >> p.second >> p.first;
  sort(vp.begin(), vp.end());
  int b = -1, res = 0;
  for(auto& p : vp){
    if(p.second >= b){
      b = p.first;
      ++res;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
# 毎回挿れるか挿れないかの二択の探索をしてみる
# 2値なのでbit全探索をやってみる
# 逆ポーランド必要か？と思ったけど加算だけだしいらんかったわ助かる
s = input()
ans = 0
for bit in range(0, 1 << len(s) - 1):
    opr = []
    for i in range(len(s) - 1):
        opr.append("水着" if bit >> i & 1 == 1 else "ワンピース")
    exp = [s[0]]
    for i in range(len(opr)):
        if opr[i] == "ワンピース":
            exp[-1] += s[i + 1]
        elif opr[i] == "水着":
            exp.append(s[i + 1])
    ans += sum(list(map(int, exp)))
print(ans)


Measured memory_bytes: 9148
n,x = map(int,input().split())

b = [1]
l = [1]
for i in range(n):
    b.append(b[-1]*2+1)
    l.append(l[-1]*2+3)

#print(*b)
#print(*l)

x -= 1
res = 0
lv = n
while lv >= 0:
    #print(x,lv,l[lv],b[lv],res)
    if lv == 0:
        res += 1
        break
    elif x <= 0:
        break
    elif x >= l[lv]-1:
        res += b[lv]
        break
    elif x == l[lv] // 2:
        res += b[lv-1] + 1
        break
    elif x > l[lv] // 2:
        res += b[lv-1] + 1
        lv -= 1
        x -= l[lv] + 2
    else:
        lv -= 1
        x -= 1
print(res)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int table[] = new int[128];
        String work[] = new String[2];
        String outPut[] = {"S","H","C","D"};
 
        table['S'] = 0;
        table['H'] = 1;
        table['C'] = 2;
        table['D'] = 3;
 
        boolean check[][] = new boolean[4][14];
        for(int row = 0; row < 4; row++){
            for(int col = 1; col <= 13; col++)check[row][col] = false;
        }
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                work = br.readLine().split("\\s+");
                check[table[work[0].charAt(0)]][Integer.parseInt(work[1])] = true;
            }
 
            for(int row = 0; row < 4; row++){
                for(int col = 1; col <= 13; col++){
                    if(!check[row][col]){
                        System.out.printf("%s %d\n", outPut[row],col);
                    }
                }
            }
 
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24736
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
ll kazu(ll x) {
    a = 1;
    while(x > 1) {
        t = 1;
        k = A[x];
        while(x % k == 0) {
            x /= k;
            t++;
        }
        a *= t;
    }
    return a;
}
void input() { cin >> n; }
void solve() {
    A = vl(10000010, 0);
    A[1] = 1;
    for(i = 2; i < 10000010; i++) {
        if(A[i] == 0) {
            for(j = 1; i * j < 10000010; j++) {
                if(A[i * j] == 0)
                    A[i * j] = i;
            }
        }
    }

    for(i = 1; i <= n; i++) {
        ans += i * kazu(i);
    }

    cout << ans << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 81340
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,l=1,h=40000,t,bt=inf;
    scanf("%d",&n);
    while(l!=h){
        t=(l+h)/2;
        if(t==bt){t++;}
        if((t*t)<=n){l=t;}else{h=t-1;}
        bt=t;
    }
    printf("%d\n",l*l);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string o,e;
  	cin >> o >> e;
  
    for(int i=0;i<o.size();i++){
    	cout << o[i];
    if (i < e.size()){
        cout << e[i];
    }
    }
    cout << endl;
}

Measured memory_bytes: 256
#coding:utf-8

            
def main():
    n, k = map(int, input().split())
    minv = n
    while True:
        sur = abs(minv - k) % k
        if sur >= minv:
            break
        minv = sur
        
    print(minv)
        
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long long int (i) = 0; (i) < (int) (n); (i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

bool vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

int main(int argc, char const *argv[])
{
    int a;
    cin >> a;
    vector<int> x;
    rep(i,1000000) {
        if(vector_finder(x, a)) {
            cout << i + 1 << endl;
            return 0;
        } else {
            x.push_back(a);
            if (a % 2 == 0) {
                a /= 2;
            } else {
                a = a * 3 + 1;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
//2020-04-09 16:02:20
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string s;cin>>s;
    int ans=700;
    rep(i,0,3)if(s[i]=='o')ans+=100;
    cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		//scanf("%d %d",&a,&b);
		a=a+b;
		int count=0;
		while(a>0){
			a/=10;
			count++;
		}
		printf("%d\n",count);
	}
	return 0;
}


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

using namespace std;

typedef long long llint;

int main() {
  llint n;
  cin >> n;
  if (n % 2) {
    cout << 0 << endl;
  } else {
    llint ans = 0;
    for (llint i = 5; i <= n; i *= 5) {
      llint cnt = n / i;
      ans += cnt / 2;
    }
    cout << ans << endl;
  }

  return 0;
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main() {
	int n, r, p, c;

	while( 1 ) {
		cin >> n >> r; if( n == 0 && r == 0 ) break;
		vector<int> card( n );
		vector<int> tmp( n );
		// if n == 3 -> 3 2 1
		REP( i, n ) card[i] = n - i;

		REP( i, r ) {
			cin >> p >> c;
			tmp = card;
			REP( j, p + c - 1 ) {
				if( j < c ) card[j] = tmp[j + p - 1];
				else		card[j] = tmp[j - c];
			}
		}
		cout << card[0] << endl;
	}

}


Measured memory_bytes: 3048
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b,c,d]=nrin(4)
  out(a+b==c+d?'Balanced':a+b>c+d?'Left':'Right')
}
main()


Measured memory_bytes: 7372
class BellmanFord():
    def __init__(self, N):
        self.N = N
        self.edges = []

    def add(self, u, v, d, directed=False):
        """
        u = from, v = to, d = cost
        directed = Trueのとき、有向グラフである。
        """
        if directed is False:
            self.edges.append([u, v, d])
            self.edges.append([v, u, d])
        else:
            self.edges.append([u, v, d])

    def BellmanFord_search(self, s):
        """
        :param s: 始点
        :return: d[i] 始点sから各点iまでの最短経路
        """
        d = [float('inf') for i in range(self.N)]
        d[s] = 0
        numEdges = len(self.edges)
        while True:
            update = False
            for i in range(numEdges):
                e = self.edges[i]
                # e: 辺iについて [from,to,cost]
                if d[e[0]] != float("inf") and d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
                    update = True
            if not update:
                break
        return d

    def BellmanFord_negative_bool(self, start, numNodes):
        # 負の閉路の検出, Trueなら負の閉路が存在する
        d = [float('inf') for i in range(self.N)]
        d[start] = 0
        numEdges = len(self.edges)
        for i in range(numNodes):
            for j in range(numEdges):
                e = self.edges[j]
                if d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
                    if i == numNodes-1 and e[1] == numNodes-1:
                        return True, d
        return False, d


N, M = map(int, input().split())
graph = BellmanFord(N)
for i in range(M):
    a, b, c = map(int, input().split())
    graph.add(a-1, b-1, -c, directed=True)

hasNegativeCycle, d = graph.BellmanFord_negative_bool(0, N)
if hasNegativeCycle:
    print('inf')
else:
    print(-1 * d[N-1])


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define INF 1e9
#define MAX_V 10000
using namespace std;

struct edge{int to, cap, rev;};
vector<edge> G[MAX_V]; //??°???????????£??\?????????
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

//from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});  
}


//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

//s??????t???????????§???????±???????
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}


int main(){
  int n,m;
  cin>>n>>m;
  
  int A[1001],B[1001];
  for(int i=0,a,b;i<m;i++){
    cin>>A[i]>>B[i];
    add_edge(A[i],B[i],1);
    add_edge(B[i],A[i],1);
  }
  int s,t;
  cin>>s>>t;
  cout <<max_flow(s,t)<<endl;

  vector<int> ans;  
  for(int i=0;i<m;i++){
    int a=A[i],b=B[i];
    int flg=0;
    for(int j=0;j<G[a].size();j++)
      if(G[a][j].to==b&&G[a][j].cap>=1)flg=1;
    if(flg) ans.push_back(i+1);
  }

  cout <<ans.size()<<endl;
  for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3484
#include <iostream>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

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

	cout << x * x * x << endl;
	
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll n,a,b;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>a>>b;
  cout<<MIN(a*n,b)<<endl;

}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import functools 

def gcd(a, b):
    if a > 0 and b == 0:
        return a
    if a < b:
        a, b = b, a
    r = a % b
    return gcd(b, r)

def lcm(a, b):
    return  a * b // gcd(a, b)

line = input()
n = int(line)
line = input()
a = list(map(int, line.split()))
print(functools.reduce(lambda x,y: lcm(x, y), a))


Measured memory_bytes: 6280
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n < 1200)
        cout << "ABC" << endl;
    else if (1200 <= n && n < 2800)
        cout << "ARC" << endl;
    else 
        cout << "AGC" << endl;
    return 0;
}

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

const int maxn = 1e5+5;
int n;
vector<int> adj[maxn];

map<pair<int,int>,int> mp;
int ans[maxn];

void dfs(int i, int p, int c) {
    if (i != p) {
        ans[mp[make_pair(i,p)]] = c;
    }
    int d = 1;
    for (int j: adj[i]) {
        if (j == p) continue;
        if (d == c) d++;        
        dfs(j,i,d++);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        mp[make_pair(a,b)] = i;
        mp[make_pair(b,a)] = i;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1,1,0);
    int res = 0;
    for (int i = 0; i < n-1; i++) {
        res = max(res,ans[i]);
    }
    cout << res << '\n';
    for (int i = 0; i < n-1; i++) {
        cout << ans[i] << '\n';
    }
}



Measured memory_bytes: 19328
// 全方位木DP
// educational dp contest V - Subtree

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

using ll = long long;
using namespace std;

ll n, m;
vector<ll> G[100100];
ll dp[100100];

void dfs1(ll v, ll p = -1){
    dp[v] = 1; // v:black固定
    for(auto nv : G[v]) {
        if(nv != p) {
            dfs1(nv, v);
            dp[v] *= dp[nv]+1; // nv:whiteの分+1する
            dp[v] %= m;
        }
    }
} // 通常の木DP

void dfs2(ll v, ll p = -1, ll dpp = 0){
    ll nn = G[v].size();
    // 積を累積しておく配列（前から、後ろから）
    vector<ll> mul1(nn), mul2(nn);
    // vの子nvについて問題を解く準備
    rep(i,nn){
        ll nv = G[v][i];
        if(nv == p) {
            mul1[i] = mul2[i] = (dpp+1) % m; // p:whiteno分だけ+1する
            dp[v] *= dpp+1; // p:whiteの分だけ+1する v:black固定
            dp[v] %= m;
        } // nv=pの時、dvの更新をする
        else mul1[i] = mul2[i] = (dp[nv]+1) % m; // nv:whiteの分+1する
    }
    // 前からの累積
    rep(i,nn-1){
        mul1[i+1] *= mul1[i];
        mul1[i+1] %= m;
    }
    // 後ろからの累積
    rrep(i,nn-1){
        mul2[i] *= mul2[i+1];
        mul2[i] %= m;
    }
    rep(i,nn){
        ll nv = G[v][i];
        if(nv != p) {
            ll a = (i ? mul1[i-1] : 1); // 前からの累積
            ll b = (i+1 < nn ? mul2[i+1] : 1); // 後ろからの累積
            dfs2(nv, v, a*b%m); // nvのdp更新は再帰先でされる
        } // 子nvについて再帰的にDPを更新していく
    }
}

int main() {
    cin >> n >> m;
    rep(i,n-1){
        ll x, y; cin >> x >> y; x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dfs1(0,-1); // 木DP
    dfs2(0,-1); // 全方位木DP

    rep(i,n) cout << dp[i] << endl;
    return 0;
}

Measured memory_bytes: 21232