akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
	while (NULL != x->left) x = x->left;
	return x;
}

Node treeMaximum(Node x){

	return NIL;
}

Node treeSearch(Node u, int k){
	while (u)
	{
		if (u->key == k) return u;
		else if (k < u->key) u = u->left;
		else u = u->right;
	}
	return NIL;
}

Node treeSuccessor(Node x)
{
	if (NULL != x->right) return treeMinimum(x->right);

	printf("aaaaaaaaaaaaaaaaaaaaa");
	Node y = x->parent;
	while (NULL != y && x == y->right)
	{
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y

	if (NULL == z->left || NULL == z->right) y = z;
	else y = treeSuccessor(z);

	if (NULL != y->left) x = y->left;
	else x = y->right;

	if (NULL != x) x->parent = y->parent;

	if (NULL == y->parent)
		root = x;
	else
	{
		if (y == y->parent->left)
			y->parent->left = x;
		else
			y->parent->right = x;
	}
	if (y != z) z->key = y->key;

	free(y);
}

void insert(int k){
	Node y = NIL;
	Node x = root;

	Node z = (Node)malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (k < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;
	if (y == NULL)
		root = z;
	else{
		if (k < y->key)
			y->left = z;
		else
			y->right = z;
	}
}

void inorder(Node u){
	if (u == NULL) return;

	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node u){
	if (u == NULL) return;

	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}


int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", com);
		if (com[0] == 'f'){
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i'){
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}
	return 0;
}

Measured memory_bytes: 21464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e15;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

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

int bfs(vector<vector<int>>& m, int Y,int X,int T){
	vector<vector<int>> vis(500, vector<int>(500, 0));
	queue<tuple<int,int,int>> q;
	q.emplace(Y,X,T);
	while(!q.empty()){
		int y, x, t;
		tie(y,x,t)=q.front(); q.pop();

		if(t == 0)  continue;
		vis[y][x] = true;

		rep(i,6){
			int ny=y+dy[i];
			int nx=x+dx[i];
			if(m[ny][nx] or vis[ny][nx]) continue;
			vis[ny][nx]=true;
			q.emplace(ny,nx,t-1);
		}
	}
	int cnt=0;
	rep(i,500)rep(j,500)cnt+=vis[i][j];
	return cnt;
}

signed main(){
	int t,n;
	while (cin>>t>>n,t) {
		vector<vector<int>> m(500, vector<int>(500, 0));
		rep(i,n){
			int x,y;
			cin>>x>>y;
			x+=200;y+=200;
			m[y][x]=true;
		}
		int sx,sy;
		cin>>sx>>sy;
		sx+=200;sy+=200;
		cout<<bfs(m,sy,sx,t)<<endl;

	}

	return 0;
}



Measured memory_bytes: 6756
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    final long INF = -1_000_000_000_000_000L;
    long[] dist = new long[N];
    for (int i = 1; i < N; i++) dist[i] = INF;
    int[][] edges = new int[M][2];
    int[] costs = new int[M];

    for (int i = 0; i < M; i++) {
      edges[i] = new int[] {scanner.nextInt() - 1, scanner.nextInt() - 1};
      costs[i] = scanner.nextInt();
    }

    for (int i = 0; i < N - 1; i++) {
      for (int j = 0; j < M; j++) {
        int from = edges[j][0];
        int to = edges[j][1];
        int cost = costs[j];
        if (dist[from] > INF) {
          long newValue = dist[from] + cost;
          if (newValue > dist[to]) dist[to] = newValue;
        }
      }
    }

    boolean[] negative = new boolean[N];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        int from = edges[j][0];
        int to = edges[j][1];
        int cost = costs[j];
        if (dist[from] > INF && dist[from] + cost > dist[to]) negative[from] = true;
        if (negative[from]) negative[to] = true;
      }
    }
    if (negative[N - 1]) System.out.println("inf");
    else System.out.println(dist[N - 1]);
  }
}


Measured memory_bytes: 28432
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
using namespace std;

int main()
{
	int a, b, v;
	double theta;
	double tmp, tmp2;

	cin >> a >> b >> v;

	if (2 * v >= a * a * b) {
		tmp = (double)b / a;
		tmp2 = (double)v / (a * a * a);
		theta = 2 * (tmp - tmp2);
	} else {
		tmp = a * b * b;
		theta = tmp / (2 * v);
	}


	printf("%.12f", atan(theta) * 180.0 / PI);

	return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
int ans = 0;

void find(int n)
{
    for(int x=1; x*x<n; x++)
    {
        for(int y=1; y*y<n; y++)
        {
            if(x*x+y*y >= n)
                break;
            for(int z=1; z*z<n; z++)
            {
                if((x*x+y*y+z*z +x*y+y*z+z*x) > n)
                    break;
                ans += ((x*x+y*y+z*z+x*y+y*z+z*x)== n);
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        ans = 0;
        find(i);
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3580
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto X = RD;
	auto remain = X % 100;
	auto cnt = X / 100;
	
	writeln(cnt*5 >= remain ? 1 : 0);
	stdout.flush;
	debug readln;
}

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

int main(){

  long long N;

  long long a[5];

  long long b[5];
  
  cin>>N;


  for(int i=0;i<5;i++){
	cin>>a[i];

	if(a[i]>=N){
	  b[i]=1;
	}else{
	  if(N%a[i]==0){
		b[i]=N/a[i];
	  }else{
		b[i]=N/a[i]+1;
	  }
	}
  }

  long long cnt=0;

  long long temp=0;
  
  for(int i=0;i<5;i++){

	if(i==0){
	  cnt+=b[i];
	  
	}else{
	  if(temp+1+b[i]>cnt){
		cnt=temp+1+b[i];
		temp+=1;
	  }else{
		cnt=cnt+1;
		temp+=1;
	  }
  
	}
  }

  cout<<cnt<<endl;  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int r,s,p;
int point(char ss){
    int ret;
    if(ss=='r'){
        ret=p;
    }else if(ss=='s'){
        ret=r;
    }else{
        ret=s;
    }
    return ret;
}

int main(){
    int n,k;
    cin>>n>>k>>r>>s>>p;
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<k;++i){
        int j=i;
        while(j<n){
            if(j>=k){
                if(s[j-k]!=s[j]){
                    ans+=point(s[j]);
                }else{
                    s[j]='x';
                }
            }else{
                ans+=point(s[j]);
            }
            j+=k;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

struct ran{
  int l,r;
  bool operator<(const ran &other)const{return r < other.r;}
};

int main(){

  int n,m;
  cin >> n >> m;
  vector<ran> v(m);
  rep(i,m)cin >> v[i].l >> v[i].r;
  sort(ALL(v));
  int last = -1;
  int res = 0;
  rep(i,m)if(v[i].l > last)last = v[i].r-1,res++;
  cout << res << endl;
  



  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,n) for(size_t i=l; i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using mii = map<int,int>;
using pii = pair<int,int>;
using ti3 = tuple<int,int,int>;

int main(){
  ll n,k; cin>>n>>k;
  cout<<min(n%k,(k-n%k))<<endl;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double sum = 0;
    for(int i=0;i<n;i++){
      double a = sc.nextInt();
      sum += 1/a;
    }
    double ans = 1/sum;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES //M_PI, M_E
	#include<bits/stdc++.h>
	#define mod 1000000007
	#define ll long long int
	#define ar array
	#define pb push_back
	ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
	using namespace std;

	int main()
	{
		ios::sync_with_stdio(false);
		cin.tie(NULL);
		long double ans = 1;
		int n;
		cin>>n;
		int flag = 0;
		for(long double i= 0,j; i<n; i++)
		{
			cin>>j;
			if(ans<=(ll)1e18 && flag ==0)
				ans *=j;
			if(ans>(ll)1e18)
				flag = 1;
			if((ll)j==0)
				ans = 0,flag= 0;
		}
		if(flag) cout<<-1<<endl;
		else cout<<(ll)ans<<endl;
		return 0;
	}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,i,j,m = 0,ans = 0;
    cin >> n;
    vector< ll >v(n);
    for(i = 0; i < n; i++)cin>>v[i];
    rep(i,0,n){
        if(v[i] < m){
            ans += (m - v[i]);
        }
            m = max(m , v[i]);
    }
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 4792
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int sum;
		
		while(true){
		sum = sc.nextInt();
		if(sum == 0)break;
		
		for(int i = 0; i < 9; i++)
			sum -= sc.nextInt();
		
		System.out.println(sum);
	}
		sc.close();
	}
}

Measured memory_bytes: 17316
def COM(n, r):
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, MAX):
        fac.append(fac[i - 1] * i % MOD)
        inv.append(-inv[MOD % i] * (MOD // i))
        finv.append(finv[i - 1] * inv[i] % MOD)
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD
 
 
MOD = 10 ** 9 + 7
MAX = 10 ** 6

X, Y = map(int, input().split())
a = X + Y
if(a % 3 != 0 or X < (a // 3) or Y < (a // 3)):
  print(0)
else:
  b = a // 3
  x = X-b
  y = Y-b
  c = x+y
  print(COM(c, x))

Measured memory_bytes: 159928
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

int main(){

    while(true){
        string c;
        getline(cin,c);
       if(c.size()==1&&c[0]=='.'){break;}
       else{
           bool f=true;
           stack<int> m;
           rep(i,c.size()){
               if(c[i]=='('){
               m.push(1);
               }else if(c[i]==')'){
                   if(!m.empty()&&m.top()==1){
                       m.pop();
                   }else{
                      f=false;
                      break;
                   }
               }else if(c[i]=='['){
                   m.push(2);
               }else if(c[i]==']') {
                   if (!m.empty()&&m.top()==2) {
                       m.pop();
                   } else {
                       f = false;
                       break;
                   }

               }
           }
           if(!m.empty())f=false;
           if(f)cout<<"yes"<<endl;
           else cout<<"no"<<endl;
}

    }
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=505;
int n,a[maxn];
int res[maxn*maxn];
pin v[maxn];
int main(){
	read(n);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)v[i]=mk(a[i],i);
	sort(v+1,v+1+n);
	rep(i,1,n){
		if(res[v[i].w1]){
			puts("No");
			return 0;
		}
		res[v[i].w1]=v[i].w2;
		int left=v[i].w2-1;
		rep(j,1,v[i].w1){
			if(!left)break;
			if(!res[j]){
				res[j]=v[i].w2;
				left--;
			}
		}
		if(left){
			puts("No");
			return 0;
		}
	}
	rep(i,1,n){
		int left=n-i;
		rep(k,a[i]+1,n*n){
			if(!left)break;
			if(!res[k]){
				res[k]=i;
				left--;
			}
		}//assert(left);
		if(left){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
//	printf("%d\n",n);
	rep(i,1,n*n)printf("%d ",res[i]);
	return 0;
}


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

string f[10] = {
	"* = ****",
	"* =* ***",
	"* =** **",
	"* =*** *",
	"* =**** ",
	" *= ****",
	" *=* ***",
	" *=** **",
	" *=*** *",
	" *=**** "
};

int main(){
	string s;
	bool flag = false;

	while( cin >> s ){
		string ans[10];
		if( flag ){
			cout << endl;
		}else{
			flag = true;
		}
		while( s.size() < 5 ){
			s = "0" + s;
		}

		for(int i=0 ; i < s.size() ; i++ ){
			ans[i] = f[s[i]-'0'];
		}
		for(int x=0 ; x < 8 ; x++ ){
			for(int y=0 ; y < s.size() ; y++ ){
				cout << ans[y][x];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> a >> b;
	ans = max(a , b);
	ans *= 2;
	if (a != b) ans--; 

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


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
main() {
 int N;
 cin >> N;
 vector<string> vec(N);
  
 for (int i=0; i<N; i++){
  cin >> vec.at(i);
 }
  
 sort(vec.begin(), vec.end());
 int count =N;
  
 for (int i=0; i<N-1; i++){
 
   if (vec.at(i)==vec.at(i+1))
     count--;
 }
cout << count << endl;
}



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 1876543210

int main()
{
  int n,m;cin>>n>>m;
  while(n!=0&&m!=0)
  {
    vector<int> c(m);
    vector<int> x(n);
    int i,j,k;
    rep(i,m)cin>>c[i];
    rep(i,n)cin>>x[i];
    vector<vector<int>> dp(n+1,vector<int>(256,INF));
    dp[0][128]=0;
    rep(i,n)rep(j,256)rep(k,m)
    {
      int aft=j+c[k];
      if(aft>255)aft=255;
      if(aft<0)aft=0;
      int add=(x[i]-aft);
      dp[i+1][aft]=min(dp[i+1][aft],dp[i][j]+add*add);
    }
    int ans=INF;
    rep(i,256)ans=min(ans,dp[n][i]);
    cout<<ans<<endl;
    cin>>n>>m;
  }
}



Measured memory_bytes: 23820
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=100010;
ll a[MAXN],b[MAXN],n,ans;
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n+1;i++) {scanf("%d",&a[i]);}
	for (int i=1;i<=n;i++) {scanf("%d",&b[i]);}
	for (int i=n;i>=1;i--) {
		ans+=min(b[i],a[i+1]),b[i]-=min(b[i],a[i+1]);
		if (b[i]) {
			ll t=min(b[i],a[i]);
			ans+=t,b[i]-=t,a[i]-=t; 
		}
	}
	printf("%lld\n",ans);
}

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

//create arrays outside of main()

int a[100];

int main(){

    int age;
    int regCost;
    int cost;

    cin >> age >> regCost;

    if(age<=5){
        cost = 0;
    } else if(age>=6 && age<=12){
        cost = regCost/2;
    } else {
        cost = regCost;
    }

    cout << cost;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1) / 2 + m * (m - 1) / 2);
}


Measured memory_bytes: 31488
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    double a = 0.000000;
    double ans;
    cin >> n;
    if(n == 1) ans = 1.0000000;
    else if(n %2==0) ans = 0.500000000;
    else{
        a = ((n-1)/2)+1;
        ans = a/n;
    }
    cout << fixed << setprecision(7) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// D - Knight

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

// mod p （pは素数）の下でのべき乗を求める
ll mod_pow(ll a, ll n, ll p) {
	ll result = 1;
	while (n > 0) {
		if (n & 1) result = result * a % p;
		a = a * a % p;
		n >>= 1;
	}
	return result;
};

// mod p（pは素数）の下での逆元を求める（フェルマーの小定理を利用）
ll mod_inverse(ll a, ll p) {
	return mod_pow(a, p-2, p);
}

// mod p （pは素数）の下での除算 (a / b)
ll mod_devide(ll a, ll b, ll p) {
	return a * mod_inverse(b, p) % p;
}

// mod p （pは素数）の下での組み合わせ（nCk）を計算
ll mod_comb(ll n, ll k, ll p) {
	ll numerator = 1;
	for (int i=n; i>n-k; i--) {
		numerator *= i;
		numerator %= p;
	}

	ll denominator = 1;
	for (int i=k; i>0; i--) {
		denominator *= i;
		denominator %= p;
	}

	return mod_devide(numerator, denominator, p);
}

int main()
{
	ll X, Y;
	cin >> X >> Y;

	// move_1: X方向に1, Y方向に2
	// move_2: X方向に2, Y方向に1
	// 1 * move_1 + 2 * move_2 = X
	// 2 * move_1 + 1 * move_2 = Y
	ll move_1 = (2 * Y - X) / 3;
	ll move_2 = (2 * X - Y) / 3;
	ll move_total = move_1 + move_2;

	if (1 * move_1 + 2 * move_2 != X) {
		cout << 0 << endl;
		return 0;
	}

	if (2 * move_1 + 1 * move_2 != Y) {
		cout << 0 << endl;
		return 0;
	}

	if (move_1 < 0 || move_2 < 0 || move_total != (X + Y) / 3) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = mod_comb(move_total, move_1, MOD);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> A(n);
    rep(i,n){
        ll a;
        cin>>a;
        a--;
        A[i]=a;
    }

    vector<ll> visit(n,-1);
    visit[0]=0;
    ll now=0;
    ll cnt=0;
    ll loop=0;
    while(cnt<=k){
        cnt++;
        now=A[now];
        if(visit[now]!=-1){
            loop=cnt-visit[now];
            break;
        }else{
            visit[now]=cnt;
        }
    }

    if(loop){
        ll nk=(k-visit[now])%loop;
        rep(i,nk)now=A[now];
    }else{
        now=0;
        rep(i,k)now=A[now];
    }

    cout<<now+1<<endl;
}

Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int64_t i=ini;i<n;i++)
#define _rep(i,ini,n) for(int64_t i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int64_t FastPow(int64_t n, int64_t m){
    if(m==0) return 1;
    if(m==1) return n;

    int64_t v=FastPow(n,m/2);
    v=(v*v)%MOD;
    if(m%2) v=(v*n)%MOD;
    return v;
}

int64_t RevSrc(int64_t n, int64_t m){
    return FastPow(n,m-2);
}

int64_t Factr(int64_t n, int64_t m){
    int64_t v=1;
    _rep(i,n,n-m+1) v=(v*i)%MOD;
    //cerr<<n<<" "<<m<<" "<<v<<endl;
    return v;
}

int64_t Comb(int64_t n, int64_t m){
    return (Factr(n,m)*RevSrc(Factr(m,m),MOD))%MOD;
}

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

    int64_t ans=1;
    rep(i,0,N) ans=(ans*(M-i))%MOD;

    int64_t _ans=ans,tmp=1,comb1,comb2=1;
    rep(i,1,N) tmp=(tmp*(M-i))%MOD;
    comb1=Factr(N,1);

    int f=-1;
    rep(i,1,N+1){
        int64_t v=((comb1*RevSrc(comb2,MOD))%MOD*tmp)%MOD;

        if(f>0) _ans=(_ans+v)%MOD;
        else{
            _ans-=v;
            if(_ans<0) _ans+=MOD;
        }

        tmp=(tmp*RevSrc(M-i,MOD))%MOD;
        comb1=(comb1*(N-i))%MOD;
        comb2=(comb2*(i+1))%MOD;
        f*=-1;
    }

    ans=(ans*_ans)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll M, D;
    cin >> M >> D;

    ll ans = 0;
    for (ll i = 22; i <= D; i++) {
        ll j = i / 10;
        ll k = i % 10;
        if (1 <= j*k && j*k <= M && j >= 2 && k >= 2) {
            ans++;
            // cout << j << " " << k << endl;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
int main()
{
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int AB = 2 * C;
  int ans = AB * (X + Y);
  rep(i, 0, X + Y)
      ans = min(ans, AB * i + A * max(0, X - i) + B * max(0, Y - i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  double n;cin>>n;
  double res;
  res=ceil(n/2);
  printf("%.10lf\n",res/=n);
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ss := make([]string, n)
	ysp48 := makeBools(n, n)

	for i := 0; i < n; i++ {
		ss[i] = getNextString(scanner)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			ysp48[i][j] = true
			for k := 1; k < n && ysp48[i][j]; k++ {
				ysp48[i][j] = ss[index(i+k, n)][j] == ss[i][index(j+k, n)]
			}
		}
	}

	ans := n * n

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			for k := 0; k < n; k++ {
				if ysp48[index(i+k, n)][index(j+k, n)] == false {
					ans--
					break
				}
			}
		}
	}

	fmt.Fprintln(writer, ans)
}

func makeBools(h, w int) [][]bool {
	index := make([][]bool, h, h)
	data := make([]bool, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}
func index(i, n int) int {
	if i < 0 {
		i += n
	}
	return i % n
}


Measured memory_bytes: 896
#include<cstdio>
int v[100007];
int main(){
  int n,m;scanf("%d%d",&n,&m);
  for(int i=1,a,b;i<=m;++i){
    scanf("%d%d",&a,&b);
    v[a]^=1;v[b]^=1;
  }
  bool flag=true;
  for(int i=1;i<=n;++i){
    if(v[i])flag=false;
  }
  if(flag)printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 512
n = gets.chomp.split('').map(&:to_i)
number = 0
for i in 1..n.length
    if n.length == i
        if i % 2 == 1
            for num in 1..i
                number += n[num - 1] * (10 ** (i - num))
            end
            for num in 1..i / 2
                i = i - 2 > 0 ? i : 2
                number -= 9 * (10 ** (i - 2 * num))
            end
            puts number
        else
            for num in 1..i / 2
                number += 9 * (10 ** (i - 2 * num))
            end
            puts number
        end
        break
    end
end

Measured memory_bytes: 1788
def depth_first_search ms, visit_logs, visit_cnts, cnt
  cnt += 1
  i = visit_logs.last
  visit_cnts[i] = [cnt, nil]
  ms[i].each do |a|
    if visit_cnts[a - 1].nil?
      visit_logs << a - 1
      visit_cnts, cnt = depth_first_search(ms, visit_logs, visit_cnts, cnt)
    end
  end

  cnt += 1
  visit_logs.pop
  visit_cnts[i][1] = cnt

  return visit_cnts, cnt
end

n = gets.chomp.to_i
ms = Array.new(n)
visit_cnts = Array.new(n)
cnt = 0
n.times do
  num, degree, *adjacents = gets.chomp.split(' ').map(&:to_i)
  ms[num - 1] = adjacents
end
while true
  undone_i = visit_cnts.find_index{|d| d.nil? }
  break unless undone_i
  visit_cnts, cnt = depth_first_search ms, [undone_i], visit_cnts, cnt
end
visit_cnts.each_with_index do |l, i|
  puts "#{i + 1} #{l[0]} #{l[1]}"
end


Measured memory_bytes: 6996
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    vector<ll> A(5,0);
    for(ll i=0;i<5;i++)cin>>A[i];
    vector<ll> B(5,0);
    ll ans=0;
    for(ll i=0;i<5;i++)ans+=((A[i]+9)/10)*10;
    for(ll i=0;i<5;i++)B[i]=(10-(A[i]%10))%10;
    sort(B.begin(), B.end());
    print(ans-B[4])

    return 0;
}

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

using namespace std;
ll mod = 1e9 + 7;
char s[1004][1004];
int dp[1005][1005];
int n , m;
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
        cin >> s[i][j];
        dp[1][1] = 1;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            if (s[i][j] == '.' && i + j > 2)
            {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n][m] << endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
char s[1010][1010];
int n,m,i,j,k;
int fin;
int x[1010][1010];
int c;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m>>i;
    for(i=0;i<n;i++)
        cin>>s[i];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            if(s[i][j]=='#')
                break;
        if(j<m)
        {
            for(j=0;j<m;j++)
            { 
                if(s[i][j]=='#')
                    break;
                for(k=fin;k<=i;k++)
                    x[k][j]=c+1;
            }
            for(;j<m;j++)
            {
                if(s[i][j]=='#')
                    c++;
                for(k=fin;k<=i;k++)
                    x[k][j]=c;
            }
            fin=i+1;
        }
    }
    for(i=fin;i<n;i++)
        for(j=0;j<m;j++)
            x[i][j]=x[i-1][j];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            cout<<x[i][j]<<' ';
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 4224
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((s (coerce (read-line) 'simple-base-string))
         (n (length s))
         (nexts (make-array (list n 26) :element-type 'uint32))
         (dp (make-array (+ n 1) :element-type 'uint32 :initial-element #xffffffff))
         (seqs (make-array (+ n 1) :element-type 'list)))
    (declare (uint31 n))
    (let ((table (make-array 26 :element-type 'uint31 :initial-element n)))
      (loop for i from (- n 1) downto 0
            do (setf (aref table (- (char-code (aref s i)) 97)) i)
               (dotimes (c 26)
                 (setf (aref nexts i c) (aref table c)))))
    (setf (aref dp n) 1)
    (setf (aref seqs n) (list #\a))
    (loop for i from (- n 1) downto 0
          for res = #xffffffff
          do (dotimes (c 26)
               (if (= n (aref nexts i c))
                   (when (< 1 res)
                     (setf res 1)
                     (setf (aref seqs i) (list (code-char (+ c 97)))))
                   (let ((new-value (+ 1 (aref dp (+ 1 (aref nexts i c))))))
                     (when (< new-value res)
                       (setf res new-value)
                       (setf (aref seqs i)
                             (cons (code-char (+ c 97))
                                   (aref seqs (+ 1 (aref nexts i c)))))))))
             (assert (/= res #xffffffff))
             (setf (aref dp i) res))
    (dolist (c (aref seqs 0))
      (write-char c))
    (terpri)))

#-swank (main)


Measured memory_bytes: 45544
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
const double PI=acos(-1.0);
int main()
{
	int a,b;
	while( cin>>a>>b )
	{
		cout<<max(a+b,max(a*b,a-b))<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;
int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<ll> v(26, 0);
    ll sum = 1;
    for(int i=0;i<n;i++) {
        v[s[i] - 'a']++;
    }
    for(int i = 0; i<26;i++) {
        sum = (sum * (v[i] + 1)) % MOD;
    }
    cout << ((sum  + MOD - 1) % MOD )<< endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n, q;
VI g[N];
int ans[N];

void dfs(int v, int p)
{
	for(auto i: g[v])
		if (i != p)
		{
			ans[i] += ans[v];
			dfs(i, v);
		}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n >> q;
	FOR(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		g[u].PB(v);
		g[v].PB(u);
	}
	
	FOR(i, 0, q)
	{
		int u, v;
		cin >> u >> v;
		ans[u] += v;
	}
	
	dfs(1, 0);
	FOR(i, 1, n + 1)
		cout << ans[i] << ' ';
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

int main(){
    int result,a,b,c,x;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x==i*500+j*100+k*50){
                    result = result +1;
                }
            }
        }
    }

    cout << result <<endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	cout << N + N * N + N * N*N << endl;
}

Measured memory_bytes: 3608
// ABC085

// inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  const N = parseInt(input[0],10);
  const Y = parseInt(input[1],10);
  var result = "-1 -1 -1";

  for(var x=0;x<=N;x++) {
    for(var y=0;y<=N;y++) {
      var z = N - (x+y);
      if(z < 0)z = 0;
      var total = x + y + z;
      var sum = (x*10000) + (y*5000) + (z*1000);
      if(total==N && sum==Y) result = x+" "+y+" "+z;
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

long fact(int x, int n, long xx) {
  long ans = 1; 
  for (int i = 0; i < n; i++) ans = (ans * x) % xx;
  return ans;
}
  

int main() {
  int n;
  cin >> n;
  
  long xx = 1;
  for (int i=0; i<9; i++) xx *= 10;
  xx += 7;
  
  long ans = (fact(10, n, xx) - 2 * fact(9, n, xx) + fact(8, n, xx)) % xx;
  while (ans < 0) ans += xx;
  cout << ans << endl;
}




Measured memory_bytes: 3628
// https://atcoder.jp/contests/dp/tasks/dp_i
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define EPS (1e-7)
#define INF (1e9)
#define MODI (1000000007)

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// dp[i][j] : コインをi枚使い、j枚が表である確率
// double dp[3001][3001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    // 入力、DP後、DP前
    vector<double> p(n), dpA(n + 1, 0), dpB(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    dpB[0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            // i-1回目で表の枚数がj-1で、i回目が表
            // i-1回目で表の枚数がjで、i回目が裏
            dpA[j] = dpB[j - 1] * p[i - 1] + dpB[j] * (1.0 - p[i - 1]);
        }
        swap(dpB, dpA);
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += dpB[i];
    }
    printf("%0.10f\n", ans);

    return 0;
}

Measured memory_bytes: 384
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;

const int N = 2e5 + 5;

int n;
long long k;
int a[N], vis[N];

int main()
{
  cin >> n >> k;
  for(int i = 0 ; i < n ; i++)
    cin >> a[i], a[i]--;
  int cur = 0, root;
  vis[0] = 1;
  while(true) {
    cur = a[cur];
    if(!--k) {
      cout << cur + 1 << endl;
      return 0;
    }
    if(vis[cur]) {
      root = cur;
      break;
    }
    vis[cur] = 1;
  }
  vector<int> v {root};
  cur = a[root];
  while(cur != root) {
    v.push_back(cur);
    cur = a[cur];
  }
  k %= sz(v);
  cout << v[k] + 1 << endl;
  return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

P f(int x) {
    int a = x % 10;
    int b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
    return P(a, b);
}

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

    int n; cin >> n;
    map<P, int> sums;
    REPS(i, 1, n) {
        P p = f(i);
        sums[p]++;
    }
    int ans = 0;
    REPS(i, 1, n) {
        P p = f(i);
        P q(p.se, p.fi);
        ans += sums[q];
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    string s;
    cin>>n>>s;
    int arr[3][4001]={};
    for(int i=n-1;i>=0;i--)
        for(int j=0;j<3;j++)
            arr[j][i]=arr[j][i+1]+("RGB"[j]==s[i]);
    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]=='G'&&s[j]=='B'||s[i]=='B'&&s[j]=='G'){
                sum+=arr[0][j+1];
                int k=j+j-i;
                if(0<=k&&k<n&&s[k]=='R')
                    sum--;
            }
            if(s[i]=='R'&&s[j]=='B'||s[i]=='B'&&s[j]=='R'){
                sum+=arr[1][j+1];
                int k=j+j-i;
                if(0<=k&&k<n&&s[k]=='G')
                    sum--;
            }
            if(s[i]=='R'&&s[j]=='G'||s[i]=='G'&&s[j]=='R'){
                sum+=arr[2][j+1];
                int k=j+j-i;
                if(0<=k&&k<n&&s[k]=='B')
                    sum--;
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	if(N%1000==0){
		cout << 0 << endl;
	}else{
		cout << (1000-N%1000) << endl;
	}
	return 0;
}


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

using namespace std;

struct Info{ int color, num;};
vector<Info> V;

void add(int col, bool odd){

  if(V.empty()){
    V.push_back((Info){col,1});
    return;
  }

  if(odd){
    //odd
    if(V.back().color == col) V.back().num++;
    else V.push_back((Info){col,1});
  }else{
    //even
    if(V.back().color == col) V.back().num++;
    else{
      int tmp = 1;
      while(!V.empty() && V.back().color != col){
	tmp += V.back().num;
	V.pop_back();
      }
      V.push_back((Info){col,tmp});
    }
  }
}

void print(){
   for(int i = 0; i < (int)V.size(); i++)
     cout << V[i].color << " " << V[i].num << endl;
   cout << endl;
}

int main(){
  int n;
  while(cin >> n && n){
    V.clear();
    for(int i = 0; i < n; i++){
      int in;
      cin >> in;
      add(in, !(i%2));
      // print();
    }

    int ans = 0;
    for(int i = 0; i < (int)V.size(); i++)
      if(V[i].color == 0) ans += V[i].num;

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

Measured memory_bytes: 1220
import java.util.*;

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

		int N = scan.nextInt();

		int max = 0;
		int ret = 0;
		for(int i = 0; i < N;i++){
			int h = scan.nextInt();
			
			if(max <= h){
				ret++;
				max =h;
			}
		}

		System.out.println(ret);
	}
}


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

int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  if(S[K-1]=='A')S[K-1]='a';
  else if(S[K-1]=='B')S[K-1]='b';
  else if(S[K-1]=='C')S[K-1]='c';
  cout << S << endl;
}

Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N,M,X=rl()
A=rl()
import bisect
ind = bisect.bisect_left(A,X)
print(min(ind,M-ind))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int N = 400 + 5;
int graph[N][N],h,w;
char a[25][25];
void floyd(){
	int s = 1;
	for(int k = 0; k < h*w; k++){
		for(int i = 0; i < h*w; i++){
			if(graph[i][k] != INF)
			for(int j = 0; j < h*w; j++)
				if(graph[i][j] > graph[i][k] + graph[k][j]){
					graph[i][j] = graph[i][k] + graph[k][j];
				}					
		}
	}
}
int main()
{
    cin >> h >> w;
    memset(graph,INF,sizeof(graph));
    for(int i = 0; i < h; i++){
    	for(int j = 0; j < w; j++){
    		cin >> a[i][j];
    		graph[i*w+j][i*w+j] = 0;
		}
		getchar();
	}
	for(int i = 0; i < h; i++){
    	for(int j = 0; j < w; j++){
    		if(a[i][j] == '.'){
    			if(i + 1 < h && a[i+1][j] == '.'){
    				graph[i*w+j][(i+1)*w+j] = 1;
    				graph[(i+1)*w+j][i*w+j] = 1;
				}
				if(i - 1 > 0 && a[i-1][j] == '.'){
    				graph[i*w+j][(i-1)*w+j] = 1;
    				graph[(i-1)*w+j][i*w+j] = 1;
				}
				if(j + 1 < w && a[i][j+1] == '.'){
    				graph[i*w+j][i*w+j+1] = 1;
    				graph[i*w+j+1][i*w+j] = 1;
				}
				if(j - 1 > 0 && a[i][j-1] == '.'){
    				graph[i*w+j][i*w+j-1] = 1;
    				graph[i*w+j-1][i*w+j] = 1;
				}
			}
		}
	}
	floyd();
	int maxn = 0;
	for(int i = 0; i < h*w; i++){
		for(int j = 0; j < h*w; j++){
			if(maxn < graph[i][j] && graph[i][j] < INF)
				maxn = graph[i][j];
		}
	}
	cout << maxn << endl;
    return 0;
}

Measured memory_bytes: 896
n = int(input())
s = []
for i in range(n):
    s.append(input())

ac = s.count('AC')
wa = s.count('WA')
tle = s.count('TLE')
re = s.count('RE')

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


Measured memory_bytes: 16180