akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,x,y,b,p,all,mix;
    cin>>n;
    for(int i=0;i<n;i++){
        all=9999999,mix=9999999;
        cin>>x>>y>>b>>p;
        all=x*b+y*p;
        if(b>4&&p>1)all=all*0.8;
        if(b<=4&&p<=1)mix=x*5*0.8+y*2*0.8;
        if(b<=4&&p>1)mix=x*5*0.8+y*p*0.8;
        if(b>4&&p<=1)mix=x*b*0.8+y*2*0.8;
        //cout<<all<<" "<<mix<<endl;
        cout<<min(all,mix)<<endl;
    }
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <complex>
#include <iomanip>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;
const double EPS = 1e-10;
//二つのスカラーが等しいか
#define EQ(a, b) (abs((a) - (b)) < EPS)
//二つのベクトルが等しいか
#define EQV(a, b) (EQ((a), real(), (b).real()) && EQ((a), imag(), (b).imag()))
#define curr(P, i) P[i]
#define next(P, i) P[(i + 1) % P.size()]

double dot(P a, P b)
{
    return real(a) * real(b) + imag(a) * imag(b);
}

double cross(P a, P b)
{
    return real(a) * imag(b) - imag(a) * real(b);
}

int is_orthogonal(P a1, P a2, P b1, P b2)
{
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}
int is_parallel(P a1, P a2, P b1, P b2)
{
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

int ccw(P a, P b, P c)
{
    b -= a;
    c -= a;
    if (cross(b, c) > 0)
        return 1;
    if (cross(b, c) < 0)
        return -1;
    if (dot(b, c) < 0) // c--a--b on line
        return 2;
    if (norm(b) < norm(c)) //a--b--c on line or a==b
        return -2;
    return 0; // a--c--b on line a==c or b==c
}

int is_intersected_ls(P a1, P a2, P b1, P b2)
{
    return ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
           ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0;
}

double Area(vec &g)
{
    double A = 0;
    for (int i = 0; i < g.size(); ++i)
    {
        A += cross(curr(g, i), next(g, i));
    }
    return A / 2.0;
}
int main(void)
{
    int N;
    cin >> N;
    vec v;
    for (int i = 0; i < N; ++i)
    {
        double x, y;
        cin >> x >> y;
        P c = {x, y};
        v.push_back(c);
    }
    cout << fixed << setprecision(1) << Area(v) << endl;
}


Measured memory_bytes: 3292
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

int main(){
    ll n,a,b;
    cin >>n>>a>>b;
    ll ans;
    if((b-a)%2==0){
        ans=(b-a)/2;
    }else{
        ans=min(n-a,b-1);
        ans=min(ans,n-b+(b-a)/2+1);
        ans=min(ans,a-1+(b-a)/2+1);
    }
    cout<<ans<<endl;
    return 0;
}



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

int main(){
    int Np;
    int Znum;
    int a,b;
    int ans;

    cin >> Znum;
    cin >> Np;

    while(Znum>0){
        a = Znum % Np;
        b += a*pow(10,ans);
        Znum = Znum/Np;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
H,W,M = map(int,input().split())
hs = [0]*H
ws = [0]*W
s = set()
for i in range(M):
    h,w = map(int,input().split())
    hs[h-1] += 1
    ws[w-1] += 1
    s.add((h-1,w-1))

mh = 0; mw = 0
for i in range(H):
    mh = max(mh,hs[i])
for i in range(W):
    mw = max(mw,ws[i])

Is = []; Js = []
for i in range(H):
    if mh ==  hs[i]:
        Is.append(i)
for i in range(W):
    if mw == ws[i]:
        Js.append(i)
ans = mh + mw
flag = 0
for i in Is:
    for j in Js:
        if (i,j) in s:
            continue
        print(ans)
        exit()
print(ans-1)

Measured memory_bytes: 83568
N = gets.to_i
XY = readlines.map {|s| s.split.map(&:to_i) }
a = XY.sort_by {|x,y| x+y }
x1,y1,x2, y2 = *a[0], *a[-1]
ans = (x1-x2).abs + (y1-y2).abs
a = XY.sort_by {|x,y| x-y }
x1,y1,x2, y2 = *a[0], *a[-1]
puts [ans, (x1-x2).abs + (y1-y2).abs].max

Measured memory_bytes: 46984
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<usize>();
    let t=read::<usize>();
    let mut c=2000;
    for _ in 0..n{
        let a=read::<usize>();
        let b=read::<usize>();
        if b<=t&&a<c{c=a}
    }
    if c<2000{println!("{}",c)}else{println!("TLE")}
}


Measured memory_bytes: 4476
/**
 *    author:  tourist
 *    created: 27.01.2020 01:09:52       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long r, b;
  cin >> r >> b;
  auto Count = [&](long long p, long long q, long long bound) {
    long long sx = 0;
    long long sy = 0;
    long long cnt = 0;
    for (long long x = 0; x * p <= bound; x++) {
      long long y = (bound - x * p) / q;
      sx += x * (y + 1);
      sy += y * (y + 1) / 2;
      cnt += y + 1;
    }
    return make_tuple(sx, sy, cnt);
  };
  auto Test = [&](long long p, long long q) {
    bool inv = false;
    if (p < q) {
      swap(p, q);
      swap(r, b);
      inv = true;
    }
    long long low = 0, high = 1;
    while (true) {
      auto got = Count(p, q, high);
      if (get<0>(got) * p + get<1>(got) * q > r * p + b * q) {
        break;
      }
      low = high;
      high <<= 1;
    }
    while (low + 1 < high) {
      long long mid = (low + high) >> 1;
      auto got = Count(p, q, mid);
      if (get<0>(got) * p + get<1>(got) * q > r * p + b * q) {
        high = mid;
      } else { 
        low = mid;
      }
    }
    auto got = Count(p, q, low);
    long long sx = get<0>(got);
    long long sy = get<1>(got);
    long long cnt = get<2>(got);
    long long s = sx * p + sy * q;
    long long add = (r * p + b * q - s) / high;
    long long x = 0;
    while ((high - x * p) % q != 0) {
      ++x;
    }
    sx += x * add + q * (add * (add - 1) / 2);
    long long y = (high - x * p) / q;
    while (y >= p) {
      x += q;
      y -= p;
    }
    sy += y * add + p * (add * (add - 1) / 2);
    cnt += add;
    if (sx <= r && sy <= b) {
      cout << cnt - 1 << '\n';
      exit(0);
    }
    bool ret = (sx > r) ^ inv;
    if (inv) {
      swap(r, b);
    }
    return ret;
  };
  long long p0 = 0, q0 = 1;
  long long p1 = 1, q1 = 0;
  while (true) {
    if (Test(p0 + p1, q0 + q1)) {
      p0 = p0 + p1;
      q0 = q0 + q1;
    } else {
      p1 = p0 + p1;
      q1 = q0 + q1;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    float ans = 0, ans1 = 0;
    int i, N;
    float A[1000];
    
    scanf("%d", &N);
    //printf("%d\n", N);
    
    for(i = 0; i < N; i++){
        scanf("%f", &A[i]);
        //printf("%g\n", A[i]);
    }
    
    for(i = 0; i < N; i++){
        ans1 = ans1 + (1 / A[i]);
        //printf("%g\n", ans1);
    }
    
    ans = 1 / ans1;
    printf("%f\n", ans);
    
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

struct edge{int to;ll cap;int rev;};

int MAX_V=20050;
int tmp1,tmp2;

vector<vector<edge>> g(MAX_V);//グラフの隣接リスト表現
vin level(MAX_V);//distance form s
vin iter(MAX_V);//どこまで調べたか

void add_edge(int from,int to,ll cap=(ll)inf){
    tmp1=g[to].size();tmp2=g[from].size();
    g[from].push_back((edge){to,cap,tmp1});//g[to]のg[to].size()番目にfromが入っている
    g[to].push_back((edge){from,0,tmp2});//g[from]のg[from].size()-1番目にtoが入っている
}

void bfs(int s){
    fill(all(level),-1);
    queue<int> q;
    q.push(s);
    level[s]=0;
    while(q.size()){
        int v=q.front();q.pop();
        for(auto& e:g[v]){
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                q.push(e.to);
            }
        }
    }
}

//増加パスをdfsで探す
//v:今見てる頂点 t:終点 f:流量
int dfs(int v,int t,ll f){
    if(v==t)return f;
    for(int& i=iter[v];i<(int)g[v].size();i++){
        edge& e=g[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s,int t){
    ll flow=(ll)0;
    ll f;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        fill(all(iter),0);
        while((f=dfs(s,t,inf))>0)flow+=f;
    }
}

int main(){
    int h,w;cin>>h>>w;
    vstr S(h);
    rep(i,h)cin>>S[i];
    //各マスinとoutを2つ用意
    //(i,j)のinは2(i*w+j)で, outは2(i*w+j)+1で表される
    int s=2*h*w;//s→ヤギ
    int t=s+1;//追加したグリッドのマス(ゴール)→t
    int tmp;
    rep(i,h)rep(j,w){
        tmp=2*(i*w+j);
        if(S[i][j]=='X'){
            if(i==0||i==h-1||j==0||j==w-1){
                cout<<-1<<endl;
                return 0;
            }
            add_edge(tmp,tmp+1);
            add_edge(s,tmp);
        }
        else add_edge(tmp,tmp+1,(ll)1);
        if(i>0)add_edge(tmp+1,tmp-2*w);
        if(i<h-1)add_edge(tmp+1,tmp+2*w);
        if(j>0)add_edge(tmp+1,tmp-2);
        if(j<w-1)add_edge(tmp+1,tmp+2);
        if(i==0||i==h-1||j==0||j==w-1)add_edge(tmp+1,t);
    }
    cout<<max_flow(s,t)<<endl;
}

Measured memory_bytes: 7564
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX = 1e5+4;
int a[MAX],b[MAX];
int f[102][MAX];
//f[i][j] la so tien lon nhat den vat thu i va ba lo co can nang la j
int n,c;
signed main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=c;j++)
		{
			if(a[i] <= j)
			{
				f[i][j] = max(f[i-1][j],f[i-1][j-a[i]]+b[i]);
			}
			else
			{
				f[i][j] = f[i-1][j];
			}
		}
	}
	
	int best = -1;
	for(int i=1;i<=c;i++)
	{
		best = max(best,f[n][i]);
	}
	
	cout<<best;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std; 
int n ; long long int a[500];long long int sum[500];
long long int dp[500][500];
long long int func(int i , int j)
{
	if(dp[i][j]!=-1)
	return(dp[i][j]);
	
	if(i==j)
	return(dp[i][j]=a[i]);
	else if(j-i==1)
	return(dp[i][j]= a[i]+a[j]);
	
	long long int p = min(func(i+1,j), func(i,j-1)); 
	for(int k = 2; k<=(j-i)-1; k++)
	{
		p = min(p,func(i,i+k-1)+func(i+k,j));
	}
	
	return(dp[i][j]= p+sum[j]-sum[i-1]);
	
}

int main()
{
	cin>>n ; a[0]= 0 ; 
	for(int i = 1 ; i<=n ; i++)
	cin>>a[i];
	sum[0]= 0;
	for(int i = 1; i<=n ; i++)
	sum[i]= sum[i-1]+a[i];
	memset(dp,-1,sizeof(dp));
	cout<<func(1,n);
	return(0);
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long
main(){
int k,sum = 0,x;
cin>>k;
for(int a = 1;a<=k ; a++){
    for(int b = 1;b<=k;b++){
        for(int c = 1;c<=k;c++){
            x = __gcd(a,b);
            sum += __gcd(x,c);
        }
    }
}
cout<<sum<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>

using namespace std;

void swap(int *a, int *b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(void){
    string input;
    
    while(getline(cin, input), !cin.eof()){
        int n[3];
        int tmp;
        
        sscanf(input.c_str(), "%d %d %d", n, n + 1, n + 2);
        
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(n[i] < n[j]) swap(n + i, n + j);
            }
        }
        
        printf("%d %d %d\n", n[0], n[1], n[2]);
        
    }
    
    return(0);
}



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

int main() {
  int D;
  cin >> D;
  if (D==22) {cout << "Christmas Eve Eve Eve" << endl;}
  else if (D==23){cout << "Christmas Eve Eve" << endl;}
  else if (D==24){cout << "Christmas Eve" << endl;}
  else if (D==25){cout << "Christmas" << endl;}
  
  return 0;
}

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

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

	int N = S.size();
	int ans = N;
	int ptn = 0;
	int cnt = 0;
	for( int i = 0; i < N; i++ ) {
		if( S[i] - '0' != ptn ) cnt++;
		ptn = 1 - ptn;
	}
	ans = min( ans, cnt );
	ptn = 1;
	cnt = 0;
	for( int i = 0; i < N; i++ ) {
		if( S[i] - '0' != ptn ) cnt++;
		ptn = 1 - ptn;
	}
	ans = min( ans, cnt );

	cout << ans << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(0);
  int a, b;
  
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    vec.push_back(a);
    vec.push_back(b);
  }
  
  for (int k = 0; k < N; k++) {
    int counter = 0;
    for (int j = 0; j < 2 * M; j++) {
      if (vec.at(j) == k+1)
        counter += 1;
    }
    cout << counter << endl;
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println((int)Math.pow(N, 3));
		sc.close();
	}

}
/*
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□■■□□
■■■■■■□□□■□■■■□□□
□□□□□■□□□■■■□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□■■■□□□■□□□□□□□
□■■■□■□□□■□□□□□■□
■■□□□■□□□■■□□□■■□
□□□□□■□□□□■■■■■□□
□□□□□■□□□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
■■■■■■■■■■■■■■■■□
□□□□□□□■□□□□□□□□□
□□□□□□■■■□□□□□□□□
□□□□□□■□■□□□□□□□□
□□□□□□■□■■□□□□□□□
□□□□□■■□□■□□□□□□□
□□□□□■□□□■■□□□□□□
□□□□■■□□□□■■□□□□□
□□□■■□□□□□□■■□□□□
□□■■□□□□□□□□■■□□□
■■■□□□□□□□□□□■■■□
*/

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

int main(void){
    int a, b, c;
    int p, q, r;
    cin >> p >> q >> r;

    a = p + q;
    b = q + r;
    c = r + p;

    if(a < b){
        if(a < c){
            cout << a << endl;
        }
        else{
            cout << c << endl;
        }
    }
    else if(b < c){
        if(b < a){
            cout << b << endl;
        }
        else{
            cout << a << endl;
        }
    }else if(c < a){
        if(c < b){
            cout << c << endl;
        }
        else{
            cout << b << endl;
        }
    } else {
        cout << a << endl;
    }
}

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    for (ll& it : p)
        cin >> it, --it;
    for (ll& it : c)
        cin >> it;
    vector<vector<ll>> pre(n, vector<ll>(1, 0));
    for (int i = 0; i < n; i++) {
        int idx = p[i];
        pre[i].push_back(c[i]);
        while (idx != i) {
            pre[i].push_back(pre[i].back() + c[idx]);
            idx = p[idx];
        }
    }
    ll ans = -(1e18L);
    for (int i = 0; i < n; i++) {
        ll sum = 0, len = (ll)pre[i].size() - 1;
        if (pre[i].back() > 0) {
            ll l = k / len, r = k % len;
            sum += pre[i].back() * l;
            sum += *max_element(pre[i].begin(), pre[i].begin() + r + 1);
            if (l > 1) {
                ll altsum = pre[i].back() * (l - 1);
                altsum += *max_element(pre[i].begin(), pre[i].end());
                sum = max(sum, altsum);
            } else if (l == 1) {
                ll altsum = *max_element(pre[i].begin() + 1, pre[i].end());
                sum = max(sum, altsum);
            }
        } else {
            ll r = min(len, k);
            sum += *max_element(pre[i].begin() + 1, pre[i].begin() + r + 1);
        }
        ans = max(ans, sum);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 218748
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  double n,y,b,r,t;
  
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>y;
    double ans=-1;
    double genri=-1;
    for(int i=0;i<n;i++){
      cin>>b>>r>>t;
      double temp;
      if(t==1){
	temp=1+y*r/100;
      }else{
	temp=pow(1+r/100,y);
      }
      
      if(temp>genri){
	genri=temp;
	ans=b;
      }
    }
    cout<<ans<<"\n";
  }
  return 0;

}
    



Measured memory_bytes: 3504
#include<stdio.h>
static int MAX = 100;
static int INFTY = (1<<21);
static int WHITE = 0;
static int GRRAY = 1;
static int BLACK = 2;

int n;
int M[100][100];

int prim(){
  int u,minv,i,v;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(M[u][v] != INFTY && color[v] != BLACK){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRRAY;
	}
      }
    }
  }
  int sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }

  return sum;
}

int main(){
  int i,j,e;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1) ? INFTY :e;
    }
  }
  printf("%d\n",prim());

  return 0;
}



Measured memory_bytes: 2108
import java.util.*;

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

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();

        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 22996
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        n: u64,
    }
    println!("{}", n * (n + 1) / 2);
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import gcd

def main():
    N = int(input())
    minus_iwashi = {}
    iwashi = {}
    a0 = 0
    b0 = 0
    a0b0 = 0
    
    for _ in range(N):
        a,b = map(int,input().split())
        if a < 0 and b > 0:
            a = -a
            b = -b
        elif a < 0 and b < 0:
            a = -a
            b = -b
        if a == 0 and b == 0:
            a0b0 += 1
            continue
        if a == 0 and b != 0:
            a0 += 1
            continue
        if b == 0 and a != 0:
            b0 += 1
            continue
        #print(a,b)
        if b < 0:
            a,b = -b,a
            #print('mini{}{}'.format(a,b))
            x = gcd(a,b)
            a //= x
            b //= x
            if (a,b) in minus_iwashi:
                minus_iwashi[(a,b)] += 1
            else:
                minus_iwashi[(a,b)] = 1
        elif b > 0:
            x = gcd(a,b)
            a //= x
            b //= x
            if (a,b) in iwashi:
                iwashi[(a,b)] += 1
            else:
                iwashi[(a,b)] = 1
    
    power = [1]
    for _ in range(N):
        power.append(power[-1]*2%MOD)
    '''
    print(power)
    print(iwashi)
    print(minus_iwashi)
    print(a0,b0)
    '''
    
    if a0 > 0 and b0 > 0:
        ans = (power[a0] + power[b0] - 1)%MOD
    elif a0 > 0:
        ans = power[a0]
    elif b0 > 0:
        ans = power[b0]
    else:
        ans = 1

    for k,v in iwashi.items():
        if k in minus_iwashi:
            ans *= (power[v] + power[minus_iwashi[k]] - 1)%MOD
            ans %= MOD
        else:
            ans *= power[v]
            ans %= MOD
    
    for k,v in minus_iwashi.items():
        if k in iwashi:
            continue
        else:
            ans *= power[v]
            ans %= MOD
    ans += a0b0
    print((ans - 1)%MOD)
if __name__ == '__main__':
    main()



Measured memory_bytes: 130708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;
map<int,int> mp;
int n,x;
string s,st,u;
int main()
{
	cin>>n;
	bool flag=1;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		if(mp[x]) flag=0;
		mp[x]++;
	}
	if(flag) cout<<"YES";
	else cout<<"NO";
	return 0;
 } 

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

int Cnt[xx];

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

  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;

  for (int i = 0; i < n;i++){
    cin >> a[i];
    sum += a[i];
    Cnt[a[i]]++;
  }
  int q;
  cin >> q;
  while(q--){
    int b, c;
    cin >> b >> c;
    int ans = sum - (Cnt[b] * b) + (Cnt[b] * c);
    sum = ans;
    Cnt[c] += Cnt[b];
    Cnt[b] = 0;
    cout << ans << '\n';
  }
}

Measured memory_bytes: 4532
#include<stdio.h>
#include<stdlib.h>


void creatFrame(int h, int w){
	int i , j;
	/*h = 1*/
	for(i = 0 ; i < w ; i++){
		printf("#");
	}
	printf("\n");
	/*else*/
	for(i = 1 ; i < h-1 ; i ++){
		printf("#");
		for(j = 1 ; j < w-1 ; j++){
			printf(".")	;
		}
		printf("#\n");
	}
	/*h = h*/
	for(i = 0 ; i < w ; i++){
		printf("#");
	}
	printf("\n");
} 

int main(){
	int h,w;
	scanf("%d%d",&h, &w);
	while(h != 0 && w != 0){
		creatFrame(h,w);
		scanf("%d%d", &h, &w);
		printf("\n");
	}
	
	 
	
	
	return 0 ;
} 


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  for(int i=0;i<N-1;i++)
    if(S[i]==S[i+1]){
      cout<<i+1<<' '<<i+2<<endl;
      return 0;
    }
  for(int i=0;i<N-2;i++)
    if(S[i]==S[i+2]){
      cout<<i+1<<' '<<i+3<<endl;
      return 0;
    }
  cout<<"-1 -1\n";
}

Measured memory_bytes: 3764
import java.util.*;
import java.io.*;
public class Main {
	
	static int[] flame;
	static int n = 0;;
	static double ave = 0;
	
	public static void main(String[] args) throws Exception{
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			n = Integer.parseInt(br.readLine());
			flame = new int[n];
			flame = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		}
		
		int sum = 0;
		for (int a : flame) {
			sum += a;
		}
		ave = sum / (double)n;
		
		double[] aves = Arrays.stream(flame).mapToDouble(a -> Math.abs(ave - a)).toArray();
		
		int index = 0;
		for (int i=0; i<aves.length; i++) {
			if(aves[i] < aves[index]) index = i; 
		}
		
		System.out.println(index);
	}

}


Measured memory_bytes: 26708
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	int N;
	cin>>N;
	if(N%2==1){
		double d=double(N/2+1)/double(N);
		setp(d,10)
		cout<<endl;
	}
	else{
		double d=double(N/2)/double(N);
		setp(d,10)
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int x=0;
	vector<int> v;
	for (int i = 0; i < n ; ++i)
	{
		/* code */
		if(s[i] == 'I'){
			x++;
			v.push_back(x);
		}
		else if(s[i] == 'D'){
			x--;
			v.push_back(x);
		}
	}
	if(*max_element(v.begin(), v.end()) > 0){
		cout<<*max_element(v.begin(), v.end())<<endl;
	}
	else{
	cout<<0<<endl;	
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[31] = {0};
    int i;
    int n;
    for(i = 0; i < 28; i++){
        scanf("%d",&n);
        a[n] = 1;
    }
    for(i = 1; i <= 30; i++){
        if(a[i] == 0) printf("%d\n",i);
    }

    return 0;
}

Measured memory_bytes: 592
#include <cstdio>

int N;
int mod = 1000000007;
int cs[200008];
int not_first[200008];
long long recent[200008];
int main() {
	long long cur = 1;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		scanf("%d", &cs[i]);
		if(not_first[cs[i]]) {
			if(cs[i-1] != cs[i]) {
				cur += recent[cs[i]];
				cur %= mod;
			}
			recent[cs[i]] = cur;
		} else {
			recent[cs[i]] = cur;
			not_first[cs[i]] = 1;
		}
	}
	printf("%lld\n", cur);
	return 0;
}

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

using namespace std;

int main(){

  int h, w;
  cin >> h >> w;

  string m[h];
  string ans[h];

  for (int i = 0; i < h; i++){
    cin >> m[i];
  }

  string s;
  string mark;
  int flag;

  int new_h = 0;

  for (int i = 0; i < h; i++){
    s = m[i];
    flag = 0;
    for (int j = 0; j < w; j++){
      mark = s[j];
      if (mark == "#"){
        flag = 1;
      }
    }
    if (flag == 1){
      ans[new_h] = s;
      new_h += 1;
    }
  }


  for (int j = w - 1; 0 <= j; j--){
    flag = 1;
    for (int i = 0; i < new_h; i++){
      mark = ans[i][j];
      if (mark == "#"){
        flag = 0;
      }
    }
    if (flag == 1){
      for (int i = 0; i < new_h; i++){
        s = ans[i];
        s.erase(s.begin()+j);
        ans[i] = s;
      }
    }
  }

  for (int i = 0; i < new_h; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    char[] t = sc.next().toCharArray();
    ArrayList<Character> s_array = new ArrayList<>();
    ArrayList<Character> t_array = new ArrayList<>();
    for (int i = 0; i < s.length; i++) {
      s_array.add(s[i]);
    }
    for (int i = 0; i < t.length; i++) {
      t_array.add(t[i]);
    }
    Collections.sort(s_array);
    Collections.sort(t_array, Comparator.reverseOrder());
    for (int i = 0; i < s_array.size(); i++) {
      s[i] = s_array.get(i);
    }
    for (int i = 0; i < t_array.size(); i++) {
      t[i] = t_array.get(i);
    }
    String ss = new String(s);
    String tt = new String(t);
    if (ss.compareTo(tt) < 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9+10;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
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;}
/*----------------------------------------------*/


signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int k=0;
  rep(i,n) if(a[i]%2!=0||(a[i]%6==0||a[i]%10==0)){
    k++;
  }
  if(k==n) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i] = list(map(int, input().split()))
a.sort()
ans=0
for i in range(n):
    ans+=a[i][0]*min(m,a[i][1])
    m-=a[i][1]
    if m<=0:
        break
print(ans)

Measured memory_bytes: 28656
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;

int main() {
  long long h, w;
  scanf("%lld%lld", &h, &w);
  long long ans = LLONG_MAX;
  for (int magic = 0; magic < 2; magic++) {
    swap(h, w);
    for (int i = 1; i < h; i++) {
      long long p1 = i * w;
      {
        long long p2 = (h - i) * (w / 2);
        long long p3 = (h - i) * (w - w / 2);
        ans = min(ans, max(p1, max(p2, p3)) - min(p1, min(p2, p3)));
      }
      {
        long long hh = h - i;
        long long p2 = (hh / 2) * w;
        long long p3 = (hh - hh / 2) * w;
        ans = min(ans, max(p1, max(p2, p3)) - min(p1, min(p2, p3)));
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)cin >> a[i][j];
    }
    int n;
    cin >> n;
    vector<int>b(n);
    for(int i=0;i<n;i++)cin >> b[i];
    vector<vector<bool>>ccc(3,vector<bool>(3,false));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(a[j][k] == b[i]){
                    ccc[j][k] = true;
                }
            }
        }
    }
    bool chkk = false;
    for(int i=0;i<3;i++){
        bool chkkk = true;
        bool chkkkk = true;
        for(int j=0;j<3;j++){
            if(ccc[i][j]==false){
                chkkk = false;
            }

            if(ccc[j][i]==false){
                chkkkk = false;
            }
        }
        if(chkkk||chkkkk){
            chkk = true;
        }
    }
    if(ccc[0][0] && ccc[1][1] && ccc[2][2])chkk=true;
    if(ccc[0][2] && ccc[1][1] && ccc[2][0])chkk=true;

    if(chkk){
        cout << "Yes"<<endl;
        
    }else cout<<"No"<<endl;

}

Measured memory_bytes: 3616
#include<set> 
#include<map>
#include<cmath>    
#include<queue>    
#include<vector>    
#include<cstdio>    
#include<ctime>   
#include<cstring>    
#include<iostream>    
#include<algorithm>    
#define INF 0x3f3f3f3f
using namespace std;
long long read(){
    long long f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 50000
int main(){
	int n=read(),x,ans=0;
	for(int i=1;i<=n;i++){
		x=read();
		while(x%2==0) x/=2,ans++;
	}
	printf("%d\n",ans);
	return 0;
}  

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back 
#define MP make_pair
typedef long long ll;
const ll INF=1<<28;
const ll LINF=1ll<<61;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n;
char s[511][511];
int solve()
{
	int ret=2333;
	for(int i=1;i<=n;i++)
	{
		bool ok=0,ok2=0;
		for(int j=1;j<=n;j++)
		{
			if(s[j][i]=='#')
			{
				ok=1;
			}
		}
		for(int j=1;j<=n;j++)
		{
			if(s[i][j]=='#')
			{
				ok2=1;
			}
		}
		if(ok||ok2)
		{
			int cnt=0;
			if(!ok&&ok2)cnt++;
			for(int j=1;j<=n;j++)
			{
				cnt+=(s[i][j]=='.');
			}
			ret=min(ret,cnt);
		}
	}
//	cout<<"ret="<<ret<<endl;
	if(ret!=2333)
	{
		for(int i=1;i<=n;i++)
		{
			bool ok=1;
			for(int j=1;j<=n;j++)
			{
				ok&=(s[j][i]=='#');
			}
		if(ok)ret--;
		}
	}
	if(ret==2333)return -1;else return ret+n;
}
int dis[1024];
int q[1024],qn;
int trans(int msk,int x,int y)
{
	int t=(msk>>(x*3))&7,ret=0;
	for(int i=0;i<9;i++)
	{
		if(i%3==y)ret|=((t>>(i/3))&1)<<i;
		else ret|=((msk>>i)&1)<<i;
	}
	return ret;
}
void solve2(int x)
{
//	cout<<"x="<<x<<endl;
	memset(dis,-1,sizeof(dis));
	qn=0;
	q[qn++]=x;
	dis[x]=0;
	for(int i=0;i<qn;i++)
	{
		int x=q[i];
		for(int t1=0;t1<3;t1++)
		{
			for(int t2=0;t2<3;t2++)
			{
				int nxt=trans(x,t1,t2);
//				cout<<t1<<" "<<t2<<" "<<nxt<<endl;
				if(dis[nxt]==-1)
				{
					dis[nxt]=dis[x]+1;
					q[qn++]=nxt;
				}
			}
		}
//		exit(0);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
	}/*
	n=3;
	for(int t=1;t<512;t++)
	{
		for(int i=1;i<=3;i++)
		{
			for(int j=1;j<=3;j++)
			{
				if((t>>(i*3+j-4))&1)
				{
					s[i][j]='#';
				}
				else s[i][j]='.';
			}
		}*/
	int ans=solve();
	
	cout<<ans<<endl;
/*	int id=0;
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			if(s[i][j]=='#')id|=1<<((i-1)*3+j-1);
		}
	}
	solve2(id);
	cout<<dis[511]<<endl;
	solve2(t);
		int ans2=dis[511];
		if(ans!=ans2)
		{
			cout<<"WA:"<<t<<" "<<ans<<endl;
		}
	}*/
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int a,A,b,B,c;
    scanf("%d",&a);
    A=a%10;
    b=a/10;
    B=b%10;
    c=b/10;
    if(A==7||B==7||c==7)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;

}


Measured memory_bytes: 1616
n,k = map(int, input().split())

dic = {}
for _ in range(n):
    a,b = map(int, input().split())
    if a not in dic:
        dic[a] = 0
    dic[a] += b

idx = 0
for key in sorted(dic.keys()):
    idx += dic[key]
    if idx >= k:
        print(key)
        break


Measured memory_bytes: 10588
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int K;
	cin >> K;
	
	int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	
	cout << arr[K - 1] << endl;
}


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

int main() {
  string S;
  cin>>S;
  int ans=700;
  if(S[0]=='o')ans+=100;
  if(S[1]=='o')ans+=100;
  if(S[2]=='o')ans+=100;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    return right;
}

int main(int argc, const char *argv[])
{
    int a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

vector<ll> fact, invfact;
ll modpower(ll x, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n&1)res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll inv(ll n){
    return modpower(n,MOD-2,MOD);
}
void COMinit(ll k){ //空っぽの配列を二つ
   k++;
   fact.resize(k, 0);
   invfact.resize(k, 0);
   fact[0] = 1;
   repi(i, k, 1)
   {
       fact[i] = fact[i - 1] * i % MOD;
   }
   invfact[k - 1] = inv(fact[k - 1]);
   repd(i, k - 2, 0)
   {
       invfact[i] = invfact[i + 1] * (i + 1) % MOD;
   }
   return;
}
ll nCk(vector<ll> &fact,vector<ll> &invfact,ll n, ll k){ //この関数を使う前にCOMinit
   if (k < 0 || n < k)
       return 0LL;
   return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}
ll com(ll n, ll k)
{
    ll iv = 1;
    ll fa = 1;
    repi(i, k, 0)
    {
        fa *= (n - i);
        fa %= MOD;
    }
    repi(i, k + 1, 1)
    {
        iv *= inv(i);
        iv %= MOD;
    }
    return fa * iv % MOD;
}

//---------main function----------

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    repi(i,n,0){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    repi(i,k,0){
        ans += p[i];
    }
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)

#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld\n",a)

#define stll(a) stoll(a,nullptr,10)
#define all(a) a.begin(),a.end()
#define PII pair<ll,ll>
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define EL printf("\n")
#define ff first
#define ss second
#define rev(a) reverse(all(a))


#define mem(ar,val) memset(ar,val,sizeof(ar))
#define ssort(ar) sort(ar.begin(),ar.end())
#define csort(ar,comp) sort(ar.begin(),ar.end(),comp)

#define bug1(a) cerr<<"test "<<a<<endl;
#define bug2(a,b) cerr<<"test "<<a<<" "<<b<<endl;
#define bug3(a,b,c) cerr<<"test "<<a<<" "<<b<<" "<<c<<endl;
#define bug4(a,b,c,d) cerr<<"test "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define fout freopen("output.txt","w",stdout)
#define fin  freopen("input.txt","r",stdin)

/// unordered_map<int,int>mp;
/// mp.reserve(1024);
/// mp.max_load_factor(0.25);

/// pbds
/// *find_by_order(k) - return k th largest element.. 0 based
/// order_of_key(k) - number of items strictly smaller than k

///  priority_queue <ll, vector<ll>, greater<ll> >

/*
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
*/

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll ar[100005];
int main()
{
    ll n,x,mx;
    cin>>n>>x;
    for(int i=1;i<=n;i++)
        cin>>ar[i];

    ll ans =0;
    for(int i=1;i<n;i++)
    {
        mx = ar[i]+ar[i+1];
        if(mx<=x)continue;
        ans+=min(ar[i+1],mx-x);
        ar[i+1]-=min(ar[i+1],mx-x);;
        mx=ar[i]+ar[i+1];
        if(mx<=x)continue;
        ans+=min(ar[i],mx-x);
        ar[i]-=min(ar[i],mx-x);
    }
    if(ar[n]>x)
        ans+=ar[n]-x;
    cout<<ans<<endl;
}













Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main() {
  ll N, Y ; cin >> N >> Y;
  rep(i,N+1){
    rep(j,(N-i+1)){
      if( Y == i*10000 + j*5000 + (N-i-j)*1000 ){
        cout << i << " " << j << " " << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3564
# -*- coding: utf-8 -*-
import fractions
def lcm(x, y):
    return (x*y) // fractions.gcd(x, y)
def main():
    A,B,C,D = map(int,input().split())
    E = lcm(C,D)
    Cc = B // C
    Dd = B // D
    Ee = B // E
    flo = A-1
    Cf = flo // C
    Df = flo // D
    Ef = flo // E
    All = B-(Cc+Dd-Ee)
    Sub = flo-(Cf+Df-Ef)
    print(int(All - Sub))
if __name__ == '__main__':
    main()

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

int main(){
  int N,i,j;
  double sum=0,num=0;
  cin >> N;
  vector<pair<int,int>> t(N);
  for(i=1;i<N;++i)
    num += i;
  for(i=0;i<N;++i)
    cin >> t.at(i).first >> t.at(i).second;
  for(i=0;i<N;++i){
    for(j=i+1;j<N;++j){
      double dis = sqrt(pow(t.at(i).first-t.at(j).first,2)+pow(t.at(i).second-t.at(j).second,2));
      sum += dis;
    }
  }
  sum /= num;
  cout << setprecision(100) << sum * (N-1) << endl;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;
const double pi = acos(-1);

int n;
struct node{int x,y;}a[maxn]; int cnt;
inline bool cmp(const node x,const node y){return x.x<y.x;}
int sx,sy,ex,ey;

int t[maxn],tp;

int main()
{
	scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
	bool tx=false,ty=false;
	if(sx>ex) swap(sx,ex),tx=true;
	if(sy>ey) swap(sy,ey),ty=true;
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		if(sx<=x&&x<=ex&&sy<=y&&y<=ey) a[++cnt]=(node){x,y};
	}
	for(int i=1;i<=cnt;i++)
	{
		if(tx) a[i].x=sx+(ex-a[i].x);
		if(ty) a[i].y=sy+(ey-a[i].y);
	}sort(a+1,a+cnt+1,cmp);
	
	for(int i=1;i<=cnt;i++)
	{
		if(!tp) t[++tp]=a[i].y;
		else
		{
			int l=1,r=tp;
			while(l<=r)
			{
				int mid=l+r>>1;
				if(t[mid]<a[i].y) l=mid+1;
				else r=mid-1;
			}++r;
			t[r]=a[i].y; if(t[tp+1]) ++tp;
		}
	}
	double ans=100.0*(ex-sx+ey-sy)+5*pi*tp-20.0*tp;
	if(tp==ex-sx+1||tp==ey-sy+1) ans+=5*pi;
	printf("%.15lf\n",ans);
	
	return 0;
}


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

const int INF = 1001001001;

ll d[205][205];

int main() {
    int n, m, R;
    cin >> n >> m >> R;
    int r[R];
    for (int i = 0; i < R; i++) {
        cin >> r[i];
        r[i]--;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }
    for (int i = 0, a, b, c; i < m; i++) {
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = d[b][a] = c;
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    sort(r, r + R);
    ll ans = INF;
    do {
        ll cnt = 0;
        for (int i = 1; i < R; i++) {
            cnt += d[r[i - 1]][r[i]];
        }
        ans = min(ans, cnt);
    } while (next_permutation(r, r + R));
    cout << ans << endl;
}

Measured memory_bytes: 512