akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,a[200010] = {1},op[200010] = {1};
	string s;
	cin >> n >> s;
	if(s[0] != 'B'){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1;i < s.length();i++){
		a[i] += a[i - 1];
		if((a[i] % 2 != 0) ^ (s[i] == 'W')){
			op[i] = -1;
			a[i + 1] += -1;
		}else{
			op[i] = 1;
			a[i] += 1;
		}
	}
	int opsum = 0,ans = 1,tmp = 0;
	for(int i = 0;i <= 2 * n;i++) opsum += op[i];
	for(int i = 0;i < 2 * n;i++){
		if(op[i] == -1) ans = ans * tmp % MOD;
		tmp += op[i];
	}
	for(int i = 1;i <= n;i++) ans = ans * i % MOD;
	if(opsum) cout << 0 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3716
#include <iostream>

using namespace std;
int ans[3];
int main(){
	ans[0] = ans[1] = ans[2] = -1;
	int N, Y;
	cin >> N;
	cin >> Y;

	if( N > Y / 1000 || Y % 1000 != 0 ) {
		goto end;
	}
	Y /= 1000;

	for(int man=Y/10; man>=0; man--){
		int tmp1 = Y - man * 10;
		int t1 = N - man;
		if( t1 < 0 || tmp1 < 0 ) break;
		else if( tmp1 == 0 && t1 == 0 ) {
			ans[0] = man; ans[1] = 0; ans[2] = 0;
			goto end;
		}
		for(int go=tmp1 / 5; go>=0; go--){
			int tmp2 = tmp1 - go * 5;
			int t2 = t1 - go;
			if(tmp2 < 0 || 2 < 0) break;
			else if( tmp2 == 0 && t2 == 0) {
				ans[0] = man; ans[1] = go; ans[2] = 0;
				goto end;
			}
			for(int ic=tmp2; ic>=0; ic--){
				int tmp3 = tmp2 - ic;
				int t3 = t2 - ic;
				if(tmp3 < 0 || t3 < 0) break;
				else if( tmp3 == 0 && t3 == 0) {
					ans[0] = man; ans[1] = go; ans[2] = ic;
					goto end;
				}
			}
		}
	}

end:
	cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
	return 0;
}


Measured memory_bytes: 256
n=gets.chomp.to_i
t,a=gets.chomp.split.map(&:to_i)
h=gets.split.map(&:to_i)
tmp=[]
for x in 1..n
  tmp[x-1]=(t-h[x-1]*0.006-a).abs
end
puts tmp.index(tmp.min)+1


Measured memory_bytes: 1788
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli A, B, C;
	cin >> A >> B >> C;

	cout << A * B / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    int c=0;
    for(int i=2;i<=n;i++){
        if((s[i-1]=='B' && s[i-2]=='A')&& s[i]=='C'){
            c++;
        }
    }
    cout<<c;
}


Measured memory_bytes: 3608
H, W, A, B = map(int, input().split())

mat = [[0] * W for _ in range(H)]

#左上
for i in range(B):
    for j in range(A):
        mat[i][j] = 1

#右下
for i in range(B, H):
    for j in range(A, W):
        mat[i][j] = 1

for line in mat:
    print("".join(map(str, line)))


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

const double eps = 1e-9;

bool same(double a, double b) { return abs(a - b) < eps; }

struct P {
    double x, y;
    P() : x(0), y(0) {}
    P(double x, double y) : x(x), y(y) {}
    P operator + (P b) { return P(x + b.x, y + b.y); }
    P operator - (P b) { return P(x - b.x, y - b.y); }
    P operator * (double b) { return P(x * b, y * b); }
    P operator / (double b) { return P(x / b, y / b); }
    double operator * (P b) { return x * b.x + y * b.y; }
    double operator ^ (P b) { return x * b.y - y * b.x; }
    double abs() { return hypot(x, y); }
    P unit() { return *this / abs(); }
};

struct L{
    // ax + by + c = 0
    double a, b ,c, o;
    P pa, pb;
    L() : a(0), b(0), c(0), o(0), pa(), pb() {}
    L(P pa, P pb) : a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), o(atan2(-a, b)), pa(pa), pb(pb) {}
    P project(P p) { return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs()); }
    P reflect(P p) { return p + (project(p) - p) * 2; }
    double get_ratio(P p) { return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs()); }
};

bool parallel(L x, L y) { return same(x.a * y.b, x.b * y.a); }

P intersect(L x, L y) { return P(-x.b * y.c + x.c * y.b, x.a * y.c - x.c * y.a) / (-x.a * y.b + x.b * y.a); }

int main() {
    int q; cin >> q; while (q--) {
        P p0, p1, p2, p3; cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        if (((p1 - p0) ^ (p3 - p2)) == 0) cout << "2" << '\n';
        else if (((p1 - p0) * (p3 - p2)) == 0) cout << "1" << '\n';
        else cout << "0" << '\n';
    }
}



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

using namespace std;

int main()
{
    long long int n, m, a, s = 0;

    cin >> n >> m;

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

    long long int ans;
    
    if (s > n)
        ans = -1;
    else
        ans = n - s;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3632
row,col=map(int,input().split())
maze=[list(input()) for _ in range(row)]
result = []
 
def create_next_adj_list(point):
  cur_x, cur_y, cur_depth = point
  return [(cur_x, cur_y+1, cur_depth+1), (cur_x+1, cur_y, cur_depth+1), (cur_x, cur_y-1, cur_depth+1), (cur_x-1, cur_y, cur_depth+1)]
 
for r in range(row):
  for c in range(col):
    if maze[r][c] == '.':
 
      visited = [ [0]*col for _ in range(row)]
      visited[r][c] = -1
    
      adj_list = [(r, c+1, 0), (r+1, c, 0), (r, c-1, 0), (r-1, c, 0)]

      while adj_list:
        point = adj_list.pop(0)

        if 0<=point[0]<row and 0<=point[1]<col and visited[point[0]][point[1]] != -1:
          visited[point[0]][point[1]] = -1
          if maze[point[0]][point[1]] != '#':
            for adj in create_next_adj_list(point):
              adj_list.append(adj)

      result.append(point[-1])

print(max(result))

Measured memory_bytes: 3188
K = int(input())
table = [1,2,3,4,5,6,7,8,9]
for i in table:
  if len(table) > K:
    break
  x = i % 10
  for j in range(max(0, x - 1), min(x + 2, 10)):
    table.append(i * 10 + j)
print(table[K-1])


Measured memory_bytes: 7316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
const int inf = 1e9;
int main(){
	int n,t[3];
	cin >> n >> t[0] >> t[1] >> t[2];
	vector<int> l(n);
	for(int i=0; i<n; i++){
		cin >> l[i];
	}
	l.push_back(0);
	l.push_back(0);
	l.push_back(0);

	int ans = inf;
	sort(l.begin(), l.end());
	do{
		int num[3] = {};
		int len[3] = {};
		int p = 0;
		int idx = 0;
		for(int i=0; i<3; i++){
			while(l[p] != 0){
				num[idx]++;
				len[idx] += l[p];
				p++;
			}
			p++;
			idx++;
		}
		bool ng = false;
		for(int i=0; i<3; i++){
			if(num[i] == 0) ng = true;
		}
		if(ng) continue;
		int sub = 0;
		for(int i=0; i<3; i++){
			sub += (num[i]-1)*10 +abs(len[i] -t[i]);
		}
		ans = min(ans, sub);
	}while(next_permutation(l.begin(), l.end()));
	cout << ans << endl;
	return 0;
}

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

int main(){
  int D, T, S;
  cin>> D>>T>>S;
  float time = (float)D/S;
  if(time <= T){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3584
program main
  implicit none
  integer :: M,N
  integer,allocatable :: A(:)
  integer :: i
  integer :: out, tot
  read(*,*) N, M
  allocate(A(N))
  read(*,*) A(:)
  out = 0
  tot = sum(A)
  do i = 1,N
     if (A(i) < tot/(4.e0*M) ) cycle
     out = out + 1
  end do
  if (out >= M ) then
     write(*,'(a)') 'Yes'
  else 
     write(*,'(a)') 'No'
  end if
end program main


Measured memory_bytes: 2924
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    assert(MOD>=SIZE);
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
LL f(int n,int m){
    return m*mypow(m-1,n-1)%MOD;
}
int main(){
    MOD=998244353;
    build();
    int N,M,K;
    R(N,M,K);
    LL an=0;
    FOR(i,0,K){
        ADD(an,C(N-1,i)*f(N-i,M));
    }
    W(an);
    return 0;
}


Measured memory_bytes: 19388
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert
#define mp make_pair

const int MAX = 1e5;

int main() {
	int x, n;
	cin>>x>>n;
	vi a(n);
	vi c(n);
	if (n == 0) {
		cout<<x<<endl;
		return 0;
	}

	map<int, bool> cnt;
	for (int i = 0;i < n;++i) {
		cin>>a[i];
		cnt[a[i]] = true;
	}

	vector<pair<int, int>> ans;
	int c1;
	for (int i = 0;i <= 101;++i) {
		if (cnt.find(i) == cnt.end()) {
			c1 = i - x;
			ans.pb(mp(abs(c1), c1));
		}
	}

	sort(all(ans));
	printf("%d\n", ans[0].s + x);
	return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

#define lp(n) for(int i=0;i<n;i++)
#define LP(n,i) for(int i=0;i<n;i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483637
#define llmax 9223372036854775807
typedef long long ll;

using namespace std;

string s,smem;
int n,cnt;

/*ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	ll g=gcd(x,y);
	return x/g*y;
}*/

int main(){
	cin>>n>>s;
	smem=s;
	cnt=0;
	lp(smem.size()){
		if(s[i]=='('){
			cnt++;
			for(int j=i+1;j<smem.size();j++){
				if(s[j]==')'){
					s[j]=0;
					cnt--;
					break;
				}
			}
		}
	}
	lp(cnt)
		smem=smem+')';
	cnt=0;
	s=smem;
	for(int i=smem.size()-1;i>=0;i--){
		if(s[i]==')'){
			cnt++;
			for(int j=i-1;j>=0;j--){
				if(s[j]=='('){
					s[j]=0;
					cnt--;
					break;
				}
			}
		}
	}
	
	lp(cnt)
		smem='('+smem;
	cout<<smem<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);
const int maxn=1e5+5;
const int mod=1e9+7;

int main()
{
    int a;
    sint(a);
    if(a%2)
    printf("%d",a/2);
    else
        printf("%d",a/2-1);
    return 0;

}


Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
//using
using namespace std;
using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
//グローバル変数宣言
int a=0,b=0,c=0;

signed main(){
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <stdlib.h>
#include <numeric>
#include <string>
using namespace std;
int main(){
  	int a;
  	string s;
    cin >> a >> s;
    if(a>=3200){
      cout<<s<<endl;
    }else{
      
          cout<<"red"<<endl;
          
      }
       
 
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int a,b;cin>>a>>b;
    a=gcd(a,b);
    int t=1;
    for(int i=2;i*i<=a;i++)if(a%i==0){
        t++;
        while(a%i==0)a/=i;
    }
    if(a-1)t++;
    cout<<t<<endl;
}


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

using namespace std;

//#define int long long

void solve()
{
	int n;
	cin >> n;
	
	int pos = 1;
	
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		
		if(x == pos)
		{
			pos++;
		}
	}
	
	if(pos == 1)
		cout << -1;
	else
		cout << n - (pos - 1);
}

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
//	cin >> t;

	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,i,c=0;
  cin>>n;
  vector<int64_t> a(n);
  map<int64_t,int64_t> l,r;
  for(i=0;i<n;i++){
    cin>>a.at(i);
    if(l.count(i+a.at(i))) l.at(i+a.at(i))++;
    else l[i+a.at(i)]=1;
    if(r.count(i-a.at(i))) r.at(i-a.at(i))++;
    else r[i-a.at(i)]=1;
  }
  for(auto p:l){
    auto k=p.first;
    auto v=p.second;
    if(r.count(k)) c+=v*r.at(k);
  }
  cout<<c<<endl;
}

Measured memory_bytes: 28076
n,m=[int(i) for i in input().split()]
lista=[]
listb=[]

for i in range(m):
  a,b = [int(i) for i in input().split()]
  lista.append(a)
  listb.append(b)
  
maxa = max(lista)
minb = min(listb)

if minb<maxa:
  print(0)
else:
  print(minb-maxa+1)


Measured memory_bytes: 11052
//code for hackerrank problem: deforestation
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 101010
int n;

vector <int> v[N];
int f[N];

void dfs(int r, int p) {
  f[r] = 0;
  for(int i = 0; i < (int)v[r].size(); i ++) {
    if(p == v[r][i]) continue;
    dfs(v[r][i], r);
    f[r] ^= f[v[r][i]] + 1;
  }
}

int main() {
    int T = 1;
    while(T --) {
      scanf("%d", &n);
      for(int i = 1; i <= n; i ++) v[i].clear();
      for(int i = 1; i < n; i ++) {
        int x, y;
        scanf("%d%d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
      }
      dfs(1, 0);
      if(f[1]) puts("Alice"); else puts("Bob");
    }
    return 0;
}


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

count = 0
for i in range(n):
    if a[i] < 0:
        count += 1

if count % 2 == 0:
    for i in range(n):
        a[i] = abs(a[i])
    total = sum(a)
else:
    for i in range(n):
        a[i] = abs(a[i])
    total = sum(a) - min(a)*2

print(total)

Measured memory_bytes: 14412
def main(A,N):
    A = [0] + A
    for a in range(N//2,0,-1):
        #print(inds[ind::ind+1])
        if sum(A[a::a]) %2== 0:
            A[a] = 0
        else:
            A[a] = 1
        
    res = [x for x in range(0,N+1) if A[x]]
    print(len(res))
    print(*res)

N = int(input())
A = [int(x) for x in input().split()]
    
main(A,N)


Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
ll pow(int n, int e)
{
    ll ans = 1;
    for (int i = 0; i < e; i++)
    {
        ans *= n;
    }
    return ans;
}
ll N;
ll sum = 0;

int main()
{
    cin >> N;
    int keta = 0;
    ll num = N;
    while (num > 0)
    {
        num /= 10;
        keta++;
    }
    ll NN;
    if (N > 8 && N % 10 != 9)
    {
        /* keta-1を一つへらす */
        NN = (N / (pow(10, keta - 1)) - 1) * pow(10, keta - 1);
        /*keta-1まで9で埋める */
        for (int i = 1; i < keta; i++)
        {
            NN += 9 * pow(10, i - 1);
        }
    }
    else
    {
        NN = N;
    }
    while (NN > 0)
    {
        sum += NN % 10;
        NN /= 10;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h> 
#define ll long long 
#define pb push_back
#define vec vector<int>
#define fo(i,n) for (int i = 0; i < n; i++)
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
using namespace std;  




int main()
{

ll n;
cin>>n;
vector<ll> v(n);
for(int i=0;i<n;i++)
{
    cin>>v[i];
}

       
       ll maxx = 0 , count = 0;
     for(int i = 0; i < n;i++)
     {
     	maxx = max(maxx , v[i]);
     	count += abs(maxx - v[i]);
     }
     cout<<count<<endl;
}

Measured memory_bytes: 4804
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>

/* #define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
sort(a, a + SIZE_OF_ARRAY(a)); 配列内を昇順ソート(aという配列) */

using namespace std;

int main(){
    int n,t;
    cin >> n >> t;
    int sec[n+1]; //indexの1~nにt_1~t_nの値をそれぞれ代入
    sec[0]=0;
    for(int i=1;i<n+1;i++){
        cin >> sec[i];
        // printf("sec[%d]:%d",i,sec[i]);
    }
    /* 入力 */
    /* 差分の配列を用意 */
    /*t_1とt_2の差分はsub[0],t_2とt_3の差分はsub[1]...
    t_(n-1)とt_(n)の差分はsub[n-2]に格納される   */
    int sub[n-1];
    for(int i=0;i<n-1;i++){
        sub[i] = sec[i+2] - sec[i+1];
        // printf("sub[%d]:%d",i,sub[i]);
    }

    int ans = 0;

    for(int j=0;j<n-1;j++){
        if(sub[j] >= t){ //2人のスイッチの感覚がシャワーの出る間隔より長い場合、tをそのまま加算すればいい
            ans += t; //シャワー間隔を加算
        }
        else{ //sub[j] < t
            ans += sub[j];
        }
    }
    ans += t;
    printf("%d",ans);

}


Measured memory_bytes: 1792
n, t = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
x = []
for i in range(n):
     if a[i][1] <= t:
          x.append(a[i][0])
if x != []:
     print(min(x))
else:
     print("TLE")

Measured memory_bytes: 3060
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        string[] suji = ReadLine().Split(' ');
        int max = 0;
        int min = 1000000000;
        for(int i=0;i<kazu;i++){
            int a = int.Parse(suji[i]);
            max = Max(max,a);
            min = Min(min,a);
        }
        WriteLine(max-min);
    }
}


Measured memory_bytes: 13140
from operator import itemgetter
n=int(input())
data=[]
for i in range(n):
    x0,y0,h0=map(int,input().split())
    data.append([h0,x0,y0])
data.sort(reverse=True)
if n==1 or data[1][0]==0:
    print(data[0][1],data[0][2],data[0][0])
else:
    x=0
    y=0
    buf=0
    for cx in range(101):
        buf=0
        for cy in range(101):
            buf=0
            h=data[0][0]+abs(data[0][1]-cx)+abs(data[0][2]-cy)
            for i in range(1,n):
                if data[i][0]==0:
                    break
                else: 
                    h_i=data[i][0]+abs(data[i][1]-cx)+abs(data[i][2]-cy)
                    if h_i!=h:
                        buf=1
                        break
            if buf==0:
                x=cx
                y=cy
                break
        if buf==0:
            break
    print(x,y,h)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  ll x,y,z;
  cin >> x >> y >> z;
  
  cout << min({ x*y*(z%2), y*z*(x%2), z*x*(y%2) }) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n, w);
    vector<PII> a(n);
    for(auto& p : a){
        cin >> p.first >> p.second;
    }
    VI dp(w + 1);
    for(int i = 0; i < n; ++i){
        for(int j = w; j >= 0; --j){
            if (j + a[i].first <= w){
                dp[j + a[i].first] = max(dp[j + a[i].first], dp[j] + a[i].second);
            }
        }
    }
    cout << *max_element(ALL(dp));

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if(i%2==0) cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
N = int(input())
A = [int(input()) for i in range(N)]


sorted_A = list(reversed(sorted(A)))

maxiuam = sorted_A[0]

is_there_tow_maximum = A.count(maxiuam) >= 2
if is_there_tow_maximum:
    answer = (str(maxiuam) + "\n") * N
    print(answer)
    exit()

second = None
for Ai in sorted_A:
    if Ai < maxiuam:
        second = Ai
        break

answer = [second if Ai == maxiuam else maxiuam for Ai in A]
answer = "\n".join(map(str, answer))

print(answer)


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i=0; i<n; i++) cin >> s[i];
    int m;
    cin >> m;
    vector<string> t(m);
    for (int i=0; i<m; i++) cin >> t[i];

    map<string, int> w{};
    for (int i=0; i<n; i++) {
        w[s[i]]++;
    }
    for (int i=0; i<m; i++) {
        w[t[i]]--;
    }

    int maxval = 0;
    for (auto i = w.begin(); i != w.end(); i++) {
        if (i->second > maxval) maxval = i->second;
    }
    cout << maxval << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
  cin >> N;
  vector<char> a(N);
  for (int i=0; i<N; i++){
  	cin >> a.at(i);
  }
 
  int y=0;
  for (int i=0; i<N; i++){
  if (a.at(i)=='Y'){
  	y=1;
  }
  }
  
  if (y==1){
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 「ABC → BCA」の置換はAとBCの交換とみなせるはず
		Scanner in = new Scanner(System.in);
		String base = in.next();
		base = base.replace("BC", "X");

		int cntA = 0;
		long answer = 0;
		
		char[] targ = base.toCharArray();
		for ( int i = 0; i < targ.length; i++ ) {
			if ( targ[i] == 'A' ) cntA++;
			else if ( targ[i] == 'X' ) answer += cntA;
			else cntA = 0;
		}

		System.out.println(answer);
		in.close();
	}
}

Measured memory_bytes: 34988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC056B___NarrowRectanglesEasy
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            int w = input[0];
            int al = input[1];
            int ar = input[1] + w;
            int bl = input[2];
            int br = input[2] + w;

            int result = 0;
            //decide to move direction
            if (br < al)
            {
                result = al - br;
            }
            else if (ar < bl)
            {
                result = bl - ar;
            }
            else
            {
                result = 0;
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

typedef struct Node{
  int key;
  Node *prev;
  Node *next;
} Node;

class DList{
public:
  DList(){
    // nil = (Node*)malloc(sizeof(Node));
    nil = new Node;
    nil->next = nil;
    nil->prev = nil;
  }
  ~DList(){
    delete nil;
  }
  void insert(int key){
    Node *x = new Node;
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
  }
  Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key) cur = cur->next;
    return cur;
  }
  void deleteNode(Node *t){
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    delete t;
  }
  void deleteKey(int x){
    Node *t = listSearch(x);
    deleteNode(t);
  }
  void deleteFirst(){
    deleteNode(nil->next);
  }
  void deleteLast(){
    deleteNode(nil->prev);
  }
  void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
      if(cur == nil) break;
      if(isf++>0) printf(" ");
      printf("%d", cur->key);
      cur = cur->next;
    }
    printf("\n");
  }

private:
  Node *nil;
};


int main(){
  int key, n;
  // int size = 0;
  char com[20];
  // int np = 0, nd = 0;
  // scanf("%d", &n);
  cin >> n;
  DList dl;
  // init();
  for(int i=0; i<n; i++){
    cin >> com;
    // scanf("%s%d", com, &key);
    if(com[0] == 'i'){
      cin >> key;
      dl.insert(key);
      // np++;
      // size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F') dl.deleteFirst();
        else dl.deleteLast();
      }
      else{
        cin >> key;
        dl.deleteKey(key);
        // nd++;
      }
      // size--;
    }
  }

  dl.printList();

  return 0;
}



Measured memory_bytes: 34316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPopularVote solver = new BPopularVote();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPopularVote {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int a[] = new int[n];
            long sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            if (sum % 4 == 0) {
                long k = sum / (4 * m);
                int c = 0;
                for (int i = 0; i < n; i++) {
                    if (a[i] >= k) c++;
                }
                if (c >= m) out.println("Yes");
                else out.println("No");
            } else {
                long k = sum / (4 * m);
                k += 1;
                int c = 0;
                for (int i = 0; i < n; i++) {
                    if (a[i] >= k) c++;
                }
                if (c >= m) out.println("Yes");
                else out.println("No");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

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

    int cnt = 0;
    for(int i = 0; i < S.length(); i++)
    {
        if(S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G')
        {
            for(int j = i; j < S.length(); j++)
            {
                if(S[j] == 'A' or S[j] == 'T' or S[j] == 'C' or S[j] == 'G')
                {
                    int ans = j - i + 1;
                    cnt = max(cnt, ans);
                }
                else
                {
                    break;
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
a.extend(list(map(int, input().split())))
a.extend(list(map(int, input().split())))

N = int(input())
is_called = [False]*9
for _ in range(N):
    b = int(input())
    if b in a:
        idx = a.index(b)
        is_called[idx] = True


def isBingo(a) -> bool:
    ret = False
    # よこ
    ret |= all([a[0], a[1], a[2]])
    ret |= all([a[3], a[4], a[5]])
    ret |= all([a[6], a[7], a[8]])
    # たて
    ret |= all([a[0], a[3], a[6]])
    ret |= all([a[1], a[4], a[7]])
    ret |= all([a[2], a[5], a[8]])
    # ななめ
    ret |= all([a[0], a[4], a[8]])
    ret |= all([a[2], a[4], a[6]])
    return ret


print("Yes" if isBingo(is_called) else "No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll ans=a[0];
    reverse(a,a+n);
    for(int i=0;i<n;i++){
        if(i&1)a[i]=24-a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        ans=min(ans,a[i]-a[i-1]);
    }
    cout << ans<<endl;
    return 0;
}


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

int gcd(int a,int b){
	if(!b)return a;
	return gcd(b,a%b);
}

int main(){
	int K;
	scanf("%d",&K);
	printf("%d\n",360/gcd(K,360));
	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
const int maxn=1<<22;
typedef long long ll;
typedef unsigned long long ull;
int data[maxn][21],n,k;
int mem[maxn*2];
char s[maxn];
int mx=1000000000,mxl=0;
void update(int sta,int nums,int len) {
    mem[sta|(1<<len)]+=nums;
    if(mem[sta|(1<<len)]>=k)
        if(mxl<len)mxl=len,mx=sta;
        else if(mxl==len)mx=min(mx,sta);

}
int main() {
    scanf("%d%d",&n,&k);
    for(int i=0;i<=n;i++) {
        scanf("%s",s);//len=2^i
        for(int j=0;j<(1<<i);j++) {
            int tmp=j;
            tmp|=1<<i;
            data[tmp][0]+=(s[j]=='1');
        }
    }
    for(int i=0;i<=n;i++) {
        for(int j=0;j<(1<<(n+1));j++) {
            if(!data[j][i])continue;//t-s
            ull s=j&((1<<i)-1),t=j>>i;int l=(32-__builtin_clz(t))-1;//有t多少位
            if(i)update(s,data[j][i],i);
            if(!l){continue;}
            t^=(1<<l);
            int first1=(32-(t?__builtin_clz(t):32));
            unsigned int num=t<<(32-l);
            int first0=l?(l-((~num)?__builtin_clz(~num):l)):0;
            int newt,news;
            if(first1>0){
                newt=t&((1<<first1)-1);
                newt|=(1<<first1-1);
                news=(s<<1)|1;
                data[(newt<<(i+1))|news][i+1]+=data[j][i];
            }
            if(first0>0){
                newt=t&((1<<first0)-1);
                newt|=(1<<first0-1);
                news=(s<<1);
                data[(newt<<(i+1))|news][i+1]+=data[j][i];
            }
        }
    }
    if(mx==1000000000){puts("");return 0;}
    for(int i=mxl;i>=1;i--) {
        printf("%d",(mx&(1<<i-1))?1:0);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 185728
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    set<int> b;
    bool pairwise = true;
    int g;
    REP(i, n) {
        cin >> a[i];
        if (pairwise) {
            auto p = prime_factorization(a[i]);
            for (auto q : p) {
                if (b.count(q.first) > 0) {
                    pairwise = false;
                    break;
                }
                b.emplace(q.first);
            }
        }
        if (i == 0) g = a[i];
        else g = gcd(g, a[i]);
    }
    if (pairwise) cout << "pairwise coprime" << endl;
    else if (g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}


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

int main() {
    int n;
    cin >> n;
    int ans = 1e9+1;
    for(int i = 0; i <= n; i++) {
        int a = i, b = n - i;
        int cnt = 0;
        while(a > 0) cnt += a%6, a /= 6; 
        while(b > 0) cnt += b%9, b /= 9;
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N);

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

    vector<int> v;
    vector<int> steped(N);
    for (int i = 0; i < N; ++i) steped[i] = 0;

    int cnt = 2;
    steped[0] = 1;
    v.push_back(1);
    int now = 1;
    int ans = 1;
    int n_loop = 0;
    while(K > 0) {
        ans = A[now-1];
        now = A[now-1];
        K -= 1;
        // cout << "now = " << now << endl;
        // cout << "cnt = " << cnt << endl;
        // cout << "K = " << K << endl;
        if (K == 0) break;
        v.push_back(now);
        if (steped[now-1] == 0) {
            steped[now-1] = cnt;
            cnt += 1;
        } else {
            n_loop = cnt - steped[now-1];
            // cout << "n_loop = " << n_loop << endl;
            K %= n_loop;
            ans = v[K + steped[now-1] - 1];
            break;
        }
    }
    cout  << ans << endl;
    return 0;
}

Measured memory_bytes: 5800
import sys

def f(a, b):
    return max(len(str(a)), len(str(b)))


def main():
    input = sys.stdin.readline
    N = int(input())
    n = int(N**0.5)

    ans = 11
    for i in range(1, n+1):
        if N % i == 0:
            ans = min(ans, f(i, N//i))

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3188
N = int(input())
T, A = map(int, input().split())
Hn = list(map(int, input().split()))

best = abs(A - (T - (10**5) * 0.006 + 1))
best_i = -1
for i, H in enumerate(Hn):
    t = T - H * 0.006
    d = abs(A - t)
    if d < best:
        best = d
        best_i = i
print(best_i+1)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

struct UnionFind {
    vector<pair<long long, long long>> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(long long N) : par(N) { //最初は全てが根であるとして初期化
        for(long long i = 0; i < N; i++) {
          par[i].first = i;
          par[i].second = 1;
        }
    }

    long long root(long long x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x].first == x) return x;
        return par[x].first = root(par[x].first);
    }

    void unite(long long x, long long y) { // xとyの木を併合
        long long rx = root(x); //xの根をrx
        long long ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[ry].second += par[rx].second;
        par[rx].first = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(long long x, long long y) { // 2つのデータx, yが属する木が同じならtrueを返す
        long long rx = root(x);
        long long ry = root(y);
        return rx == ry;
    }
};

long long N, M;
pair<long long, long long> p[100000];

int main() {
  cin >> N >> M;
  for(long long i = 0; i < M; i++) {
    cin >> p[i].first >> p[i].second;
    p[i].first--;p[i].second--;
  }

  UnionFind tree(N);

  long long ans[100001] = {0};
  ans[0] = N * (N-1) / 2;

  for(long long i = M - 1; i >= 1; i--) {
    long long s = p[i].first, t = p[i].second;
    if(!tree.same(s, t)) {
      long long rs, rt;
      rs = tree.root(s);
      rt = tree.root(t);
      long long n = tree.par[rs].second * tree.par[rt].second;
      // cout << s << " " << t << endl;
      // cout << rs << " " << rt << " " << n << endl;
      ans[M-i] = ans[M-i-1] - n;
    } else {
      ans[M-i] = ans[M-i-1];
    }
    tree.unite(s, t);
  }

  for(long long i = M-1; i >= 0; i--) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
    long long int a,b,c,d,i,x[100000],y=0;
    cin>>a;

    cout<<a+(a*a)+(a*a*a)<<endl;

}


Measured memory_bytes: 3588
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int i = in.nextInt();
        switch (i % 10) {
            case 2: case 4: case 5: case 7: case 9:
                out.println("hon");
                break;
            case 0: case 1: case 6: case 8:
                out.println("pon");
                break;
            case 3:
                out.println("bon");
                break;
        }
        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32696
#include <stdio.h>
#include <string.h>
int main(void){
    char c[1000000]={};
    gets(c);
    long int sum=0;
    long int leftM=0;
    long int rightM=0;
    for(int i=0;i<strlen(c)+1;i++){
        
        
        if(c[i-1]=='<' && c[i-2]=='<'){
            leftM++;
        }else{
            leftM=0;
            for(int j=1;i-j>=0 && c[i-j]=='<';j++)leftM++;
        }
        
        if(c[i]=='>' && c[i-1]=='>'){
            rightM--;
        }else{
            rightM=0;
            for(int j=0;i+j<=strlen(c) && c[i+j]=='>';j++)rightM++;
        }
        //printf("%d ,%d %d \n",i,leftM, rightM);   
        
        (leftM>=rightM)?(sum+=leftM):(sum+=rightM);
    }
    printf("%ld\n",sum);
}

Measured memory_bytes: 2616
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m := scanInt(), scanInt()
	as := make([]int, n)
	sum := 0
	for i := range as {
		as[i] = scanInt()
		sum += as[i]
	}
	sort.Ints(as)

	type card struct{ n, s int }
	cs := make([]card, m)
	for i := range cs {
		cs[i].s, cs[i].n = scanInt(), scanInt()
	}
	sort.Slice(cs, func(i, j int) bool { return cs[i].n > cs[j].n })

	p := 0
lb:
	for _, v := range cs {
		for i := 0; i < v.s; i++ {
			if p >= len(as) || v.n < as[p] {
				break lb
			}
			sum += v.n - as[p]
			p++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 6224