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

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

  vector<int> a(N);

  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }

  int odd = 0;

  for(int i = 0; i < N; i++){
    if(a.at(i) % 2 == 1){
      odd++;
    }
  }

  if (odd % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

  // if(odd % 2 == 1){
  //   cout << "No" << endl;
  // }else{
  //   cout << "Yes" << endl;
  // }
}


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

#define gc() getchar()

#define ll long long
#define ri register int 

using std::cout;
using std::swap;
using std::bitset;

inline int read()
{
	int ret=0;char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))
	{
		ret=ret*10+ch-'0';
		ch=gc();
	}
	return ret;
}

const int MAXN=51;
const int MAXM=21;

int n,m;

int en,eh[MAXN];
struct edge
{
	int v,next;
}e[MAXN*2];
inline void add_edge(int u,int v)
{
	e[++en]=(edge){v,eh[u]};eh[u]=en;
	e[++en]=(edge){u,eh[v]};eh[v]=en;
}

int fa[MAXN],d[MAXN];
void dfs(int u)
{
	for(ri i=eh[u],v;i;i=e[i].next)
	{
		v=e[i].v;
		if(v!=fa[u])
		{
			fa[v]=u;
			d[v]=d[u]+1;
			dfs(v);
		}
	}
}

ll rt[1<<MAXM],a[1<<MAXM],ans;
inline ll lowbit(ll x){return x&-x;}
inline int op(ll x){return x&1?1:-1;}
inline ll pro(int t){return (ll)1<<n-1-t;}
inline ll route(int u,int v)
{
	ll ret=0;
	while(u!=v)
	{
		if(d[u]<d[v])swap(u,v);
		ret|=(ll)1<<u-2;
		u=fa[u];
	}
	return ret;
}
inline int cnt(ll x)
{
	int ret=0;
	while(x)
	{
		ret+=x&1;
		x>>=1;
	}
	return ret;
}

int main()
{
//	freopen("in.in","r",stdin);
	
	n=read();
	for(ri i=2,u,v;i<=n;++i)
	{
		u=read();v=read();
		add_edge(u,v);
	}
	dfs(1);
	
	m=read();
	for(ri i=0,u,v,t;i<m;++i)
	{
		u=read();v=read();
		rt[1<<i]=route(u,v);
	}
	for(ri i=1,j;i<(1<<m);++i)
	{
		j=lowbit(i);
		rt[i]=rt[i-j]|rt[j];
		a[i]=pro(cnt(rt[i]));
		ans+=op(cnt(i))*a[i];
	}
	printf("%lld\n",((ll)1<<n-1)-ans);
	
	return 0;
}

Measured memory_bytes: 20152
a,b,c = map(int,input().split())

cnt = 0
if a %2 == 0:
    cnt += 1
if b %2 == 0:
    cnt += 1
if c %2 == 0:
    cnt += 1
if cnt >= 2:
    print('Tem')
else:
    print('Hom')


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    cout << abs((n - 2)) * abs((m - 2)) << endl;

    return 0;
}


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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  for (int i = 0; i < N; ++i) {
    int x; cin >> x; X = max(X, x);
  }
  for (int i = 0; i < M; ++i) {
    int y; cin >> y; Y = min(Y, y);
  }
  if (Y - X >= 1) cout << "No War" << endl;
  else cout << "War" << endl;
}

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

using namespace std;

typedef long long Int;
typedef vector<Int> vec;
typedef vector<vec> mat;

int mod;

mat mul(mat &A, mat &B)
{
    mat C(A.size(), vec(B[0].size()));
    
    for (int i = 0; i < A.size(); i++){
        for (int j = 0; j < B[0].size(); j++){
            for (int k = 0; k < A[0].size(); k++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    
    return (C);
}

mat pow(mat &A, Int n)
{
    mat B(A.size(), vec(A.size()));
    
    for (int i = 0; i < A.size(); i++){
        B[i][i] = 1;
    }
    
    while (n > 0){
        if (n & 1){
            B = mul(B, A);
        }
        A = mul(A, A);
        n >>= 1;
    }
    
    return (B);
}

int main()
{
	int n, m, a, b, c, t;
	int S[64];

	while (scanf("%d %d %d %d %d %d", &n, &m, &a, &b, &c, &t) && n){
		for (int i = 0; i < n; i++) scanf("%d", S + i);
		mat X(n, vec(n));
		for (int i = 0; i < n; i++){
			if (i) X[i][i - 1] = a;
			X[i][i] = b;
			if (i < n - 1) X[i][i + 1] = c;
		}
		mod = m;
		X = pow(X, t);
		for (int i = 0; i < n; i++){
			Int ans = 0;
			for (int j = 0; j < n; j++) ans = (ans + X[i][j] * S[j]) % m;
			printf("%lld%c", ans, " \n"[i + 1 == n]);
		}
	}

	return (0);
}

Measured memory_bytes: 1276
/**
 * Author  : Dhakad@123
 * Created : 24.08.2020
 **/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)


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


	int n;
	cin >> n;

	vector<int>a(n);

	rep(i, n){
		cin >> a[i];
	}


	ll ans =  0;

	int max_val = a[0];


	REP(i,1,n){

		if(max_val > a[i]){
			ans += max_val - a[i];
		}
		else{
			max_val = a[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3892
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int main(){
  ll n,m;
  ll a[56],b[56],c[56],d[56];
  ll i,j,s;
  ll min;

  scanf("%lld %lld", &n, &m);

  for(i = 1;i <= n;i++) scanf("%lld %lld", &a[i], &b[i]);
  for(i = 1;i <= m;i++) scanf("%lld %lld", &c[i], &d[i]);

  for(i = 1;i <= n;i++){
    min = 100100100100;
    for(j = 1;j <= m;j++){
      if((abs(a[i] - c[j]) + abs(b[i] - d[j])) < min){
        s = j;
        min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      }
    }

    printf("%lld\n", s);
  }

  return 0;
}


Measured memory_bytes: 128
S = list(str(input()))

ans = 0
start_index = 0
for end_index in range(len(S)):
  if S[start_index] == "A" or S[start_index] == "C" or S[start_index] == "G" or S[start_index] == "T":
    if S[end_index] == "A" or S[end_index] == "C" or S[end_index] == "G" or S[end_index] == "T":
      ans = max(ans,end_index - start_index + 1)
    else:
      start_index = end_index
  else:
    start_index = end_index

print(ans)


Measured memory_bytes: 3060
from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sa = [0] + list(accumulate(a))
sb = [0] + list(accumulate(b))

ans = 0
p = m
for i in range(n + 1):
    for j in range(p, -1, -1):
        if sa[i] + sb[j] <= k:
            ans = max(ans, i + j)
            p = j
            break
print(ans)


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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;}

struct Pos{
    int x,y;
    Pos(int x,int y):x(x),y(y){}
};

int H,W;
int Ch,Cw;
int Dh,Dw;
string field[1005];
int d[1000005];
int s[1005][1005];
bool visited[1005][1005];
int id;
set<int> E[1000005];


void init(){
    id=0;
    for(int i=0;i<1000003;++i)d[i]=INF;
    for(int i=0;i<1003;++i){
        for(int j=0;j<1003;++j){
            s[i][j]=-1;
            visited[i][j]=false;
        }
    }
}

void bfs1(int sx,int sy){
    queue<Pos> que;
    que.push(Pos(sx,sy));
    s[sy][sx]=id;
    while(que.size()){
        Pos p=que.front();
        que.pop();
        visited[p.y][p.x]=true;
        for(int i=0;i<4;++i){
            int nx=p.x+dx[i],ny=p.y+dy[i];
            if(nx<0||nx>=W||ny<0||ny>=H)continue;
            if(visited[ny][nx])continue;
            if(s[ny][nx]!=-1)continue;
            if(field[ny][nx]=='#')continue;
            que.push(Pos(nx,ny));
            s[ny][nx]=id;
        }
    }
    id++;
}

void bfs2(int s){
    queue<int> que;
    que.push(s);
    d[s]=0;
    while(que.size()){
        int p=que.front();
        que.pop();
        for(auto u:E[p]){
            if(d[u]!=INF)continue;
            que.push(u);
            d[u]=d[p]+1;
        }
    }
}

signed main(){
    init();
    cin>>H>>W;
    cin>>Ch>>Cw;
    cin>>Dh>>Dw;
    Ch--,Cw--;
    Dh--,Dw--;
    for(int i=0;i<H;++i)cin>>field[i];
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            if(field[y][x]=='#')continue;
            if(s[y][x]!=-1)continue;
            bfs1(x,y);
        }
    }
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            if(field[y][x]=='#')continue;
            for(int i=-2;i<=2;++i){
                for(int j=-2;j<=2;++j){
                    int nx=x+i,ny=y+j;
                    if(nx<0||nx>=W||ny<0||ny>=H)continue;
                    if(s[ny][nx]==s[y][x])continue;
                    if(field[ny][nx]=='#')continue;
                    E[s[y][x]].insert(s[ny][nx]);
                    E[s[ny][nx]].insert(s[y][x]);
                }
            }
        }
    }
    bfs2(s[Ch][Cw]);
    if(d[s[Dh][Dw]]==INF)cout<<-1<<endl;
    else cout<<d[s[Dh][Dw]]<<endl;
}

Measured memory_bytes: 87592
#include <iostream>

using namespace std;

int main() {
	int n,x;
	while (cin >> n >> x) {
		if (n == 0 && x == 0) {
			break;
		}
		int counter = 0;
		for (int i = 1; i <= n-2; i++) {
			for (int j = i+1; j <= n-1; j++) {
				for (int k = j+1; k <= n; k++) {
					if (i+j+k == x) {
						counter++;
					}
				}
			}
		}
		cout << counter << endl;
	}
	return 0;
}

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

#define   ll    long long int

const int N = 200005;
ll A[N], F[N];
ll n, k;

int ok(ll x)
{
    ll i, j, s = 0;
    for (i = 1; i <= n; i++)
        s += max(0LL, A[i] - (x / F[i]));
    if (s <= k)
        return 1;
    return 0;
}

ll bin_( )
{
    ll lo = 0, hi = (ll) 1e12, mid, ans = (ll) 1e12 + 10;

    while (lo <= hi)
    {
        mid = lo + (hi - lo) / 2;
        if (ok(mid) == 1)
        {
            ans = min(ans, mid);
            hi = mid - 1;
        }
        else
        {
            lo = mid + 1;
        }
    }
    return ans;
}

int main( )
{
    ll i, j;
    cin >> n >> k;
    for (i = 1; i <= n; i++)
        cin >> A[i];
    for (i = 1; i <= n; i++)
        cin >> F[i];
    sort(A + 1, A + n + 1);
    sort(F + 1, F + n + 1, greater<int>( ));
    cout << bin_( ) << '\n';
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



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

 
 int n;  cin>>n;

 vector<int>v(n);  for(auto &i : v)cin>>i;

 int mn=n+100; int cnt=0;
 for(int i=0;i<n;i++)
 {
   mn=min(mn,v[i]);
   if(mn==v[i])cnt++;

 }

 cout<<cnt<<"\n";
   
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
s = [input() for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

d = {'AC':0,'WA':0,'TLE':0,'RE':0}

for i in s:
    d[i] = d.get(i,0) + 1

for k,v in d.items():
    print(k+' x '+str(v))

Measured memory_bytes: 16336
import java.util.Scanner;


public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int a = 2;
		int n = sc.nextInt();

		int rezult = 0;

		rezult = lcm(a, n);

		System.out.println(rezult);
	}

	private static int gcd(int a, int n) {
		if(a < n) {
			return gcd(n, a);
		}
		if(n == 0) {
			return a;
		}
		return gcd(n, a % n);
	}

	private static int lcm(int a, int n) {
		return a * n / gcd(a, n);
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e5+10;
char s[N];
ll ans;
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	int x=0,sum=1; ans=0;
	for (int i=2;i<=n;i++) if (s[i]!=s[i-1]) {
		if (s[i-1]=='<') x=sum,ans+=1ll*(1+sum)*sum/2; else ans+=1ll*(1+sum)*sum/2-(ll)min(sum,x),x=0; 
		sum=1;
	} else sum++;
	if (s[n]=='<') x=sum,ans+=1ll*(1+sum)*sum/2; else ans+=1ll*(1+sum)*sum/2-(ll)min(sum,x),x=0;
	printf("%lld\n",ans); 
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;
const ll  N  = 1000000007 ;// prime modulo value

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, k, p, d;
ll x;
ll A, B;
string s;

// <------------- Implement Functions Here ----------> //

vll factor(ll n) {
	vll f;
	for(ll i=1;i*i <= n;i++) {
		if(n%i==0)
			f.pb(i);
	}
	return f;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>m>>d;
	ll cnt = 0;
	for(ll i=2;i<=min(81ll,m);i++) {
		vll f = factor(i);
		for(ll j=0;j<f.size();j++) {
			if(f[j] < 10 && f[j] > 1 && i/f[j] < 10 && i/f[j] > 1) {
				if(f[j]*10 + i/f[j] <= d)
					cnt++;
				if(i/f[j] * 10 + f[j] <= d && f[j]!=i/f[j])
					cnt++;
			}
		}
	}
	cout<<cnt;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,string>>p(m);
    rep(i,m) {
        cin >> p[i].first >> p[i].second;
    }
    int cnt_ac = 0;
    int cnt_wa = 0;
    map<int,bool>mp;
    map<int,int>mp2;
    rep(i,m) {
        if(!mp[p[i].first]) {
            if(p[i].second == "AC") {
                mp[p[i].first] = true;
                cnt_ac++;
            }
            if(p[i].second == "WA") {
                mp2[p[i].first]++;
            }
        }
    }
    rep(i,m) {
        if(mp[p[i].first]) {
            cnt_wa +=mp2[p[i].first];
            mp2[p[i].first] = 0;
        }
    }
    cout << cnt_ac <<" " <<  cnt_wa << endl;

}

Measured memory_bytes: 15872
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
//stl
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <list>
#include <bitset>
#include <iomanip>

#define ll long long
#define ioio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define F first
#define S second
const ll mod = 1000000007;
const double eps = 1e-9;
const double pi = acos(-1.0);

using namespace std;

int module(int a, int b)
{
	return (a % b + b) % b;
}

vector<vector<int>>g;
vector<int>used;

bool dfs(int v, int pcol)
{
	if (pcol == 1)
		used[v] = 2;
	else
		used[v] = 1;
	int call = used[v];
	bool f = 1;
	for (auto i : g[v])
	{
		if (used[i] == 0)
		{
			f &= dfs(i, call);
		}
		else
		{
			if (used[v] == used[i])
			{
				return false;
			}
		}
	}
	return f;
}


void solve()
{
	int n;
	cin >> n;
	set<int>s;
	for (int i = 0; i < n; ++i)
	{
		int t;
		cin >> t;
		s.insert(t);
	}
	cout << (s.size() == n ? "YES" : "NO");
}


int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ioio;
	/*int n;
	cin >> n;
	for (int i = 0; i < n; ++i)*/
	{
		solve();
	}
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    long long int a, b, work;
    cin >> a >> b;
    long long int m = a, n = b;
    while (1)
    {
        work = a % b;
        if(work == 0){
            break;
        }
        a = b;
        b = work;
    }

    cout << m * n / b;
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().rstrip())
p = list(map(int, sys.stdin.readline().rstrip().split()))
ind = list(range(1, n + 1))
tmp = []
for i, j in zip(p, ind):
    if i == j:
        tmp.append(i)
count = 0
ans = 0
for ii, i in enumerate(p):
    if count >= len(tmp):
        break
    if i == tmp[count]:
        ans += 1
        count += 1
        if ii > len(p) - 1 or count > len(tmp)-1:
            break
        # print(ii, count)
        if p[ii + 1] == tmp[count]:
            count = count + 1
print(ans)


Measured memory_bytes: 57196
n=int(input())
a=list(map(int, input().split()))
p=1
for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            p=0

if p==0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
size = int(input())
li = list(map(int,input().split()))
"""ans = [0]*size
for i in li:
    if i not in ans:
        ans[i-1] = 1
    else:
        ans[i-1] += 1
for i in ans:
    print(i)
"""
from collections import Counter
c1 = Counter(li)
ans2 = [0] * size
for i,j in c1.items():
    ans2[i-1] = j
for i in ans2:
    print(i)


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  vector<pair<int, int>> AB(N - 1);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    AB[i] = make_pair(a, b);
  }

  int K = 0;
  map<pair<int, int>, int> color;
  vector<int> cs(N, 0);

  vector<bool> used(N, false);
  deque<int> dq;
  used[0] = true;
  dq.emplace_back(0);

  while (!dq.empty()) {
    int x = dq.front();
    dq.pop_front();

    K = max(K, (int)G[x].size());

    int cur = 1;
    for (int y : G[x]) {
      if (used[y]) continue;
      if (cur == cs[x]) cur++;
      cs[y] = color[make_pair(x, y)] = color[make_pair(y, x)] = cur++;
      used[y] = true;
      dq.emplace_back(y);
    }
  }

  cout << K << '\n';
  for (int i = 0; i < N - 1; i++) {
    cout << color[AB[i]] << '\n';
  }
  return 0;
}


Measured memory_bytes: 19712
from itertools import groupby

s = input()
n = int(input())
ans = 0
comp_k = []
comp_s = []
for k,v in groupby(s):
  comp_k += [k]
  comp_s += [len(list(v))]

if len(comp_s) == 1:
  print(comp_s[0] * n // 2)
  quit()

a = 0
if comp_k[0] == comp_k[-1]:
  a += comp_s[0]//2 + comp_s[-1]//2
  comp_s[0] += comp_s.pop()
  a -= comp_s[0]//2

for i in comp_s:
  ans += i // 2
ans *= n

print(ans + a)

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


bool is_prime(int num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}


int main() {
    int X;
    cin >> X;
    if (X == 2) {
        cout << 2 << endl;
        return 0;
    }
    if (X % 2 == 0) X++;
    while (!is_prime(X)) X += 2;
    cout << X << endl;
}


Measured memory_bytes: 256
def calc(n)
  d = 0
  d,n = d+n%10, n/10 while n > 0
  return d
end
K = gets.to_i
ans = 1
K.times do |i|
  p ans
  k,tmp,list = 0,ans+1,[]
  while tmp > 0
    n = (tmp+1)*(10**k)-1
    list << [n/calc(n).to_f,n]
    tmp /= 10
    k += 1
  end
  ans = list.sort[0][1]
end


Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  set<ll>se;
  for(int i=0;i<k;i++){
    ll a;cin>>a;
    while(a--){
      ll b;cin>>b;
      se.insert(b);
    }
  }
  cout<<n-se.size()<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 200001
typedef long long ll;
using namespace std;

int main(){
    int N;
    ll A[SIZE];
    ll max=0;
    ll ans=0;
    cin >> N;
    cin >> A[0];
    max = A[0];
    for(int i = 1 ; i < N ; i++){
        cin >> A[i];
        if(max < A[i]){
            max = A[i];
        }else{
            ans += max - A[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5140
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


using namespace std;

int main(){

int n;
cin>>n;
int alpha[n][26]={};//0で初期化

int Alpha[26];

for(int i=0;i<n;i++){
string s;
cin>>s;
    for(int k=0;k<s.size();k++){
        int t=s[k]-'a';
        alpha[i][t]++;
    }
}
for(int k=0;k<26;k++){
    Alpha[k]=100;
    for(int i=0;i<n;i++){
    Alpha[k]=min(Alpha[k],alpha[i][k]);
    }
}

for(int i=0;i<26;i++){
    for(int k=0;k<Alpha[i];k++){
        char c='a'+i;
        cout<<c;
    }
}

 return 0;
}

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

int main(void){
  double H, W, x, y;
  cin >> W >> H >> x >> y;
  if(fabs(W/2-x)/W<1e-9 && fabs(H/2-y)/H<1e-9){
    cout << H*W/2 << " " << 1;
  }else{
    cout << H*W/2 << " " << 0;    
  }
  return 0;
}


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

double calc_Det(double, double, double, double);
 
int main() {
    double a, b, c, d, e, f;
    double x, y;
 
    while (cin >> a >> b >> c >> d >> e >> f) {
        x = (double)calc_Det(c, b, f, e) / calc_Det(a, b, d, e);
        y = (double)calc_Det(a, c, d, f) / calc_Det(a, b, d, e);

        if (fabs(x) < 1e-3) { x = 0.0; }
        if (fabs(y) < 1e-3) { y = 0.0; }
        printf("%.3f %.3f\n", x, y);
    }
}
 
double calc_Det(double a, double b, double c, double d) {
    return a*d - b*c;
}


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

int N, m;

int s[104];
int main(){
  cin.sync_with_stdio(false);
  cin >> N;
  m = 1000;
  for(int i = 0; i < N; i++){
    cin >> s[i];
    if(s[i] % 10 != 0){
      m = min(m, s[i]);
    }
  }

  int S = 0;

  for(int i = 0; i < N; i++){
    S += s[i];
  }

  if(S % 10 == 0){
    if(m == 1000){
      cout << 0 << endl;
    }else{
      cout << S - m << endl;
    }
  }else{
    cout << S << endl;
  }
  return 0;

}

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

typedef bool B;
typedef long double D;
typedef complex<D> P;
typedef vector<P> VP;
typedef struct {P s,t;} L;
typedef vector<L> VL;
typedef struct {P c;D r;} C;
typedef vector <C> VC;

const D eps=1.0e-10;
const D pi=acos(-1.0);
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}
#define X real()
#define Y imag()

D ip(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D ep(P a, P b) {return a.X * b.Y - a.Y * b.X;}
D sq(D a) {return sqrt(max(a, (D)0));}
P vec(L l){return l.t-l.s;}
inline P input(){D x,y;cin >> x >> y; return P(x,y);}
// ???????????¬????????¨???


D area(VP pol){
	int n=pol.size();
	D sum=0.0;
	rep(i,n){
		D x=pol[i%n].X-pol[(i+1)%n].X;
		D y=pol[i%n].Y+pol[(i+1)%n].Y;
		sum+=x*y;
	}
	return abs(sum/2.0);
}

int main(void){
	int n;
	cin >> n;
	VP pol;
	rep(i,n) pol.push_back(input());
	D ans=area(pol);
	cout.precision(1);
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 1304
fun main() {
    val (n, m, q) = next3Int()
    val values = Array(q) { IntArray(4) { nextInt() } }
    values.sortByDescending { it[3] }
    val a = IntArray(n) { 1 }
    var max = 0L
    while (true) {
        var sum = 0L
        for (value in values) {
            if (a[value[1] - 1] - a[value[0] - 1] == value[2]) {
                sum += value[3]
            }
        }
        max = kotlin.math.max(max, sum)
        if (a[0] == m) {
            break
        }
        for (i in n - 1 downTo 0) {
            if (a[i] < m) {
                a[i]++
                for (j in i + 1 until n) {
                    a[j] = a[i]
                }
                break
            }
        }
    }
    println(max)
}

val scanner = java.util.Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt() = scanner.nextInt()
fun next2Int() = Pair(scanner.nextInt(), scanner.nextInt())
fun next3Int() = Triple(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
fun nextLong() = scanner.nextLong()
fun nextLine(): String = scanner.nextLine()
fun nextList() = nextLine().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLongList() = nextList().map(String::toLong)
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")

Measured memory_bytes: 40172
n = int(input())
nums = list(map(int, input().split()))

ans = 0
exit = False

while True:
    for num in nums:
        if num % 2 != 0:
            exit = True
            break
    if exit:
        break

    ans += 1

    for i in range(len(list(nums))):
        nums[i] = nums[i] // 2

print(ans)


Measured memory_bytes: 3064
<?php
list($n) = explode(" ", trim(fgets(STDIN)));
$x = [];
$y = [];
for ($i=0; $i<$n; $i++) {
  list($x[$i], $y[$i]) = explode(" ", trim(fgets(STDIN)));
}

$distance = 0;
for ($i=0; $i<$n; $i++){
  for ($j=$i+1; $j<$n; $j++){
    $dx = ($x[$i] - $x[$j]) * ($x[$i] - $x[$j]);
    $dy = ($y[$i] - $y[$j]) * ($y[$i] - $y[$j]);
    $distance += sqrt($dx + $dy);
  }
}

$p = ($n * ($n-1) ) / 2;

$ave = $distance / $p;

echo $ave * ($n-1);

Measured memory_bytes: 4732
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
int ps4[4][2]={0,1,0,-1,1,0,-1,0};
int ps8[8][2]={0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,-1,-1,1};
inline int min(int a,int b,int c) {return min(a,min(b,c));}
inline int max(int a,int b,int c) {return max(a,max(b,c));}
inline int min(int a,int b,int c,int d){return min(min(a,b,c),d);}
inline int max(int a,int b,int c,int d){return max(max(a,b,c),d);}
//struct Edge{int p, next, w;}edge[maxn];
//inline add_edge(int u, int v, int w){edge[cnt]=Edge{v,head[u],w}; head[u]=cnt++;}
const int N=200005;
///Code begin..................................................................


int main ()
{
    string s;
    cin>>s;
    for (int i=0; i<s.length()-1; ++i) {
        if (s[i]=='A'&&s[i+1]=='C') {puts("Yes"); return 0;}
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i,n)    for(int i = 0; i < (int)n; i++)

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    while(true){
        if((a - 1) * (ans - 1) + a >= b)
            break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    int K = A;
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
        K = max(K, x[i]);
    }
    K = A;
    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(K * N + 1, 0)));
    dp[0][0][0] = 1;
            for (int s = 0; s < K * N + 1; ++s) {
        for (int k = 0; k < N + 1; ++k) {
    for (int j = 0; j < N + 1; ++j) {
                if (x[j - 1] > s && j >= 1) {
                    dp[j][k][s] = dp[j - 1][k][s];
                }
                if (x[j - 1] <= s && j >= 1 && k >= 1) {
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
                }
            }   
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += dp[N][i][i * A];
    }
    cout << ans << endl;
}


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

int ti;

#define mid ((l+r)>>1)
const int maxn=200100;
const int INF=1e9;
void chkmin(int &x,int y){
	x=x<y?x:y;
}
int Min(int x,int y){
	return x<y?x:y;
}
struct node{
	int l,r;
}b[maxn];
bool cmp(const node &A,const node B){
	return A.r<B.r;
}
int n,m;
int a[maxn],cnt[maxn];
int f[maxn],g[maxn];
int tr[maxn<<2];
void Build_tree(int h,int l,int r){
	tr[h]=INF;
	if(l==r)return;
	Build_tree(h<<1,l,mid);
	Build_tree(h<<1|1,mid+1,r);
}
int Query(int h,int l,int r,int p){
	if(l==r) return tr[h];
	if(p<=mid)
		return Min(Query(h<<1,l,mid,p),tr[h]);
	else
		return Min(Query(h<<1|1,mid+1,r,p),tr[h]);
}
void updata(int h,int l,int r,int s,int t,int v){
	if(s<=l&&r<=t){
		chkmin(tr[h],v);
		return;
	}
	if(t<=mid)
		updata(h<<1,l,mid,s,t,v);
	else if(s>mid)
		updata(h<<1|1,mid+1,r,s,t,v);
	else{
		updata(h<<1,l,mid,s,mid,v);
		updata(h<<1|1,mid+1,r,mid+1,t,v);
	}
}
void solve(){
	for(int i=1;i<=n;i++)
		f[i]=g[i]=INF;
	for(int i=1;i<=m;i++)
		f[i]=g[i]=INF;
	Build_tree(1,1,n);
	int ps=1;
	for(int i=1;i<=m;i++){
		while(ps<=b[i].r){
			chkmin(g[ps],g[ps-1]+a[ps]);
			ps++;
		}
		ti=ps-1;
		f[i]=Query(1,1,n,b[i].l)+cnt[b[i].r];
		chkmin(f[i],g[b[i].l-1]+cnt[b[i].r]-cnt[b[i].l-1]);
		updata(1,1,n,b[i].l,b[i].r,f[i]-cnt[b[i].r]);

		chkmin(g[b[i].r],f[i]);
	}
	while(ps<=n){
		chkmin(g[ps],g[ps-1]+a[ps]);
		ps++;
	}
}
int main(){
//	freopen("hamming.in","r",stdin);
//	freopen("hamming.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		cnt[i]=cnt[i-1]+(a[i]==0);

	scanf("%d",&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&b[i].l,&b[i].r);
	sort(b+1,b+m+1,cmp);

	solve();
	printf("%d\n",g[n]);
	return 0;
}


Measured memory_bytes: 8064
#include<iostream>
using namespace std;
#define MAX 2000000000
int main(){
    int ans=100,cnt,c;
    string s;
    cin>>s;
    for(int i=0;i<'z'-'a'+1;i++){
        cnt=c=0;
        for(int j=0;j<s.size();j++){
            if(s[j]==char('a'+i))cnt=max(cnt,c),c=0;
            else c++;
        }
        cnt=max(cnt,c);
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[n+1];
  int b[n];
  for(int i=0; i<n+1; i++) cin>>a[i];
  for(int i=0; i<n; i++) cin>>b[i];

  int64_t ans = 0;
  for(int i=0; i<n; i++) {
    if(a[i]>=b[i]) ans += b[i];
    else {
      ans += a[i];
      if(b[i]-a[i]<=a[i+1]) {
        ans += b[i]-a[i];
        a[i+1] -= b[i]-a[i];
      }
      else {
        ans += a[i+1];
        a[i+1] = 0;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef int ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(ll D, const vector<ll> &c, const vector<vector<ll>> &s, const vector<ll> &t) {
  vector<ll> last(26, 0);
  ll score = 0;
  REP(d, D) {
    ll i = t[d] - 1;
    score += s[d][i];
    last[i] = d + 1;
    REP(j, 26) {
      score -= c[j] * (d + 1 - last[j]);
    }
  }
  return score;
}

ll calc_diff(ll D, ll pre, ll next, const vector<ll> &c, const vector<vector<ll>> &s, ll d, vector<ll> &t) {
  ll diff = s[d - 1][next] - s[d - 1][pre];
  {
    ll l = 0;
    FOR(i, 1, d) {
      if (t[i - 1] - 1 == next) {
        l = i;
      }
    }
    ll r = D + 1;
    FOR(i, d + 1, D + 1) {
      if (t[i - 1] - 1 == next) {
        r = i;
        break;
      }
    }
    ll x = r - d;
    ll y = d - l;
    diff += c[next] * x * y;
  }
  {
    ll l = 0;
    FOR(i, 1, d) {
      if (t[i - 1] - 1 == pre) {
        l = i;
      }
    }
    ll r = D + 1;
    FOR(i, d + 1, D + 1) {
      if (t[i - 1] - 1 == pre) {
        r = i;
        break;
      }
    }
    ll x = r - d;
    ll y = d - l;
    diff -= c[pre] * x * y;
  }
  return diff;
}

void solve(ll D, vector<ll> c, vector<vector<ll>> s, vector<ll> t, ll M, vector<ll> d, vector<ll> q) {
  ll score = calc_score(D, c, s, t);
  REP(i, M) {
    ll pre = t[d[i] - 1] - 1;
    ll next = q[i] - 1;
    t[d[i] - 1] = next + 1;

    score += calc_diff(D, pre, next, c, s, d[i], t);
    cout << score << endl;
  }
}

int main() {
  ll D;
  scanf("%d", &D);
  vector<ll> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%d", &c[i]);
  }
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  vector<ll> t(D);
  for (int i = 0; i < D; i++) {
    scanf("%d", &t[i]);
  }
  ll M;
  scanf("%d", &M);
  vector<ll> d(M);
  vector<ll> q(M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &d[i]);
    scanf("%d", &q[i]);
  }
  solve(D, move(c), move(s), move(t), M, move(d), move(q));
  return 0;
}


Measured memory_bytes: 3944
n = int(input())
a = [int(i) for i in input().split()]
mod,x,p,ans = 10**9+7,[0],1,0
for i in range(n):
	x.append((x[-1]+pow(i+1,mod-2,mod))%mod)
	p = (p*(i+1))%mod
for i in range(n): ans = (ans+a[i]*(x[i+1]+x[n-i]-1))%mod
print((p*ans)%mod)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = x;
        boolean flag = true;
        long ans = 0;
        while (flag) {
            if (z > y) {
                flag = false;
                break;
            }
            ans++;
            z = z * 2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string str;
    while(cin>>str){
        for(int i=(int)str.size()-1;i>0;i--){
            for(int j=0;j<=i;j++){
                str[j]=(str[j]+str[j+1]-2*'0')%10+'0';
            }
        }
        cout<<str[0]<<endl;
    } 
    return 0;
}


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

constexpr int MAX_A = 7368792;

bool solve(){
    int m, n;
    cin >> m >> n;
    if(m == 0) return true;
    vector<bool> ok(MAX_A, false);
    for(int i=m;i<=MAX_A;i++){
        if(!ok[i]){
            if(n>0){
                for(int j=i;j<MAX_A;j+=i){
                    ok[j] = true;
                }
                n--;
            }else{
                cout << i << endl;
                break;
            }
        }
    }
    return false;
}

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


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    int a;
    cin>>a;
    cout<<a+pow(a,2)+pow(a,3)<<endl;

    return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main(void)
{
int a ,b ,c;
scanf("%d%d%d" ,&a ,&b ,&c);
if(a < b&&b < c)printf("Yes\n");
if(a > b||b > c||a == b||c == b||a == c)printf("No\n");
return 0;
}

Measured memory_bytes: 1756
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int W, a, b;

	cin >> W >> a >> b;

	if (a > b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int ans;
	if (a <= b && b <= a + W) {
		ans = 0;
	}
	else {
		ans = b - (a + W);
	}

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



Measured memory_bytes: 256
line = input()
n = int(line.split()[0])
m = int(line.split()[1])

sum_table = []
list = []
sentakushi = [1, -1]

for i in range(0, n):
    line = input()
    x = int(line.split()[0])
    y = int(line.split()[1])
    z = int(line.split()[2])
    list.append([x, y, z])

ans = 0
for i in sentakushi:
    for j in sentakushi:
        for k in sentakushi:
            sum_table = []
            for count in range(0, n):
                tmp = list[count][0]*i + list[count][1]*j + list[count][2]*k
                sum_table.append(tmp)
            sum_table.sort()
            sum_table.reverse()

            sum = 0
            for count in range(0, m):
                sum += sum_table[count]

            if sum > ans:
                ans = sum
print(ans)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
int mod = 1000000007;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    vi l(n); rep(i,n) cin >> l[i];

    sort(all(l));
    int cnt = 0;
    for(int i = n-1; i >= 1; --i) {
        for(int j = i-1; j >= 0; --j) {
            int low = abs(l[i]-l[j]);
            auto iter = upper_bound(all(l), low);
            int index = iter - l.begin();
            cnt += max(0, j-index);
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using myui = uint64_t;
using myint = int64_t;

template <typename T>
using vec = vector<T>;

template<typename T>
T diff(const T& a, const T& b) {
    return a > b ? a - b : b - a;
}

myint impl(myui n, myui k, const vec<array<myui, 3>>& abcs, vec<array<myint, 3>>& vals) {
    if (vals[n][k] == -1) {
        myui max_val = 0;
        for(myui kn = 0; kn < 3; kn++) {
            if (k != kn) {
                myui res = impl(n-1, kn, abcs, vals);
                if (res > max_val) max_val = res;
            }
        }
        vals[n][k] = max_val + abcs[n][k];
    }
    return vals[n][k];
}

myint solve(myui n, const vec<array<myui, 3>>& abcs) {
    vec<array<myint, 3>> vals(n, {-1, -1, -1});
    for(myui i = 0; i < 3; i++) vals[0][i] = abcs[0][i];
    for(myui k = 0; k < 3; k++) impl(n-1, k, abcs, vals);
    return *max_element(vals[n-1].begin(), vals[n-1].end());
}

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

    {
        myui n;
        cin >> n;

        vec<array<myui, 3>> abcs;
        for(myui i = 0; i < n; i++) {
            myui a, b, c;
            cin >> a >> b >> c;
            abcs.push_back({a, b, c});
        }

        cout << solve(n, abcs) << endl;
    }

    return 0;
}


Measured memory_bytes: 13296
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    LL a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    LL x = c - a - b;
    if (x < 0) {
        printf("No\n");
    } else if (4 * a * b < (c-a-b) * (c-a-b)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


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

int main() {
  string b;

  cin >> b;

  if (b == "A") {
    cout << "T";
  }
  else if (b == "C") {
    cout << "G";
  }
  else if (b == "G") {
    cout << "C";
  }
  else {
    cout << "A";
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, M, X, a;
    cin >> N >> M >> X;
    vector<int> A(N, 0);
    rep(0, i, M)
    {
        cin >> a;
        A.at(a) = 1;
    }
    int b = 0, c = 0;
    for (int i = X; i < N; i++)
    {
        if (A.at(i))
        {
            b++;
        }
    }
    for (int i = X; i >= 0; i--)
    {
        if (A.at(i))
        {
            c++;
        }
    }

    cout << min(b, c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct S {
    ll s, t, x;
    
    bool operator<(const S &b) {
        return x < b.x;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    vector<S> stx(n);
    rep(i, n) cin >> stx[i].s >> stx[i].t >> stx[i].x;
    sort(all(stx));
    set<pair<ll, ll>> d;
    rep(i, q) {
        ll tmp;
        cin >> tmp;
        d.insert(make_pair(tmp, i));
    }
    vector<ll> ans(q, -1);
    rep(i, n) {
        ll l = stx[i].s - stx[i].x;
        ll r = stx[i].t - stx[i].x;
        auto it = d.lower_bound(make_pair(l, -1));
        while(it != d.end()) {
            if (it->first >= r) break;
            ans[it->second] = stx[i].x;
            d.erase(it++);
        }
    }
    rep(i, q) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 20608
# include<stdio.h>
int main(void)
{
	int a, b, c;
    scanf("%i %i %i", &a, &b, &c);
    int min = a + b;
    if (min > b + c)
    {
        min = b + c;
    }
    if (min > a + c)
    {
        min = a + c;
    }
    printf("%i\n", min);
    return 0;
}



Measured memory_bytes: 128
n, y = map(int, input().split())

def helper(n,y):

    for ten in range(n,-1,-1):
        for five in range(n-ten, -1,-1):


            one = n-ten-five
            sum = 10000*ten + 5000*five + 1000*one

            if y == sum:
                return('{} {} {}'.format(ten,five,one))


    return('-1 -1 -1')

print(helper(n,y))



Measured memory_bytes: 3060
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

string m(string a, string b)
{
    if (a == "T" && b == "T") return "T";
    if (a == "T" && b == "F") return "F";
    if (a == "F" && b == "T") return "T";
    return "T";
}

void main()
{
    auto N = readln.chomp.to!int;
    auto ps = readln.split.to!(string[]);

    auto c = m(ps[0], ps[1]);
    foreach (x; ps[2..$]) {
        c = m(c, x);
    }
    writeln(c);
}


Measured memory_bytes: 4336