akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	int ix;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ix = a[i];
		b[ix] = i;
	}
	for(int i=1;i<=n;i++){
		cout<<b[i]<<" ";
	}
	

}

Measured memory_bytes: 1664
from sys import stdin

def main():
    N = int(input())

    ans = 0
    for i in range(1, N + 1):
        if any((1 <= i <= 9,
                100 <= i <= 999,
                10000 <= i <= 99999)):
            ans += 1
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pi>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


ll pow(int a, int n, int mod){
    if(n == 1) return a;
    if(n%2 == 0) return pow(1LL*a*a%MOD, n/2, MOD);
    return 1LL*a*pow(1LL*a*a%MOD, n/2, MOD)%MOD;
}


pair<int, vi> bfs(const vvi& g, int x){
    vi d(g.size(), -1);
    queue<int> q; q.push(x);
    int u = -1;
    d[x] = 0;
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(auto& v:g[u]){
            if(d[v] != -1) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    return mp(u, d);
}


vi dist(const vvi& g){
    auto p1 = bfs(g, 0);
    auto p2 = bfs(g, p1.first);
    auto p3 = bfs(g, p2.first);
    vi res(g.size());
    rep(i, g.size()) res[i] = max(p2.second[i], p3.second[i]);
    sort(res.begin(), res.end());
    return res;
}


char grid[52][52];

int main(){
    int h, w;
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> grid[i+1][j+1];
    rep(i, h) rep(j, w) {
        if(grid[i+1][j+1]=='#'){
            cout << "#";
            if(j==w-1) cout << endl;
            continue;
        }
        int cnt=0;
        REP(k, -1, 2) REP(l, -1, 2) {
            if(grid[i+k+1][j+l+1]=='#') cnt+=1;
        }
        cout << cnt;
        if(j==w-1) cout << endl;
    }
}


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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll A, B, N; cin >> A >> B >> N;
    ll x;
    if(B-1 >= N) x = N;
    else x = B*(N/B)-1;
    cout << (A*x/B) - A*(x/B) << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#define llint long long

using namespace std;

llint n, k;
llint a[100005], ans[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1;i <= n; i++) cin >> a[i];
	
	for(int i = 1;i <= n; i++) ans[a[i]] = i;
	for(int i = 1;i <= n; i++) cout << ans[i] << " "; cout << endl;
	
	
	return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>

int main(){
  int i,j=0,k=0;
  
  int a,b;
  
  scanf("%d %d",&a,&b);
  
  k = b-a;
  
  for(i=1;i<k;i++)
    j += i;
  
  printf("%d\n",j-a);
  return 0;
}

Measured memory_bytes: 128
n=int(input())
lst=list(map(int,input().split()))
al=0
bo=0
while True:
    m=max(lst)
    al+=m
    lst.remove(m)
    if len(lst)==0:
        break
    m=max(lst)
    bo+=m
    lst.remove(m)
    if len(lst)==0:
        break
print(al-bo)



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

using namespace std;

const int N = 3000 + 10;
const int MOD = 998244353;

int f[N][N];

int main()
{
	int a, b, c, d, i, j;
	cin>>a>>b>>c>>d;
	f[a][b] = 1;
	for (i=a+1; i<=c; i++) f[i][b] = 1LL * f[i-1][b] * b % MOD;
	for (i=b+1; i<=d; i++) f[a][i] = 1LL * f[a][i-1] * a % MOD;
	for (i=a+1; i<=c; i++)
		for (j=b+1; j<=d; j++)
			f[i][j] = (((1LL * f[i-1][j] * j % MOD + 1LL * f[i][j-1] * i % MOD) % MOD - 1LL * f[i-1][j-1] * (i - 1) * (j - 1) % MOD) % MOD + MOD) % MOD;
	cout<<f[c][d]<<endl;		
	return 0;
}

Measured memory_bytes: 38896
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int c = parseInt(sc.next());
		int d = parseInt(sc.next());
		sc.close();
		String ans="";
		while(true) {
			c-=b;
			if(c<=0) {
				ans="Yes";
				break;
			}
			a-=d;
			if(a<=0) {
				ans="No";
				break;
			}
		}
		out.println(ans);
	}
}


Measured memory_bytes: 26924
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = input()
    alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
    ans = [alp[alp.find(i)+n] for i in s]
    print(*ans,sep = "")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 43248
/*
 * 英小文字からなる文字列 S が与えられます。 Tが空文字列である状態から始め、以下の操作を好きな回数繰り返すことで S=T とすることができるか判定してください。
 * 
 *    T の末尾に dream dreamer erase eraser のいずれかを追加する。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 入力を一文字ずつにする
            sc.useDelimiter("");
            // 10文字読み込む
            String s = sc.next();
            s = getString(s, 9, sc);
            
            // 改行文字だけになるまで続ける
            while(s.length() > 1){
            	// eraserが先頭にあるならそれを消し、10文字になるまで読み込む
            	if(s.length() >=6 && s.substring(0, 6).equals("eraser")){
            		s = s.substring(6);
            		s = getString(s, 6, sc);
            	// eraseが先頭にあるならそれを消し、10文字になるまで読み込む、dreamが先頭にある、かつdreamerが先頭にないならdreamを消し、10文字になるまで読み込む、dreameraseが先頭にあるならdreamを消し、10文字になるまで読み込む
            	}else if((s.length() >=5 && s.substring(0, 5).equals("erase")) || (s.length() >=6 && s.substring(0, 5).equals("dream") && !s.substring(0, 6).equals("dreame")) || (s.length() >=10 && s.substring(0, 10).equals("dreamerase"))){
            		s = s.substring(5);
            		s = getString(s, 5, sc);
            	// 残りが、(dreamまたはdreamer) + 改行文字ならばおしまい
            	}else if((s.length() == 6 && s.substring(0, 5).equals("dream")) || (s.length() == 8 && s.substring(0, 7).equals("dreamer"))){
            		s = "";
            	// dreamerが先頭にある、かつdreameraseが先頭にないならdreamerを消し、10文字になるまで読み込む
            	}else if(s.length() >=10 && s.substring(0, 7).equals("dreamer") && !s.substring(0, 10).equals("dreamerase")){
            		s = s.substring(7);
            		s = getString(s, 7, sc);
            	// それ以外なら題の操作では生成できない文字列なのでNOを出力してreturn
            	}else{
            		System.out.println("NO");
                    sc.close();
                    return;
            	}
            }
            
            // 改行文字だけになったら題の操作で生成できるということなのでYESを出力
            System.out.println("YES");
            sc.close();
        }
        
        // n文字分入力を読み取ってsに追加する関数getString
        public static String getString(String s, int n, Scanner sc){
        	// 改行文字を読みとったらもうそれ以上は読み込まない
        	if(!s.substring(s.length()-1).equals("\n")){
        		for(int i=0; i<n && !s.substring(s.length()-1).equals("\n"); i++){
        			s += sc.next();
        		}
        	}
            
            return s;
        }
    }
	

Measured memory_bytes: 46776
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>


int descending_compare(const void *a, const void *b) {
	if (*(int*)a > *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

int ascending_compare(const void *a, const void *b) {
	if (*(int*)a < *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y) {
	if (y == 0) {
		return x;
	}
	else if (x > y) {
		return gcd(y, x % y);
	}
	else {
		return gcd(x, y % x);
	}
}



long long factorial(int x) {
	long long rtn = 1;
	int i;
	for (i = x; i > 1; i--) {
		rtn = (rtn*i);
	}
	return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

int main(void) {
	int x, y;
    scanf("%d %d", &x, &y);
    int sx = -1*x;
    int sy = -1*y;
    int ans = 0;
    while (x != y && x != sy && sx != y && sx != sy){
        x++;
        sx++;
        ans++;
    }
    if (x == y){
        printf("%d\n", ans);
        return 0;
    }else if (x == sy){
        ans++;
    }else if (sx == y){
        ans++;
    }else if (sx == sy){
        ans += 2;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 888
$a, $b, $c, $d = \
  gets.split(//).map(&:to_i)

def get_str ops
  return "#{$a}#{ops[0]}#{$b}#{ops[1]}#{$c}#{ops[2]}#{$d}"
end

ops = ["+", "-"]
res_op = nil
ops.repeated_permutation(3).each{ |_ops|
  if eval(get_str(_ops)) == 7
    res_op = _ops
    break
  end
}

puts get_str(res_op) + "=7"

Measured memory_bytes: 1788
#include<iostream>
#include<stack>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
  string c;
  stack<int> s;
  int a, b;
  while (cin >> c) {
    if (c[0] == '+') {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(a + b);
    } else if (c[0] == '-') {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(b - a);
    } else if (c[0] == '*') {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(a * b);
    } else {
      s.push(atoi(c.c_str()));
    }
  }
  cout << s.top() << endl;
  return 0;
}



Measured memory_bytes: 3208
#include <iostream>
 using namespace std;
 int main(){
 string S;
 cin >> S;
 int ans = 700;
 if(S[0] == 'o') ans += 100;
 if(S[1] == 'o') ans += 100;
 if(S[2] == 'o') ans += 100;
 cout << ans << endl;
 }

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		sA();
	}

	void sA() {
		String S = sc.next();
		String ss[] = S.split("/");
		int date = Integer.parseInt(ss[0]) * 10000 + 
				Integer.parseInt(ss[1]) * 100 +
				Integer.parseInt(ss[2]);
		if(date > 20190430) {
			System.out.println("TBD");
		}
		else System.out.println("Heisei");
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 22612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18



int main() {

	int n, m; cin >> n >> m;

	int a[1000], b[1000], c[1000], dist[100][100];

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				dist[i][j] = 0;
			}
			else {
				dist[i][j] = INF;
			}
		}
	}

	for (int i = 0; i < m; i++) {
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	int ans = m;
	
	for (int i = 0; i < m; i++) {
		bool shortest = false;
		
		if (dist[a[i]][b[i]]==c[i])shortest = true;
		

		if (shortest == true) {
			ans--;
		}
	}

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

Measured memory_bytes: 256
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline())
    A = [int(x) for x in stdin.readline().rstrip().split()]

    A.sort(reverse=True)
    A_max = A.pop(0)

    A_minus = [i for i in A if i < 0]
    A_plus = [j for j in A if j >= 0]

    if len(A_minus) > 0:
        print(A_max - sum(A_minus) + sum(A_plus))

        A_minus.sort(reverse=False)
        tmp = A_minus.pop(0)

        for j in range(len(A_plus)):
            print(str(tmp) + " " + str(A_plus[j]))
            tmp = tmp - A_plus[j]

        print(str(A_max) + " " + str(tmp))
        tmp = A_max - tmp

        for i in range(len(A_minus)):
            print(str(tmp) + " " + str(A_minus[i]))
            tmp = tmp - A_minus[i]

    else:
        A_plus.sort(reverse=False)
        tmp = A_plus.pop(0)
        print(A_max - tmp + sum(A_plus))
        for i in range(len(A_plus)):
            print(str(tmp) + " " + str(A_plus[i]))
            tmp = tmp - A_plus[i]

        print(str(A_max) + ' ' + str(tmp))


Measured memory_bytes: 13964
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pi 3.14159265358979
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		rep(i, h) {
			rep(j, w) {
				if ((j + i) % 2 == 0)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> v = {abs(a - b), abs(a - c), abs(b - c)};
  sort(all(v));
  cout << v[0] + v[1] << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int m = 32, s = 0, c = 0;
            int[] l = new int[n];
            for (int i = 0; i < n; i++)
                l[i] = sc.nextInt();
            while (m > 0) {
                m -= c++ % 2 == 0 ? (m - 1) % 5 : l[s++ % l.length];
                System.out.println(m < 0 ? 0 : m);
            }
        }
    }
}


Measured memory_bytes: 28432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<c/a*b<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define per(i,a,b) for(ll i=b-1;i>=a;i--)
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
string s[50];
ll n;
signed main() {
    cin>>n;
    rep(i,n)cin>>s[i];
    rep(j,26) {
        int m = 100;
        rep(i, n)m = min(m, (int) count(begin(s[i]), end(s[i]),(char)j+97));
        rep(i, m) cout <<(char)(j+97);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
float sums=0;
int main(){
	int n;
	cin>>n;
	float nums;
	for(int i=0;i<n;i++){
		cin>>nums;
		sums+=1.0/nums;
	}
	sums=1.0/sums;
	printf("%f",sums);
	return 0;
}






























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

ll f[101010], rf[101010];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}

void init() {
    f[0] = 1;
    rep2(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
    rep2(i, 0, 101010) rf[i] = inv(f[i]);
}

ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main(){
  init();
	int n, k;
	cin >> n >> k;

  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  sort(a.begin(), a.end());
  mint max_sum = 0, min_sum = 0;
  rep2(i, k-1, n){
    mint now = a.at(i);
    max_sum += now * C(i, k-1);
  }
  for(int i = n-k; i >= 0; i--){
    mint now = a.at(i);
    min_sum += now * C(n-i-1, k-1);
  }
  mint ans = max_sum - min_sum;
  cout << ans.x << endl;

	return 0;
}

Measured memory_bytes: 2176
# https://atcoder.jp/contests/agc038/tasks/agc038_a

from itertools import combinations

H, W, A, B = map(int, input().split())

for _ in range(B):
    print("0" * A + "1" * (W-A))
for _ in range(H - B):
    print("1" * A + "0" * (W-A))

Measured memory_bytes: 39792
Var X,A,B,Tmp:Longint;
Begin
        //Assign(Input,'EXPIRED.INP'); Reset(Input);
        //Assign(Output,'EXPIRED.OUT'); Rewrite(Output);
        Readln(X,A,B);
        Tmp:=B-A;
        If Tmp<=X Then
                Begin
                If B<=A Then Write('delicious')
                Else Write('safe')
                End
        Else Write('dangerous');
        //Close(Input);
        ///Close(Output);
End.


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> p;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		p.push_back({b,a});
	} 
	sort(all(p));
	int ans=0;
	int endtime = 0;
	rep(i,m){
		if(p[i].second>=endtime){
			ans++;
			endtime=p[i].first;
		}
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 1400
/**
  @file c.cpp
  @title 404 Not Found - AtCoder
  @url https://atcoder.jp/contests/abc133/tasks/abc133_c
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

template <class T>
void show(vector<T>& v) {
  for (uint i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}

int main() {
  int i, j;

  int L, R;
  cin >> L >> R;

  const int mod = 2019;

  if (R - L >= 2019) {
    cout << "0" << endl;
    return 0;
  }

  vector<int> ans;
  for (i = L % mod; i < R % mod; i++) {
    for (j = i + 1; j <= R % mod; j++) {
      ans.push_back((i * j) % mod);
    }
  }

  sort(ALL(ans));
  // show(ans);
  cout << ans[0] << endl;

  return 0;
}


Measured memory_bytes: 9068
#!/usr/bin/env python3
import sys
from statistics import mean
from bisect import bisect_left
INF = float("inf")


def cmb(n, r):
    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    if r == 0:
        return 1
    if r == 1:
        return n

    numer = [n - r + k + 1 for k in range(r)]
    denom = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denom[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numer[k - offset] /= pivot
                denom[k] /= pivot

    result = 1
    for k in range(r):
        if numer[k] > 1:
            result *= int(numer[k])

    return result


def solve(N: int, A: int, B: int, v: "List[int]"):
    v.sort()
    ave = mean(v[N-A:])
    ma = v[-1]
    print(ave)

    num = v.count(v[N-A])
    hamidashi = v[:N-A].count(v[N-A])
    if ma == ave and hamidashi > 0:
        # すべて同じ価値の場合
        # A個に拘らなくて良い。
        tot = 0
        for i in range(A, B+1):
            # print(num, hamidashi+i)
            tot += cmb(num, i)
        print(tot)
    else:
        print(cmb(num, hamidashi))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    v = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5080
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
	int n, m, c;
	int i, j;
	int b[20];
	int input;
	int sum;
	int cnt = 0;

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

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

		for (j = 0; j < m; j++)
		{
			scanf("%d", &input);

			sum += b[j] * input;
		}

		cnt += (sum + c > 0);
	}
	
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int cost[200005]={0};
vector<int>node[200005];

int dfs(int from,int pos);
int main(){
  int n;
  int q;
  cin>>n>>q;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  
  for(int i=0;i<q;i++){
    int data,index;
    cin>>index>>data;
    cost[index]+=data;
  }

  dfs(0,1);
  for(int i=1;i<n;i++){
    cout<<cost[i]<<' ';
  }
  cout<<cost[n]<<endl;
  return(0);
}

int dfs(int from,int pos){
  cost[pos]+=cost[from];
  for(int i=0;i<node[pos].size();i++){
    int next=node[pos][i];
    if(next!=from){
      dfs(pos,next);
    }
  }
  return(0);
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

Vll fac(200005);
Vll invfac(200005);

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

void modfactorial(ll n, ll mod)
{
  REP(i, n+1)
  {
    if (i == 0) fac[i] = 1;
    else fac[i] = i * fac[i-1] % mod;
  }
}

void invmodfactorial(ll n, ll mod)
{
  invfac[n] = modpow(fac[n], mod-2, mod);
  REPR(i, n) invfac[i] = invfac[i+1] * (i+1) % mod;
}

ll modnCk(ll n, ll k, ll mod)
{
  ll res = fac[n];
  res *= invfac[k];
  res %= mod;
  res *= invfac[n-k];
  return res % mod;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  modfactorial(H+W+1, MOD);
  invmodfactorial(H+W+1, MOD);
  ll ans = 0;
  ans += modnCk(B+H-A-1, B, MOD) * modnCk(A+W-B-1, A, MOD);
  ans %= MOD;
  if (B == W-1)
  {
    cout << ans << endl;
    return 0;
  }
  REP(i, H-A-1)
  {
    ans += modnCk(i+B, i, MOD) * modnCk(W-B-2+H-i-1, W-B-2, MOD);
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];
            var LRList = Enumerable.Range(0, M).Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToArray());

            var min = 0;
            var max = 100001;
            foreach (var LR in LRList)
            {
                var L = LR[0];
                var R = LR[1];

                min = Math.Max(min, L);
                max = Math.Min(max, R);
            }

            var output = Math.Max(max - min + 1, 0);
            Console.WriteLine(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 17452
#include<stdio.h>
int main(){
int a,b=0;
while(1){
scanf("%d\n",&a);
if(a==0){
break;
}
a=1000-a;
if(a>=500){
b++;
a=a-500;
}
if(a>=100){
b=a/100+b;
a=a%100;
}
if(a>=50){
b=a/50+b;
a=a%50;
}
if(a>=10){
b=a/10+b;
a=a%10;
}
if(a>=5){
b=a/5+b;
a=a%5;
}
if(a>=1){
b=a+b;
}
printf("%d\n",b);
b=0;
}
return 0;
}





Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;
int main() {
    double X, Y, N;
    cin >> N;
    double x[10],y[10];
    for (int i = 0; i < N; ++i)
    {
        cin >> x[i] >> y[i];
    }
    double dist=0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i; j < N; ++j)
        {
            X = (x[i]-x[j])*(x[i]-x[j]);
            Y = (y[i]-y[j])*(y[i]-y[j]);
            dist += sqrt(X + Y);
        }
    }
    cout << setprecision(10) << fixed << (2.0*dist)/N ;
    return 0;
}

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

int N, W;
int w[101], v[101];
int DP[101][10001];

int rec(int i, int j)
{
	if(DP[i][j]>=0)
		return DP[i][j];

	if(i==N)
		return DP[i][j] = 0;

	if(j<w[i])
		return DP[i][j] = rec(i+1, j);

	int res1 = rec(i+1, j);
	int res2 = rec(i+1, j-w[i])+v[i];

	if(res1>res2)
		return DP[i][j] = res1;
	else
		return DP[i][j] = res2;

}

int main()
{
	cin >> N >> W;
	for(int i=0; i<N; i++)
		cin >> v[i] >> w[i];

	for(int i=0; i<=N; i++){
		for(int j=0; j<=W; j++){
			DP[i][j] = -1;
		}
	}

	cout << rec(0, W) << endl;
}



Measured memory_bytes: 7000
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#include<sstream>
#include<math.h>
#include<cctype>
#include<stdlib.h>
#include <cstring>
#include<cstdlib>
#include<cstdio>
#include<functional>
using namespace std;
int main()
{
	string str;
	while (cin >> str)
	{
		string output = "None";
		char letter = 'a';
		int len = str.length();
		for (int i = 0;i < 26;i++,letter++)
		{
			int flag = 0;
			for (int j = 0;j < len;j++)
				if (str[j] == letter)
				{
					flag = 1;
					break;
				}
			if (!flag)
			{
				output = letter;
				break;
			}
		}
		cout << output << endl;
	}
	return 0;
}

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

int dx[12] = {-2, -2, -2,  2, 2, 2, -1, 0, 1, -1,  0,  1};
int dy[12] = {-1,  0,  1, -1, 0, 1,  2, 2, 2, -2, -2, -2};

int main(){
    int px, py, n, x, y;
    while(cin >> px >> py){
        if(px + py == 0)    break;

        set<pair<int,int>> pyon;
        pyon.insert({px,py});
        cin >> n;

        for(int i = 0; i < n; i++){
            cin >> x >> y;
            set<pair<int,int>> next;
            for(pair<int,int> p : pyon){
                for(int j = 0; j < 12; j++){
                    int newx = p.first + dx[j];
                    int newy = p.second + dy[j];
                    if(0 <= newx && newx <= 9 && 0 <= newy && newy <= 9 && max(abs(newx-x), abs(newy-y)) <= 1){
                        next.insert({newx, newy});
                    }
                }
            }
            pyon = next;
        }

        if(pyon.size() > 0){
            cout << "OK" << endl;
        }else{
            cout << "NA" << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3012
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N,K=map(int,input().split())
    if K%2==1:
        print((N//K)**3)
    else:
        cnt=0
        for i in range(1,N+1):
            if 2*(i%K)==K:
                cnt+=1
        print(cnt**3+(N//K)**3)




resolve()

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)
for i in range(N-1):
    if A[i]+1 == A[i+1]:
        ans += C[A[i]-1]
print(ans)

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W, N; cin >> H >> W >> N;
    int ix, iy; cin >> iy >> ix;
    int sx, sy;
    string S, T; cin >> S >> T;
    int lim = N*2;
    char dir[] = {'R', 'U', 'L', 'D'};
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, -1, 0, 1};
    rep(i, 4){
        //cout << i << endl;
        char tak = dir[i], aok = dir[(i+2)%4];
        sx = ix; sy = iy;
        rep(j, lim){
            if(j % 2 == 0){
                if(S[j/2] == tak){
                    sx += dx[i];
                    sy += dy[i];
                }
            }
            else{
                if(T[j/2] == aok){
                    int nx = sx+dx[(i+2)%4];
                    int ny = sy+dy[(i+2)%4];
                    if(1 <= nx && nx <= W) sx = nx;
                    if(1 <= ny && ny <= H) sy = ny;
                }
            }
            if(sx <= 0 || sx > W || sy <= 0 || sy > H){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 920
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
ll N, M;
int cnt = 0;
ll ans = 0LL;
int tmp;
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    else
        return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a/gcd(a, b)) * b;
}
int main(){
    cin >> N;
    ll T[N];
    for(ll i = 0; i < N; i++) cin >> T[i];
    ans = 1LL;
    for(ll i = 0; i < N; i++){
        ans = (ll)lcm(T[i], ans);
    }
    cout << (ll)ans << endl;
    return 0;
}

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

int main() {
	string S,T,X;
	char a;
	cin >> S >> T;
	X = S;
	if (S.size() == T.size()) {
		for (int j = 0; j < S.size(); j++) {
			a = S[S.size() - 1];
			for (int i = 0; i < S.size() - 1; i++) {
				S[i + 1] = X[i];
			}
			S[0] = a;
			X = S;
			if (S == T) {
				cout << "Yes" << endl;
				break;
			}
		}
	}
	if (S != T) {
		cout << "No" << endl;
	}
	getchar();
	getchar();
}

Measured memory_bytes: 256
def conb(a,b):
    now=1
    for i in range(b):
        now=int(now*(a-i)/(i+1))
    return now
N,A,B=map(int,input().split())
V=list(map(int,input().split()))
V.sort(reverse=True)
line=V[A-1]
if V[0]==line:
    ans=0
    for i in range(A,min(V.count(V[0]),B)+1):
        ans+=conb(V.count(V[0]),i)
    print(V[0])
    print(ans)
elif line>V[A]:
    print(sum(V[:A])/A)
    print(1)
else:
    idx=V.index(line)
    cnt=V.count(line)
    print((sum(V[:idx])+line*(A-idx))/A)
    print(conb(cnt,A-idx))

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

//#template
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); }
template <class T> inline T max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); }
//#endtemplate

//#define
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define clr(x) memset(x, 0, sizeof(x))
#define mmid ((lf + rg) >> 1)
#define lson root * 2, lf, mmid
#define rson root * 2 + 1, mmid + 1, rg
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template <class T, class S> ostream &operator<<(ostream &o, const pair<T, S> &A) {
    o << "(" << A.fi << " " << A.se << ")";
    return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &A) {
    o << "[";
    for (auto &i : A) {
        o << " " << i;
    }
    o << " ]";
    return o;
}
//#enddefine

const int mod = int(1e9) + 7;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int dx[] = { -1, 0, 1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

const int N = 1e5 + 5;
string a[55];

void sol() {
    // Solve Function
    int n, m;
    while (cin >> n >> m) {
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        bool ans = true;
        for (int i = 0; ans && i < n; ++i) {
            for (int j = 0; ans && j < m; ++j) {
                if (a[i][j] == '#') {
                    bool flag = false;
                    for (int k = 0; k < 4; ++k) {
                        int x = i + dx[k], y = j + dy[k];
                        if (x < 0 || y < 0 || x >= n || y >= m) continue;
                        if (a[x][y] == '#') {
                            flag = true;
                            break;
                        }
                    }
                    ans &= flag;
                }
            }
        }
        if (ans)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(0);
#ifdef CFENGLV
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    clock_t _time = clock();
#endif
    int T;
    // cin >> T;
    // for(int cas = 1; cas <= T; ++cas) {
    // cout << "Case #" << cas << ": ";
    sol();
    // }
#ifdef CFENGLV
    cerr << "Time: " << static_cast<double>(clock() - _time) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
#endif
    return 0;
}


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

int main(void){
  int i,n,k,s=0;
  int l[100];

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

  for(i=0;i<n;i++)
    scanf("%d",&l[i]);

  sort(l,l+n);

  for(i=n-1;i>n-k-1;i--)
    s+=l[i];

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

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
long long a[1000009];
bool cmp(long long a,long long b) {
	return a>b;
}
int  main() {
	long long ans=0;
	long long s;
	cin>>s;
	for(long long i=1; i<=s; i++)
		cin>>a[i];
	sort(a+1,a+1+s,cmp);
	ans=a[1];
	long long tot=2;

	if(s==2) {
		cout<<a[1]<<endl;
		return 0;
	}
	if(s==1)
	{
		cout<<"0"<<endl;
		return 0; 
	 } 


	for(long long i=2; i<=s; i++) {
		if(tot+1==s) {
			ans=ans+a[i];
			break;
		} else if(tot+2==s) {
			ans=ans+a[i]*2;
			break;
		} else {
			ans=ans+a[i]*2;
			tot=tot+2;
		}

	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4752
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from itertools import product

def main():
  N, A, B, C = map(int, input().strip().split(' '))
  bamboos = [int(input()) for _ in range(N)]
  pattern = list(product(*[[0,1,2,3] for _ in range(N)]))
  score = 1000000000
  for p in pattern:
    _A, _B, _C = 0, 0, 0
    count = -3
    flag_A, flag_B, flag_C = False, False, False
    for i, n in enumerate(p):
      if n == 0:
        _A += bamboos[i]
        flag_A = True
        count += 1
      if n == 1:
        _B += bamboos[i]
        flag_B = True
        count += 1
      if n == 2:
        _C += bamboos[i]
        flag_C = True
        count += 1
    if count < 0 or not all([flag_A, flag_B, flag_C]):
      continue
    _score = (abs(A-_A)+abs(B-_B)+abs(C-_C)) + (10 * count)
    if score > _score:
      score = _score
  print(score)
  pass

if __name__=='__main__':
  main()


Measured memory_bytes: 10996
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;


int main() {

	int N, K;
	cin >> N >> K;

	vector<int> vVec(N);
	for (int i = 0; i < N; i++)
	{
		cin >> vVec[i];
	}
	int count = 0;
	for (int i = 0; i < N; i++)
	{
		if (vVec[i] >= K)
		{
			++count;
		}
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long x = sc.NextLong();

        long answer = 0;
        answer += x / 11 * 2;
        long mod = x % 11;
        if (mod > 0)
        {
            answer += mod > 6 ? 2 : 1;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
# include <iostream>
using namespace std;
long long n,x;
long long det(long long a,long long b){
    if(a>b)
        swap(a,b);
    if(b%a==0)
        return 2*a*(b/a)-a;
    return 2*a*(b/a)+det(a,b-a*(b/a));
}
int main () {
    cin>>n>>x;
    if(2*x==n){
        cout<<3*(n/2)<<"\n";
        return 0;
    }
    cout<<n+det(x,n-x)<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  int i;
  long long int s=0;
  scanf("%d\n",&N);

  int a[N],b[N];

  for(i=0;i<N;i++) scanf("%d ",&a[i]);
  for(i=0;i<N;i++) scanf("%d ",&b[i]);

  for(i=0;i<N;i++)
    if (a[i]<=b[i])
      s += (b[i]-a[i])/2;
    else
      s -= a[i]-b[i];
  if(s>=0)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}



Measured memory_bytes: 256
def bfs(i, c):
    global V, C

    q = [i]
    while len(q) > 0:
        j = q.pop()
        if C[j] == -1:
            C[j] = c
            q += V[j]

n, m = map(int, raw_input().split())
V = [[] for _ in range(n)]
C = [-1] * n
for _ in range(m):
    l, r = map(int, raw_input().split())
    V[l].append(r)
    V[r].append(l)

c = 0
for i in range(n):
    if C[i] == -1:
        bfs(i, c)
        c += 1

q = int(raw_input())
for _ in range(q):
    s, t = map(int, raw_input().split())
    if C[s] == C[t]:
        print "yes"
    else:
        print "no"

Measured memory_bytes: 28972
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
using namespace std;
int main()
{
	IOS;
	int t=1;
	//cin >> t;
	while (t--) 
	{
		ll n,i,j,k,count=0;
		cin>>n;
		ll a[n];
		for(i=0;i<n;i++) cin>>a[i];
		for(i=0;i<n-2;i++)
		{
			for(j=i+1;j<n-1;j++)
			{
				for(k=j+1;k<n;k++)
				{
					if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
					{
						if(a[i]+a[j]>a[k]&&a[j]+a[k]>a[i]&&a[k]+a[i]>a[j]) count++;
					}
				}
			}
		}
		cout<<count<<endl;
	}
}


Measured memory_bytes: 3648