akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int a[100];
		rep(i, n)
			scanf("%d", &a[i]);
		
		int key;
		scanf("%d", &key);
		
		int cnt = 0;
		int left = 0, right = n;
		while(left < right){
			++cnt;
			int mid = (left + right-1) / 2;
			if(a[mid] == key)
				break;
			if(a[mid] < key)
				left = mid + 1;
			else
				right = mid;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N, C=0;
  cin >> N;
  vector<int> h(N);
  for (int i=0; i<N; i++) {
    cin >> h[i];
  }
  while (true) {
    int fin=1, m;
    for (int i=0; i<N; i++) {
      if (h[i]>0) {
        fin=0;
        m=i;
        break;
      }
    }
    if (fin==1) {break;}
    while (m<N && h[m]>0) {
      h[m]--;
      m++;
    }
    C++;
  }
  cout << C << endl;
}

Measured memory_bytes: 3628
import math

k, a, b = map(int, input().split())
inc = a - b
if k <= a:
    print(1)
elif inc < 0:
    if k <= a:
        print(1)
    else:
        print(-1)
elif inc == 0:
    print(-1)
else:
    from decimal import *
    getcontext().prec = 500
    print(math.ceil(Decimal(k-a) / Decimal(inc))*2+1)






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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	vc<pi> lr;
	const int inf=LLONG_MAX/3;
	int mx=-inf,mn=inf;
	rep(i,n){
		int l,r;cin>>l>>r;
		l--;
		chmax(mx,l);
		chmin(mn,r);
		lr.eb(l,r);
	}
	
	int ans=0;
	for(auto z:lr){
		chmax(ans,max(int(0),mn-mx)+z.b-z.a);
	}
	vc<pi> t;
	rep(i,n){
		int a=max(int(0),mn-lr[i].a);
		int b=max(int(0),lr[i].b-mx);
		t.eb(b,-a);
	}
	sort(all(t));
	int w=inf;
	rep(i,n){
		auto z=t[i];
		z.b=-z.b;
		if(i)
			chmax(ans,w+z.a);
		chmin(w,z.b);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5360
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
    inline char gc()
    {
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x)
    {
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc())
        {   
            if(ch==-1)return *this;sgn|=ch=='-';
        }
        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

/**
贪心
排序之后会发现，两个数之间组对
前面那个是两个之间小的那个
所以每次循环只需要把
两个数之间的前一项相加即可 
**/
int a[10001];
int ans=0,n;
int main()
{
    cin >> n;
    for(int i=1;i<=2*n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+2*n);
    for(int i=1;i<=2*n;i+=2)
    {
        ans += a[i];
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
 
int main(){
	
	ll a;
	double b;
	cin>>a>>b;
	ll c = round(b*100);
	cout << a*c/100 << endl;
	
	
}


Measured memory_bytes: 3744
n = int(input())
list6 = [6**i for i in range(7)]
list9 = [9**i for i in range(6)]
m = {}
def ans(n):
    if n <= 5:
        return n
    elif n in m:
        return m[n]
    else:
        m6 = max(i for i in list6 if i <= n)
        m9 = max(i for i in list9 if i <= n)
        l6 = n - m6
        l9 = n - m9
        m[n] = min(ans(l6)+1,ans(l9)+1)
        return m[n]
print(ans(n))

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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> Y(N);
    for (int i=0; i<N; i++){
        int value;
        cin >> value;
        X.at(i) = Y.at(i) = value;        
    }

    //sort
    sort(Y.begin(),Y.end());

    int midl = Y.at(N/2 - 1);
    int midr = Y.at(N/2);

    vector<int> B(N);
    for(int i=0; i<N; i++) {
        if (X.at(i) <= midl) {
            B.at(i) = midr;
        } else if(X.at(i) >= midr) {
            B.at(i) = midl;
        } else {
            cout << "Error" << endl;
        }
    }

    //output
    for(int i=0; i<N; i++) {
        cout << B.at(i) << endl;
    }    
}

Measured memory_bytes: 4480
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#define debug(x) cout<<x<<"\n";
#define Max(a,b) ((a)>(b)?(a):(b))
typedef long long ll;
const int N=1e5+10;
const ll inf=0x3f3f3f3f3f3f;
using namespace std;
ll arr[N];
int main()
{	
	ll x,n,cnt=0;
	while(cin>>n>>x)
	{
		for(int i=0;i<n;i++)
		cin>>arr[i];
		ll ans=0;
		if(arr[0]>x)
		{
			ans+=((arr[0]-x));
			arr[0]=x;	
		}
		for(int i=0;i<n;i++)
		{
			if(arr[i]+arr[i+1]>x)
			{
				ll temp=arr[i]+arr[i+1]-x;
				ans+=temp;
				if(arr[i+1]>=temp)
				arr[i+1]-=temp;
				else
				{
					arr[i+1]=0;
					arr[i]-=(arr[i]-x);
				}
			}
		}
		//debug(arr[0]);debug(arr[1]);
		cout<<ans<<"\n";
	}
	return 0;
} 

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

int main() {
int N;
cin >> N;
vector<int> A(N);
 
//  for( int j = 0; j < N; j++){
//        cin >> A.at(j);
//  }
  
  int i = 0;
  
  while(i < N){
    cin >> A.at(i);
    int r;
      r = A.at(i) %2;
    int p, q;
      p =  A.at(i) %3;
      q =  A.at(i) %5;
      	if((r == 0) && !(p == 0 || q == 0)){
      		 cout << "DENIED"<<endl;
    		   break;
   		    }
           i++;
   	       if( i == N){
    	   cout << "APPROVED"<<endl;
 		 }
  	}
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	int max = 1;
	int cnt = 0;
	int maxcnt = 0;
	
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		int num = i;
		while (num % 2 == 0) {
			num /= 2;
			cnt++;
		}
		if (maxcnt < cnt) {
			max = i;
			maxcnt = cnt;
		}
		cnt = 0;
	}
	
	cout << max << endl;
	
	return (0);
}

Measured memory_bytes: 256
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define MOD 10000000009

int main() {
ll i,j,n,m,a,b,c=0;
cin>>n>>a;
while(n>=500){
n=n%500;
}
for(i=0;i<=a;i++){
    //for(j=1;j<=2*a;j++){
        if(i*1==n){
            c=1;
        }
        if(c==1){
            cout<<"Yes";
            return 0;
        }
    //}
}
if(c==0){
    cout<<"No";
}
return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
cnt = 0
sumnum = 0
minnum = float('inf')
for i in A:
    if i < 0:
        i *= -1
        cnt += 1
    minnum = min(minnum, i)
    sumnum += i
if cnt%2 == 0:
    print(sumnum)
else:
    print(sumnum-2*minnum)

Measured memory_bytes: 64880
while True:
    n, r = map(int, input().split())
    if n == 0:
        break
    cards = list(range(n, 0, -1))
    for p, c in (map(int, input().split()) for _ in [0]*r):
        cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]

    print(cards[0])


Measured memory_bytes: 5620
N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

# (x + y) % 2 が全部同じじゃなかったらどう頑張ってもむり
if len(set([(x + y) % 2 for x, y in zip(X, Y)])) != 1:
    print(-1)
    exit()


def directions_str(fx, fy, tx, ty, arm):
    if fx == tx and fy == ty:
        return ''
    if abs(fx - arm - tx) + abs(fy - ty) < arm:
        return 'L' + directions_str(fx=fx - arm, fy=fy, tx=tx, ty=ty, arm=arm // 2)
    if abs(fx + arm - tx) + abs(fy - ty) < arm:
        return 'R' + directions_str(fx=fx + arm, fy=fy, tx=tx, ty=ty, arm=arm // 2)
    if abs(fx - tx) + abs(fy - arm - ty) < arm:
        return 'D' + directions_str(fx=fx, fy=fy - arm, tx=tx, ty=ty, arm=arm // 2)
    if abs(fx - tx) + abs(fy + arm - ty) < arm:
        return 'U' + directions_str(fx=fx, fy=fy + arm, tx=tx, ty=ty, arm=arm // 2)


# 全部 (x + y) % 2 == 1 なら、2^n, 2^(n-1), ..., 2, 1 って腕を作れば (x+y) <= 2^(n+1)-1 まではどこでも行ける。
# 全部 (x + y) % 2 == 0 なら、上記から 1 だけ伸ばせばどこでも行ける。
arms = []
for n in range(39):
    arms.append(2 ** n)
    if 2 ** n > 10 ** 9:
        break
arms.sort(reverse=True)

if (X[0] + Y[0]) % 2 == 1:
    print(len(arms))
    print(' '.join(map(str, arms)))
    for x, y in zip(X, Y):
        print(directions_str(fx=0, fy=0, tx=x, ty=y, arm=arms[0]))
else:
    arms.append(1)
    print(len(arms))
    print(' '.join(map(str, arms)))
    for x, y in zip(X, Y):
        print(directions_str(fx=0, fy=0, tx=x, ty=y + 1, arm=arms[0]) + 'D')


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> P;
typedef pair<ll,pair<int, int> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT32_MAX;
const int MAX_N = int(1e5) + 5;
const int MAX_V = 100005;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

struct edge {
    ll to, cost;
};

vector<edge> G[MAX_V];
ll dmin[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que; //小さいものから取り出す
    fill(dmin, dmin + MAX_V, LLINF);
    dmin[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dmin[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            if (dmin[e.to] > dmin[v] + e.cost) {
                dmin[e.to] = dmin[v] + e.cost;
                que.push(P(dmin[e.to], e.to));
            }
        }
    }
}

int main() {
    int n,m,st;
    cin >> n >> m >> st;
    REP(i,m){
        ll u,v,c;
        cin >> u >> v >> c;
        G[u].push_back({v,c});
    }
    dijkstra(st);
    REP(i,n){
        if(dmin[i]==LLINF)cout << "INF" << endl;
        else cout << dmin[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 19384
#include<bits/stdc++.h>
using namespace std;
static const int N=1001;
int lcs(string X,string Y){
  int c[N+1][N+1] = {};
  int m=X.size();
  int n=Y.size();

  int max1=0;
  X=' '+X;
  Y=' '+Y;

  //for(int i=1;i<=m;i++){
  //  c[i][0]=0;
  //}
  //for(int j=1;j<=n;j++){
  //  c[0][j]=0;
  //}

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else {
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      max1=max(max1,c[i][j]);
    }
  }
  return max1;
}

int main(){
  string s1,s2;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }
  return 0;
}



Measured memory_bytes: 7108
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
if(N/100==7){
  cout << "Yes" <<endl;
}
else if(N%100/10==7){
  cout << "Yes" <<endl;
}
else if(N%100%10==7){
  cout << "Yes" <<endl;
}
else{
  cout << "No" <<endl;
}
}

Measured memory_bytes: 3608
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			BigInteger a=sc.nextBigInteger();
			BigInteger b=sc.nextBigInteger();
			BigInteger ans=a.add(b);
			if(ans.toString().length()<=80){
				System.out.println(ans);
			}else{
				System.out.println("overflow");
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 18464
/*
 *  Created on: 2 / 8 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
	//stp(0)
	Eslam__Waheed;
	int n; cin >> n;
	cout << ((n >= 30) ? "Yes" : "No");
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){  
  int a,b,c,d,e,f;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op=='?')break;
    else{
      if(op=='+'){
	int c=a+b;
	cout << c << endl;
      }
      else if(op=='-'){
	int c=a-b;
	cout<<c<<endl;
      }
      else if(op=='/'){
	int c=a/b;
	cout<<c<<endl;
      } 
      else if(op=='*'){
	int c=a*b;
	cout<<c<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

int main(){
   int n,a,b;
   string s;
   cin>>n>>a>>b>>s;
   int d=0,f=0;
   for(int i=0;i<n;i++){
       if(s[i]=='a'){
           if(d+f<a+b){
               cout<<"Yes"<<endl;
               d++;
           }
           else cout<<"No"<<endl;
       }
       else if(s[i]=='b'){
           if(d+f<a+b && f<b){
               cout<<"Yes"<<endl;
               f++;
           }
           else cout<<"No"<<endl;
       }
       else cout<<"No"<<endl;
   }

}
 
   

Measured memory_bytes: 1464
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   string s; cin >> s;
   rep(i,0,s.size()){
      if(s[i] == '?') cout << "D";
      else cout << s[i];
   }
   cout << '\n';
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int P[100005];
int D[100005];

void init(int n)
{
	REP(i, n)
	{
		P[i] = i;
		D[i] = 0;
	}
}

int find(int x)
{
	if (x == P[x])
	{
		return x;
	}
	return P[x] = find(P[x]);
}

void unit(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (D[x] < D[y])
	{
		P[x] = y;
	}
	else
	{
		P[y] = x;
		if (D[x] == D[y])D[x]++;
	}
}

bool same(int x, int y)
{
	return find(x) == find(y);
}

int L[100005];

int main()
{
	int N, M;
	cin >> N >> M;
	memset(L, -1, sizeof(L));
	init(N);
	REP(i, N)
	{
		int k;
		cin >> k;
		REP(j, k)
		{
			int l;
			cin >> l;
			l--;
			if (L[l] == -1)
			{
				L[l] = i;
				continue;
			}
			unit(i, L[l]);
		}
	}

	FOR(i, N, 1)
	{
		if (!same(i, i - 1))
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int a,b;
  cin >> a >> b;

  b = b*2+1;
  int ans = a/b;
  if(a%b!=0) ++ans;

  cout << ans << endl;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := iScan()
	b := iScan()
	fmt.Println(a * b / gcd(a, b))
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 1772
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int A[N];
  
  int L=0,R=0,ans=0;
  //右を向いてる人の累積和
  if(S[0]=='E') A[0]=1;
  else A[0]=0;
  for(int i=1; i<N; i++){
    if(S[i]=='E') A[i]=A[i-1]+1;
    else A[i]=A[i-1];
  }
  //0番目がリーダー
  ans = A[N-1];
  
  //i番目がリーダー
  for(int i=1; i<N; i++){
    L = i-A[i-1];
    R = A[N-1]-A[i];
    ans = min(L+R,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1796
def max(a,b); a > b ? a : b; end
  
N,K = gets.split.map(&:to_i)
V = gets.split.map(&:to_i)
L = Array.new(N + 1, 0)
R = Array.new(N + 1, 0)
M = V.each_with_index.select{|v,i| v < 0 }

V.each.with_index(1){|v,i| L[i] = L[i - 1] + v }
V.reverse_each.with_index(1){|v,i| R[i] = R[i - 1] + v }

ans = 0
(0 .. N).each do |l|
  break if l > K
  (0 .. N).each do |r|
    break if l + r > K || l + r > N
    
    u0 = M.select{|v,i| i < l || i >= N - r }
          .map(&:first)
          .min(K - (l + r))
          .inject(0,&:+)
    
    ans = max(ans, L[l] + R[r] - u0)
  end
end
puts ans

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> N(n);
  for(int i=0; i<n; i++){
    cin >> N.at(i);
  }
  
  double sum;
  for(int i=0; i<n; i++){
    sum=sum+N.at(i);
  }
  
  double judge=sum/(4*m);
  int count=0;
  for(int i=0; i<n; i++){
    if(N.at(i)>=judge){
      count++;
    }
  }
  
  if(count>=m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

void fnInput(vector<int>& rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  
  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnInsertionSort(vector<int>& rvnSort, int nGap, int& rnSortCnt)
{
  for (int nSorting = nGap; nSorting < rvnSort.size() ; nSorting++)
  {
    int nTrg = rvnSort[nSorting];
    int nSorted = nSorting - nGap;

    while (nSorted >= 0         &&
           nTrg < rvnSort[nSorted])
    {
      rvnSort[nSorted + nGap] = rvnSort[nSorted];
      nSorted -= nGap;

      rnSortCnt++;
    }
    rvnSort[nSorted + nGap] = nTrg;
  }
}

void fnShellSort(vector<int>& rvnSort, vector<int>& rvnGap, int& rnSortCnt)
{
  for (int nGap = 1; nGap <= rvnSort.size(); nGap = 3 * nGap + 1)
    rvnGap.push_back(nGap);
  
  for (int i = rvnGap.size() - 1; i >= 0; i--)
    fnInsertionSort(rvnSort, rvnGap[i], rnSortCnt);
}

void fnOutput(const vector<int>& cnrvnSort, const vector<int>& cnrvnGap, int nSortCnt)
{
  cout << cnrvnGap.size() << endl;

  for (int i = cnrvnGap.size() - 1; i >= 0; i--)
  {
    if (i != cnrvnGap.size() - 1) cout << " ";
    cout << cnrvnGap[i];
  }
  cout << endl;

  cout << nSortCnt << endl;

  for (int i = 0; i < cnrvnSort.size(); i++)
    cout << cnrvnSort[i] << endl;
}

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

  vector<int> vnSort;
  vector<int> vnGap;
  int nSortCnt = 0;

  fnInput(vnSort);
  fnShellSort(vnSort, vnGap, nSortCnt);
  fnOutput(vnSort, vnGap, nSortCnt);

  return 0;
}

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

int main()
{
	const int TYPENUM = 4;
	const int RANKNUM = 13;
	bool card[TYPENUM][RANKNUM] = { false };
	char type[] = { "SHCD" };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		char c;
		int r;
		int idx;
		cin >> c >> r;
		if (c == 'S')
			idx = 0;
		else if (c == 'H')
			idx = 1;
		else if (c == 'C')
			idx = 2;
		else if (c == 'D')
			idx = 3;
		card[idx][r-1] = true;
	}
	for (int i = 0; i < 4; i++)
		for (int j = 0; j <13; j++)
			if (card[i][j] == false)
				cout << type[i] << " " << j+1 << endl;
}


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	while(cin>>n>>m){
		vi in(n);
		rep(i,n)in[i]=i;
		while(m--){
			int a;cin>>a;
			vvi out(2);
			rep(i,n)out[(i<n/2?1:0)].pb(in[i]);
			in=vi(0);
			int t=0;
			while(1){
				rep(i,a){
					if(out[t].size()==0)break;
					in.pb(out[t][0]);
					out[t].erase(out[t].begin());
				}
				t^=1;
				if(in.size()==n)break;
			}
		}
		cout<<in[in.size()-1]<<endl;
	}
}

Measured memory_bytes: 1220
#include <stdio.h>
#define N 100000

int a[N]={};

int search(int c)
{
	if(c==a[c]) return c;
	
	return a[c]=search(a[c]);
}

int main(void)
{
 int i,n,m,q,s,t;

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

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

 for(i=0;i<m;i++){
     scanf("%d %d",&s,&t);
     if(search(s)!=search(t)) a[search(t)]=search(s);
 }

 scanf("%d",&q);

 for(i=0;i<q;i++){
     scanf("%d %d",&s,&t);
     if(search(s)==search(t)) printf("yes\n");
     else printf("no\n");
 }

 return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto x : v) cerr << x << ' '; cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	const int n = 1000000;
	vector<bool> flag(n);
	vi prime;
	for (int p = 2; p < n; p++) {
		if (flag[p]) continue;
		prime.push_back(p);
		for (int q = p + p; q < n; q += p) flag[q] = true;
	}

	int x; cin >> x;
	auto it = lower_bound(all(prime), x);
	if (it == prime.end()) puts("BUG");
	cout << *it << endl;
}


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


int main()
{
    int n;
    while(cin>>n)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        int i;
        for(i=1;i*n<a;i++);
        if(i*n>b)
            cout<<"NG"<<endl;
        else
            cout<<"OK"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N; string s;
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if(abs(a-c) <= d || abs(b-c) <= d && abs(a-b) <= d) puts("Yes");
	else puts ("No");
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

const int MAXV = 200000;

ll f[MAXV + 1], fi[MAXV + 1];

void init() {
    f[0] = 1;
    for (int i = 1; i <= MAXV; i++) {
        f[i] = f[i - 1] * i % MOD;
    }

    fi[MAXV] = modpow(f[MAXV], MOD - 2);
    for (int i = MAXV; i > 0; i--) {
        fi[i - 1] = fi[i] * i % MOD;
    }
}

ll comb(int r, int c) {
    if (r < c) return 0;
    return f[r] * fi[c] % MOD * fi[r - c] % MOD;
}

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;

    ll div100 = modpow(100, MOD - 2);
    a = a * div100 % MOD;
    b = b * div100 % MOD;
    c = c * div100 % MOD;

    ll aa = a * modpow((a + b) % MOD, MOD - 2) % MOD;
    ll bb = b * modpow((a + b) % MOD, MOD - 2) % MOD;

    ll ans = 0;
    for (int i = n; i < 2 * n; i++) {
        ll hoge = modpow(aa, n) * modpow(bb, i - n) % MOD + modpow(aa, i - n) * modpow(bb, n) % MOD;
        hoge %= MOD;
        hoge = hoge * comb(i - 1, n - 1) % MOD * i % MOD;
        (ans += hoge) %= MOD;
    }

    cout << ans * modpow((MOD + 1 - c) % MOD, MOD - 2) % MOD << endl;
    return 0;
}

Measured memory_bytes: 3328
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res

N = int(input())
res = prime_factorize(N)
ans = []
for v, ex in res:
    for _ in range(ex):
        ans.append(str(v))
print(str(N) + ":", " ".join(ans))


Measured memory_bytes: 5640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
int main()
{
    int N; cin >> N;
    cout << N * 800 - (N / 15) * 200 << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 

n,k,*a = list(map(int,read().split()))
for i in range(n): a[i] -= 1

na = [0]*n
v = 0
while k:
    if k&1: v = a[v]
    for j, aj in enumerate(a):
        na[j] = a[aj]
    a,na = na,a
    i += 1    
    k >>= 1

print(v+1)

Measured memory_bytes: 93600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    string T = "";
    rep(i, S.size()) {
        int o = ans;
        for (int j = 1; j <= S.size() - i; ++j) {
            if (S.substr(i, j) != T) {
                ++ans;
                T = S.substr(i, j);
                i += j - 1;
                break;
            }
        }
        if (o == ans) {
            T.push_back(S[i]);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e5+100;
vector<PII> ad[sz];
ll n;
ll ans[sz];
ll len[sz];
void DFS(ll p,ll parent,ll sum)
{
    len[p]=sum;
    for(auto xx: ad[p])
    {
        if(xx.s != parent){
            if(((sum+xx.f) & 1ll) == (len[p] &1ll) ){
                ans[xx.s]=ans[p];
            }
            else{
                ans[xx.s]=(ans[p] ^ 1ll );
            }
            DFS(xx.s,p,sum+xx.f);
        }
    }
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        for(i=0;i<=n;i++) ad[i].clear();
        for(i=1;i<n;i++){
            cin>>p>>q>>x;
            ad[p].pb({x,q});
            ad[q].pb({x,p});
        }
 
        ans[1]=0;
        DFS(1,-1,0);
        for(i=1;i<=n;i++){
            cout<<ans[i]<<endl;
        }
    }
 
 
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
int mod=int(1e9)+7;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int h[n+1];
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    ll dp[n+1];
    for(int i=1;i<=n;i++){
        dp[i]=mod;
    }
    dp[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=max(1,i-k);j<i;j++){
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n]<<"\n";
}

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

using namespace std;

typedef long long ll;

int main () {
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.size(); ++i) {
		if ((i + 1) % 2 == 1) {
			if (s[i] == 'L') {
				cout << "No";
				return 0;
			}
		}
		else if ((i + 1) % 2 == 0) {
			if (s[i] == 'R') {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

struct P
{
	double x, y;
	P(double x, double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return x*x + y*y;
	}
	
	bool operator<(const P& v)const
	{
		return y != v.y ? y < v.y : x < v.x;
	}
	bool operator>(const P& v)const
	{
		return y != v.y ? y > v.y : x > v.x;
	}
};

int ccw(P a, P b, P c) 
{
	b = b - a; c = c - a;
	if (b.cross(c) > 0)   return +1;			// counter clockwise
	if (b.cross(c) < 0)   return -1;			// clockwise
	if (b.dot(c) < 0)     return +2;			// c--a--b on line
	if (b.length2() < c.length2()) return -2;   // a--b--c on line
	return 0;
}

vector<P> convex_hull(vector<P>& points)
{
	int n = points.size(), k = 0;
	sort(points.begin(), points.end());
	vector<P> ch(2 * n);
	for (int i = 0; i < n; ch[k++] = points[i++]) // lower-hull
	{
		while (k >= 2) 
		{
			int state = ccw(ch[k - 2], ch[k - 1], points[i]);
			if (state > 0 || state < -1)
			{
				break;
			}
			--k;
		}
	}
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = points[i--]) // upper-hull
	{
		while (k >= t)
		{
			int state = ccw(ch[k - 2], ch[k - 1], points[i]);
			if (state > 0 || state < -1)
			{
				break;
			}
			--k;
		}
	}
	ch.resize(k - 1);
	return ch;
}

vector<P> points;

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

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;
		points.push_back(P(x, y));
	}

	vector<P> output = convex_hull(points);

	printf("%d\n", output.size());
	for (auto& v : output)
	{
		printf("%d %d\n", (int)v.x, (int)v.y);
	}
	
	return 0;
}


Measured memory_bytes: 7492
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define eps 1e-9
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, p;
llint w[100005], b[100005];
double d[100005];


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> p;
	for(int i = 1; i <= n; i++) cin >> w[i] >> b[i];
	
	llint sum = 0;
	for(int i = 1; i <= n; i++){
		d[i] = (100-p)*w[i] + p*b[i];
		sum -= p * b[i];
	}
	sort(d+1, d+n+1);
	reverse(d+1, d+n+1);
	
	for(int i = 1; i <= n; i++){
		sum += d[i];
		if(sum >= 0){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2560
//
//  main.cpp
//  AT
//
//  Created by 黄道煜 on 2018/8/11.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#define LL long long
using namespace std;

int n, k;

int main()
{
    scanf("%d%d", &n, &k);
    if(n%k==0) printf("0");
    else printf("1");
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using LL = long long;
const int AMAX = 100000;
LL cnt[AMAX + 1];
int main(void) {
 int N;
 LL K;
 cin >> N >> K;
 
 for (int i = 0; i < N; ++i) {
 int A, B;
 cin >> A >> B;
 cnt[A] += B;
}
for (int ans = 1; ans <= AMAX; ++ans){
 if (K <= cnt[ans]) {
 cout << ans << endl;
 break;
}
 K -= cnt[ans]; 
}
 return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int a[10000];
int min(int n){
	int minimum=a[0];
	for (int i=1; i<n; i++){
		if (minimum>a[i]) minimum = a[i];
	}
	return minimum;
}
int max(int n){
	int maximum = a[0];
	for (int i=1; i<n; i++){
		if (maximum<a[i]) maximum = a[i];
	}
	return maximum;
}
long longsum(int n){
	long SUM = a[0];
	for (int i=1; i<n; i++){
		SUM+=a[i];
	}
	return SUM;
}
int main (){
	int n;
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> a[i];
	}
	cout << min(n) << " " << max(n) << " " << longsum(n) << endl;
}

Measured memory_bytes: 3116
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define DEBUG
#undef DEBUG

using ll = long long;

int H, W;

ll max_min(ll s1, ll s2, ll s3)
{
    return max({s1, s2, s3}) - min({s1, s2, s3});
}

// 縦3分割
ll trivert(ll h, ll w)
{
    if(h == 2)
        return numeric_limits<ll>::max();

    if(w % 3 == 0)
        return 0;
    else
        return w;

#if 0
    ll ans = numeric_limits<ll>::max();

    for(ll h1 = 1; h1 <= h-2; ++h1) {
        ll s1 = h1 * w;

        ll h2 = h - h1;
        ll s2 = h2/2 * w;
        ll s3 = (h2-h2/2) * w;

        ans = min(ans, max_min(s1, s2, s3));
    }

    return ans;
#endif
}

// 縦分割後に一方を横分割
ll verthoriz(ll h, ll w)
{
    ll ans = numeric_limits<ll>::max();

    for(ll h1 = 1; h1 <= h-1; ++h1) {
        ll s1 = h1 * w;

        ll h2 = h - h1;
        ll s2 = h2 * (w/2);
        ll s3 = h2 * (w-w/2);

        ans = min(ans, max_min(s1, s2, s3));
    }

    return ans;
}

void solve()
{
    ll ans = min({
        trivert(H,W),
        trivert(W,H),
        verthoriz(H,W),
        verthoriz(W,H)
    });

    cout << ans << "\n";
}

int main()
{
    cin >> H >> W;

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int a[5];
int ans = 1<<30;

int main()
{
  rep( i, 5 )
    scanf( "%d", a+i );

  do
  {
    int cnt = 0;

    rep( i, 5 )
    {
      cnt = (cnt+9)/10*10;
      cnt += a[i];
    }

    ans = std::min( ans, cnt );
  } while( std::next_permutation( a, a+5 ) );

  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 128
s = input()
t = input()

n = len(s) - len(t)
l = len(t)

res = 0
for i in range(n+1):
    cnt = 0
    for j in range(l):
        if s[i+j] == t[j]:
            cnt += 1
    res = max(res, cnt)

print(l - res)

Measured memory_bytes: 8900
#include<stdio.h>
#include<math.h>

struct point{double x,y;};

void koch(int n, struct point p1, struct point p2){
  struct point  a,b,c;
  double th=M_PI/3;

  if(n==0) return;
    
  a.x=(2.0*p1.x+1.0*p2.x)/3.0;
  a.y=(2.0*p1.y+1.0*p2.y)/3.0;
  b.x=(1.0*p1.x+2.0*p2.x)/3.0;
  b.y=(1.0*p1.y+2.0*p2.y)/3.0;
  c.x=(b.x-a.x)*cos(th)-(b.y-a.y)*sin(th)+a.x;
  c.y=(b.x-a.x)*sin(th)+(b.y-a.y)*cos(th)+a.y;

  koch(n-1,p1,a);
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n-1,a,c);
  printf("%.8f %.8f\n",c.x,c.y);
  koch(n-1,c,b);
  printf("%.8f %.8f\n",b.x,b.y);
  koch(n-1,b,p2);

}

int main(){
  int n;
  struct point p1,p2;
  
  scanf("%d",&n);

  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;
  
  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}



Measured memory_bytes: 2048
q = [*1..9]
k = gets.to_i
x = 0
k.times do |i|
  x = q.shift
  q.push(x * 10 + x % 10 - 1) unless x % 10 == 0
  q.push(x * 10 + x % 10)
  q.push(x * 10 + x % 10 + 1) unless x % 10 == 9
end
puts x

Measured memory_bytes: 3964
def Roll(c, lst) :
    if c == 'N' :
        lst[0], lst[1], lst[5], lst[4] = lst[1], lst[5], lst[4], lst[0]
    elif c == 'S' :
        lst[0], lst[1], lst[5], lst[4] = lst[4], lst[0], lst[1], lst[5]
    elif c == 'E' :
        lst[0], lst[2], lst[5], lst[3] = lst[3], lst[0], lst[2], lst[5]
    elif c == 'W' :
        lst[0], lst[2], lst[5], lst[3] = lst[2], lst[5], lst[3], lst[0]
    return lst
    

def Comp_Dice(dice_A, dice_B) :
    for i in range(4) :
        if dice_B[1] == dice_A[1] :
            break
        else :
            Roll('S', dice_B)
    if dice_B[1] != dice_A[1] :
        Roll('E', dice_B)
        for i in range(4) :
            if dice_B[1] == dice_A[1] :
                break
            else :
                Roll('S', dice_B)
    for i in range(4) :
        if dice_B[0] == dice_A[0] :
            break
        else :
            Roll('E', dice_B)

    if dice_B[0] == dice_A[0] and dice_B[1] == dice_A[1] and dice_B[2] == dice_A[2] and dice_B[3] == dice_A[3] and dice_B[4] == dice_A[4] and dice_B[5] == dice_A[5] :
        return "Same"
    else :
        return "Different"
        
import copy
ans = "Yes"
N = int(input())
dice_X = list(map(int, input().split()))
for i in range(N-1) :
    dice_Y = list(map(int, input().split()))
    if Comp_Dice(dice_X, dice_Y) == "Same" :
        ans = "No"
        break

print(ans)    


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin>>a>>b;
	if ((a+b)%2==1){
		cout<<(a+b+1)/2;
	}
	else {
		cout<<(a+b)/2;
	}
	return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  for(int i=0;i<M;i++)  cin >> X.at(i);

  if(N>=M){
    cout << 0 << endl;
    return 0;
  }

  sort(X.begin(),X.end());
  vector<int> dis(M-1);
  for(int i=0;i<M-1;i++){
    dis.at(i)=X.at(i+1)-X.at(i);
    //cout << dis.at(i) << endl;
  }
  sort(dis.begin(),dis.end());
  reverse(dis.begin(),dis.end());
  long long sum=0;
  for(int i=0;i<N-1;i++){
    sum+=(long long)dis.at(i);
    //cout << dis.at(i) << endl;
  }
  cout << X.at(M-1)-X.at(0)-sum << endl;

  return 0;
}


Measured memory_bytes: 1024
def main():
    total1 = list(map(int, input().split()))
    total = list(map(int, input().split()))

    num = total1[1]

    s_total = sorted(total)

    money = 0
    for i in range(num):
        money += s_total[i]

    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  string t;
  cin >> t;
  ll n = t.size();
  rep(i, n){
    if (t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;
  
  return 0;
}

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

const bool DEBUG = false;
int main() {
	int N, K;
	cin >> N >> K;
	int64_t sum = 0;
	for (int b = K + 1;b <= N;b ++) { // 各bについてaが何通りか考える
		sum += N / b * (b - K); // N/a*aまでのbの通り数
		if (N - (N / b * b) >= K) {
			sum += N - (N / b * b) - K + 1; // 残りのbの通り数
		}
		if (DEBUG) { // デバッグ用
			for (int a = 1;a <= N;a ++) {
				if (a % b >= K) cout << "(" << a << "," << b << ")" << endl;
			}
			cout << b << ":" << N / b * (b - K) << "+" << (N - (N / b * b) - K >= 0 ? N - (N / b * b) - K + 1 : 0) << endl;
		}
	}
	if (K == 0) cout << (int64_t)N * N; // コーナーケース
	else cout << sum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

こういう時は、まずあるbを固定して考える ただしbはKより大きい
その時、aはまずKからb-1までのb-K通りある
あとはN/a*aからa-1までを考えれば終わり
*/

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

typedef long long LL;
const int MaxN = 600;
using namespace std;

int n, m = 300, w;
int a[MaxN + 5][MaxN + 5]; 
int c[MaxN + 5][MaxN + 5], r[MaxN + 5][MaxN + 5];
char s[305][305];
struct NODE {
	int x, y;
}p[300 * 300 + 5];

int main() 
{
	while(~scanf("%d%d", &n, &w)) {
		for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1); 
		int tot = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= w; j++) {
				if(s[i][j] == '#') {
					int x = i + j - 1, y = i - j + m;
					p[++tot] = (NODE){x, y};
					a[x][y] = 1;
				}
			}
		}
		m *= 2;
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= m; j++) {
				c[i][j] = c[i - 1][j] + a[i][j]; 
				r[i][j] = r[i][j - 1] + a[i][j];
			}
		}
		long long res = 0;
		for (int i = 1; i <= tot; i++) {
			int x = p[i].x, y = p[i].y;
			for (int d = 2; d <= m; d += 2) {
				if(x + d <= m && a[x + d][y]) {
					if(y + d <= m) res += c[x + d - 1][y + d] - c[x][y + d];
					if(y - d >= 0) res += c[x + d - 1][y - d] - c[x][y - d];
				}
				if(y + d <= m && a[x][y + d]) {
					if(x + d <= m) res += r[x + d][y + d] - r[x + d][y - 1]; 
					if(x - d >= 0) res += r[x - d][y + d] - r[x - d][y - 1];
				}
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n;

vector<int> lose[100005];
vector<int> sizes[100005];
int dp[100005];

void dfs(int id){
	int len = lose[id].size();
	dp[id] = len + 1;
	for(auto to: lose[id]){
		dfs(to);
		sizes[id].push_back(dp[to]);
	}
	sort(sizes[id].begin(), sizes[id].end());
	for(int i = 0; i < len; i++){
		dp[id] = max(dp[id], sizes[id][i] + len - i);
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 2; i <= n; i++){
		int x;
		scanf("%d", &x);
		lose[x].push_back(i);
	}
	dfs(1);
	printf("%d\n", dp[1] - 1);
	return 0;
}

Measured memory_bytes: 19328
#include<iostream>
#include<stdlib.h>
using namespace std;

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *pointer;

node s;
pointer nil=&s;
pointer R=nil;


void insert(pointer z){
  pointer y=nil;
  pointer x=R;
  while(x!=nil){
    y=x;
    if(z->key < x->key)x=x->l;
    else x=x->r;
  }
  z->p=y;
  if(y==nil) R = z;
  else if(z->key < y->key) y->l= z;
  else y->r=z;
}


void print(pointer t,int pp){
  if(t==nil) return;
  if(pp)cout<<" "<<t->key;
  print(t->l,pp);
  if(!pp)cout<<" "<<t->key;
  print(t->r,pp);
}

pointer find(pointer x,int k){
  while(x!=nil && k!=x->key){
    if(k < x->key ) x=x->l;
    else x=x->r;
  }
    return x;
  }


int main(){
  int n;
  cin>>n;
  string str;
  for(int i=0;i<n;i++){
    cin>>str;
    if(str=="insert"){
      pointer   T=(pointer)malloc(sizeof(node));
      cin>>T->key;
      T->l=nil;
      T->r=nil;
      insert(T);
    }else if(str=="print"){
      print(R,0);
      cout<<endl;
      print(R,1);
      cout<<endl;
    }else if(str=="find"){
      int a;
        cin>>a;
	pointer point=find(R,a);
	if(point->key==a) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
    }
  
  }
  return 0;
}

Measured memory_bytes: 19960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sort(v) sort(v.begin(),v.end())
#define pb push_back
#define in insert
int main()
{
    int a,b,h;
    cin>>a>>b>>h;
    cout<<0.5*h*(a+b)<<endl;
}


Measured memory_bytes: 3780