akhauriyash/Code-Regression huggingface dataset:
// In the Name of God

#include <bits/stdc++.h>

using namespace std;

#define	ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)
#define itr iterator
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define ub upper_bound
#define lb lower_bound

const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
const double eps = 1e-15;
const int pw = 257;

int n, a[N], k, c;
ll sum;

int main() {
	#ifdef Madi
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
	#endif

	ios_base :: sync_with_stdio(false); cin.tie(NULL);

	cin >> n;
	rep(i, 1, n)
		cin >> a[i];

	rep(i, 1, n)
		sum += a[i];
	
	if (sum % (n * 1ll * (n + 1) / 2) != 0)
		return cout << "NO", 0;

	k = c = sum / (n * 1ll * (n + 1) / 2);

	a[0] = a[n];
	rep(i, 1, n) {
		if ((a[i - 1] - a[i] + k) % n != 0 || (a[i - 1] - a[i] + k) < 0)
			return cout << "NO", 0;
		c -= (a[i - 1] - a[i] + k) / n;
	}

	if (c)
		return cout << "NO", 0;
	cout << "YES";
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    println(a+a*a+a*a*a)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34320
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
#define LL long long
using namespace std;
int n,b[N+5],S[N+5];LL a[N+5],c[N+5],tmp[N+5];
struct P
{
	LL x,y;I P(Con LL& a=0,Con LL& b=0):x(a),y(b){}
	I P operator - (Con P& o) Con {return P(x-o.x,y-o.y);}
	I LL operator ^ (Con P& o) Con {return x*o.y-y*o.x;}
}p[N+5];
int main()
{
	RI i,Mx;scanf("%d",&n);
	for(Mx=0,i=1;i<=n;++i) scanf("%lld",a+i),tmp[i]=a[i],a[i]>=a[Mx]&&(Mx=i);
	for(i=Mx;i<=n;++i) a[i-Mx+1]=tmp[i];for(i=1;i^Mx;++i) a[i+(n-Mx+1)]=tmp[i];
	for(i=1;i<=n;++i) scanf("%d",b+i),tmp[i]=b[i];
	for(i=Mx;i<=n;++i) b[i-Mx+1]=tmp[i];for(i=1;i^Mx;++i) b[i+(n-Mx+1)]=tmp[i];
	for(a[++n]=a[1],i=2;i<=n;++i) c[i]=2*c[i-1]-c[i-2]+2*b[i-1],a[i]-=c[i];
	RI T=0;for(i=1;i<=n;++i)
	{
		p[i]=P(i,a[i]);W(T>1&&((p[S[T]]-p[S[T-1]])^(p[i]-p[S[T]]))>0) --T;S[++T]=i;
	}
	LL ans=a[S[1]]+a[S[T]];for(i=2;i<=T;++i) ans+=(a[S[i]]+a[S[i-1]])*(S[i]-S[i-1]);
	for(i=1;i<=n;++i) ans+=2*c[i];return printf("%.15lf",(ans-2*a[1])/2.0/(n-1)),0;
}

Measured memory_bytes: 13072
#include <stdio.h>

int main(void){
	int high[10];
	int i, j, tmp;
	
	for (i = 0; i < 10; i++) scanf("%d", &high[i]);
	
	for (i = 0; i < 3; i++){
		for (j = 9; j > i; j--){
			if (high[j-1] < high[j]){
				tmp = high[j-1];
				high[j-1] = high[j];
				high[j] = tmp;
			}
		}
	}
	
	for (i = 0; i < 3; i++)	printf("%d\n", high[i]);
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
const int DIV_NUM = 1000000000 + 7; 
int main() {
  int N;
  cin >> N;
  long long ans = 1;
  for (int i = 1; i <= N ; ++i) {
    ans *= i;
    ans %= DIV_NUM;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int n, m;
vector<vector<int>>v;
vector<int>p;

//bit全探索で整数bitからスイッチの全通りの状態の組み合わせを復元できるようにし、
//整数bitをswitch_stateと紐づけてチェック、決め打ち(電球がつかなければfalse,そうでなければtrueを返す)した
bool check(int bit) {

	//switch_stateをスイッチの数(n個)用意
	vector<bool>switch_state(n, false);
	rep(i, n) {
		if (bit & (1 << i)) {	//スイッチの状態を整数bitから復元(ここではtrueをONとしている)
			switch_state[i] = true;
		}
	}

	rep(i, p.size()) {

		int cnt = 0;
		rep(j, v[i].size()) {
			if (switch_state[v[i][j] - 1]) {	//switch_stateの添え字は0始まりなので注意
				cnt++;
			}
		}

		if (!(cnt % 2 == p[i])) {	//矛盾すればfalseを返す
			return false;
		}

	}

	return true;
}

int main() {
	cin >> n >> m;
	v.resize(m);
	rep(i, m) {
		int k;	cin >> k;
		v[i].resize(k);
		rep(j, k) {
			cin >> v[i][j];
		}
	}

	p.resize(m);
	rep(i, m)cin >> p[i];

	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		if (check(bit))ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			int l = 0;
			int r = 1_000_000_000;
			while (l < r - 1) {
				int mid = (l + r) / 2;

				int cutCount = 0;
				for (int i = 0; i < n; i++) {
					cutCount += (a[i] - 1) / mid;
				}

				if (cutCount <= k) {
					r = mid;
				} else {
					l = mid;
				}
			}

			System.out.println(r);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 50164
S=list(input())
l=len(S)
Ans=0
for i in range(l-1):
    del S[-1]
    if len(S)%2==0:
        for j in range(len(S)//2):
            flag=True
            for k in range(len(S)//2):
                if S[k]!=S[k+len(S)//2]:
                    flag=False
            if flag==True and Ans<len(S):
                Ans=len(S)
print(Ans)

Measured memory_bytes: 3064
#include <stdio.h>
void length(int x, int y, int len_in_adv, int W, int H, char s[W][H], int visited[W][H]);
int ret;

int main(){
    int W, H;
    int x, y;
    int white = 0;
    char temp;
    scanf("%d %d\n", &H, &W);

    char s[W][H];
    int visited[W][H];

    for(y = 0; y < H; ++y){
        for(x = 0; x < W; ++x){
            visited[x][y] = H * W + 1;

            scanf("%c", &s[x][y]);
            if(s[x][y] == '.'){
                white++;
            }
        }
        if(y < H - 1){
            scanf("%c", &temp);
        }
    }

    ret  = H * W + 1;
    length(0, 0, 1, W, H, s, visited);

    if(ret  == H * W + 1){
        printf("-1\n");
    }else{
        printf("%d\n", white - ret);
    }
    return 0;
}

void length(int x, int y, int len_in_adv, int W, int H, char s[W][H], int visited[W][H]){
    visited[x][y] = 1;

    if(len_in_adv >= ret ||
    x > W - 1||x < 0||
    y > H - 1 || y < 0){
        return;
    }

    if(x == W - 1 && y == H - 1){
        if(len_in_adv < ret){
            ret = len_in_adv;
        }
        return;
    }
    if(y + 1 < H && s[x][y + 1] == '.' && visited[x][y + 1] > len_in_adv + 1){
        length(x, y + 1, len_in_adv + 1, W, H, s, visited);
        visited[x][y + 1] = len_in_adv + 1;
    }
    if(y - 1 >= 0 && s[x][y - 1] == '.' && visited[x][y - 1] > len_in_adv + 1){
        length(x, y - 1, len_in_adv + 1, W, H, s, visited);
        visited[x][y - 1] = len_in_adv + 1;
    }
    if(x + 1 < W && s[x + 1][y] == '.' && visited[x + 1][y] > len_in_adv + 1){
        length(x + 1, y, len_in_adv + 1, W, H, s, visited);
        visited[x + 1][y] = len_in_adv + 1;
    }
    if(x - 1 >= 0 && s[x - 1][y] == '.' && visited[x - 1][y] > len_in_adv + 1){
        length(x - 1, y, len_in_adv + 1, W, H, s, visited);
        visited[x - 1][y] = len_in_adv + 1;
    }
    return;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>

long long INF = 10000000;

int main(void){
    int n;
    std::cin >> n;

    int dp[n+1];
    for(int i = 0; i < n+1; i++){
        dp[i] = INF;
    }
    dp[0] = 0;

    for(int i = 0; i < n; i++){

        // i+1, i+6, i+36,...
        int s = 1;
        while(1){
            if(i + s > n) break;
            dp[i+s] = std::min(dp[i+s], dp[i] +1);
            s *= 6;
        }

        //i+1, i+9, i+81,...
        s = 1;
        while(1){
            if(i+s > n) break;
            dp[i+s] = std::min(dp[i+s], dp[i]+1);
            s *= 9;
        }
    }
    std::cout << dp[n] << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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()
typedef long long ll;

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



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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int gcd(int a, int b)
{
    if (a%b == 0) {
        return b;
    }
    else {
        return gcd(b, a%b);
    }
}
 
int main() 
{
  int k,ans = 0;
  cin >> k;
  
  for (int a = 1; a <= k; ++a) {
      for (int b = 1; b <= k; ++b) {
          for (int c = 1; c <= k; ++c) {
              
              ans += gcd(gcd(a,b),c);
          
          }   
      }   
  }
  
  cout << ans << "\n";
  
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

int INF = 1<<30;
int main( ){
    int n,m;
    cin>>n>>m;
    //定義時に()で宣言するとpush_backできない?
    vi conne[n];
    vi cnt(n,0);

    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--; b--;
        conne[a].push_back(b);
        conne[b].push_back(a);
    }
    rep(i,m){
        int p,x;
        cin>>p>>x;;
        p--;
        cnt[p]+=x;
    }
    vector<bool> is_visited(n,false);
    queue<int> q;
    q.emplace(0);
    is_visited[0]=true;
    while(!q.empty()){
        int ele=q.front(); q.pop();
        for(auto itr=conne[ele].begin();itr!=conne[ele].end();itr++){
            if(is_visited[*itr]==false){
                cnt[*itr]+=cnt[ele];
                is_visited[*itr]=true;
                q.push(*itr);
            }
        }
    }
    rep(i,n)cout<<cnt[i]<<" ";
    return 0;
}




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

#define ll long long int
#define endl '\n'
#define inf 1e18
#define mod 1000000007
vector<ll>tree[200005];
ll vis[200005];
ll cnt=0;
ll dfs(ll v)
{
    cnt++;
    vis[v]=true;
    for(int child:tree[v])
    {
        if(!vis[child])
        {
            dfs(child);
        }
    }
    return cnt-1;
}
void testCase()
{
    //ll t; cin>>t; while(t--)
    {
        ll n,m;
        cin>>n>>m;

        for(int i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            tree[x].push_back(y);
            tree[y].push_back(x);
        }
        ll ans=0;

        for(int i=1;i<=n;i++)
        {
            if(!vis[i])
            {
                dfs(i);
                ans=max(ans,cnt);
                cnt=0;
            }
        }
        cout<<ans<<endl;



    } 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

Measured memory_bytes: 22340
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        ArrayList<Integer> l = new ArrayList<>();
        for(int i =0; i < N ;i++){
            l.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(l);
        if(l.get(l.size()/2) == l.get(l.size()/2-1)){
            System.out.println(0);
        }else{
            System.out.println(l.get(l.size()/2)-l.get(l.size()/2-1));
        }
    }
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;



int main() {

    ll X;
    cin >> X;

    ll sen = X / 500;
    X = X - (sen * 500);
    sen *= 1000;

    ll go = X / 5;
    // X /= 5;
    go *= 5;

    cout << sen + go;


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


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

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (n == i*j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
# by the authority of GOD
import os,sys
from io import BytesIO, IOBase

def main():
    mod=10**9+7
    n= int(input())
    if n==1:
        print(0)
    elif n==2:
        print(2)
    else:
        print(((pow(10,n,mod)+pow(8,(n),mod))%mod - (pow(9,n)*2)%mod)%mod)
#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 73584
fun main(args: Array<String>) {
  val N = readInt()
  val A = readInts()
  println(A.sum() - A.size)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 38664
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

#define fs first

#define sc second

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int p[2];
	int sp[2] = {};
	cin >> s;
	cin >> p[0] >> p[1];
	vector<int> dd[2];
	int cnt = 0, in = 0;
	REP(i, s.size()){
		if(s[i] == 'F')
			cnt++;
		else{
			if(in == 0)
				sp[0] += cnt;
			else
				dd[in%2].push_back(cnt);
			cnt = 0;
			in++;
		}
	}
	if(in == 0)
		sp[0] += cnt;
	else
		dd[in%2].push_back(cnt);

	REP(k, 2){
		int diff = 10000;
		p[k] += diff; sp[k] += diff;
		vector<bool> dp(20000, 0);
		dp[sp[k]] = 1;
		REP(i, dd[k].size()){
			vector<bool> dp2(20000, 0);
			REP(j, 20000){
				if(!dp[j]) continue;

				if(j+dd[k][i] < 20000)
					dp2[j+dd[k][i]] = 1;
				if(j-dd[k][i] >= 0)
					dp2[j-dd[k][i]] = 1;
			}
			dp = dp2;
		}
		if(!dp[p[k]]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 384
INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

n = int(read())
cnt = 0
for i in range(n):
    a = int(read())
    if a%2 == 1:
        cnt += 1
        
if cnt == 0:
    print "second"
else:
    print "first" 


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

using namespace std;
using ll = long long;

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

int main() {
  int n, d;
  cin >> n >> d;
  int x[n][d];
  rep(i, n) { rep(j, d) cin >> x[i][j]; }

  auto f = [](int n) {
    for (int i = 1; i * i <= n; ++i) {
      if (i * i == n) return true;
    }
    return false;
  };

  int ans = 0;
  rep(i, n) rep(j, i) {
    int d2 = 0;
    rep(k, d) {
      int dx = x[i][k] - x[j][k];
      d2 += dx * dx;
    }
    if (f(d2)) ++ans;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3540
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    m = min(a, b)
    M = max(a, b)

    print(str(m) * M)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int MAXN = 105;

int a[MAXN];

int main() {

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

    int sum = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }

    vector<int> v;
    for (int i = 0; i < n; i++) {
        if (1ll * a[i] * 4 * m >= sum) {
            v.push_back(a[i]);
        }
    }

    if (sz(v) < m) {
        puts("No");
    } else {
        puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e3 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;

int u[N][N] , a[N][N];

void solve() {
    int h , w , c1 , d1 , c2 , d2;
    cin >> h >> w;
    cin >> c1 >> d1;
    cin >> c2 >> d2;
    for(int i = 1; i <= h; i ++) {
        for(int j = 1; j <= w; j ++) {
            char c;
            cin >> c;
            if(c == '.')
                a[i][j] = 1;
            u[i][j] = inf;
        }
    }
    u[c1][d1] = 1;
    priority_queue<array<int,3> > q;
    q.push({-1, c1 , d1});
    while(q.size()) {
        array<int,3> cr = q.top();
        q.pop();
        pair<int,int> cur = make_pair(cr[1] , cr[2]);
        int dx[] = {0 , 0 , 1 , -1};
        int dy[] = {1 , -1 , 0 , 0};
        for(int i = 0; i < 4; i ++) {
            int x = cur.F + dx[i];
            int y = cur.S + dy[i];
            if(a[x][y] && u[cur.F][cur.S] < u[x][y]) {
                u[x][y] = u[cur.F][cur.S];
                q.push({-u[x][y] , x , y});
            }
        }
        for(int i = max(1 , cur.F-2); i <= min(h , cur.F+2); i ++) {
            for(int j = max(1 , cur.S-2); j <= min(w , cur.S+2); j ++) {
                if(a[i][j] && u[cur.F][cur.S]+1 < u[i][j]) {
                    u[i][j] = u[cur.F][cur.S]+1;
                    q.push({-u[i][j] , i , j});
                }
            }
        }
    }
    if(u[c2][d2] == inf) u[c2][d2] = 0;
    cout << u[c2][d2] - 1;
}
/*
*/
main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>



void solve() {
    int x;
    cin >> x;
    cout << (1 - x) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
#define y1 y_1
#define x1 y_2
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 20;
const int M = 1e6 + 2;
const int mod = 1e9 + 7;
const int inf = 2e9 + 3;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

/*
	BIN POISK EBANA V ROT
	DP EBANA V ROT
	DO EBANA V ROT
*/

int n;
ll a[N];

int main() {
	data();
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	ll now = 0;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += (a[i] * now) % mod;
		ans %= mod;
		now += a[i];
		now %= mod;
	}
	cout << ans;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    // 処理
    // 出力
    if (n == 7 || n == 5 || n == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	int h, a;
	cin >> h >> a;
	cout << (h-1) / a+1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;
using pii = pair<int,int>;

int main(){
    int N,M;
    cin >> N >> M;
    vector<pii> jobs(N);
    rep(i,N){
        int a,b;cin>> a >> b;
        jobs[i]=make_pair(a,b);
    }
    sort(All(jobs));

    priority_queue<int> pq;
    int cur = 0;
    int res = 0;
    for(int i=1;i<=M;i++){
        if(cur<N){
            while(jobs[cur].first<=i){
                pq.push(jobs[cur].second);
                cur++;
                if(cur>=N)break;
            }
        }
        if(!pq.empty()){
            res += pq.top();pq.pop();
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1660
/*input
2 100
*/

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

int main() {
  int x, y;
  cin >> x >> y;
  int z = 4*x-y;
  bool ok = true;
  if (z%2 != 0) ok = false;
  if (z < 0 ||  2*x < z) ok = false;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3620
import collections
goukei = 0

N = int(input())
Ai = list(map(int, input().split()))
number = [j for j in range(1, N+1, 1)]
plus_Ai = [x + y for (x, y) in zip(Ai, number)]
minus_Ai = [x - y for (y, x) in zip(Ai, number)]
c = collections.Counter(plus_Ai)

for i in minus_Ai:
    goukei += c[i]
print(goukei)


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

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

  int count = 0;
  int ans = 0;
  int K,A;
  vector<vector<int>> data(30,vector<int>(30));
  int maximam;

  for(int i = 0 ; i < N;++i){
    cin >> K;
    for(int j = 0; j < K;++j){
      cin >> data.at(i).at(j);
    }
    maximam = max(maximam,K);
    K =0;
  }

  for(int i = 1; i <=M; ++i){
    for(int j=0;j<N;++j){
      for(int k = 0;k < maximam;++k){
        if(i == data.at(j).at(k)) count++;
      }
    }
    if(count == N)ans++;
    count =0;
  }
  cout << ans << endl;
}
 

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

int main(void) {
  int a[3];
  int i = 0,min = 10000,max = 0;
  for (i = 0;i < 3;++i) {
    scanf("%d",&a[i]);
  }
  for (i = 0;i < 3;++i) {
    if (a[i] < min) {
      min = a[i];
    }
  }
  for (i = 0;i < 3;++i) {
    if (a[i] > max) {
      max = a[i];
    }
  }
  printf("%d",abs(max - min));
  return 0;
}

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

int main() {
	// your code goes here
	string txt;
	cin>>txt;
	
	int cont =0;
	int ant =0;
	char l;
	for(int i =0;i< txt.length(); i++){
		
		l=txt[i];
		
		if(l =='R'){
			cont++;
		}
		
		else {
			
			cont=0;
		}
		
		if(cont > ant)ant = cont;
		
		
	}
	if(cont > ant)cout<<cont;
	else cout<<ant;
	
	return 0;
}

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

using namespace std;

int main(void)
{
    char S[1000000];
    cin >> S;

    vector<int> vec;

    for (int i = 0; S[i] != '\0';)
    {
        if (S[i] == '<')
        {
            int n = 0;
            //vec.push_back(n);
            while (S[i] == '<')
            {
                n++;
                vec.push_back(n);
                i++;
            }
        }
        else
        {
            int n = 0;
            while (S[i] == '>')
            {
                n++;
                i++;
            }

            if (vec.size() != 0)
            {
                if (vec[vec.size() - 1] < n)
                {
                    vec[vec.size() - 1] = n;
                }
            }
            else
            {
                vec.push_back(n);
            }
            n--;
            while (n >= 0)
            {
                vec.push_back(n);
                n--;
            }
        }
    }

    long long sum = 0;

    for (int i = 0; i < vec.size(); i++)
    {
        sum += vec[i];
        //cout << vec[i] << " ";
    }
    //cout << endl;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2932
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		WriteLine((long)Floor(GetDecimal() * GetDecimal()));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 10000001
#define infpos 10e5
#define infneg -10e5
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b)
{return (a.first-a.second > b.first-b.second);}

int main(){
ll t,x,n,h,d,j,ans,maxi,s;
cin>>n;
vector<int> a(n+1,0),b(n+1,0),c(n+1,0);
for(ll i=1;i<=n;i++)
    cin>>a[i];
for(ll i=1;i<=n;i++)
    cin>>b[i];
for(ll i=1;i<=n-1;i++)
    cin>>c[i];
s=0;
for(ll i=1;i<=n;i++)
{
    s+=b[a[i]];
    if( i<=n-1 && a[i+1]== a[i]+1) s+=c[a[i]];
}
cout<<s<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());

	long long sum = 0;
	bool f = true;
	int it = 0;
	for (int i = 1; i < n; i++) {
		sum += a[it];

		if (f) {
			f = false;
			it++;
		}
		else {
			f = true;
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 4044
#include<cstdio>

using namespace std;

int main(){
    int A, B, C, X;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &X);
    int ans = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if (500 * i + 100 * j + 50 * k == X) ans++;            
            }
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
n = int(input())
a, b = map(int,input().split())
p = [int(x) for x in input().split()]
x,y,z = 0,0,0
for i in p:
    if i <= a:
        x += 1
    elif i <= b:
        y += 1
    else:
        z += 1
print(min(x,y,z))

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second

const int MAXN = 200005;
int ans[MAXN];
bool used[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n, x;
    cin >> n >> x;
    int f = 2 * n - 1;
    if (x == 1 || x == f)
    {
        cout << "No" << endl;
        return 0;
    }
    ans[f/2] = x-1;
    ans[f/2 + 1] = x;
    ans[f/2 + 2] = x + 1;
    used[x-1] = true;
    used[x] = true;
    used[x+1] = true;

    int cur = f;
    for (int i=f/2-1;i>=1;i--)
    {
        while (used[cur])
        {
            cur--;
        }
        ans[i] = cur;
        used[cur] = true;
    }

    cur = 1;
    for (int i=f/2+3;i<=f;i++)
    {
        while (used[cur])
        {
            cur++;
        }
        ans[i] = cur;
        used[cur] = true;
    }
    cout << "Yes" << endl;
    for (int i=1;i<=f;i++)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 2560
N = int(input())
res = N
for i in range(N+1):
    cc = 0
    t = i
    while t > 0:
        cc += t % 6
        t //= 6
    t = N - i
    while t > 0:
        cc += t % 9
        t //= 9
    res = min(res, cc)
print(int(res))

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

#define MAX 1000000
#define L 14

char H[MAX][L];

int ctoi(char rom){
  if(rom=='A')return 1;
  else if(rom=='C')return 2;
  else if(rom=='G')return 3;
  else if(rom=='T')return 4;
  else return 0;
}

int getvalue(char ary[]){
  int sum=0,a=1,i;
  for(i=0;i<strlen(ary);i++){
    sum+=a*(ctoi(ary[i]));
    a*=5;
  }
  return sum;
}

int jud1(int key){return key%MAX;}
int jud2(int key){return 1+(key%(MAX-1));}

int find(char ary[]){
  int key,i,jud;
  key=getvalue(ary);
  for(i=0;;i++){
    jud=(jud1(key)+i*jud2(key))%MAX;
    if(strcmp(H[jud],ary)==0)return 1;
    else if(strlen(H[jud])==0)return 0;
  }
  return 0;
}

int insert(char ary[]){
  
  int key,i,jud;
  
  key=getvalue(ary);
  for(i=0;;i++){
    jud=(jud1(key)+i*jud2(key))%MAX;
    if(strcmp(H[jud],ary)==0)return 1;
    else if(strlen(H[jud])==0){
      strcpy(H[jud],ary);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n;
  char ary[L],command[9];
  for(i=0;i<MAX;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",command,ary);
    if(command[0]=='i'){
      insert(ary);
    }
    else{
      if(find(ary)){
	printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return 0;
}

	

		     
		     
 



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

template <class T>
struct BIT {
  vector<T> lst;
  int treesize;
  // constructor
  BIT(int newn = 0) {
    treesize = newn;
    lst.resize(treesize + 1);
    for(int i = 0; i <= treesize; ++i) lst[i] = 0;
  }
  // a_place += num
  bool add(int place, T num) {
    while(place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
    return 1;
  }
  // add wide ver.(add num between l and r)
  bool addw(int left, int right, T num) {
    while(left <= right && left >= 1 && right <= treesize)
      add(left++, num);
    return 1;
  }
  // sum between l and r
  T calcsum(int place) {
    T answer = 0;
    while(place > 0) {
      answer += lst[place];
      place -= place & -place;
    }
    return answer;
  }
  // sum between l and r(calcsum wide ver.)
  T calcsumw(int left, int right) {
    return calcsum(right) - calcsum(left - 1);
  }
};

long long n, req;
vector<long long> a, ls;

long long solve();
bool isans(long long now);

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a.push_back(x);
    ls.push_back(x);
  }
  req = (n * (n + 1) + 2) / 4;
  sort(ls.begin(), ls.end());
  ls.erase(unique(ls.begin(), ls.end()), ls.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long l = 0, r = ls.size() - 1, now = ls[0];
  while(r - l > 0) {
    if(r - l == 1) {
      if(isans(ls[r]))
        now = ls[r];
      else
        now = ls[l];
      break;
    }
    else {
      now = ls[(r + l) / 2];
      if(isans(now))
        l = (r + l) / 2;
      else
        r = (r + l) / 2;
    }
  }
  return now;
}
// yes 1,no 0
bool isans(long long now) {
  BIT<long long> bits = BIT<long long>(1 + n),
                 inv = BIT<long long>(3 * n);
  long long ans = 0;
  // calculate cumlative number(1 or -1 progression)
  for(int i = 0; i <= n; ++i) {
    if(i == 0 || a[i - 1] >= now)
      bits.add(i + 1, 1);
    else
      bits.add(i + 1, -1);
  }
  // avoid runtime error
  bits.add(1, n);
  // calculate inversion number
  for(int i = 1; i <= n + 1; ++i) {
    ans += inv.calcsum(bits.calcsum(i));
    inv.add(bits.calcsum(i), 1);
  }
  // cout << now << " " << ans << " " << req << endl;
  if(ans >= req)
    return 1;
  else
    return 0;
}


Measured memory_bytes: 5100
#include<stdio.h>

int main()
{
    int n,k,s=0,i,j,temp=0;
    int l[100];
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&l[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(l[i]<l[j]){
                temp=l[i];
            l[i]=l[j];
            l[j]=temp;
        }
        }

    }
    for(i=0;i<k;i++)
    {
        s+=l[i];

    }
   printf("%d",s);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int gcd(int,int);

void main(){
    int k;
    int ans=0;
    scanf("%d",&k);
    for (int i = 1; i <=k; ++i) {
        for (int j = 1; j <=k ; ++j) {
            for (int l = 1; l <=k; ++l) {
                ans+=gcd(gcd(i,j),l);
            }
        }
    }
    printf("%d",ans);
}
int gcd(int m,int n){
    if(n==0)
     return m;
    else
        return gcd(n,m%n);
}

Measured memory_bytes: 1728
// WA
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");
  let N = Number(inputs[0].split(" ")[0]);
  let K = Number(inputs[0].split(" ")[1]);
  let hs = inputs.slice(1).map(h => Number(h));

  let temp = hs.sort((a, b) => a - b);
  console.error(temp);

  temp = temp.map((h, index, hs) => {
    if (index + K - 1 < hs.length) {
      return hs[index + K - 1] - hs[index];
    }
    return null;
  });
  console.error(temp);

  temp = temp.filter(x => x !== null);

  console.error(temp);

  console.log(Math.min(...temp));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

  int a[n][m], b[m];

  for (int i=0;i<n; i++){
    for (int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }
  for (int i=0;i<m; i++){
    cin >> b[i];
  }

  for (int i=0;i<n; i++){
    int ans=0;
    for (int j=0; j<m; j++){
      ans += a[i][j]*b[j];
    }
    cout << ans << endl;
  }

}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int W, H;
  cin >> W >> H;
  vector<long long> p(W);
  vector<long long> q(H);

  for(int i = 0; i < W; i++) cin >> p[i];
  for(int i = 0; i < H; i++) cin >> q[i];

   sort(p.begin(), p.end());
   sort(q.begin(), q.end());

   int w = W + 1, h = H + 1;
   long long res = 0;
   int i = 0, j = 0;
  while(i < W || j < H){
    if(j < H && (i == W || p[i] > q[j])){
      res += q[j]*w;
      --h;
      ++j;
    }
    else{
      res += p[i] * h;
      --w;
      ++i;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()
def factorization(n):
  res = []
  if n%2==0:
    res.append(2)
  for i in range(3,math.floor(n//2)+1,2):
    if n%i==0:
      c = 0
      for j in res:
        if i%j==0:
          c=1
      if c==0:
        res.append(i)
  if len(res)==0:
    res = [n]
  return res
def fact2(n):
  p = factorization(n)
  res = []
  for i in p:
    c=0
    z=n
    while 1:
      if z%i==0:
        c+=1
        z/=i
      else:
        break
    res.append([i,c])
  return res
def fact(n):#階乗
  ans = 1
  m=n
  for _i in range(n-1):
    ans*=m
    m-=1
  return ans
def comb(n,r):#コンビネーション
  if n<r:
    return 0
  l = min(r,n-r)
  m=n
  u=1
  for _i in range(l):
    u*=m
    m-=1
  return u//fact(l)
def combmod(n,r,mod):
  return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
  r=copyQueue(q)
  ans=[0]*r.qsize()
  for i in range(r.qsize()-1,-1,-1):
    ans[i] = r.get()
  print(ans)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1]*n

  def find(self, x): # root
    if self.parents[x]<0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)

    if x==y:
      return

    if self.parents[x]>self.parents[y]:
      x,y = y,x

    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self,x):
    return -1*self.parents[self.find(x)]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def members(self,x): # much time
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]

  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
  x = 1
  zero = "0"*n
  ans = []
  ans.append([0]*n)
  for i in range(2**n-1):
    ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
    x+=1
  return ans;
def arrsSum(a1,a2):
  for i in range(len(a1)):
    a1[i]+=a2[i]
  return a1
def maxValue(a,b,v):
  v2 = v
  for i in range(v2,-1,-1):
    for j in range(v2//a+1): #j:aの個数
      k = i-a*j
      if k%b==0:
        return i
  return -1
def copyQueue(q):
  nq = queue.Queue()
  n = q.qsize()
  for i in range(n):
    x = q.get()
    q.put(x)
    nq.put(x)
  return nq
def get_sieve_of_eratosthenes(n):
  data = [2]
  #data = [0,0,0]
  for i in range(3,n+1,2):
    data.append(i)
    data.append(0)
  for i in range(len(data)):
    interval = data[i]
    if interval!=0:
      for j in range(i+interval,n-1,interval):
        data[j] = 0
  ans = [x for x in data if x!=0]
  #ans = data[:]
  return ans


a,b = readInts()

#print(a+b)
print(a*b)

Measured memory_bytes: 9644
#include <stdio.h>

int main () {
	
	char s[10];
	scanf("%s", &s);
	
	if(s[1] == 'B'){
		s[1] = 'R';
		printf("%s", s);
	}else if (s[1] == 'R'){
	 	s[1] = 'B';
		printf("%s", s);
	}
	
	return 0;
}

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

int main() {
  int N, K;
  int sum = 0;
  cin >> N >> K;
  vector<int> price(N);
  for (int i = 0; i < N; i++) {
    cin >> price.at(i);
  }
  sort(price.begin(), price.end());
  for (int i = 0; i < K; i++) {
    sum += price.front();
    price.erase(price.begin());
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3688
N = int(input())
A = list(map(int, input().split()))
m = sum(A) / float(N)
ans = 0
min_diff = 10**6
for i, a in enumerate(A):
    tmp = abs(a - m)
    if tmp < min_diff:
        min_diff = tmp
        ans = i
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,s=0,maxn=0;
	char a;
	cin>>n;
	while(n--){
	cin>>a;
	maxn=max(maxn,s);
	if(a=='I'){
	s++;
	continue;
	}
	s--;
	}
	maxn=max(maxn,s);
	cout<<maxn<<endl;
	return 0;
}

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

void dfs(vector<vector<int>>& Tree, vector<int>& Dists, int now, int before) {
	for (int u : Tree[now]) {
		if (u == before) continue;
		Dists[u] = Dists[now] + 1;
		dfs(Tree, Dists, u, now);
	}
}

int main() {
	int N, u, v;
	cin >> N >> u >> v;
	u--, v--;
	vector<vector<int>> Tree(N);
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B;
		Tree[A - 1].push_back(B - 1);
		Tree[B - 1].push_back(A - 1);
	}
	vector<int> DistT(N), DistA(N);
	dfs(Tree, DistT, u, -1);
	dfs(Tree, DistA, v, -1);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (DistT[i] > DistA[i]) continue;
		ans = max(ans, DistA[i] - 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 15936