akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T x; cin >> x; return x; }

struct vec2d {
	double x, y;
	vec2d() {}
	vec2d(double x, double y) :x(x), y(y) {}
	double norm()const {
		return hypot(x, y);
	}
	vec2d operator+(const vec2d&v)const {
		return vec2d(x + v.x, y + v.y);
	}
	vec2d operator-(const vec2d&v)const {
		return vec2d(x - v.x, y - v.y);
	}
	bool operator==(const vec2d&v)const {
		return x == v.x && y == v.y;
	}
	bool operator!=(const vec2d&v)const {
		return !operator==(v);
	}
	static double distance(const vec2d&v0, const vec2d&v1) {
		return (v0 - v1).norm();
	}
	static double cos_arg(const vec2d&v0, const vec2d&v1) {
		return (v0.x * v1.x + v0.y * v1.y) / v0.norm() / v1.norm();
	}
	static double cross_product(const vec2d&v0, const vec2d&v1) {
		return v0.x * v1.y - v0.y * v1.x;
	}
};
vector<vec2d>get_convex_hull(vector<vec2d>input) {
	sort(ALL(input), [](vec2d v0, vec2d v1) {return v0.y < v1.y || (v0.y == v1.y) && v0.x < v1.x; });
	vector<vec2d>output;
	output.push_back(input[0]);
	output.push_back(input[1]);
	for (int i = 2; i < input.size(); ++i) {
		output.push_back(input[i]);
		while (output.end() - 2 != output.begin() && vec2d::cross_product(*(output.end() - 3) - *(output.end() - 2), *(output.end() - 1) - *(output.end() - 2)) > 0) {
			output.erase(output.end() - 2);
		}
	}
	output.push_back(input[input.size() - 2]);
	for (int i = input.size() - 3; i >= 0; --i) {
		output.push_back(input[i]);
		while (output.end() - 2 != output.begin() && vec2d::cross_product(*(output.end() - 3) - *(output.end() - 2), *(output.end() - 1) - *(output.end() - 2)) > 0) {
			output.erase(output.end() - 2);
		}
	}
	output.pop_back();
	return output;
}
double diameter(vector<vec2d>vertex, bool guaranteed = true) {
	if (!guaranteed) {
		vertex = get_convex_hull(vertex);
	}
	auto comp_y = [](const vec2d&v0, const vec2d&v1) {return v0.y < v1.y; };
	int min_y_idx = distance(vertex.begin(), min_element(ALL(vertex), comp_y));
	int max_y_idx = distance(vertex.begin(), max_element(ALL(vertex), comp_y));
	double ret = -1;
	int p = min_y_idx, q = max_y_idx;
	int num = vertex.size();
	do {
		ret = max(vec2d::distance(vertex[p], vertex[q]), ret);
		int next_p = (p + 1) % num;
		int next_q = (q + 1) % num;
		if (vec2d::cross_product(vertex[next_p] - vertex[p], vertex[next_q] - vertex[q]) > 0) {
			q = next_q;
		} else {
			p = next_p;
		}
	} while (p != min_y_idx || q != max_y_idx);
	return ret;
}
signed main() {
	SETP;
	int n = in();
	vector<vec2d>vertex(n);
	REP(i, n) {
		double x = in<double>(), y = in<double>();
		vertex[i] = (vec2d(x, y));
	}
	cout << diameter(vertex) << endl;
}


Measured memory_bytes: 5596
/*
FIND YOUR PURPOSE BECOME UNSTOPPABLE---->>> ?????? 
                    ,.
                  ,_> `.   ,';
              ,-`'      `'   '`'._
            ,,-) ---._   |   .---''`-),.
          ,'      `.  \  ;  /   _,'     `,
      ,--' ____       \   '  ,'    ___  `-,
      _>   /--. `-.              .-'.--\   \__
    '-,  (    `.  `.,`~ \~'-. ,' ,'    )    _\
    _<    \     \ ,'  ') )   `. /     /    <,.
  ,-'   _,  \    ,'    ( /      `.    /        `-,
  `-.,-'     `.,'       `         `.,'  `\    ,-'
  ,'       _  /   ,,,      ,,,     \     `-. `-._
  /-,     ,'  ;   ' _ \    / _ `     ; `.     `(`-\
  /-,        ;    (o)      (o)      ;          `'`,
,~-'  ,-'    \     '        `      /     \      <_
/-. ,'        \                   /       \     ,-'
  '`,     ,'   `-/             \-' `.      `-. <
    /_    /      /   (_     _)   \    \          `,
      `-._;  ,' |  .::.`-.-' :..  |       `-.    _\
        _/       \  `:: ,^. :.:' / `.        \,-'
      '`.   ,-'  /`-..-'-.-`-..-'\            `-.
        >_ /     ;  (\/( ' )\/)  ;     `-.    _<
        ,-'      `.  \`-^^^-'/  ,'        \ _<
        `-,  ,'   `. `"""""' ,'   `-.   <`'
          ')        `._.,,_.'        \ ,-'
            '._        '`'`'   \       <
              >   ,'       ,   `-.   <`'
                `,/          \      ,-`
                `,   ,' |   /     /
                  '; /   ;        (
                  _)|   `       (
                  `')         .-'
                    <_   \   /    
                      \   /\(
                        `;/  `
*/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define ll long long int
using ld = long double;
#define INF 100000000
int main(){
	speed;
	ld a;
	ld b;
	cin>>a>>b;
	b*=1000;
	ll ans=a*b/1000;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
int a[4][4],v[4][4];
int b[105];
int n;
int main()
{
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
		}
	}
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	memset(v,0,sizeof(v));
	for(int i=0;i<n;i++)
	{
		int flag=0;
		for(int j=1;j<=3;j++)
		{
			
			for(int k=1;k<=3;k++)
			{
				if(a[j][k]==b[i])
				{
					v[j][k]=1;
					flag=1;
					break;
				}	
			}
			if(flag==1)	break;
		}
	}
	int flag=0;
	for(int i=1;i<=3;i++)
	{
		if(v[i][1]==1&&v[i][2]==1&&v[i][3]==1||v[1][i]==1&&v[2][i]==1&&v[3][i]==1)
		{
			flag=1;
		}
	}
	if(v[1][1]==1&&v[2][2]==1&&v[3][3]==1||v[1][3]==1&&v[2][2]==1&&v[3][1]==1)
		flag=1;
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> d(n);
  for (long long i=0; i<n; i++){
    cin >> d[i].first >> d[i].second;
  }
  double ans = 0;
  for (long long i=0; i<n; i++){
    for (long long j=0; j<n; j++){
      ans += sqrt((d[i].first - d[j].first)*(d[i].first - d[j].first) + (d[i].second - d[j].second) * (d[i].second - d[j].second));
    }
  }
  cout << setprecision(10) << ans/n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>
#include <random>
#include<algorithm>

#define int_max 2147483647;

//AGC 30

void Problem_A(void)
{
    int a ,b ;
    std::cin>>a>>b;
    if(b%a == 0)
    {
        std::cout<<a+b;
    }
    else
    {
        std::cout<<b - a;
    }
}

void Problem_B(void)
{
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int> > mat (n,std::vector<int>(m+1));
    for(int i = 0; i < n ; i ++)
    {
        std::cin>> mat[i][0];
        for(int j = 1 ; j <= int(mat[i][0]); j++)
        {
            std::cin>>mat[i][j];
        }
    }

    std::vector<int> manage_vec(m);
    for(int i = 0; i < m; i ++)
    {
        manage_vec[i] = 0;
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= int(mat[i][0]); j++)
        {
            manage_vec[mat[i][j]] = manage_vec[mat[i][j]] + 1;
        }
    }

    for (int i = 0; i < m; i++)
    {
        if(manage_vec[i] == n)
        {
            std::cout<<i;
        }
    }
    
    return;
}
int main(int argc, char const *argv[])
{
    Problem_A();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long long n,min=1000000000000000,a[5];
	cin >> n;
	for(int i=0;i<5;i++){
		cin >> a[i];
		if(min>a[i])	min = a[i];
	}
	int sub = 5;
	if(n%min==0)	sub--;
	cout << n/min+sub << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

//int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

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


int A = 0, C = 1, G = 2, T = 3;
int N;
long long memo[110][4][4][4]= {};
long long mod = 1000000007;
long long ans = 0;

int main(){
    scanf("%d",&N);
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                if(i==A && j==G && k==C)continue;
                if(i==G && j==A && k==C)continue;
                if(i==A && j==C && k==G)continue;
                memo[3][i][j][k] = 1;
            }
        }
    }
    for(int m = 4;m <= N;m++){
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                for(int l = 0;l < 4;l++){
                    if(i==A && j==G && k==C)continue;
                    if(i==G && j==A && k==C)continue;
                    if(i==A && j==C && k==G)continue;
                    if(i==A && k==G && l==C)continue;
                    if(i==A && j==G && l==C)continue;
                    memo[m][i][j][k] += memo[m-1][j][k][l];
                    memo[m][i][j][k] %= mod;
                }
            }
        }
    }
    }
    

    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                ans += memo[N][i][j][k];
                ans %= mod;
            }
        }
    }
    printf("%lld\n",ans);

    return 0;
}



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


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define mem(arr,x) memset(arr,x,sizeof(arr))
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve()
{
    ll n;
    cin>>n;
     string arr;
     ll n1=0,n2=0,n3=0,n4=0,i;
     for(i=0;i<n;i++)
     {
      cin>>arr;
      if(arr=="AC")
        n1++;
      else if(arr=="WA")
        n2++;
      else if(arr=="TLE")
        n3++;
      else if(arr=="RE")
        n4++;
     }
     cout<<"AC"<<" "<<"x"<<" "<<n1<<endl;
     cout<<"WA"<<" "<<"x"<<" "<<n2<<endl;
     cout<<"TLE"<<" "<<"x"<<" "<<n3<<endl;
     cout<<"RE"<<" "<<"x"<<" "<<n4<<endl;
}

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

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

template<typename T> class Dijkstra {
public:
  using pit = pair<int, T>;
  struct edge {
    int to; T cost;
  };
  int N;
  vector<vector<edge>> G;
  vector<T> D;
  Dijkstra(int n) : N(n), G(n), D(n, numeric_limits<T>::max()) {}
  void add(int from, int to, T cost) {
    G.at(from).push_back((edge) {to, cost});
  }
  void solve(int start) {
    priority_queue<pit, vector<pit>, greater<pit>> Q;
    D.at(start) = 0;
    Q.push(pit(start, 0));
    while (Q.size()) {
      auto [now, dist] = Q.top();
      Q.pop();
      for (auto [next, cost] : G.at(now)) {
        if (dist + cost < D.at(next)) {
          D.at(next) = dist + cost;
          Q.push(pit(next, D.at(next)));
        }
      }
    }
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H, W, sh, sw, gh, gw;
  cin >> H >> W >> sh >> sw >> gh >> gw;
  sh--, sw--, gh--, gw--;
  int st = 0, go = 0;
  vector<vector<pair<int, char>>> S(H, vector<pair<int, char>>(W));
  for (int i = 0, id = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      if (i == sh && j == sw) st = id;
      if (i == gh && j == gw) go = id;
      S.at(i).at(j) = {id++, c};
    }
  }
  
  vector<int> mh(4), mw(4);
  mh = {-1, 0, 1, 0};
  mw = {0, 1, 0, -1};

  Dijkstra<long> D(H * W);
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      for (int i = h - 2; i <= h + 2; i++) {
        for (int j = w - 2; j <= w + 2; j++) {
          if (i < 0 || i >= H || j < 0 || j >= W) continue;
          if (S.at(i).at(j).second == '.') D.add(S.at(h).at(w).first, S.at(i).at(j).first, 1);
        }
      }
      for (int i = 0; i < 4; i++) {
        int nh = h + mh.at(i);
        int nw = w + mw.at(i);
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (S.at(nh).at(nw).second == '.') D.add(S.at(h).at(w).first, S.at(nh).at(nw).first, 0);
      }
    }
  }

  D.solve(st);

  if (D.D.at(go) == LONG_MAX) return cout << -1 << "\n", 0;
  cout << D.D.at(go) << "\n";
}


Measured memory_bytes: 368672
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=223456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,k;
    while(sf("%d %d",&n,&k)==2)
    {
        int ara[n+5];
        int fre[S+5];
        memset(fre,0,sizeof fre);
        for(int i=0;i<n;i++)sf("%d",&ara[i]),fre[ara[i]]++;

        sort(fre,fre+S);
        reverse(fre,fre+S);
        int sum=0;
        for(int i=0;i<k;i++)
        {
            sum+=fre[i];
        }

        pf("%d\n",n-sum);
    }
    return 0;
}
 









 




























Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5][5];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      for(int k=0;k<=100;k++){
	if(a[0][0]-i==a[0][1]-j&&a[0][1]-j==a[0][2]-k){
	  if(a[1][0]-i==a[1][1]-j&&a[1][1]-j==a[1][2]-k){
	    if(a[2][0]-i==a[2][1]-j&&a[2][1]-j==a[2][2]-k){
	      cout<<"Yes"<<endl;
	      return(0);
	    }
	  }
	}
      }
    }
  }
  cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int prime[51000]; //i盤目の素数
bool is_prime[51001]; //is_prime[i]がtrueならiは素数

void sieve(int n){ //n以下の素数を返す
	int p=0;
	for(int i=0;i<=n;i++) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
		}
	}
}

int main(){
	sieve(51000);
	int n;
	while(cin>>n){
		int pre,after;
		rer(i,1,51000){
			if(i<n && is_prime[i]) pre=i;
			if(i>n && is_prime[i]){
				after=i; break;
			}
		}
		o(pre<<" "<<after);
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100
 
char data[MAX][MAX/2][MAX];
int plen, cnum, width, cspace, page;
int x, y;
string ss;
 
void init(){
    page = 0;
    for(int i = 0 ; i < MAX ; i++){
	for(int j = 0 ; j < MAX/2 ; j++){
	    for(int k = 0 ; k < MAX ; k++){
		data[i][j][k] = '.';
	    }
	}
    }
}
 
bool check(){
    bool ok = true;
    if(ss.empty()) return ok;
 
    for(int i = 0 ; i < plen ; i++){
	for(int j = 0 ; j < cnum*width+cspace*(cnum-1) ; j++){
	    if(data[i][j][page] != '.') return ok;
	}
    }
    return !ok;
}
 
void change(){
    y++;
    if(y == plen){
	y = 0;
	x++;
	if(x == cnum){
	    x = y = 0;
	    page++;
	}
    }
}
 
void insert(string &str){
    int size = str.size(), start;
    int end, p = 0;
    bool flg = true;
 
    while(flg){
	start = x*(width+cspace);
	if(size - p <= width){
	    end = start + size - p;
	    flg = false;
	}else{
	    flg = true;
	    end = start + width;
	}
	for(int i = start ; i < end ; i++, p++){
	    if(p == size){ 
		flg = false;
		break;
	    }
	    data[y][i][page] = str[p];
	}
	change(); 
    }
}
 
void print(){
    if(!check()) page--;
    for(int k = 0 ; k <= page ; k++){
	for(int i = 0 ; i < plen ; i++){
	    for(int j = 0 ; j < cnum*width+cspace*(cnum-1) ; j++){
		cout << data[i][j][k];
	    }
	    cout << endl;
	}
	cout << '#' << endl;
    }
    cout << '?' << endl;
}
 
int main(){
    string str;
    while(cin >> plen && plen){
	init();
	cin >> cnum >> width >> cspace;
 
	cin.ignore();
	x = y = 0;
	while(getline(cin,str), str != "?"){
	    ss = str;
	    if(str.empty()){
		change();
	    }else{
		insert(str);
	    }
	}
	print();
    }
    return 0;
}

Measured memory_bytes: 3488
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // int Nを受け取る
		int zolo = 0; // ゾロ目が連続して出た回数
		boolean three = false; // ゾロ目が3回連続して出たフラグ
		for(int i = 0; i < N; i++) {
			int D1 = sc.nextInt(); // int D1を受け取る
			int D2 = sc.nextInt(); // int D2を受け取る
			if(D1 == D2) {
				zolo += 1;
			} else {
				zolo = 0;
			}
			if(zolo == 3) {
				three = true;
			}
		}
		sc.close(); // 標準入力を終了

		if (three) {
			// ゾロ目が3回以上続けて出た
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 36028
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define ll long long

using namespace std;

int main(){
ll n,k,buf;
vector<ll> h;
cin>>n>>k;
for(ll i=0;i<n;i++){
  cin>>buf;
  h.push_back(buf);
}
sort(h.begin(),h.end());

buf = h[k-1]-h[0];
for(ll i=0;i<n-k+1;i++){
if(buf>h[k-1+i]-h[0+i])
buf=h[k-1+i]-h[0+i];
}
printf("%d\n",buf);

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvp g;
vi a,d;

void dfs(int v,int pre,int c){
	int I=(c==1?2:1);
	for(auto p:g[v]){
		int u=p.first;
		if(u!=pre){
			a[p.second]=I;
			dfs(u,v,I);
			I++;
			if(I==c) I++;
		}
	}
}

int main(){
	cin>>n;
	g=vvp(n);
	d=vi(n);
	a=vi(n-1);
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back({v,i});
		g[v].push_back({u,i});
		d[u]++;d[v]++;
	}
	dfs(0,-1,0);
	int m=0;
	for(auto i:d) m=max(m,i);
	cout<<m<<endl;
	for(auto i:a) cout<<i<<endl;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

int P(int n, int x) {
  int preso = pow(2,n+1) - 3;
  if(n == 0) return 1;
  if(x >= preso*2+3) return 2*P(n-1, preso) + 1;
  else if(x >= preso+3) return P(n-1, preso) + P(n-1, x-preso-2) + 1;
  else if(x == preso+2) return P(n-1, preso) + 1;
  else if(x >= 2) return P(n-1, x-1);
  else return 0;
}

signed main() {
  int N, X; cin >> N >> X;
  if(X == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  cout << P(N, X) << endl;
  


}

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

void solve()
{
    int n;
    cin >> n;
    if (n % 1000 == 0) {
        cout << 0 << endl;
        return;
    }
    cout << 1000 - n % 1000 << endl;;
}

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

    /* int T; */
    /* cin >> T; */
    /* for (int t = 0; t < T; ++t) { */
        solve();
    /* } */
    return 0;
}


Measured memory_bytes: 3648
def main():
    n = int(input())
    a = list(map(int, input().split()))
    count = 0

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

    print(count)


if __name__ == '__main__':
    main()


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

#define	MOD 1000000007

int	main() {
	long N, A, B;
	cin >>N >>A >>B;
	long S=0;
	if (1==N) {
		if (A==B)
			S=1;
		else
			S=0;
	} else if (B<A)
		S=0;
	else
		S=(B-A)*(N-2)+1;
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();
		if(n > 1) {
			n -= 2;
		}
		if(m > 1) {
			m -= 2;
		}
		System.out.println(n * m);
	}

}


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

int main()
{
    int a,b,c = 0;
    cin >> a >> b >> c;
    
    if((c >=a) && (c <=b)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define ll long long

using namespace std;

struct RSQRAQ {
	int n;
	vector<ll> dat, lazy;

	RSQRAQ() {}
	RSQRAQ(int n_) {
		n = 1; while (n < n_) n *= 2;
		dat.assign(n * 2, 0);
		lazy.assign(n * 2, 0);
	}

	void eval(int len, int k) {
		if (lazy[k] == 0) return;
		if (k * 2 + 1 < n * 2 - 1) {
			lazy[2 * k + 1] += lazy[k];
			lazy[2 * k + 2] += lazy[k];
		}
		dat[k] += lazy[k] * len;
		lazy[k] = 0;
	}

	// [a, b)
	ll update(int a, int b, ll x, int k, int l, int r) {
		eval(r - l, k);
		if (b <= l || r <= a) return dat[k];
		if (a <= l && r <= b) {
			lazy[k] += x;
			return dat[k] + lazy[k] * (r - l);
		}
		return dat[k] = update(a, b, x, 2 * k + 1, l, (l + r) / 2) + update(a, b, x, 2 * k + 2, (l + r) / 2, r);
	}
	ll update(int a, int b, ll x) { return update(a, b, x, 0, 0, n); }

	// [a, b)
	ll query(int a, int b, int k, int l, int r) {
		eval(r - l, k);
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) return dat[k];
		ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
	ll query(int a, int b) { return query(a, b, 0, 0, n); }
};

signed main() {
	int n, m; cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	RSQRAQ seg(m + 1);
	for (int i = 0; i < n - 1; ++i) {
		int b = (a[i + 1] - a[i] + m) % m;
		if (b == 1 || b == 0) continue;
		seg.update(max(0, a[i + 1] - b + 1), a[i + 1], 1LL);
		seg.update(a[i + 1], a[i + 1] + 1, -b + 1LL);
		if (a[i + 1] - b + m + 1 < m)
			seg.update(a[i + 1] - b + m + 1, m, 1LL);
	}
	vector<ll> times(m + 1, 0);
	{ // 1に設定したときの回数を求める
		ll res = 0;
		for (int i = 0; i < n - 1; ++i)
			res += min((a[i + 1] - a[i] + m) % m, (a[i + 1] - 1 + m) % m + 1);
		times[1] = res;
	}
	for (int i = 1; i < m; ++i) {
		times[i + 1] = times[i] - seg.query(i, i + 1);
	}
	ll ans = 100000000000000LL;
	for (int i = 1; i <= m; ++i)
		ans = min(ans, times[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5504
MOD = 10**9 + 7


def main():
    # TDPC E or EDPC S
    S = input()
    N = len(S)
    D = int(input())
    dp = [[[0]*D for _ in range(2)] for _ in range(N+1)]
    dp[0][0][0] = 1
    from itertools import product
    for i, smaller, dsum in product(range(N), [True, False], range(D)):
        lim = 9 if smaller else int(S[i])
        for d in range(lim+1):
            dp[i+1][smaller or d < lim][(dsum+d) % D] += dp[i][smaller][dsum]
            dp[i+1][smaller or d < lim][(dsum+d) % D] %= MOD
    print((dp[N][0][0] + dp[N][1][0] - 1) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61532
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define     sc(a)       scanf("%d",&a)
#define     sc2(a,b)    scanf("%d%d",&a,&b)
#define     line        "\n"
#define     space       " "
#define     MAX         100010
#define     MOD         1000000007
#define     Q           int nn ; scanf("%d",&nn); for (int xx=0;xx<nn;xx++)
#define     ff          first
#define     ss          second
#define     pf(a)       printf("%d\n",a)
#define     pfs(a)      printf("%d ",a)
#define     pf2(a,b)    printf("%d %d\n",a,b)
#define     itm(it)     map<int,int>:: iterator it
#define     its(it)     set<int>:: iterator it
#define     ac_sort(v)  sort(v.begin(),v.end())
#define     dc_sort(v)  sort(v.rbegin(),v.rend())
typedef long long lld;
using namespace std;
int main()
{
    int n ; sc(n);
    bool f =0, flag =0;
    while (n){
        for (int x=2;x*x<=n;x++){
            if (n%x==0) flag=1;
        }
        if (flag==0){
            break;
        }
        else flag=0,n++;
    }
    pf(n);
}


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

int main(){
    int N;
    cin >> N;
    
    int vals[N];
    for(int i = 0; i < N; i++){
        cin >> vals[i];
    }
    
    for(int i = N-1; i >= 0; i--){
        if (i < N-1) printf(" ");
        cout << vals[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
#include <cstdint>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
#define mod 1000000007
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


ll comb(int n, int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int compare_char(const void* left, const void* right) {
	char *left_char = (char *)left;
	char *right_char = (char *)right;

	return strcmp(left_char, right_char);
}

int main(){


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

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	ll i, j, k, l, m, n, len;
	ll B, C, D, N, M, K, num_R, num_G, num_B, ans;
	ll sum = 0, sum_B = 0, sum_C = 0, max, min, count = 0, Q, W, X;
	ll **A, *d, *Asum;
	char S[3];


	ll temp1, temp2;




	cin >> N >> K;




	Asum = (ll *)malloc(sizeof(ll)* N);


	for (i = 0; i < N; i++)
		Asum[i] = 0;

	for (i = 0; i < K; i++){
		cin >> temp1;
		for (j = 0; j < temp1; j++){
			cin >> temp2;
			Asum[temp2 - 1]=1;

		}
	}


	count = 0;
	for (i = 0; i < N; i++){
		if (Asum[i] == 0){
			count++;
		}

	}

	cout << count << endl;

	return 0;

}//1 2 3 4 5 6
    

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define C getchar()
#define ll long long
using namespace std;
int read()
{
	int x=0,l=1;char c=C;
	for (;c<'0'||c>'9';c=C) if (c=='-') l=-1;
	for (;c>='0'&&c<='9';c=C) x=(x<<1)+(x<<3)+(c^48);
	return x*l;
}

int main()
{
	int a=read(),b=read();
	string st;
	if (a<0&&b>0) st="Zero";
	if (a>0) st="Positive";
	if (b<0)
		if ((b-a+1)&1) st="Negative";
			else	   st="Positive";
	cout<<st;
	return 0;
}

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

/* clang-format off */
// #define int long long
// #define double long double
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

template <typename T> inline size_t maxElement(T beginIt, T endIt) { return max_element(beginIt, endIt); }
template <typename T> inline size_t minElement(T beginIt, T endIt) { return min_element(beginIt, endIt); }
template <typename T> inline size_t maxIndex(T beginIt, T endIt) { return distance(beginIt, *max_element(beginIt, endIt)); }
template <typename T> inline size_t minIndex(T beginIt, T endIt) { return distance(beginIt, *min_element(beginIt, endIt)); }
template <typename T> inline int sum(T beginIt, T endIt) { return accumulate(beginIt, endIt, 0); }
template <typename T> inline int mean(T beginIt, T endIt) { return sum(beginIt, endIt) / distance(beginIt, endIt); }
template <typename T> inline void debug(T x) { cerr << x << " " << "(L:" << __LINE__ << ")" << endl; }
/* clang-format on */

signed main(void) {
  /* */
  int num; // num
  // num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // double num; // num
  // num = 0; // count, result
  // num = numeric_limits<double>::min(); // max
  // num = numeric_limits<double>::max(); // min
  int N;
  array<int, 10> A;
  string S;
  /* */

  string T;
  cin >> S;
  cin >> T;
  bool flag = false;

  for (auto it = S.begin(); it != S.end(); ++it) {
    // cout << S.substr(it - S.begin(), S.end() - it) << " " << T.substr(0, S.end() - it) << endl;
    // cout << S.substr(0, it - S.begin()) << " " << T.substr(S.end() - it, it - S.begin()) << endl;
    if (S.substr(it - S.begin(), S.end() - it) == T.substr(0, S.end() - it) &&
        S.substr(0, it - S.begin()) == T.substr(S.end() - it, it - S.begin())) {
      flag = true;
      break;
    }
    S.substr(it - S.begin(), S.end() - it);
    T.substr(S.end() - it);
    S.substr(it - S.begin());
    T.substr(S.end() - it, it - S.begin());
    
  }
  
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  // cout << num << endl;
  // cout << fixed << setprecision(10) << num << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
#import numpy as np
#import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
n,k=map(int,input().split())
x=list(map(int,input().split()))
s=0
for i in range(n):
    if x[i]>=0:
        s=i
        break
else:
  s=n
res=10**9
if s+k-1<n:
  res=x[s+k-1]
if s-k>=0 and res>abs(x[s-k]):
  res=abs(x[s-k])
for i in range(1,k):
    if s+k-i-1>n-1 or s-i<0:
        continue
    if x[s+k-i-1]+2*abs(x[s-i])<res:
        res=x[s+k-i-1]+2*abs(x[s-i])
for i in range(1,k):
    if s-k+i<0 or s+i-1>n-1:
        continue
    if abs(x[s-k+i])+2*x[s+i-1]<res:
        res=abs(x[s-k+i])+2*x[s+i-1]
print(res)


Measured memory_bytes: 84332
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int h,w;cin>>h>>w;
	int a[110][110];
	char c;
	for(int i=0;i<h;i++)
	{
		int f=0;
		for(int j=0;j<w;j++)
		{
			cin>>c;
			if(c=='c')
			{
				f=1;
				a[i][j]=0;
			}
			else
			{
				if(f==0)a[i][j]=-1;
				else a[i][j]=a[i][j-1]+1;
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(j)cout<<" "<<a[i][j];
			else cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
		int sum = 0;
        for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			sum += map[i];
		}
        
        int M = sc.nextInt();
		for (int i = 0; i < M; i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			
			System.out.println(sum - map[p-1] + x);
		}
		
		
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;
#define rep(i, n) for (int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for (int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    vector<int> C(M), D(M);
    rep(i, N) cin >> A[i] >> B[i];
    rep(i, M) cin >> C[i] >> D[i];
    vector<int> res(N);
    rep(i, N)
    {
        int target = 0;
        int dist = INF;
        rep(j, M)
        {
            if (dist > abs(A[i] - C[j]) + abs(B[i] - D[j]))
            {
                dist = abs(A[i] - C[j]) + abs(B[i] - D[j]);
                target = j;
            }
        }
        res[i] = target + 1;
    }
    rep(i, N) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int r = 0, b = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r++;
        } else {
            b++;
        }
    }

    cout << (r > b ? "Yes" : "No") << endl;
}


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


class StringSearch {
	const int n;
	string S;
	vector<int> SA, Rank;
public:
	StringSearch(const string &S_)
		: n(S_.size()), S(S_), SA(n + 1), Rank(n + 1)
	{
		for (int i = 0; i <= n; i++) {
			SA[i] = i;
			Rank[i] = i < n ? S[i] : -1;
		}

		int k = 1;
		vector<int> tmp(n + 1);
		auto Compare_SA = [=](int i, int j) {
			if (Rank[i] != Rank[j]) return Rank[i] < Rank[j];
			else {
				int ri = i + k <= n ? Rank[i + k] : -1;
				int rj = j + k <= n ? Rank[j + k] : -1;
				return ri < rj;
			}
		};
		for (; k <= n; k *= 2) {
			sort(SA.begin(), SA.end(), Compare_SA);

			tmp[SA[0]] = 0;
			for (int i = 1; i <= n; i++) {
				tmp[SA[i]] = tmp[SA[i - 1]] + (Compare_SA(SA[i - 1], SA[i]) ? 1 : 0);
			}
			for (int i = 0; i <= n; i++) {
				Rank[i] = tmp[i];
			}
		}
	}

	bool Contain(const string &T) {
		int a = 0, b = n;
		while (b - a > 1) {
			int c = (a + b) / 2;
			if (S.compare(SA[c], T.length(), T) < 0) a = c;
			else b = c;
		}
		return S.compare(SA[b], T.length(), T) == 0;
	}
};

int main()
{
	int Q;
	string T, P;
	cin.sync_with_stdio(false);
	cin >> T;
	StringSearch SS(T);
	cin >> Q;
	while (Q--) {
		cin >> P;
		cout << SS.Contain(P) << endl;
	}
	return 0;
}

Measured memory_bytes: 16628
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}
const double PI = acos(-1);
const double EPS = 1e-9;
int solve()
{
	ll q;cin>>q;
	ll theta=0;
	double x=0,y=0;

	ll ans=0;
	while(1)
	{
		theta+=q;
		ans++;
		double cur = (PI/180)*(double)theta + (PI/2);
		x = x+cos(cur);
		y = y+sin(cur);
		if(abs(x)<=EPS && abs(y)<=EPS)
		{
			cout<<ans<<"\n";
			return 0;
		}
	}
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

int main()
{

    int t;
    cin>>t;
    cout<<t+t*t+t*t*t;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n=sc.nextInt();
		long n=sc.nextLong();
		long k=sc.nextLong();
		//String s=sc.next();
		//long[] array=new long[n];
		int sum=1,buff,max=0,min=0;
		//int[] array=new int[l];
		//String s="",m="",h="";

		for(long i=0;i<n;i++) {
			if(sum*2<=sum+k)sum=sum*2;
			else sum+=k;
			//System.out.println(sum);
		}
		//Arrays.sort(array)
		System.out.println(sum);
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




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

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 13;

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

    int mul = 1;

    vector<ll> dp(N);
    dp[0] = 1;

    for(int i = S.length() - 1; i >= 0; i--) {
        char c = S[i];
        vector<ll> nextDP(N);

        if(c == '?') {
            for(int k = 0; k < 10; k++) {
                for (int j = 0; j < N; j++) {
                    nextDP[(k * mul + j) % N] += dp[j];
                    nextDP[(k * mul + j) % N] %= MOD;
                }
            }
        } else {
            int k = c - '0';

            for(int j = 0; j < N; j++) {
                nextDP[(k * mul + j) % N] += dp[j];
                nextDP[(k * mul + j) % N] %= MOD;
            }
        }

        mul *= 10;
        mul %= 13;
        dp = nextDP;
    }

    cout << dp[5] << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

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

    vl mae(n);  // a[i]より前にあるa[i]より小さい数の個数
    vl ushiro(n);  // a[i]より後ろにあるa[i]より小さい数の個数
    rep(i, n) {
        exrep(j, 0, i-1) {
            if(a[j] < a[i]) {
                mae[i]++;
            }
        }
    }
    rep(i, n) {
        exrep(j, i+1, n-1) {
            if(a[j] < a[i]) {
                ushiro[i]++;
            }
        }
    }

    ll ans = 0;
    rep(i, n) {
        ll x = ushiro[i];
        ll y = (k*(k+1)/2)%mod;
        ans += (x*y)%mod;
        ans %= mod;
    }
    rep(i, n) {
        ll x = mae[i];
        ll y = (k*(k-1)/2)%mod;
        ans += (x*y)%mod;
        ans %= mod;
    }
        
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(10e5+3)
#define fim '\n'
#define ll long long
#define f first
#define s second
#define debug(x) cout << "DEBUG " << x << endl
using namespace std;
typedef pair<int, int> pii;

int grau[MAXN], dp[MAXN];
vector<int> rota[MAXN];

int dfs(int u) {
	if(dp[u] != -1)
		return dp[u];
	if(rota[u].size() == 0)
		return dp[u] = 0;
	
	for(int i = 0; i < rota[u].size(); i++)
		dp[u] = max(dp[u], dfs(rota[u][i])+1);
	return dp[u];
}

int main(){
	cin.tie(NULL);
	cout.tie(NULL);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		rota[a].pb(b);
		grau[b]++;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		if(grau[i] == 0) ans = max(ans, dfs(i));
	cout << ans << endl;
}


Measured memory_bytes: 36736
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    mini = 999
    ANS = 0
    for i in range(102):
        if P.count(i) == 0:
            if mini > abs(X-i):
                mini = abs(X-i)
                ANS = i
    print(ANS)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;

int max3(int a, int b, int c){
	return max(a, max(b, c));
}

int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	
	int a, b;
	cin >> a >> b;
	print(max3(a + b, a - b, a * b));
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res=0;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

int sx,sy,gx,gy;
int n;
int xs[1001];
int ys[1001];
const int dy[2][6]={{1,0,-1,-1,-1,0},{1,1,0,-1,0,1}};
const int dx[2][6]={{0,1,1,0,-1,-1},{0,1,1,0,-1,-1}};
map<pii,int> d[6];
int lx,ly;
set<pii> obj;

int main(){
  cin>>sx>>sy>>gx>>gy;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>xs[i]>>ys[i];
    obj.insert(pii(ys[i],xs[i]));
  }
  cin>>lx>>ly;
  priority_queue<pair<int,pair<pii,int> >,vector<pair<int,pair<pii,int> > >,greater<pair<int,pair<pii,int> > > > pq;
  pq.push(make_pair(0,make_pair(pii(sy,sx),0)));
  d[0][pii(sy,sx)]=0;
  while(pq.size()){
    pair<int,pair<pii,int> > p=pq.top();pq.pop();
    int ccost=p.first;
    int cy=p.second.first.first;
    int cx=p.second.first.second;
    int dig=abs(cx)%2;
    int t=p.second.second%6;
    //cout<<cy<<" "<<cx<<" "<<ccost<<endl;
    for(int j=0;j<6;j++){
      int inst=abs((ll)cy*cx*(t+j))%6;
      int add=j;
      for(int i=0;i<6;i++){
	int ncost=ccost+(inst!=i)+add;
	int ny=cy+dy[dig][i];
	int nx=cx+dx[dig][i];
	pii np=pii(ny,nx);
	if(ny>=-ly&&nx>=-lx&&ny<=ly&&nx<=lx
	   &&obj.count(np)==0
	   &&(d[(t+j)%6].count(np)==0||d[(t+j)%6][np]>ncost)){
	  d[(t+j)%6][np]=ncost;
	  pq.push(make_pair(ncost,make_pair(np,(t+1+j)%6)));
	}
      }
    }
  }
  int res=1<<30;
  for(int i=0;i<6;i++)
    if(d[i].count(pii(gy,gx))>0)
      res=min(res,d[i][pii(gy,gx)]);
  if(res==(1<<30))res=-1;
  cout<<res<<endl;
  return 0;
}


  

Measured memory_bytes: 16208
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
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;}


const long long INF = 1LL << 60;
long long dp[100010];

//bucket1
bool ch[10] = {0};
bool check(int n){
    while(n!=0){
        if(ch[n%10]) return false;
        n /= 10;
    }
    return true;
}



// --------write my code!!!!!----------//

int main(){
    string s; cin >> s;
    string res;
    for(int i=0;i<s.length();++i){
        if(s[i]=='B') {
            if(res.length()==0) continue;
            else res.pop_back();
        }
        else res += s[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
long long gcd(long long a,long long b)
{
  if(a>b)
  {
    swap(a,b);
  }
  if(a==0){return b;}
  else return gcd(b%a,a);
}

int main()
{
  ios::sync_with_stdio(false);
  long long n,m;
  string s,l;
  cin>>n>>m>>s>>l;
  long lcm;
  lcm=((n*m))/gcd(n,m);
  long long si,li;
  si=lcm/m;li=lcm/n;
  long long cnt=gcd(n,m);
  for(long long i=0;i<cnt;i++)
  {
    if(s[i*si]!=l[i*li]){cout<<-1;return 0;}
  }
  cout<<lcm;

  return 0;

}


Measured memory_bytes: 764