akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


struct Dice {
  int omote,ura,up,down,left,right;
  Dice(vector<int> &a){
    omote = a[0]; ura = a[5];
    up = a[4]; down = a[1];
    left = a[3]; right = a[2];
  }

  void operate(int &a,int &b,int &c,int &d){
    int buf = a;
    a = b; b = c; c = d; d = buf;
  }

  void rotate(char c){
    if (c == 'E') operate(omote, left, ura, right);
    if (c == 'N') operate(omote, down, ura, up);
    if (c == 'S') operate(omote, up, ura, down);
    if (c == 'W') operate(omote, right, ura, left);
    if (c == 'R') operate(down, right, up, left);
    if (c == 'L') operate(down, left, up, right);
  }
};

int main() {
  vector<int> a(6); rep(i, 6) cin >>a[i];
  Dice dice = Dice(a);
  int q; cin >>q;
  rep(qq, q){
    int omote,down; cin >>omote >>down;
    while (dice.omote != omote){
      dice.rotate('N');
      if (dice.omote != omote) dice.rotate('W');
    }
    while (dice.down != down){
      dice.rotate('L');
    }
    cout <<dice.right <<endl;
  }
}


Measured memory_bytes: 3144
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]);
			b[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		long sum = 0;
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			sum += a[i];
			if (a[i] > b[i]) {
				min = Math.min(min, b[i]);
			}
		}
		System.out.println(min == Integer.MAX_VALUE ? 0 : sum - min);
	}
}


Measured memory_bytes: 34600
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  int N, K;
  cin >> N >> K;
  ull ans = 0;
  rep_s(i, 1, N+1){
    int div_num = N/i;
    int amari = N%i; 
    //cout << "i: " << i << ", div_num*max(0, i-K): " << div_num*max(0, i-K) << ", max(0, amari-K+1)" << max(0, amari-K+1)<<endl;
    ans += div_num*max(0, i-K);
    ans += max(0, amari-K+1);
    if (K==0) ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Node r;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x;
		String com;
		int cnt=0;
		for(int i=0; i<n; i++){
			com = sc.next();
			if(com.equals("insert")){
				x = sc.nextInt();
				insert(new Node(x, null, null, null));
				
			} else if (com.equals("find")){
				x = sc.nextInt();
				if(find(r, x) != null) System.out.println("yes");
				else System.out.println("no");
				
			} else if (com.equals("delete")){
				x = sc.nextInt();
				treeDelete(find(r, x));
				
			} else if (com.equals("print")){
				inorder(r);
				System.out.println();
				preorder(r);
				System.out.println();
			}
		}
	}
	
	static Node treeMinimum(Node x){
		while( x.l != null) x = x.l;
		return x;
	}
	
	static Node treeSuccessor(Node x){
		if (x.r != null) return treeMinimum(x.r);
		Node y = x.p;
		while(y != null && x == y.r) {
			x = y;
			y = y.p;
		}
		return y;
	}
	
	static void treeDelete(Node z) {
		Node y;
		Node x;
		
		if(z.l == null || z.r == null) y=z;
		else y = treeSuccessor(z);
		
		if(y.l != null){
			x = y.l;
		} else {
			x = y.r;
		}
		
		if (x != null) {
			x.p = y.p;
		}
		
		if (y.p == null){
			r = x;
		} else {
			if (y == y.p.l){
				y.p.l = x;
			} else {
				y.p.r = x;
			}
		}
		
		if (y != z) {
			z.key = y.key;
		}
	}
	
	static Node find(Node u, int k){
		while (u != null && k != u.key){
			if(k < u.key) u = u.l;
			else u = u.r;
		}
		return u;
	}
	
	static void insert(Node z){
		Node y = null;
		Node x = r;
		
		while (x != null){
			y = x;
			if (z.key < x.key){
				x =  x.l;
			} else {
				x = x.r;
			}
		}
		z.p = y;
		
		if (y == null){
			r = z;
		} else {
			if(z.key < y.key){
				y.l = z;
			} else {
				y.r = z;
			}
		}
	}

	static void inorder(Node u){
		if (u == null) return;
		inorder(u.l);
		System.out.print(" " + u.key);
		inorder(u.r);
	}
	static void preorder(Node u) {
		if (u == null) return;
		System.out.print(" " + u.key);
		preorder(u.l);
		preorder(u.r);
	}
}


class Node {
    int key;
    Node p = null;
	Node l = null;
	Node r = null;
    public Node(int key, Node p,Node l, Node r) {
    	this.key = key;
        this.l = l;
        this.r = r;
        this.p = p;
    }
}


Measured memory_bytes: 208024
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll k,x;
	cin>>k>>x;
	ll low=max(x-k+1,-1000000LL);
	ll hi=min(x+k-1,1000000LL);
	for(ll i=low;i<=hi;i++)
	{
	    cout<<i<<" ";
	}
	
    return 0;
}


//252908XL

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,p,cur,t=1,cnt[10010],i;
string s;
long long ans;
int main()
{
	cin>>n>>p>>s;
	if(p==2||p==5)
	{
		for(i=0;i<n;i++)
			if((s[i]-'0')%p==0)
				ans+=i+1;	
	}
	else
	{
		cnt[0]=1;
		for(i=n-1;i>=0;i--)
		{
			(cur+=(s[i]-'0')*t)%=p;
			ans+=cnt[cur]++;
			t=t*10%p;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 644
N = int(input())
S = [input() for i in range(N)]
ans = {}

for s in S:
    if s not in ans:
        ans[s] = 1
    else:
        ans[s] += 1

n = max(ans.values())
l = []
for k, v in ans.items():
    if v== n:
        l.append(k)
l.sort()
for i in l:
    print(i)


Measured memory_bytes: 35216
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N; 
int a[5][15] = {0}; 
int b[5][15] = {0}; 
int c[5][15] = {0}; 
int d[5][15] = {0}; 
for (int i = 0; i < N; i++){
int B, F, R, V; 
cin >> B >> F >> R >> V; 
if(B == 1) a[F][R] += V; 
if(B == 2) b[F][R] += V;
if(B == 3) c[F][R] += V;
if(B == 4) d[F][R] += V;
}

for (int i = 1; i <= 3; i++){
  for (int j = 1; j <= 10; j++){
 cout << " " << a[i][j];
}
 cout << endl; 
} 
 cout << "####################" << endl; 

for (int i = 1; i <= 3; i++){
  for (int j = 1; j <= 10; j++){
 cout << " " << b[i][j];
}
 cout << endl; 
} 
 cout << "####################" << endl; 

for (int i = 1; i <= 3; i++){
  for (int j = 1; j <= 10; j++){
 cout << " " << c[i][j];
}
 cout << endl; 
} 
 cout << "####################" << endl; 

for (int i = 1; i <= 3; i++){
  for (int j = 1; j <= 10; j++){
 cout << " " << d[i][j];
}
 cout << endl; 
} 
}



Measured memory_bytes: 3116
N,M,X,Y=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
mx=max(x)
y=[int(j) for j in input().split()]
my=min(y)
if X>=Y:
    print("War")
else:
    for z in range(X+1,Y+1):
        if mx<z and my>=z: 
            print("No War")
            break    
        elif z==Y:
            print("War")
            break
        else:
            continue

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int x;
    cin>>x;
    if(x>=1200){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define test() ll t; cin>>t; while(t--)
using namespace std;
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}
int main()
 {
    YUGEN;
        string s;
        cin>>s;
        int count=0,ans=0;
       vector<int> v;
       for(int i=0;i<3;i++)
       {
           if(s[i]=='R')
            count++;
           else
           {
               v.pb(count);
               count=0;
           }
       }
       v.pb(count);
          ans=*max_element(v.begin(),v.end());

       cout<<ans<<endl;

	return 0;

 }



Measured memory_bytes: 3652
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#define REP(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
using namespace std;

bool compare(tuple<int,int,int> a, tuple<int,int,int> b){
	if(get<0>(a) == get<0>(b)){
			if(get<1>(a) == get<1>(b)){
				return get<2>(a) < get<2>(b);
			}
			return get<1>(a) < get<1>(b);
		}
		return get<0>(a) > get<0>(b);
}
			
int main(){
	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<tuple<int,int,int> > inf_team(t,tuple<int,int,int>(0,0,0));//problem,time,number
		REP(i,t)get<2>(inf_team[i]) = i;
		vector<vector<int> > penalty(t,vector<int>(p,0));
		REP(i,r){
			int t_id,p_id,time;
			string mes;
			cin >> t_id >> p_id >> time >> mes;
			t_id--;p_id--;
			if(mes=="WRONG"){
				penalty[t_id][p_id]++;
			}else{
				get<1>(inf_team[t_id]) += time + 1200*penalty[t_id][p_id];
				get<0>(inf_team[t_id])++;
			}
		}
		sort(inf_team.begin(),inf_team.end(),compare);
		REP(i,t){
			cout << get<2>(inf_team[i]) + 1 << " " << get<0>(inf_team[i]) << " " << get<1>(inf_team[i]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3164
table = list(map(int, input().split()))

for i in range(0, 2):
    k = 2
    while i < k:
        if table[k] < table[k-1]:
            table[k], table[k-1] = table[k-1], table[k]
        k -= 1;
        
print(table[0], table[1], table[2])



Measured memory_bytes: 5596
#include<stdio.h>
int main()
{
    int i,j,k,n,max;

   scanf("%d%d%d",&i,&j,&k);
       if(i+j==k)
       {
           printf("Yes\n");
       }
       else if(i+k==j){
           printf("Yes\n");
       }
       else if(j+k==i){
           printf("Yes\n");
       } else{
           printf("No\n");
       }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

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


int main() {
    int n,r;
    cin>>n>>r;
    
    int ans;
    if(n>=10) ans=r;
    else ans=r+100*(10-n);
    
    dunk(ans);
}


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    int x;
    cin >> x;
    for(int i= x; i < 10000000; ++i) {
        if(IsPrime(i)) {
            cout << i << '\n';
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

ll n;
vector<vector<ll>> edge;
string s;


pair<ll,pll> dfs(ll w,ll p){
    ll cnt=0,mx=0,mx2=0,dist=0;
    if(s[w]=='1'){cnt++;}
    for(auto &I:edge[w]){
        if(I==p){continue;}
        pair<ll,pll> A=dfs(I,w);
        cnt+=A.F;
        dist+=A.S.S;
        if(mx<A.S.F){
            mx=A.S.F;
            mx2=A.S.S;
        }
    }
    return {cnt,{max(dist&1,mx-dist+mx2)+cnt,dist+cnt}};
}


int main(){
    cin>>n;
    edge.resize(n);
    cin>>s;
    for(int i=1;i<n;i++){
        ll a,b;
        cin>>a>>b; a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll ans=E;
    for(int i=0;i<n;i++){
        pair<ll,pll> ret=dfs(i,-1);
        ret.S.S-=ret.F;
        ret.S.F-=ret.F;
        if(ret.S.S%2==0 && ret.S.F==0){ans=min(ans,ret.S.S/2);}
    }
    cout<<(ans==E?-1LL:ans)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 768
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:length])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

Measured memory_bytes: 3064
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool leap[3001];
	for (int i = 0; i < 3001; i++) {
		int y = i;
		if (y % 4 != 0) { leap[i] = false; }
		else if(y%100!=0){
			leap[i] = true;
		}
		else if (y % 400 != 0) {
			leap[i] = false;
		}
		else {
			leap[i] = true;
		}
	}
	int a, b;
	bool first = true;
	while (cin >> a >> b) {
		bool ever = false;
		if (a == 0 && b == 0) { break; }
		if (!first) { cout << endl; }
		for (int i = a; i <= b; i++) {
			if (leap[i]) { ever = true; cout << i << endl; }
		}
		if (!ever)
		{
			cout << "NA" << endl;
		}first = false;
	}
	return 0;
}


Measured memory_bytes: 3048
question_num = int(input())
Time = list(map(int, input().split()))
drink_num = int(input())
spent_time = sum(Time)
drink =[]
for _ in range(drink_num):
    p, x = map(int, input().split())
    drink.append([p, x])
for p, x in drink:
    print(spent_time - (Time[p - 1] - x))

Measured memory_bytes: 9160
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n){
        cin >> a[i];
    }
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    rep(i,0,n-1){
        if(a[i+1] - 1 > a[i]){
            cout << -1 << endl;
            return 0;
        }
    }

    ll x[n] = {},cnt = 0;
    rep(i,0,n-1){
        ll index = n-i-1;
        if(x[index] == a[index]) continue;
        if(a[index] -1 == a[index-1]) cnt++;
        else cnt += a[index];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6728
package main

import (
	"fmt"
)

func main() {

	var K int64
	fmt.Scanf("%d", &K)

	var year, money int64
	year = 0
	money = 100

	for {
		if money < K {
			year++
			money = money + money/100
		} else {
			break
		}
	}
	fmt.Println(year)
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define INF 1000000000000000000
#define MOD 1000000007

int main(){
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  ll ans=0;
  for(int i=0;R*i<=N;i++){
    for(int j=0;R*i+G*j<=N;j++){
      if((N-R*i-G*j)%B==0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 200005

void solve(){
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;

}

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

long long H,W,N,sr,sc;

char S[200020];
char T[200020];

long long safeU,safeD,safeL,safeR;

queue <int> qH;
queue <int> qW;

int main(){
  cin >> H >> W >> N >> sr >> sc;
  cin >> S >> T;
  safeU=0;safeL=0;safeD=H;safeR=W;
  for (long long i=N-1;i>=0;i--){
    if (T[i]=='U'){
      safeD++;
    }else if(T[i]=='D'){
      safeU--;
    }else if(T[i]=='L'){
      safeR++;
    }else if(T[i]=='R'){
      safeL--;
    }
    if (safeU<0)safeU=0;
    if (safeD>H)safeD=H;
    if (safeL<0)safeL=0;
    if (safeR>W)safeR=W;
    //cout << safeU << " "<<safeD <<" "<< safeL <<" " << safeR <<endl;
    if (S[i]=='U'){
      safeU++;
    }else if(S[i]=='D'){
      safeD--;
    }else if(S[i]=='L'){
      safeL++;
    }else if(S[i]=='R'){
      safeR--;
    }
    //cout << safeU << " "<<safeD <<" "<< safeL <<" " << safeR <<endl;
    if (safeU>=safeD||safeL>=safeR){
      cout << "NO" << endl;
      return 0;
    }
  }
  //cout << safeU << " "<<safeD <<" "<< safeL <<" " << safeR <<endl;
  if (safeU<=(sr-1) && safeD>(sr-1) && safeL<=(sc-1) && safeR>(sc-1)){
    cout << "YES" << endl;
    return 0;
  }else{
    cout << "NO" << endl;
    return 0;
  }
}


Measured memory_bytes: 888
#include <iostream>
 
int main(void){
	int s;
  	std::cin >> s;
  	int count = 1;
  
  	while(1){
      	if(s == 4 || s == 2 || s == 1){
        	std::cout << count+3;
          	break;
        }
      
    	if(s % 2 == 0){
        	s = s/2;
        }
      	else{
        	s = 3*s + 1;
        }
      
      	++count;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
ll K,A,B;
void MAIN() {
	cin>>K>>A>>B;
	if(B/K-(A-1)/K>0)cout<<"OK";
	else cout<<"NG";
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

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

int main(){
	long long int a,b;
	cin >> a >> b;
	long long int t;
	t=(a+b)/2.0;
	if((a+b)/2.0 == (a+b)/2){
		printf("%d",t);
	}
	else{
		printf("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;


int main(){
	ll k,a,b;
	cin>>k>>a>>b;
	ll bis=1;
	if(b<=a+2){
		cout<<k+1;
		return 0;
	}
	while(k>0){
		if(bis>=a){
			if(k>=2){
				bis-=a;
				bis+=b;
				k-=2;
			}
			else {
				bis+=k;
				k=0;
			}
		}
		else{
			ll result=a-bis;
			if(k>=result){
				k-=result;
				bis+=result;
			}
			else{
				bis+=k;
				k=0;
			}
		}
	}
	cout<<bis<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define repi(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

int main(){
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int a,b,c;
      cin >> a >> b >> c;
      if(a<=c && c<=b)cout << "Yes" << endl;
      else cout << "No" << endl;
      return 0;}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0013
{
    public class Program

    {
        public static void Main(string[] args)
        {

            Stack<int> st = new Stack<int>();
            while (true)
            {
                string line = ReadSt();
                if (line == null) break;

                int n = int.Parse(line);
                if (n != 0)
                {
                    st.Push(n);
                }
                else
                {
                    Console.WriteLine(st.Pop());
                }          
            }

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

bool knapsack(vector<int> &items, int target) {
    vector<map<int, bool>> dp(items.size() + 1);
    dp[0][0] = true;
    for (int i = 0; i < items.size(); i++) {
        int item = items[i];
        for (auto e : dp[i]) {
            int next1 = e.first + item;
            dp[i + 1][next1] = true;
            int next2 = e.first - item;
            dp[i + 1][next2] = true;
        }
    }
    return dp[items.size()][target];
}

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<int> horizontals, verticals;
    bool d = true;
    int length = 0;
    for (char c : s) {
        if (c == 'F') length++;
        else {
            if (d) horizontals.push_back(length);
            else verticals.push_back(length);
            d = !d;
            length = 0;
        }
    }
    if (d) horizontals.push_back(length);
    else verticals.push_back(length);

    if (verticals.empty()) {
        verticals.push_back(0);
    }

    x -= horizontals.front();
    horizontals[0] = 0;

    bool hb = knapsack(horizontals, x);
    bool vb = knapsack(verticals, y);
    bool b = hb && vb;
    cout << (b ? "Yes" : "No") << endl;

}



Measured memory_bytes: 190720
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> A(N + 1);
	for (int i = 0; i < N + 1; i++)
	{
		cin >> A[i];
	}
	vector<int> B(N);
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}
	
	long answer = 0;
	for (int i = 0; i < N; i++)
	{
		long left = min(A[i], B[i]);
		
		answer += left;
		// i番目の町のモンスターと勇者の倒せる数を減らす。
		A[i] -= left;
		B[i] -= left;
		
		long right = min(A[i + 1], B[i]);
		
		// i+1番目の町のモンスターとi番目の勇者の倒せる数を減らす
		answer += right;
		A[i + 1] -= right;
		B[i] -= right;
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
ans = 0
cnt = [0]*(K+1)
MOD = 10**9+7

for i in range(K, 0, -1):
    cnt[i] = pow(K//i, N, MOD)
    
    for j in range(2*i, K+1, i):
        cnt[i] -= cnt[j]
        cnt[i] %= MOD
    
    ans += i*cnt[i]
    ans %= MOD

print(ans)

Measured memory_bytes: 69276
#include<iostream>
#include<set>
#include<utility>

using namespace std;

int N;
int x[50],y[50];

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
  }
  set<pair<int,int> >s;
  for(int i=0;i+N/2<N;i++){
    s.insert(make_pair(x[i]+x[i+N/2],y[i]+y[i+N/2]));
  }
  if(N%2==1||s.size()>1){
    cout<<"NA"<<endl;
  }else{
    auto p=*begin(s);
    cout<<fixed<<p.first/2.<<' '<<p.second/2.<<endl;
  }
}

  

Measured memory_bytes: 1264
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string mp[1000];
string mark[2];
int  his[3][1000][1000];
 
int main() {
 
  int h,w;
 
  cin >> h >> w;
 
  for(int i=0;i<h;i++) cin >> mp[i];
 
  for(int i=0;i<2;i++) cin >> mark[i];
  w = mp[1].size();
 
  for(int k=0;k<3;k++)  
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) 
      his[k][i][j] = 0;
   
   
   
  int ans = 0;
  for(int i=0;i<h;i++) 
    for(int j=0;j<w;j++) 
      if(i+1 < h && j+1 < w)
    if(mp[i][j] == mark[0][0] && mp[i][j+1] == mark[0][1] && mp[i+1][j] == mark[1][0] && mp[i+1][j+1] == mark[1][1]) ans++;
       
  //    cout << ans << endl;
   
  char m,t;
  int ansx,ansy,big = 0;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      int count = 0;
      int x,y;
      if(i+1 < h && j+1 <w) {
    if(mp[i][j] == mark[0][0]) count++;
    else {
      x = j;
      y = i;
      m = mark[0][0];
    }
    if(mp[i][j+1] == mark[0][1]) count++;
    else{
      x = j+1;
      y = i; 
      m = mark[0][1];     
    } 
    if(mp[i+1][j] == mark[1][0] ) count++;
    else {
      x = j;
      y = i+1;
      m = mark[1][0];
    }
    if(mp[i+1][j+1] == mark[1][1]) count++;
    else {
      x = j+1;
      y = i+1;
      m = mark[1][1];
    }
      }
      if(count == 3) {
    int k;
    if(m == 'O') k = 0;
    if(m == 'J') k = 1;
    if(m == 'I') k = 2;
    his[k][y][x]++;
    if(his[k][y][x] > big) {
      big = his[k][y][x];
      ansx = x;
      ansy = y;
      t = m;
    }
      }
    }
  }
   
  
  cout << ans+ big<< endl;      
   
  
 
  return 0;
}

Measured memory_bytes: 13972
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    b+=b+1;
    int c=a/b;
    int d=a%b;
    if(d!=0){
        c++;
    }
    cout << c<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')cout<<3<<endl;
	else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))cout<<2<<endl;
	else if(s[0]=='R'||s[1]=='R'||s[2]=='R')cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep1(i,n) for(int i = 1; i < (n); ++i)
using namespace std;
using P = pair<int, int>;

int main() {
    /*P p(2,3);
    cout << p.first << endl;
    cout << p.second << endl;
    */
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9) cout << -1 << endl;
    else cout << a * b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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

int cnt[2019];
void solve() {
	string s; cin >> s;
	int n = s.size();
	vector<int> v;
	v.push_back(0);
	int t = 1;
	int cur = 0;
	per(i, n) {
		cur += t * (s[i] - '0');
		cur %= 2019;
		v.push_back(cur);
		t = t * 10 % 2019;
	}
	ll ans = 0;
	rep(i, n + 1) {
		ans += cnt[v[i]];
		cnt[v[i]]++;
	}
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//experi();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 4604
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 2020;
const int mod = 1e9 + 7;

inline int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

inline int sub(int a, int b) {
  return a >= b ? a-b : a-b+mod;
}

inline int mul(int a, int b) {
  return llint(a)*b % mod;
}

int C[MAX][MAX];

int sum(int a, int b) {
  return b*(b+1)/2 - a*(a-1)/2;
}

int main(void) {
  REP(i, MAX) {
    C[i][0] = 1;
    FOR(j, 1, i+1) {
      C[i][j] = add(C[i-1][j], C[i-1][j-1]);
    }
  }
  
  int A, B;
  scanf("%d %d", &A, &B);

  int ret = A+1; // all blue in one segment
  for (int k = 1; k < B; ++k) { // no. of blues in first segment
    for (int l = 1; l <= B - k; ++l) { // no. of blues in second segment
      int ways = 1;

      ways = mul(ways, C[B-1][k-1]);
      ways = mul(ways, C[B-k-1][l-1]);

      int n = A + B - (B - k - l);

      if (B <= n-(B-k)) {
        int coef = sum(B, n-(B-k));
        coef = sub(coef, mul(B-1, n-(B-k) - B+1));
        ret = add(ret, mul(ways, coef));
      }
    }
  }

  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, k; cin >> n >> k;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    sort(all(vec));
    ll ans = 0;
    rep(i, k){
        ans += vec[i];
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int h, w;
vector<string> a;

int vectormax(vector<vector<int>> dist) {
  int ans = 0;
  for (int i = 0; i < dist.size(); i++) {
    ans = max(ans, *max_element(dist[i].begin(), dist[i].end()));
  }
  return ans;
}

int main() {
  cin >> h >> w;
  a.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  queue<pair<int, int>> que;
  vector<vector<int>> dist(h, vector<int>(w, -1));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        dist[i][j] = 0;
        que.push(make_pair(i, j));
      }
    }
  }

  while (!que.empty()) {
    pair<int, int> temp = que.front();
    que.pop();

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

    for (int i = 0; i < 4; i++) {
      int x, y;
      x = temp.first + dx[i];
      y = temp.second + dy[i];
      if (x < 0 || x >= h || y < 0 || y >= w) continue;
      if (dist[x][y] == -1) {
        dist[x][y] = dist[temp.first][temp.second] + 1;
        que.emplace(make_pair(x, y));
      }
    }
  }
  cout << vectormax(dist) << endl;
}

Measured memory_bytes: 13456
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include<string.h>
struct Info
{
    std::string S;
    int P;
    int index;
    Info(std::string ts, int tp, int tIndex)
    {
        S=ts;
        P=tp;
        index = tIndex;
    }
};

bool cmp(const Info &a, const Info &b)
{
    size_t alen = a.S.size();
    size_t blen = b.S.size();
    int L = alen < blen ? alen : blen;

    const char* aS = a.S.c_str();
    const char* bS = b.S.c_str();

    if(strcmp(aS,bS)==0)
    {
        return a.P > b.P;
    }

    int L2 = strncmp(aS,bS,L);
    if(L2==0)
    {
        return alen < blen;
    }

    return L2<0;
}


int main(int argc, char** argv)
{
    int N;
    std::cin >> N;
    std::vector<Info> vInfo;

    for(int i=0;i<N;i++)
    {
        int tp;
        std::string ts;
        std::cin >> ts;
        std::cin >> tp;
        vInfo.push_back(Info(ts,tp,i+1));
    }
    std::sort(vInfo.begin(),vInfo.end(),cmp);

    for(int i=0;i<N;i++)
    {
        std::cout << vInfo[i].index << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>


int main() {
#ifdef DEBUG

#endif
	int X, Y, Z;

	scanf("%d %d %d", &X, &Y, &Z);

	int ans;
	ans = (X - Z) / (Y + Z);
	printf("%d\n", ans);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
vector<T> BellmanFrod(Edges<T> &edges, int N, int source)
{
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(N, INF); //distance from source
    dist[source] = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (auto &e : edges)
        {
            if (dist[e.src] == INF)
                continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }
    vector<bool> neg(N);
    for (auto &e : edges)
    {
        if (dist[e.src] == INF)
            continue;
        if (dist[e.src] + e.cost < dist[e.to])
            neg[e.to] = true;
        if (neg[e.src] == true)
            neg[e.to] = true;
    }
    if (neg[N - 1] == true)
        return vector<T>();
    return dist;
}

int N, M, a, b;
ll c;

int main()
{
    cin >> N >> M;
    Edges<ll> edges;
    for (int i = 0; i < M; i++)
    {
        cin >> a >> b >> c;
        edges.emplace_back(a - 1, b - 1, -c);
    }
    auto v = BellmanFrod(edges, N, 0);
    if (v.size() == 0)
        cout << "inf" << endl;
    else
        cout << -v[N - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


template<typename T>
class KMP{
    vector<int> a;
    T s;

public:
    KMP(T s_arg): s(s_arg){
        int n = s_arg.size();
        a = vector<int>(n+1, -1);   // a[j+1]が[0, j]のboarderの最大の長さ
        constructBorderArray();
    }

    void constructBorderArray(){
        int j = -1;
        for(int i = 0; i < s.size(); i++){
            while(j >= 0 && s[i] != s[j]){
                j = a[j];
            }

            j++;
//            if(s[i+1] == s[j]) a[i+1] = a[j];
//            else a[i+1] = j;
            a[i+1] = j;
        }
    }

    /**
     *
     * @param x: sとマッチングさせる配列
     * @return : マッチング位置
     */
    vector<int> search(T x, int pos=0){
        int j = 0;
        vector<int> res;
        for(int i = pos; i < x.size(); i++){
            while(j >= 0 && x[i] != s[j]){
                j = a[j];
            }
            j++;
            if(j == s.size()){
                res.push_back(i - j + 1);
                j = a[j];
            }
        }
        return res;
    }

    int periodicity(int pos){
        return pos - a[pos];
    }
};


int main(){
    string s, t;    cin >> s >> t;
    string s2 = s;
    while(s2.length() < t.length() + s.length() - 1){
        s2 += s;
    }

    KMP<string> kmp{t};
    vector<int> res = kmp.search(s2);
    vector<int> nextPos(s.length(), -1);

    for(auto pos: res){
        if(pos >= s.length()){
            break;
        }
        int remain = s2.length() - pos - t.length();
        nextPos[pos] = (2 * s.length() - remain) % s.length();
    }

    vector<int> posNum(s.length(), 0);
    vector<bool> state(s.length(), false);
    for(int i = 0; i < s.length(); i++){
        int x = i;
        deque<int> que;
        int num = 0;
        while(true){
            if(!que.empty() && que.front() == x){     // ループを検知
                cout << -1 << endl;
                return 0;
            }

            if(state[x]){
                num = posNum[x];
                break;
            }

            state[x] = true;
            if(nextPos[x] == -1){
                break;
            }
            que.push_back(x);
            x = nextPos[x];
        }

        while(!que.empty()){
            x = que.back(); que.pop_back();
            posNum[x] = ++num;
        }
    }

    int ret = 0;
    for(int i = 0; i < s.length(); i++){
        ret = max(posNum[i], ret);
    }

    cout << ret << endl;



    return 0;
}

Measured memory_bytes: 12584
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        
        vector<pair<int,pair<int,int> > > v(m);
        rep(i,m) cin >> v[i].first >> v[i].second.first >> v[i].second.second;

        sort(v.begin(),v.end());

        int ans = 1;

        bool T[20005];
        memset(T,0,sizeof(T));
        T[1] = true;

        vector<int> id;

        rep(i,m) {
            int time = v[i].first;
            int s = v[i].second.first;
            int t = v[i].second.second;

            if(T[s]) {
                T[t] = true;
            }
        }

        int cnt = 0;
        REP(i,1,n+1) {
            if(T[i]) cnt++;
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll A, V, B, W;
	cin >> A >> V >> B >> W;
	ll T;
	cin >> T;
	if(W >= V) {
		cout << "NO";
		return 0;
	}
	if(T >= ((abs(A - B) + abs(V- W) - 1) / abs(V - W)))
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


Measured memory_bytes: 3632