akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long ruijyo(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	ll sum = 1;
	ll i;
	REP(i, 0, k) {
		sum *= n;
		sum %= MOD;
	}
	return sum;
}

int main()
{
	ll  i, j, k, l, m,n, sum, flag, N,  M, K, H, W, B,C,D,x,y;
	sum = 0;
	flag = 0;
	cin >> N;
	vector<ll>p(N);
	vector<ll>a(N);
	vector<ll>b(N);
	REP(i, 0, N) {
		cin >> p[i];
		a[i] = b[N - i - 1] = 20001 * (i+1);
	}
	ll cc;
	cc = 0;
	REP(i, 0, N) {
		a[p[i]-1]+=cc;
		cc++;

	}
	REP(i, 0, N) {
		cout << a[i]<<" ";

	}
	cout << endl;
	REP(i, 0, N) {
		cout << b[i]<<" ";
	}



	return 0;
	

	
}













Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int a,p;
	cin >> a >> p;
	cout << (3 * a + p)/2 << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;//for StringBuilder
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        int r = s.Count(f => f == 'R');
        int ans = 0;
        for (int i = 0; i < r; i++)
        {
            if (s[i] == 'W') ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28680
#include <stdio.h>
#include <string.h>

int dx[3002][16010]={};
int dy[3002][16010]={};

int main(void){
    char s[8500];
    int x[4000]={},y[4000]={},count=0,flag=0,countx=0,county=0,X,Y;
    scanf("%s",s);
    scanf("%d%d",&X,&Y);
    for (int i=0; i<strlen(s); i++){
        if(s[i]=='F'){
            count++;
        } else {
            if (flag==0){
                x[countx]=count;
                count=0;
                countx++;
                flag=1;
            } else {
                y[county]=count;
                count=0;
                county++;
                flag=0;
            }
        }
    }
    if (flag==0){
        x[countx]=count;
    } else {
        y[county]=count;
    }
  
  
  
    dx[0][8000+x[0]]=1;

    for (int i=1; i<3001; i++){
        for (int j=0; j<16010; j++){
          if (dx[i-1][j]==1) {
	        dx[i][j+x[i]]=1;
            dx[i][j-x[i]]=1;
          }
        }
    }
    dy[0][8000+y[0]]=1;
    dy[0][8000-y[0]]=1;
    for (int i=1; i<3001; i++){
        for (int j=0; j<16010; j++){
          if (dy[i-1][j]==1) {
	          dy[i][j+y[i]]=1;
	          dy[i][j-y[i]]=1;
          }
        }
    }  
    if (dx[3000][8000+X]==1 && dy[3000][8000+Y]==1){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 374144
import java.util.*;

class Main{

    public static void main(String args[]){
        Scanner cin = new Scanner(System.in);
        int x = cin.nextInt();
        int y = cin.nextInt();
        int minxyz = Math.min(x,y);
        int seminxyz= Math.max(x,y);
        int z = cin.nextInt();

        if(z<seminxyz){
            seminxyz=z;
        }
        System.out.println(minxyz+seminxyz);


    }

}

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

int main() {
	int H, W; cin >> H >> W;
	int a[60][60];
	for(int i=0; i<=H+1; ++i) for(int j=0; j<=W+1; ++j) a[i][j]=0;
	string S;
	for(int i=0; i<H; ++i){
	    cin >> S;
	    for(int j=0; j<W; ++j){
	        if(S[j]=='#'){
	            for(int k=i; k<i+3; ++k){
	                ++a[k][j]; ++a[k][j+1]; ++a[k][j+2];
	            }
	            a[i+1][j+1]=-100;
	        }
	    }
	}
	for(int i=1; i<=H; ++i){
	    for(int j=1; j<=W; ++j){
	        if(a[i][j]<0) cout << '#';
	        else cout << a[i][j];
	    }
	    cout << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,k,l;
int mx(int x,int y)
{
	return x>y?x:y;
}
int mn(int x,int y)
{
	return x<y?x:y;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=mx(-1000000,m-n+1);i<mn(1000000,m+n);i++) printf("%d ",i);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace AtcoderExpress
{


    class Program2
    {
        static long mod = 1000000007;
        static void Main(string[] args)
        {
            //var HWK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var S = long.Parse(Console.ReadLine());

            var ans5 = (S / 500) * 1000;
            var res = S % 500;
            Console.WriteLine(ans5+5*(res/5));
        }
    }
}


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

int main(){
    int H, W;
    cin >> H >> W;
    
    // 0行0列はラベル
    // o なら白いマスのみの[行または列]
    vector<vector<char>> table(H+1, vector<char>(W + 1, '-'));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> table.at(i).at(j);
        }
    }
    
    // 行のチェック
    for (int i = 1; i <= H; i++) {
        int count = 0;
        for (int j = 1; j <= W; j++) {
            if (table.at(i).at(j) == '.') {
                count++;
            }
        }
        if (count == W) {
            table.at(i).at(0) = 'o';
        }
    }
    
    
    // 列のチェック
    int compressed_W = W;
    for (int i = 1; i <= W; i++) {
        int count = 0;
        for (int j = 1; j <= H; j++) {
            if (table.at(j).at(i) == '.') {
                count++;
            }
        }
        if (count == H) {
            table.at(0).at(i) = 'o';
            compressed_W--;
        }
    }
    
    table.at(0).at(0) = 'o';
    
    
    for (int i = 1; i <= H; i++) {
        
        if(table.at(i).at(0) == 'o') {
            continue;
        }
        int count = 0;
        for (int j = 1; j <= W; j++) {
            if (table.at(0).at(j) != 'o') {
                count++;
                cout  << table.at(i).at(j);
                if(count == compressed_W) {
                    cout << endl;
                }
            }
        }
        
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef array<int,6> Dice;
int H,W;
int I;
string s[50];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
Dice ds[8];
Dice rot(Dice d,int x){
	if(x==0) return Dice{d[4],d[0],d[2],d[3],d[5],d[1]};
	if(x==1) return Dice{d[3],d[1],d[0],d[5],d[4],d[2]};
	if(x==2) return Dice{d[1],d[5],d[2],d[3],d[0],d[4]};
	if(x==3) return Dice{d[2],d[1],d[5],d[0],d[4],d[3]};
	if(x==4) return Dice{d[0],d[3],d[1],d[4],d[2],d[5]};
	if(x==5) return Dice{d[1],d[2],d[0],d[5],d[3],d[4]};
}
void dfs(Dice d,int x,int y){
	ds[I][d[5]]=s[x][y];
	s[x][y]='.';
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<H&&0<=ny&&ny<W&&s[nx][ny]!='.') dfs(rot(d,i),nx,ny);
	}
}
int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(i,H) rep(j,W) if(s[i][j]!='.'){
		Dice d={0,1,2,3,4,5};
		dfs(d,i,j);
		I++;
	}
	map<char,int> mp;
	rep(i,8){
		int b=0;
		set<char> ss;
		rep(j,6){
			if(ds[i][j]=='#') b++;
			else ss.insert(ds[i][j]),mp[ds[i][j]]++;
		}
		if(b!=3||ss.size()!=3){
			puts("No");
			return 0;
		}
	}
	for(auto p:mp){
		if(p.sc!=4){
			puts("No");
			return 0;
		}
	}
	rep(i,8){
		rep(j,3) if(ds[i][j]=='#'&&ds[i][5-j]=='#'){
			puts("No");
			return 0;
		}
		while(ds[i][0]=='#') ds[i]=rot(ds[i],0);
		int cnt=0;
		while( (ds[i][1]=='#'||ds[i][2]=='#') && cnt<5) ds[i]=rot(ds[i],4),cnt++;
	}
	char c=(*mp.begin()).fs;
	vector<int> as;
	rep(i,8){
		int cnt=0;
		while( ds[i][0]!=c && cnt<5) ds[i]=rot(ds[i],5),cnt++;
		if(cnt<5) as.pb(i);
	}
	assert(as.size()==4);
	char x=ds[as[0]][1];
	vector<char> rs;
	{
		char xc=x;
		int cnt=0,pp=0;
		while(true){
			rep(i,4){
				if(ds[as[i]][1]==x){
					x=ds[as[i]][2];
					rs.pb(x);
					cnt++;
					break;
				}
			}
			if(x==xc) break;
			pp++;
			if(pp==6) break;
		}
		if(cnt!=4||pp==6){
			puts("No");
			return 0;
		}
	}
	for(auto p:mp){
		char cc=p.fs;
		bool ok=1;
		rep(i,4) if(cc==rs[i]) ok=0;
		if(cc==c) ok=0;
		if(ok){
			c=cc;
			break;
		}
	}
	vector<int> bs;
	rep(i,8){
		int cnt=0;
		while( ds[i][0]!=c && cnt<5) ds[i]=rot(ds[i],5),cnt++;
		if(cnt<5) bs.pb(i);
	}
	assert(bs.size()==4);
	x=ds[bs[0]][2];
	vector<char> ss;
	{
		char xc=x;
		int cnt=0;
		int pp=0;
		while(true){
			rep(i,4){
				if(ds[bs[i]][2]==x){
					x=ds[bs[i]][1];
					ss.pb(x);
					cnt++;
					break;
				}
			}
			if(x==xc) break;
			pp++;
			if(pp==6) break;
		}
		if(cnt!=4||pp==6){
			puts("No");
			return 0;
		}
	}
	rep(i,4){
		if(ss==rs){
			puts("Yes");
			return 0;
		}
		ss={ss[3],ss[0],ss[1],ss[2]};
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int d=max({a,b,c}),e=min({a,b,c});
	int f=a+b+c-d-e;
	if(d==f){
		cout<<e<<endl;
	}
	else{
		cout<<d<<endl;
	}
	return 0;
}


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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int main() {
  str(s);
  int i=s[0]-3*'A' + s[1] + s[2];
  if(i ==0 || i==3){prln("No")}
  else{prln("Yes")
          }}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	if(n/10==9||n%10==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	var N, M, K, V int
	fmt.Scan(&N)
	fmt.Scan(&M)
	l := make([]int, N)
	m := make(map[int]int, N)
	for i := 0; i < M; i++ {
	    fmt.Scan(&K)
		fmt.Scan(&V)
		m[K - 1] = m[K - 1] + 1
		if l[K-1] == 0 {
			l[K-1] = V
		} else if l[K-1] != V {
			fmt.Println(-1)
			return
		}
	}
	if N == 1 {
		fmt.Println(l[0])
	} else if l[0] == 0 && m[0] >= 1 {
		fmt.Println(-1)
		return
	} else if l[0] == 0 {
		l[0] = 1
		for _, v := range l {
			fmt.Print(v)
		}
	} else {
		for _, v := range l {
			fmt.Print(v)
		}
	}
}


Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n;
    cin>>n;
    vi vec(n+2);
    FOR(i,1,n+1){
        cin>>vec[i];
    }
    int sum=0;
    REP(i,n+1){
        sum+=abs(vec[i]-vec[i+1]);
    }
    FOR(i,1,n+1){
        cout<<sum-abs(vec[i]-vec[i-1])-abs(vec[i]-vec[i+1])+abs(vec[i-1]-vec[i+1])<<endl;;
    }
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

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

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main(){
    ll a,b;
    cin >> a >> b;
    cout << lcm(a,b);
}   

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        a = list(map(int, input().split()))

        a.sort(reverse=True)

        alice = sum(a[::2])
        bob = sum(a[1::2])

        print(alice - bob)


if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 38256
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int X = sc.nextInt();
		String ans;
		if (X >= 30) {
			ans = "Yes";
		} else {
			ans = "No";
		}

		System.out.println(ans);
		sc.close();
	}
};

Measured memory_bytes: 35776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<string> s;
    for(int i=0;i<N;i++){
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << (int) s.size() << "\n";
}

Measured memory_bytes: 19220
using System;

namespace ITP1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] i = Console.ReadLine().Split(' ');

            int W = int.Parse(i[0]);
            int H = int.Parse(i[1]);

            int x = int.Parse(i[2]);
            int y = int.Parse(i[3]);
            int r = int.Parse(i[4]);

            if (x < 0 || y < 0 || x + r > W || y + r > H)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}



Measured memory_bytes: 17984
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
void solve(vector<int> &v)
{
	sort(v.begin(),v.end());
//	reverse(v.begin(), v.end());

	int res = 0;
	for(size_t i = 0 ; i < v.size()-1 ; i+=2)
	{
		res += min(v[i],v[i+1]);
	}
	cout << res << endl;
}
int main(void)
{
	int n;
	cin >> n;
	vector<int> v;
	n*=2;
	while(n--)
	{
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
//	vector<int> v={1 ,3, 1, 2};
//	vector<int> v2 = {100 ,1 ,2 ,3 ,14 ,15 ,58 ,58, 58 ,29};
	solve(v);


	return 0;
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2019/07/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

void makez(vi &ret, string &s){
    ret.resize(s.size());
    ret[0] = s.size();
    int i = 1, j = 0;
    while (i < s.size()) {
        while (i+j < s.size() && s[j] == s[i+j]) ++j;
        ret[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < s.size() && k+ret[k] < j) ret[i+k] = ret[k], ++k;
        i += k; j -= k;
    }
}

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    vi nxt(n,-1), a, b;
    vi deg(n,0);
    string x = t;
    while(x.length()-m<m+n){
        x+=s;
    }
    makez(a, x);
    reverse(all(s));
    reverse(all(t));
    x=t+s;
    makez(b, x);
    rep(i,n){
        if(a[i+m]>=m){
            nxt[i]=(i+m)%n;
            deg[nxt[i]]=1;
        }
    }
    int ans=0;
    vi ok(n,0);
    rep(i,n){
        if(deg[i]==0){
            ok[i]=1;
            int now=i;
            int tmp=0;
            while(nxt[now]!=-1){
                now=nxt[now];
                ok[now]=1;
                tmp++;
            }
            ans=max(ans,tmp);
        }
    }
    rep(i,n) if(ok[i]==0){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20368
using System;
using System.Linq;

class A
{
	static void Main()
	{
		var z = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int h = z[0], w = z[1];
		var s = new int[h].Select(_ => Console.ReadLine()).ToArray();

		var u = new int[h, w];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				u[i, j] = 1 << 30;
		u[0, 0] = s[0][0] == '.' ? 0 : 1;

		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
			{
				if (i > 0) u[i, j] = Math.Min(u[i, j], u[i - 1, j] + (s[i - 1][j] > s[i][j] ? 1 : 0));
				if (j > 0) u[i, j] = Math.Min(u[i, j], u[i, j - 1] + (s[i][j - 1] > s[i][j] ? 1 : 0));
			}
		Console.WriteLine(u[h - 1, w - 1]);
	}
}


Measured memory_bytes: 28456
a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
e=0
j=-1
u=1/(4*b)
for i in range(b):
  if c[j] < sum(c)*u:
    e+=1
  j-=1
if e==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(const vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

bool solve(const string& n){
    return (n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]);
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string n;
    cin >> n;
    cout << (solve(n) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int b1,b2,b3, i, a = 0;
	scanf("%d %d %d", &b1,&b2,&b3);
	if (b1==1&&b2==1) {
		printf("Open\n");
	}
	else if (b3==1) {
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}
	return 0;
}


Measured memory_bytes: 2052
l, r = gets.chomp.split(' ').map{|v| v.to_i}

min = 2018
(l...r).each {|i|
    break if min == 0
    ((i+1)..r).each {|j|
        min = (i * j)%2019 if min > (i*j)%2019
        break if min == 0
    }
}

puts min

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		/*int Joken[] = new int[2];
		int joken = 0;
		while(joken < 2) {
			Joken[joken] = scan.nextInt();
		}*/
		String NL = scan.nextLine();
		String NandL[] = NL.split(" ");
		int N = Integer.parseInt(NandL[0]);
		int L = Integer.parseInt(NandL[1]);
		
		//System.out.println(N + " " + L);

		int line = 0;
		String out[] = new String[N];
		while(line < N) {
			String s = scan.nextLine();
			if(s.length() < L || s.length() > L)
				return;
			out[line] = s;
			line++;
		}

		Arrays.sort(out);

		int j = 0;
		while(j < out.length){
			System.out.print(out[j]);
			j++;
		}
		System.out.println("");

	}

}

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

#define ll long long
#define P 1000000007 

ll n,k,dp[33335];

vector<ll> fac;

ll fpow(ll a,ll b){
	ll c=1;
	for(;b;b>>=1,a=a*a%P)
		if(b&1) c=c*a%P;
	return c;
}

void work()
{
	ll ans=0;
	for(int x=0;x<fac.size();x++){
		dp[x]=fpow(k,(fac[x]+1)/2);
		for(int y=0;y<x;y++){
			if(fac[x]%fac[y]==0)
				dp[x]=(dp[x]-dp[y]+P)%P;
		}
		if(fac[x]%2) ans=(ans+dp[x]*fac[x]%P)%P; 
        else ans=(ans+dp[x]*fac[x]/2%P)%P;
	}
    cout<<ans<<endl;  
}

void init()
{
	fac.clear();
	for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            fac.push_back(i);
            if(i*i!=n) fac.push_back(n/i);
        }
    }
    sort(fac.begin(),fac.end());
}

int main()
{
	while(cin>>n>>k) init(),work();
    return 0;
}

Measured memory_bytes: 256
// Create by JJL
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

//const int N=300010,Mod=1e9+7;

int main(){
    IOS;
    /* START CODE */
    string s;
    cin>>s;
    if(s[s.size()-1]=='s'){
        s+="es";
    }
    else s+="s";
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
int main()
{
	char S[4];
	int i, j, ans=0;
	for(i = 0; i < 4; ++i){
	scanf("%c", &S[i]);
	}
	for(i = 0; i < 4; ++i) {
		for(j = 0; j < 4; ++j) {			
		if(S[i] == S[j]) {
				ans +=1;
			}
		}
	}
	if(ans == 8) {
		printf("Yes");
	}
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ll n;
  cin >> n;

  vector<ll> v;
  v.push_back(1);
  ll a=1;
  while(true){
    a*=6;
    if(a>100000)break;
    v.push_back(a);
  }
  a=1;
  while(true){
    a*=9;
    if(a>100000)break;
    v.push_back(a);
  }

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

  vector<ll> dp(n+1,1e9);
  dp[0] = 0;
  rep(i,v.size()){
    for (ll j = 0; j + v[i] <= n; ++j) {
      dp[j+v.at(i)] = min(dp[j]+1, dp[j+v[i]]);
    }
  }
  cout << dp[n] << endl;


  return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  REP(i,N){
	int b = 0;
	REP(i,10){
	  int x;
	  cin >> x;
	  b |= x<<i;
	}
	xs[i] = b;
  }
  VVI ps(N, VI(11));
  REP(i,N){
	REP(k,11)
	  cin >> ps[i][k];
  }

  int ans = -1e9;
  FOR(b,1,(1<<10)){
	int s = 0;
	VI cnt(N);
	REP(i,N){
	  REP(k,10)
		if((b&xs[i])>>k&1){
		  cnt[i]++;
		}
	}
	
	REP(i,N) s += ps[i][cnt[i]];
	maxi(ans, s);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
S = input()

P = [
    ['S', 'S'],['S', 'W'],
    ['W', 'S'],['W', 'W']
]

if S[0] == 'o':
    n1 = ['S','W','W','S']
else:
    n1 = ['W','S','S','W']

for idx, p in enumerate(P):
    for i in range(1, n-1):
        if S[i] == 'o':
            if p[i] == 'S':
                p.append(p[i-1])
            else:
                p.append('W' if p[i-1] == 'S' else 'S')
        else:
            if p[i] == 'S':
                p.append('W' if p[i-1] == 'S' else 'S')
            else:
                p.append(p[i-1])
    if n1[idx] == p[-1]:
        if  (S[-1] == 'o' and n1[idx] == 'S' and p[0] == p[-2]) or\
            (S[-1] == 'o' and n1[idx] == 'W' and p[0] != p[-2]) or\
            (S[-1] == 'x' and n1[idx] == 'W' and p[0] == p[-2]) or\
            (S[-1] == 'x' and n1[idx] == 'S' and p[0] != p[-2]):
                print(''.join(p))
                break
else:
    print(-1)


Measured memory_bytes: 12476
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())


n = I()
cnt = [0] * 10001
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            v = x*x + y*y + z*z + x*y + y*z + z*x
            if v <= n:
                cnt[v] += 1

for i in range(1, n + 1):
    print(cnt[i])


Measured memory_bytes: 9256
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;
const int MAX_N = 100005;

int a[102],b[102];

int main(){
  int N; cin >> N;
  rep(i,N) cin >> a[i];
  rep(i,N) cin >> b[i];
  REP(i,1,N) a[i] += a[i-1];
  rrep(i,N-2) b[i] += b[i+1];
  int ans = -INF;
  rep(i,N){
    ans = max(ans,a[i]+b[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC167_a
{
    class Program
    {
        static void Main(string[] args)
        {
            //文字列標準入力
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            if(S == T.Substring(0,S.Length)){
                Console.WriteLine("Yes");}else{
                Console.WriteLine("No");}
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 25880
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;

//Binary exponent
ll Bin_pow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        {
            res=res*a;
        }
        a=a*a;
        b>>=1;
    }
    return res;
}

//GCD
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}

//LCM
ll lcm(ll a,ll b)
{
	return (a*b)/gcd(a,b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll k;
	ll a,b;
	
	cin>>k>>a>>b;
	
	if(a%k==0 || b%k==0)
	{
	    cout<<"OK"<<endl;
	}
	else
	{
	    ll t=a/k;
	    if((t+1)*k<=b) cout<<"OK"<<endl;
	    else cout<<"NG"<<endl;
	}
}

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

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

    int N = S.size();
    for (int i = 0; i < N; i++) {
        for (int j = i; j <= N; j++) {
            string str = S.substr(0, i) + S.substr(j);
            if (str == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n, d = gets.split.map(&:to_i)
x = n.times.map { gets.split.map(&:to_i) }

def dis(x1, x2)
  sum = 0
  0.upto(x1.size - 1) do |i|
    sum += (x1[i] - x2[i]) ** 2
  end
  sum
end
count = 0
x.combination(2).each do |e|
  x1 = e[0]
  x2 = e[1]
  dist = dis(x1, x2)
  count += 1 if dist == Math.sqrt(dist).floor ** 2
end
puts count


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ans=0
T=0
for i in range(N):
    T+=A[i]
    if T > K:
        T-=A[i]
        break
    else:
        ans+=1
R=[]
R.append(ans)
n=ans
m=0
while(1):
    while(1):
        if m>=M: break
        T+=B[m]
        
        if T > K:
            T-=B[m]
            break
        else:
            ans+=1
            R.append(ans)
            m+=1
            
    n-=1
    if n<0: break
    T-=A[n]
    ans-=1
    

print(max(R))

Measured memory_bytes: 42192
#include <stdio.h>
#include <string.h>
#define N 1000
int main(){
  int i,j,flag;;
  char m[N],n[N];
  scanf("%s",m);
  scanf("%s",n);
  for(i=0;i<strlen(m);i++){
    flag=0;
    if(m[i]==n[0]) {
      for(j=0;j<strlen(n);j++){
	if(n[j]!=m[i+j]){
	  flag=1;
	  break;
	}
      }
      if(flag!=1) printf("%d\n",i);
    }
  }


  return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
pair<pair<string,int>,int> a[125];

int main(){
    cin>>n;
    REP(i,n)cin>>a[i].first.first>>a[i].first.second;
    REP(i,n)a[i].first.second *= -1;
    REP(i,n)a[i].second = i;
    sort(a,a+n);
    REP(i,n)cout<<a[i].second+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n,m = map(int,input().split())
count = 0
Li = []
Ri = []
for i in range(m):
  l,r = map(int,input().split())
  Li.append(l)
  Ri.append(r)
  
LM = max(Li)
RM = min(Ri)

print(np.maximum(RM - LM +1, 0))

Measured memory_bytes: 20020
<?php

$DEBUG_LEVEL = 0;

main();

function main() {
	$numSets = trim(fgets(STDIN));
	$count = 0;
	while ($count < $numSets) {
		$data = getPoints();
		$adjusted = adjustAlignment($data);
		$result = calc($adjusted);
		printf("%.3f %.3f %.3f\n", round($result[0], 3), round($result[1], 3), round($result[2], 3));
		$count++;
	}
}
function getPoints() {
	$input = trim(fgets(STDIN));

	list($x1, $y1, $x2, $y2, $x3, $y3) = explode(' ', $input);

	$a = new Point($x1, $y1);
	$b = new Point($x2, $y2);
	$c = new Point($x3, $y3);

	return array($a, $b, $c);
}

function adjustAlignment($points) {
	$minKey = 0;
	$min = $points[$minKey];

	foreach ($points as $k => $p) {
		if ($min->x > $p->x) {
			$min = $p;
			$minKey = $k;
		}
	}

	unset($points[$minKey]);

	$bottom = reset($points);
	$bottomKey = key($points);
	foreach ($points as $k => $p) {
		if ($bottom->y > $p->y) {
			$bottom = $p;
			$bottomKey = $k;
		}
	}
	unset($points[$bottomKey]);

	$top = reset($points);
	$return = array($min, $bottom, $top);

	debug($return);

	return $return;
}

function calc($points) {
	$min = $points[0];
	$a = new Point(0, 0);
	$b = $points[1]->shift(-1 * $min->x, -1 * $min->y);
	$c = $points[2]->shift(-1 * $min->x, -1 * $min->y);

	debug($a . $b . $c );
	$theta = abs($b->x) > 0.00001 ? atan($b->y / $b->x) : -3.1415926535 / 2;

	debug("theta = $theta");

	$b->rotate(-$theta);
	$c->rotate(-$theta);

	debug($a . $b . $c );

	$scale = abs(1/$b->x);
	$b->scale($scale);
	$c->scale($scale);

	$x0 = $c->x;
	$y0 = $c->y;

	$gx = 1/2;
	$gy = (- $x0 + $x0*$x0 + $y0*$y0)/(2*$y0);

	$g = new Point($gx, $gy);

	$r = sqrt($g->y * $g->y + 0.5 * 0.5);
	$r *= 1/$scale;

	$g->scale(1/$scale);
	$g->rotate($theta);
	$g->shift($min->x, $min->y);

	return array($g->x, $g->y, $r);
}

class Point {

	public $x;
	public $y;

	function __construct($x, $y) {
		$this->x = $x;
		$this->y = $y;
	}

	function scale($k) {
		$this->x *= $k;
		$this->y *= $k;
		return $this;
	}

	function rotate($theta) {
		$x = $this->x;
		$y = $this->y;
		$this->x = $x * cos($theta) - $y * sin($theta);
		$this->y = $x * sin($theta) + $y * cos($theta);
		return $this;
	}

	function shift($x, $y) {
		$this->x += $x;
		$this->y += $y;
		return $this;
	}

	function __toString() {
		return sprintf("x = %.3f, y = %.3f\n", round($this->x, 3), round($this->y, 3));
	}
}

function debug($out) {
	global $DEBUG_LEVEL;
	if (!isset($DEBUG_LEVEL) || $DEBUG_LEVEL <= 0) {
		return null;
	}
	if (is_string($out)) {
		echo $out . "\n";
	} else {
		var_dump($out);
	}
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int n, k, ans;

int main() {
int n, k;
cin >> n >> k;
vector<int> x(n);
rep (i, n) {
  cin >> x.at(i);
}
ans = 0;
rep (i, n) {
  ans += 2 * min(x.at(i), k - x.at(i));
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
def main():
    a,b,c = [int(v) for v in input().split()]
    k = int(input())

    while a>=b and k>0:
        b *= 2
        k -= 1

    while b>=c and k>0:
        c *= 2
        k -= 1
    
    print('Yes' if a<b and b<c else 'No')


main()

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, avg;
	cin >> n >> avg;
	vector <int> A(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> A[i];
	}
	const int N = 2500;
	vector<vector<ll>> dp(n + 1, vector<ll>(N + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		vector<vector<ll>> cur(n + 1, vector<ll>(N + 1));
		cur[0][0] = 1;
		for (int j = 1; j <= i; j++) {
			for (int k = 0; k <= N; k++) {
				cur[j][k] = dp[j][k] + (k - A[i] >= 0 ? dp[j - 1][k - A[i]] : 0);
			}
		}
		dp = cur;
	}
	//debug(dp);
	ll ans = 0;
	for (int j = 1; j <= n; j++) {
		ans += dp[j][j * avg];
	}
	cout << ans;	
}


Measured memory_bytes: 2316
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 120;

int DP[10005][105][3];
string k;
short n;
short D, sek;

int rek(short pos, short d, short ter) {
	//cout << pos << ' ' << d << ' ' << ter << '\n';
	if (pos == n) {
		if (ter == 2) return 0;
		if (d == 0) return 1;
		else return 0;
	}
	int &ret = DP[pos][d][ter];
	if (ret != -1) return ret;
	ret = 0;
	if (d == 0) ret += 1;
	if (pos != 0) {
		if (ter == 0 || ter == 2) ret = (ret + rek(pos + 1, d, ter)) % MOD;
		else if (ter == 1) {
			if (k[pos] - '0' == 0) ret = (ret + rek(pos + 1, d, 1)) % MOD;
			else ret = (ret + rek(pos + 1, d, 0)) % MOD;
		}
	}
	for(short i = 1; i <= 9; i++) {
		//cout << i << " EA\n";
		if (ter == 0 || ter == 2) {
			sek = (d - i) % D;
			if (sek >= 0) ret = (ret + rek(pos + 1, sek, ter)) % MOD; 
			else ret = (ret + rek(pos + 1, sek + D, ter)) % MOD;
		}
		else if (ter == 1){
			if (k[pos] - '0' < i) {
				sek = (d - i) % D;
				if (sek >= 0) ret = (ret + rek(pos + 1, sek, 2)) % MOD; 
				else ret = (ret + rek(pos + 1, sek + D, 2)) % MOD;
			}
			else if (k[pos] - '0' == i) {
				sek = (d - i) % D;
				if (sek >= 0) ret = (ret + rek(pos + 1, sek, 1)) % MOD; 
				else ret = (ret + rek(pos + 1, sek + D, 1)) % MOD;
			}
			else {
				sek = (d - i) % D;
				if (sek >= 0) ret = (ret + rek(pos + 1, sek, 0)) % MOD; 
				else ret = (ret + rek(pos + 1, sek + D, 0)) % MOD;
			}
		}
	}
	return ret;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> k;
	n = k.size();
	cin >> D;
	memset(DP, -1, sizeof DP);
	cout << rek(0, D, 1) << '\n';
}

Measured memory_bytes: 13568
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter
#from itertools import accumulate #list(accumulate(A))

S = input()

d = defaultdict(int)
for moji in S:
    d[moji] += 1
print(min(d['0'], d['1'])*2)

Measured memory_bytes: 3572
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL
 
typedef struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}*N;
 
N root = NIL;

void insert(int);
void inorder(N);
void preorder(N);
 
int main(){
  int m, i, n;
  char str[256];

  scanf("%d", &m);
 
  for(i = 0; i < m; i++){
    scanf("%s", str);
    if(strcmp(str, "insert") == 0){
      scanf("%d", &n);
      insert(n);
    }else if(strcmp(str, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}
  
void insert(int v){
  N y = NIL, x = root, z;

  z = malloc(sizeof(struct node));
  z->key = v;
  z->left = z -> right = NIL;
     
  while(x != NIL){
    y = x;
    if(z->key < x->key)   x = x->left;
    else                  x = x->right;
  }

  z->parent = y;

  if(y == NIL)               root = z;
  else if(z->key < y->key)   y->left = z;
  else                       y->right = z;
}
 
void inorder(N u){
  if(u == NIL)   return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(N u){
  if(u == NIL)   return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
#include <atcoder/segtree>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_A = 300005;

int op(int a, int b)
{
	return max(a,b);
}

int e()
{
	return 0;
}

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n)
	{
		cin >> a[i];
	}
	segtree<int,op,e> dp(MAX_A);
	rep(i,n)
	{
		int x = a[i];
		int l = x-k, r = x+k+1;
		l = max(l,0);
		r = min(r,MAX_A);
		int now = dp.prod(l,r)+1;
		dp.set(x, now);
	}
	int ans = dp.prod(0,MAX_A);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9596
#include <stdio.h>

int func(int a)
{
	if (a == 1)
	{
		return 1;
	}
	else {
		return func(a - 1)+a;
	}
}


int main()
{
	int num, ans;
	//階乗を求める
	scanf("%d", &num);
	ans = func(num);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [0] * N

for i in range(N):
	A[i] = int(input())

A.sort()

ans = 0

for t in range(2):
	coef = [0] * N
	for i in range(N):
		k = 0
		if i == 0 or i == N-1:
			k = 1 
		else:
			k = 2
		if (t + i) % 2 == 1:
			k = -k
		coef[i] = k
	coef.sort()

	val = 0
	for i in range(N):
		val += coef[i] * A[i]

	ans = max(ans, val)

print(ans)

Measured memory_bytes: 9892
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void){
    int n; cin >> n;
    vector<int> w(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        sum += w[i];
    }
    int ans = sum, tmp = 0;
    for (int i = 0; i < n; i++)
    {
        tmp += w[i];
        sum -= w[i];
        ans = min(ans, abs(tmp - sum));
    }
    cout << ans << endl;
    
}

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

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

    vector<vector<int>> G(N);    // 隣接リスト表現によるグラフ
    vector<pair<int, int>> E_in; // 辺の入力の順番を保持する

    for (int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        pair<int, int> p = make_pair(a, b);
        E_in.emplace_back(p);
    }

    queue<int> que;
    vector<int> used(N, 0);
    vector<int> parent(N, 0); // 親との間にある辺の数値
    int max_color = 0;
    map<pair<int, int>, int> E_num; // 辺への割り振った番号を保持する
    que.emplace(0); // 最初のものは何でも良いので0からにする
    used[0] = 1;
    while (que.size() != 0) {
        int state = que.front(); // 現在の状態

        que.pop();
        int color_num = 0;
        for (auto next : G[state]) {
            if (used[next] != 1) {
                color_num++;
                used[next] = 1;
                if (color_num == parent[state]) {
                    // 親との間にある辺と番号が被らないようにする
                    color_num++;
                }
                pair<int, int> p = make_pair(state, next);
                E_num[p] = color_num; //辺彩色
                parent[next] = color_num;
                que.push(next); //次の状態をqueueへ格納
            }
        }
        max_color = max(max_color, color_num);
    }

    cout << max_color << "\n";
    for (auto i : E_in) {
        cout << E_num[i] << "\n";
    }

    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
	int N,temp;
	std::cin >> N;
	std::vector<int> v;
	int mymax = -1;
	int ans = 0;
	for (size_t i = 0; i < N; i++) {
		std::cin >> temp;
		if (temp > pow(10,5)) {
			ans++;
			continue;
		}
		v.push_back(temp);
		mymax = max(mymax,temp);
	}
	std::vector<int> vv(mymax+1,0);
	for (size_t i = 0; i < v.size(); i++) {
		vv[v[i]] += 1;
	}
	for (size_t i = 0; i < vv.size(); i++) {
		if (vv[i] != i && vv[i] != 0) {
			if (vv[i] > i) {
				ans = ans + (vv[i] - i);
			}
			else {
				ans += vv[i];
			}
		}
	}

	std::cout << ans << '\n';


	return 0;
}


Measured memory_bytes: 1144