akhauriyash/Code-Regression huggingface dataset:
class SegmentTree:
  def __init__(self, size, default, op = min):
    self.size = 2**size.bit_length()
    self.dat = [default]*(self.size*2)
    self.op = op

  def update(self, i, x):
    i += self.size
    self.dat[i] = x
    while i > 0:
      i >>= 1
      self.dat[i] = self.op(self.dat[i*2], self.dat[i*2+1])

  def add(self, i, x):
    i += self.size
    self.dat[i] = self.op(self.dat[i], x)
    while i > 0:
      i >>= 1
      self.dat[i] = self.op(self.dat[i], x)

  def get(self, a, b = None):
    if b is None:
      b = a + 1
    l, r = a + self.size, b + self.size
    res = None
    while l < r:
      if l & 1:
        if res is None:
          res = self.dat[l]
        else:
          res = self.op(res, self.dat[l])
        l += 1

      if r & 1:
        r -= 1
        if res is None:
          res = self.dat[r]
        else:
          res = self.op(res, self.dat[r])
      l >>= 1
      r >>= 1
    return res

N,M = map(int,input().split())
LRC = [list(map(int,input().split())) for _ in range(M)]
LRC.sort(key=lambda x:(x[0],x[1]))
#print(LRC)

INF = 10**18
dp = SegmentTree(N,INF,min)
dp.update(0,0)
#print(dp.get(0,1))

for l,r,c in LRC:
  p = dp.get(l-1,r-1)+c
  # cf.https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/1109_nikkei2019-2-qual
  #for i in range(l,r):
  #  if p < dp.get(i):
  #    dp.update(i,p)
  if p < dp.get(r-1):
    dp.update(r-1,p)
print(dp.get(N-1) if dp.get(N-1) != INF else -1)


Measured memory_bytes: 86488
n = int(input())
ans = []*n
for _ in range(n):
    ans.append(input())
print("AC x {}".format(ans.count("AC")))
print("WA x {}".format(ans.count("WA")))
print("TLE x {}".format(ans.count("TLE")))
print("RE x {}".format(ans.count("RE")))

Measured memory_bytes: 16176
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S)-100,max(S)+100):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

Measured memory_bytes: 3060
#include<stdio.h>
int gcd(int a, int b)
{
    int r;
    while (b != 0){
    	r = a % b;
    	a = b;
    	b = r;
    }
    return a;
}

int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",1+x+y-gcd(x,y));
    return 0;
}

Measured memory_bytes: 2716
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d[]=new int[a];
	for(int i=0;i<a;i++) {
		d[i]=scan.nextInt();
	}
	for(int i=0;i<a;i++) {
		for(int j=0;;j++) {
			if((d[i]*j+1)<=b) {
				c++;
			}
			else {
				break;
			}
		}
	}
	System.out.println(c);
	scan.close();
}
}

Measured memory_bytes: 22868
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int cnt = 0;

    for(int i = 1; i <= n; i++) {
      String s = String.valueOf(i);
      int s_length = s.length();
      if(s_length%2!=0) {
        cnt +=1;
      }
    }
    
    System.out.println(cnt);
  }
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
#define sd(a) scanf("%lld",&a)
#define int long long
using namespace std;
const int maxn=2e5+10;
struct node{
    int num,pos;
    bool operator<(const node a)const{
        return num==a.num?pos>a.pos:num<a.num;
    }
};
priority_queue<node>q;
int a[maxn],b[maxn];
main(){
    int n;
    sd(n);
    for(int i=1;i<=n;++i){
        sd(a[i]);
    }
    node tmp;
    for(int i=1;i<=n;++i){
        sd(b[i]);
        tmp.num=b[i];
        tmp.pos=i;
        q.push(tmp);
    }
    int ans=0;
    while(!q.empty()){
        node now=q.top();
        q.pop();
        int pos=now.pos;
        if(b[pos]==a[pos])continue;
        int d=b[pos]-a[pos];
        int cnt=b[pos-1?pos-1:n]+b[pos+1==n+1?1:pos+1];
        if(d<cnt||b[pos]<a[pos]){puts("-1");return 0;}
        ans+=d/cnt;
        b[pos]-=d/cnt*cnt;
        tmp.num=b[pos];
        tmp.pos=pos;
        q.push(tmp);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 9072
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int n, m;
long long res[50000];
long long a[50000], b[50000], c[50000];
vector<int> g[50000], vg[50000];
int t[50000], f[50000];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) {cin >> a[i] >> b[i] >> c[i]; g[a[i]].push_back(b[i]); vg[b[i]].push_back(a[i]);}
    vector<int> v = {1}; t[1] = 1;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < g[v[i]].size(); j++)
        {
            if (t[g[v[i]][j]] == 0) {t[g[v[i]][j]] = 1; v.push_back(g[v[i]][j]);}
        }
    }
    v = {n}; f[n] = 1;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < vg[v[i]].size(); j++)
        {
            if (f[vg[v[i]][j]] == 0) {f[vg[v[i]][j]] = 1; v.push_back(vg[v[i]][j]);}
        }
    }
    fill(res, res + n + 1, -1000000000000000000);
    res[1] = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (res[b[j]] < res[a[j]] + c[j]) res[b[j]] = res[a[j]] + c[j];
    for (int j = 0; j < m; j++)
        if (t[a[j]] && res[b[j]] < res[a[j]] + c[j] && f[b[j]]) {cout << "inf"; return 0;}
    cout << res[n];
}


Measured memory_bytes: 3968
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = 2002;

int wh[N];
int bl[N];
int dp[N][N];
int W[N][N];
int B[N][N];

int mark[N * 2 + 512];

int ib[N];
int iw[N];

int main(){
    fastIO;
    for(int i = 0 ; i < N ; i ++ )
        for(int j = 0 ; j < N ;j ++ )
            dp[i][j] = (int)1e9;
    dp[0][0] = 0;
    int n;
    cin >> n;
    pair<char, int> v[2 * n];
    for(int i = 0 ; i < 2 * n; i ++ ){
        cin >> v[i].fi >> v[i].se;
        if(v[i].fi == 'W'){
            wh[v[i].se] = i;
            for(int j = i - 1; j >= 0 ; j -- ){
                if(v[j].fi == 'W' && v[j].se > v[i].se)
                    iw[v[i].se] ++ ;
            }
        }
        else{
            bl[v[i].se] = i;
            for(int j = i - 1; j >= 0 ; j -- )
                if(v[j].fi == 'B' && v[j].se > v[i].se)
                    ib[v[i].se] ++ ;
        }
    }
    for(int i = 0 ; i <= n; i ++ ){
        for(int j = 0; j < n * 2; j ++ ){
            mark[j] = 0;
            if(v[j].se > i && v[j].fi == 'B')
                mark[j] = 1;
            if(j) 
                mark[j] += mark[j - 1];
        }
        for(int j = 1; j <= n; j ++ ){
            W[j][i] = mark[wh[j]] + iw[j];
        }
    }
    for(int i = 0 ; i <= n; i ++ ){
        for(int j = 0 ; j < n * 2; j ++ ){
            mark[j] = 0;
            if(v[j].se > i && v[j].fi == 'W')
                mark[j] = 1;
            if(j)
                mark[j] += mark[j - 1];
        }
        for(int j = 1; j <= n ; j ++ )
            B[i][j] = mark[bl[j]] + ib[j];
    }
    int cost;
    for(int i = 0; i <= n; i ++ ){
        for(int j = 0; j <= n ; j ++ ){
            if(i > 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j] + W[i][j]);
            }
            if(j > 0){
                dp[i][j] = min(dp[i][j], dp[i][j-1] + B[i][j]);
            }
        }
    }
    cout << dp[n][n];
    return 0;
}
    

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

int n,m;
string N[101];
int M[101];
string B[1001];

int main(){
	while(cin >> n >> m, n != 0 && m != 0){
		for(int i = 0; i < n; i++){
			cin >> N[i] >> M[i];
		}
		for(int i = 0; i < m; i++){
			cin >> B[i];
		}
		
		int score = 0;
		for(int i = 0; i < m; i++){  // B
			for(int j = 0; j < n; j++){  // N,M
				bool f = true;
				for(int k = 0; k < 8; k++){
					if(N[j][k] != B[i][k] && N[j][k] != '*'){
						f = false;
						break;
					}
				}
				if(f){
					score += M[j];
					break;
				}
			}
		}
		cout << score << endl;

	}

	return 0;
}



Measured memory_bytes: 3052
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int n,x,d;
vvi G;
vi m;
vvi in;
vi dfs(int a,int p){
	int co=1,sum=m[a];
	rep(i,G[a].size()){
		int to=G[a][i];
		if(to==p)continue;
		vi t=dfs(to,a);
		co+=t[0];
		sum+=t[1];
	}
	in[a]={co,sum,d};
	return {co,sum};
}
signed main(){
	cin>>n>>x>>d;
	G=vvi(n);
	m=vi(n);
	in=vvi(n);
	cin>>m[0];
	rep(i,n-1){
		int a;
		cin>>m[i+1]>>a;
		G[a-1].pb(i+1);
	}
	dfs(0,-1);
	in[0][2]=inf;
	sort(all(in),[](vi a,vi b){
		return a[1]*b[0]<b[1]*a[0];
	});
	int ma=50*50*50ll;
	vi dp(ma+1,inf);
	dp[0]=0;
	rep(i,n)rep(j,min(50ll,in[i][2]))for(int k=ma;k>=0;k--)if(dp[k]+inf)
		cmin(dp[k+in[i][0]],dp[k]+in[i][1]);
	int out=0;
	rep(i,ma+1){
		int sum=i;
		int nokori=x-dp[i];
		if(nokori<0)continue;
		rep(j,n){
			int co=min(nokori/in[j][1],max(0ll,in[j][2]-50));
			sum+=co*in[j][0];
			nokori-=co*in[j][1];
		}
		cmax(out,sum);
	}
	cout<<out<<endl;
}















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

int main(){
int N,M,X;
  cin>>N>>M>>X;
  
  vector<int>A(M);
  for(int i=1; i<=M; i++){
  cin>>A[i];
  }
  int left=0;
  int right=0;

  for(int i=1; i<=M; i++){
  if(A[i]<X){left++;}
    else{right++;}
  }
  cout<<min(left, right)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////

int main(){
    string s;
    int ans = 0;
    cin >> s;
    rep(i,1,s.size()){
        if(s[i-1] != s[i])ans++;
    }
    
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int N,L;
  cin>>N>>L;
  vector<string> s(N);
  rep(i,N){
    cin>>s[i];
  }
  sort(s.begin(),s.end());
  rep(j,N){
    cout<<s[j];
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    vll vec(3);
    REP(i, 3) {
        cin >> vec.at(i);
    }
    sort(ALL(vec));
    cout << 10 * vec.at(2) + vec.at(1) + vec.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int n,K,sl,fh,cnt,ans;
char s[210];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	scanf("%s",s+1);K=rd();n=strlen(s+1);int flg=1;
	for(int i=1;i<=n;++i) flg&=s[i]==s[1];
	if(flg) {printf("%lld\n",1ll*n*K/2); return 0;}
	for(int i=1;i<=n;++i) s[i+n]=s[i];
	for(int i=2;i<=n<<1;++i)
		if(s[i]==s[i-1])
			s[i]='.';
	for(int i=1;i<=n;++i) cnt+=s[i]=='.';
	for(int i=1;i<=n;++i) ans+=s[i+n]=='.';
	printf("%lld\n",cnt+1ll*(K-1)*ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int n,z=0,ans=0;
    cin >> n;
    int data[n];
    for(int i=0;i<n;i++){
        cin >> data[i];
    }
    
    for(int i=0;i<n;i++){
         ans++;
        z=data[z];
        if(z==2){
            cout << ans<< endl;
            return 0;
        }
         z--;
    }
            cout << "-1" << endl;
            return 0;
    
}


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

class Dice{
public: 
    int n[6];
    const int order[6][4] = {
                             {0, 1, 5, 4},
                             {0, 4, 5, 1},
                             {0, 3, 5, 2},
                             {0, 2, 5, 3},
                             {1, 2, 4, 3},
                             {1, 3, 4, 2}
                            };
    
    void roll(int dir);
};

void Dice::roll(int dir){
    int temp;
    
    temp = n[order[dir][0]];
    for(int i = 0; i < 4; i++){
        if(i == 3) n[order[dir][i]] = temp;
        else n[order[dir][i]] = n[order[dir][i + 1]];
    }
}

int main(){
    Dice dice1, dice2;
    int check;
    
    for(int i = 0; i < 6; i++) cin >> dice1.n[i];
    for(int i = 0; i < 6; i++) cin >> dice2.n[i];
    
    for(int i = 0; i < 4; i++){
        dice2.roll(0);
        for(int j = 0; j < 4; j++){
            dice2.roll(2);
            
            for(int k = 0; k < 4; k++){
                check = 0;
                dice2.roll(4);
                
                for(int l = 0; l < 6; l++){
                    if(dice1.n[l] == dice2.n[l]) check++;
                    else break;
                }
                if(check == 6){
                    if(check == 6) cout << "Yes" << endl;
                    return 0;
                }
            }
            if(check == 6) break;
        }
        if(check == 6) break;
    }
    cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 3104
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>>n;
  ll a = 0;
  rep(i,n+1){
    if(i%3==0 || i%5 == 0)continue;
    a+=i;
  }
  print(a);
  return 0;
}


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

int main() {
  int r, g, b, sum;
  cin >> r >> g >> b;
  sum = r * 100 + g * 10 + b;

  if( sum % 4 == 0 )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
package main

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

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

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

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := make(map[int]int, 0)
	for i := 0; i < m; i++ {
		aa[getNextInt(scanner)] = 1
	}

	dp := make([]int, n+1)
	dp[0] = 1
	for i := 0; i < n; i++ {
		for ii := 1; ii <= 2 && i+ii <= n; ii++ {
			_, ok := aa[i+ii]
			if ok {
				continue
			}
			dp[i+ii] += dp[i]
			dp[i+ii] %= 1000000007
		}
	}
	fmt.Fprintln(writer, dp[n])

	writer.Flush()
}


Measured memory_bytes: 6912
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

typedef std::stack<int> IntStack;
typedef std::queue<int> IntQueue;
typedef std::vector<int> IntVector;
typedef std::list<int> IntList;

using namespace std;
  
int main(){
  long long N, K;
  cin >> N >> K;
  
  long long ans;
    
  long long a = N%K;
  long long b = abs(a-K);
  if(a <= b){
    ans = a;
  }else{
    ans = b;
  }
  
  cout << ans << endl;
}

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

int main(){
    int D;
    std::cin >> D;
    std::vector< int > C(26);
    std::vector< int > cur_bad(26);
    for(int i=0; i<26; i++){
        std::cin >> C[i];
        cur_bad[i] = C[i];
    }
    std::vector< std::vector< int > > S(D, std::vector< int >(26));
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            std::cin >> S[i][j];
        }
    }
    std::vector< int > T(D);
    
    for(int i=0; i<D; i++){
        int max = 0;
        int max_index = 0;
        for(int j=0; j<26; j++){
            int score = S[i][j] + cur_bad[j];
            if(max < score){
                max = score;
                max_index = j;
            }
        }
        T[i] = max_index + 1;
        cur_bad[max_index] = 0;
        for(int j=0; j<26; j++){
            cur_bad[j] += C[j];
        }
    }
    
    long long score = 0;
    std::vector< int > lasta(26, 0);
    for(int i=0; i<D; i++){
        score += S[i][T[i] - 1];
        lasta[T[i] - 1] = i + 1;
        for(int j=0; j<26; j++){
            score -= (i + 1 - lasta[j]) * C[j];
        }
    }
        
    for(int q=0; q<10000; q++){
        int qD = std::rand() % D;
        int Q = std::rand() % 26 + 1;
        //std::cout << qD << " " << Q << std::endl;
        int pre = T[qD];
        
        T[qD] = Q;
        long long ans = 0;
        std::vector< int > last(26, 0);
        for(int i=0; i<D; i++){
            ans += S[i][T[i] - 1];
            last[T[i] - 1] = i + 1;
            for(int j=0; j<26; j++){
                ans -= (i + 1 - last[j]) * C[j];
            }
        }
        if(score < ans){
            score = ans;
        }else{
            T[qD] = pre;
        }
    }
    
    
    
    
    for(int i=0; i<D; i++){
        std::cout << T[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3668
# https://tjkendev.github.io/procon-library/python/max_flow/dinic.html
import sys
def input():
	return sys.stdin.readline()[:-1]
from math import gcd
from collections import deque
class Dinic:
	def __init__(self, n):
		self.n = n
		self.g = [[] for i in range(n)]

	def add_edge(self, fr, to, cap):
		#[to, cap, rev]
		forward = [to, cap, None]
		forward[2] = backward = [fr, 0, forward]
		self.g[fr].append(forward)
		self.g[to].append(backward)

	def add_bidirectional_edge(self, v1, v2, cap1, cap2):
		edge1 = [v2, cap1, None]
		edge1[2] = edge2 = [v1, cap2, edge1]
		self.g[v1].append(edge1)
		self.g[v2].append(edge2)

	def bfs(self, s, t):
		self.level = level = [None]*self.n
		deq = deque([s])
		level[s] = 0
		g = self.g
		while deq:
			v = deq.popleft()
			lv = level[v] + 1
			for w, cap, _ in g[v]:
				if cap and level[w] is None:
					level[w] = lv
					deq.append(w)
		return level[t] is not None

	def dfs(self, v, t, f):
		if v == t:
			return f
		level = self.level
		for e in self.it[v]:
			w, cap, rev = e
			if cap and level[v] < level[w]:
				d = self.dfs(w, t, min(f, cap))
				if d:
					e[1] -= d
					rev[1] += d
					return d
		return 0

	def flow(self, s, t):
		flow = 0
		INF = 10**30
		g = self.g
		while self.bfs(s, t):
			#*self.it, = map(iter, self.g)
			self.it = list(map(iter, self.g))
			f = INF
			while f:
				f = self.dfs(s, t, INF)
				flow += f
		return flow

while True:
	n, m = map(int, input().split())
	if n == 0:
		break
	b = []
	r = []
	while len(b) < n:
		b += list(map(int, input().split()))
	while len(r) < m:
		r += list(map(int, input().split()))
	dinic = Dinic(n+m+2)
	for i, x in enumerate(b):
		dinic.add_edge(n+m, i, 1)
		for j, y in enumerate(r):
			if gcd(x, y) > 1:
				dinic.add_edge(i, n+j, 1)
	for j in range(m):
		dinic.add_edge(n+j, n+m+1, 1)
	print(dinic.flow(n+m, n+m+1))



Measured memory_bytes: 39752
import java.util.Scanner;

public class Main{

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int R = sc.nextInt();

    if (R < 1200){
      System.out.println("ABC");
    }else if (R < 2800){
      System.out.println("ARC");
    }else{
      System.out.println("AGC");
    }

  }

}


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

using namespace std;

const int MAX_N = 1000010;
const long long P = 1000000007;
int N;
long long pow8[MAX_N], pow9[MAX_N], _pow10[MAX_N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N;
	
	pow8[0] = pow9[0] = _pow10[0] = 1LL;
	for (int i = 1; i <= N; i++) {
		pow8[i] = (pow8[i - 1] * 8LL) % P;
		pow9[i] = (pow9[i - 1] * 9LL) % P;
		_pow10[i] = (_pow10[i - 1] * 10LL) % P;
	}
	
	long long ans = _pow10[N];
	ans = (ans + pow8[N]) % P;
	ans = (ans - pow9[N] + P) % P;
	ans = (ans - pow9[N] + P) % P;
	cout << ans << "\n"; 
	
	return 0;
}


Measured memory_bytes: 27068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool maximize
){
    while(lo < hi){
        if(maximize){
            const ll mid = (lo + hi + 1) / 2;
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            const ll mid = (lo + hi) / 2;
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}

void solve(long long N, long long M, long long V, long long P, std::vector<long long> A){
    sort(A.begin(), A.end(), greater<ll>());
    ll ans = binary_search(
        0, A.size() - 1,
        [&](ll x){
            if(x < P){
                return true;
            }
            if(A.at(x) + M < A.at(P - 1)){
                return false;
            }
            ll tmp = (N - x - 1 + P) * M;
            for(ll i = P - 1; i < x; ++i){
                tmp += (A.at(x) + M - A.at(i));
            }
            return tmp >= M * V;
        },
        true
    ) + 1;
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long V;
    scanf("%lld",&V);
    long long P;
    scanf("%lld",&P);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, V, P, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	string s, t;

	cin >> s >> t;

	if (t.size() == s.size() + 1 && t.substr(0, s.size()) == s) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 3592
N = int(input())
sum = 0

#文字になるときpass
for i in range(N+1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    elif i % 15 == 0 :
        pass
    else:
         sum +=  i

print(sum)


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

using namespace std;
using ll = long long;

#define y1 cgvxghg
#define y2 bjotzkb

vector<ll> x;
vector<ll> y;
int N, K;

bool ran(ll a, ll c, ll b)
{
  return a <= c && c <= b;
}

ll cnt(ll xmi, ll ymi, ll xma, ll yma)
{
  int c = 0;
  for (int i = 0; i < N; i++) {
    if (ran(xmi, x[i], xma) && ran(ymi, y[i], yma)) {
      c++;
    }
  }
  if (c >= K) {
    return (xma - xmi) * (yma - ymi);
  }
  return 8e18;
}

int main()
{
  cin >> N >> K;
  x.resize(N);
  y.resize(N);
  ll res = 8e18;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  for (int x1 = 0; x1 < N; x1++) {
    for (int x2 = 0; x2 < N; x2++) {
      if (x[x1] > x[x2]) continue;
      for (int y1 = 0; y1 < N; y1++) {
        for (int y2 = 0; y2 < N; y2++) {
          if (y[y1] > y[y2]) continue;
          res = min(res, cnt(x[x1], y[y1], x[x2], y[y2]));
        }
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		solve();
	}

	private static void solve(){
		Scanner sc=new Scanner(System.in);

		while(true){
			int n=sc.nextInt();
			int A=0,B=0;
			if(n==0)break;
			for(int i=0;i<n;i++){
				int a=sc.nextInt();
				int b=sc.nextInt();
				if(a>b)
					A+=a+b;
				else if(a<b)
					B+=a+b;
				else{
					A+=a;
					B+=b;
				}
			}
			System.out.println(A+" "+B);
		}
	}
}

Measured memory_bytes: 51744
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    int sum4 = 0;
    int sum2 = 0;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        if (a % 4 == 0)
            sum4++;
        else if (a % 2 == 0)
            sum2++;
    }
    cout << (sum4 + sum2/2 + 1> n / 2?"Yes":"No");
    return 0;
}

Measured memory_bytes: 384
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

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

        long x = sc.nextInt();
        long ans = 2;
        for (int i = 0; i < x; i++) {
            ans = (ans+1)*2;
        }
        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int l, r;
    cin >> l >> r;
    ll ans = 2019;
    if (l + 2019 <= r)
        return cout << 0, 0;
    for (int i = l; i <= r; i++)
    {
        for (int j = i + 1; j <= r; j++)
            ans = min(ans, (1LL * i * j) % 2019);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
h = input().split()
e = [1]*n
ans = 0

for i in range(n):
  h[i] = int(h[i])
#
#print(h)

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    e[b-1] = 0
  elif h[a-1] < h[b-1]:
    e[a-1] = 0
  else:
    e[a-1] = 0
    e[b-1] = 0
#
#print(e)

for i in e:
  if i==1:
    ans += 1
print(ans)


Measured memory_bytes: 87444
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main(){
    string n;cin >> n;
    string k="24579";
    for(auto &i:k){
        if(n[n.size()-1]==i){cout << "hon" << endl;return 0;}
    }
    string c="0168";
    for(auto &i:c){
        if(n[n.size()-1]==i){cout << "pon" << endl;return 0;}
    }
    cout << "bon" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int f[100010],n,a[100010],k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		f[i]=(1<<30);
		for(int j=1;i-j>=1 && j<=k;j++)
			f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
	}
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
#define mod 1000000007
using namespace std;
typedef long long LL;
LL je[200010];
LL x,y;
void Build()
{
	je[0]=je[1]=1;
	for(int i=1;i<=200005;i++)
		je[i]=(je[i-1]*i)%mod;
	return;
}
LL Gcd(LL a, LL b, LL &x, LL &y)
{
    if(b==0)
	{
        x=1;
        y=0;
        return a;
    }
    LL gcd=Gcd(b,a%b,x,y);
    LL tmp=x;
    x=y;
    y=tmp-(a/b)*y;
    return gcd;
}
LL C(LL m,LL n)
{
    Gcd(je[m]*je[n-m]%mod,mod,x,y);
    return je[n]*(x+mod)%mod;
}
int main()
{
    LL H,W,A,B;
	Build();
    LL ans=0;
	scanf("%lld%lld%lld%lld",&H,&W,&A,&B);
    for(LL i=B+1;i<=W;i++)
    {
        LL tmp=(C(H-A-1,i-1+H-A-1)*C(W-i,W-i+A-1))%mod;
        ans=(ans+tmp)%mod;
    }
	/*
	
	(a,......)
	*/
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1664
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[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 , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{s:chars};
    let mut map = HashMap::new();

    for i in 0..s.len() {
        let mut count = map.entry(s[i]).or_insert(0);
        *count += 1;
    }
    let mut ch = 'a';
    for _i in 0..26 {
        let f = match map.get(&ch) {
            Some(_v) => true,
            _ => false,
        };
        if !f {
            println!("{}", ch);
            return();
        }
        ch = (ch as u8 + 1) as char;
    }
    println!("None");
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <tgmath.h>
#include <queue>
#include <cstring>
#include <set>
typedef long long ll;
using namespace std;

int N;
int d[100];

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    set<int> setD;
    for(int i=0; i<N;i++){
        setD.insert(d[i]);
    }
    cout << setD.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


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

const int mod = 1000000007;

vector<vector<int> > edge(500002, vector<int>(0));
vector<int> p(500002, 0);

vector<int> ans(500002);



int main(){
  int n, m;
  cin >> n >> m;
  int p[m], y[m];

  vector<vector<int> > id(100001);
  rep(i, m){
    cin >> p[i] >> y[i];
    id[p[i]].push_back(y[i]);
  }

  rep(i, n + 1) {
    sort(id[i].begin(), id[i].end());
  }

  rep(i, m){
    int num;
    num = (int)(lower_bound(id[p[i]].begin(), id[p[i]].end(), y[i]) - id[p[i]].begin() + 1);
    printf("%06d%06d\n",p[i], num);
  }

  


  

}


Measured memory_bytes: 23424
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>
#include <typeinfo>
#include <memory>


using namespace std;

typedef long long ll;
typedef tuple<int, int, int> T;

#define fs first
#define sc second


int main(){
    vector<int> edge[101000];

    ll check[101000][3];
    int N, M, s, t;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edge[u].emplace_back(v);
    }
    cin >> s >> t;
    s--; t--;
    for(int i = 0; i < 101000; i++){
        for(int j = 0; j < 3; j++){
            check[i][j] = INT32_MAX;
        }
    }

    priority_queue<T, vector<T>, greater<T> > que;
    check[s][0] = 0;
    que.push(T(0, 0, s));


    while(!que.empty()){
        T x = que.top();
        que.pop();

        int d = get<0>(x);
        int r = get<1>(x);
        int u = get<2>(x);

        if(check[u][r] < d){
            continue;
        }
        for(auto v: edge[u]){
            if(check[v][(r+1)%3] > check[u][r] + 1){
                check[v][(r+1) % 3] = check[u][r] + 1;
                que.push(T(check[v][(r+1) % 3], (r+1)%3, v));
            }
        }
    }

    if(check[t][0] == INT32_MAX){
        cout << -1 << endl;
    }
    else {
        cout << check[t][0] / 3 << endl;
    }


    return 0;
}


Measured memory_bytes: 8128
#include <bits/stdc++.h>
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp  make_pair
#define pb  push_back
#define  sz(x)   (int)x.size()
#define  all(x)  x.begin(), x.end()
#define	 allr(x)  x.rbegin(), x.rend()
#define  bit(x)  __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
int mul (int x, int y) { return ((ll)x * y) % mod; } 
int sub (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 3e5;
 
ll get (ll r, ll x) {
	if (r == -1) return 0;
	return r / x + 1;
}

ll solve () {
	ll l, r, x;
	cin >> l >> r >> x;
	return get (r, x) - get (l-1, x); 
}

main () { fast_in;
    int t = 1; //cin >> t;
    while (t --) {
    	cout << solve ();    
    }
	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int a[100000];
int b[100000];

int next(int j, int n) {
    j += 2;
    if (j >= n)
        j = 1;
    return j;
}

long get_ans(int n) {
    {
        int j = 0, l = 0, r = n;
        while (l < r) {
            b[j++] = a[l++];
            if (l >= r)
                break;
            b[j++] = a[--r];
        }
    }

    rotate(b, b + n - 1, b + n);

    // for (int i = 0; i < n; i++)
    //     printf("%d%c", b[i], i == n - 1 ? '\n' : ' ');

    long ans = 0;
    for (int i = 0; i + 1 < n; i++)
        ans += abs(b[i] - b[i + 1]);
    return ans;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);

    sort(a, a + n);

    long ans = get_ans(n);

    reverse(a, a + n);

    ans = max(ans, get_ans(n));

    printf("%ld\n", ans);
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D; cin >> D;
    if(D == 22) puts("Christmas Eve Eve Eve");
    else if (D == 23) puts("Christmas Eve Eve");
    else if (D == 24) puts("Christmas Eve");
    else puts("Christmas");
    return 0;
}

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

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

   

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

int main() {
	int n;cin>>n;
	int a=100;
	for(int i=0;i<n;i++)
	{
		a=(int)ceil(a*1.05);
	}
	cout<<a*1000<<endl;
	return 0;
}

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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  long long int total = 0;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    total += a[i];
  }
  if(total >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("Impossible"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  rep(i,n) scanf("%d",&a[i]);
  sort(rng(a));
  int l = a.back();
  rep(i,n) {
    if (a[i]*2 < l) dame;
  }
  vi c(l+1);
  rep(i,n) c[a[i]]++;
  if (l&1) {
    for (int i = l/2+1; i <= l; ++i) {
      if (c[i] < 2) dame;
    }
    if (c[l/2+1] != 2) dame;
  } else {
    for (int i = l/2+1; i <= l; ++i) {
      if (c[i] < 2) dame;
    }
    if (c[l/2] != 1) dame;
  }
  puts("Possible");
  return 0;
}







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

int numbers[300005];

void f(int x, int y, int z) {
	for (int i = 0; i < y; i++) {
		if (i < z) {
			numbers[x + i] = x + y - z + i;
		}
		else {
			numbers[x + i] = x + y - 1 - i;
		}
	}
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	bool flag = b > a;
	if (flag) {
		swap(a, b);
	}
	int q, r;
	q = n / b;
	r = n % b;
	if (a < (q + (r != 0)) || a > n + 1 - b) {
		cout << -1 << endl;
		return 0;
	}
	int more = a - (q + (r != 0));
	if (more >= (b - 1)*(q - 1)) {
		f(1, b, 1);
		for (int i = 2; i <= q; i++) {
			f(b*(i - 1) + 1, b, b);
		}
		f(q*b + 1, r, more - (b - 1)*(q - 1) + 1);
	}
	else {
		int x = more / (b - 1);
		for (int i = 1; i <= x; i++) {
			f(b*(i - 1) + 1, b, b);
		}
		f(b*x+1, b , more % (b - 1) + 1);
		for (int i = x + 2; i <= q; i++) {
			f(b*(i - 1) + 1, b, 1);
		}
		f(q*b + 1, r, 1);
	}

	if (flag) {
		for (int i = 1; i <= n; i++) {
			numbers[i] = n + 1 - numbers[i];
		}
	}
	for (int i = 1; i <= n-1; i++) {
		cout << numbers[i] << " ";
	}
	cout << numbers[n] << endl;
}

Measured memory_bytes: 3328
def main():
    n, m, x = map(int, input().split())
    aa = list(map(int, input().split()))
    c0 = len([a for a in aa if a < x])
    cn = len([a for a in aa if a > x])
    print(min(c0, cn))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans=0,x;
map<ll,ll>m;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>x;
    if(m[x]==0){
        ans++;
        m[x]=1;
    }
}
cout<<ans;
}


Measured memory_bytes: 256
Var A,B,N:Longint;
    D:Array[1..100000] Of Qword;

Procedure Xuli;
Var i:Longint;
Begin
        D[1]:=1;
        For i:=2 to 100000 Do D[i]:=((D[i-1] Mod 1000000007)*(i Mod 1000000007))Mod 1000000007;
End;

Begin
        //Assign(Input,'TRAINED.INP'); Reset(Input);
        //Assign(Output,'TRAINED.OUT'); Rewrite(Output);
        Readln(A,B);
        Xuli;
        If ABS(A-B)>1 Then
                Begin
                Write(0);
                Halt;
                End;
        N:=(D[B]*D[A])Mod 1000000007;
        If A=B Then
                Begin
                N:=(D[B]*D[A]*2)Mod 1000000007;
                Write(N);
                Halt;
                End;
        Write(N);
        //Close(Input);
        ///Close(Output);
End.


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

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll turn=0;
    while(a>0 && c>0)
    {
        turn++;
        if(turn%2!=0)
        {
            c=c-b;
        }
        else
        {
            a=a-d;
        }
    }
    if(turn%2!=0)
    {
        cout<<"Yes"<<'\n';
    }
    else
    {
        cout<<"No"<<'\n';
    }

}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    unsigned long X,Y;
    int length=1;
    cin>>X>>Y;
    unsigned long temp=X;
    while(temp*2<=Y){
        temp*=2;
        length++;
    }
    cout<<length<<endl;
    return 0;
}


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

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


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

int main(int argc, const char * argv[]) {
    char a[100],b[100];
    int i,j,n,flag,alen,blen,count,ans[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",a);
        scanf("%s",b);
        j=0;
        count=0;
        flag=0;
        alen=(int)strlen(a);
        blen=(int)strlen(b);
        if(alen>80||blen>80){
            printf("overflow\n");
            flag=1;
        }
        while(alen!=0||blen!=0){
            ans[j]=count;
            if(alen!=0)
                ans[j]+=a[--alen]-'0';
            if(blen!=0)
                ans[j]+=b[--blen]-'0';
            count=ans[j]/10;
            ans[j]=ans[j]%10;
            j++;
        }
        if(count==1)
            ans[j]=1;
        else
            j--;
        if(j>=80){
            if(flag==0)
            printf("overflow\n");
        }
        else{
            for(;j>=0;j--)
                printf("%d",ans[j]);
            printf("\n");
        }
    }
            return 0;
}

Measured memory_bytes: 608