akhauriyash/Code-Regression huggingface dataset:
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
def main():
    sys.setrecursionlimit(10 ** 7)
    """inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
    eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
    dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]"""
    """for dx, dy in dd:
            nx = j + dx; ny = i + dy
                if 0 <= nx < w and 0 <= ny < h:"""
    def wi(): return list(map(int, sys.stdin.readline().split()))
    def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
    def ws(): return sys.stdin.readline().split()
    def i(): return int(sys.stdin.readline())
    def s(): return input()
    def s_list(): return list(input())
    def hi(n): return [i() for _ in range(n)]
    def hs(n): return [s() for _ in range(n)]#HeightString
    def mi(n): return [wi() for _ in range(n)]#MatrixInt
    def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
    def mip(n): return [wip() for _ in range(n)]
    def ms(n): return [ws() for _ in range(n)]
    def grid(n): return [s_list() for _ in range(n)]

    n = i()
    print(n * (n + 1) // 2 - n)


if __name__ == '__main__':
    main()

Measured memory_bytes: 6988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    ll n,cnt=0,ans=0;cin>>n;
    vector<ll> v(n);

    rep(i,n)cin>>v[i];

    for(int i=n-2;-1 < i;i--)
    {
        if(v[i]>=v[i+1]){
            cnt++;
            ans=max(ans,cnt);
        }else{
            cnt=0;
        }
    }
    ans=max(ans,cnt);

    cout<<ans<<endl;
}

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

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

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

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

int main(){
    ll a, b, k; cin>>a>>b>>k;
    for(int i=0; i<k; i++){
        if(i%2==0){
            if(a%2==1) a--;
            b+=a/2, a/=2;
        }
        else{
            if(b%2==1) b--;
            a+=b/2, b/=2;
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>

using namespace std;

int main()
{
	string a;
	cin >> a;
	for(int i = 0; i <= a.size()-1; ++i)
	{
		if(a[i] == 'C')
		{
			for(int j = i; j <= a.size()-1; ++j)
			{
				if(a[j] == 'F')
				{
					cout << "Yes";
					return 0; 
				}
			}
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x1 = scanner.nextInt(), y1 = scanner.nextInt();
			int x2 = scanner.nextInt(), y2 = scanner.nextInt();
			int xDiff = x2 - x1, yDiff = y2 - y1;
			System.out.println((x2 - yDiff) + " " + (y2 + xDiff) + " " + (x1 - yDiff) + " " + (y1 + xDiff));
		}
	}
}


Measured memory_bytes: 39732
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;


struct RSQ{
    int n;
    vector<int> dat;
    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat.resize(2 * n - 1, 0);
        // rep(i, 0, 2 * n - 1) dat[i] = MAX;
    }
    void add(int k, int a){
        k += n - 1;
        dat[k] += a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = dat[2 * k + 1] + dat[2 * k + 2];
        }
    }
    //get sum of[a, b) query(a, b, 0, 0, rq.n)
    int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    RSQ r;
    r.init(n);
    rep(i, 0, q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            r.add(x - 1, y);
        }else{
            cout << r.query(x - 1, y, 0, 0, r.n) << endl;
        }
    }
    // rep(i, 0, 15){
    //     cout << i << ' ' << r.dat[i] << endl;
    // }
}

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

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

  if (e-a < k+1){
      cout << "Yay!" << endl;
  }
  else  {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); ++i)
int main(){
    int n; cin >> n;
    rep(i,9) rep(j,9){
        if(n == (i+1)*(j+1)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var AB = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var A = AB[0];
            var B = AB[1];
            if(A<=(B/K*K))
            {
                Console.WriteLine("OK");
                return;
            }
                Console.WriteLine("NG");
        }
    }
}

Measured memory_bytes: 19116
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("ABC")) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 35484
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

string S;
int K;
int dp[110][2][4];

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

    cin >> S >> K;
    dp[0][0][0] = 1;
    REP (i, S.size()) REP (k, K + 1) {
        if (S[i] == '0') {
            dp[i + 1][0][k] += dp[i][0][k];
        } else {
            REP (d, S[i] - '0' + 1) {
                if (d == 0) dp[i + 1][1][k] += dp[i][0][k];
                else if (d < S[i] - '0' && k + 1 <= K) dp[i + 1][1][k + 1] += dp[i][0][k];
                else if (k + 1 <= K) dp[i + 1][0][k + 1] += dp[i][0][k];
            }
        }
        dp[i + 1][1][k] += dp[i][1][k];
        if (k + 1 <= K) FOR (d, 1, 10) dp[i + 1][1][k + 1] += dp[i][1][k];
    }
    cout << dp[S.size()][0][K]  + dp[S.size()][1][K] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int A,B;
  cin >> A >> B;
    if((A>13)||(B>13)){
      return 0;
    }
    if((A<1)||(B<1)){
      return 0;
    }

    if(A==1){
       A=14;
    }
    if(B==1){
       B=14;
    }


  if(A>B){
     cout << "Alice";
    }
  if(B>A){
     cout << "Bob";
    }
  if(A==B){
    cout << "Draw";
    }

}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int X = stdIn.nextInt();
		int[] L = new int[N];
		int count = 1;
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			L[i] = stdIn.nextInt();
			sum += L[i];
			if(sum <= X) {
				count++;
			}
			else {
				break;
			}
		}
		System.out.println(count);

	}

}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

long long int fac(long long int n){
  long long int m=1;
  while(n>=1) m*=n,m%=1000000007,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  vector<char> v;
  for(char i:s){
    if(i=='B'){
      if(v.size()>0){
        v.pop_back();
      }
    }else{
      v.push_back(i);
    }
  }
  rep(i,v.size()) cout<<v[i];
  cout<<endl;
}
///////////////////////////




Measured memory_bytes: 256
n = gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i);

max_lcm = 1
as.each do |a|
  next if max_lcm % a == 0
  max_lcm = a.lcm(max_lcm)
end

count = 0
as.each do |a|
  count += max_lcm / a
end

puts count % (10**9 + 7)

Measured memory_bytes: 63676
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

int main(int argc, char* argv[]) {
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;

	vector<int> l(k);

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'o') {
			l[cnt] = i;
			cnt++;
			i += c;
		}

		if (cnt == k) {
			break;
		}

	}

	cnt = k - 1;
	vector<int> r(k);
	for (int i = n-1; i >= 0; i--) {
		if (s[i] == 'o') {
			r[cnt] = i;
			cnt--;
			i -= c;
		}
		if (cnt < 0) {
			break;
		}

	}


	

	for (int i = 0; i < k; i++) {
		if (l[i] == r[i]) {
			cout << l[i] + 1 << endl;
		}
	}
	
}

Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll n,q;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    cin >> q;
    vector<ll>b(q),c(q);
    rep(i,q)cin >> b[i] >> c[i];
    vector<ll>data(2000000);
    rep(i,2000000)data[i] = 0;
    rep(i,n)data[a[i]]++;
    ll sum = 0;
    rep(i,n)sum += a[i];

    rep(i,q){
        sum -= data[b[i]] * b[i];
        sum += data[b[i]] * c[i];
        data[c[i]] += data[b[i]];
        data[b[i]] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 21208
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		System.out.println((N + X - 1) / X * T);
	}
}


Measured memory_bytes: 35768
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);

    ll i,j,h,ans;
    ll Q,K,P,C,N,X,A,B;
    ll pi = M_PI;
    long double H,M, kh,km;

    string S;
    map<long double, ll> m;
    vector<ll> aa,bb;
  
    
    cin>>N;
    
    
    rep(i,N){
        cin >> h>>Q;
        aa.push_back(h); 
        bb.push_back(Q);

    }
    

    sort(aa.begin(), aa.end());
    sort(bb.begin(), bb.end() ,std::greater<int>());
    
    if(N%2==1){
        ans=bb[(N+1)/2-1]-aa[(N+1)/2-1]+1;
    }else{
        ans=(bb[N/2-1]+bb[(N/2)]) -(aa[N/2-1]+aa[(N/2)]) +1;
      
    }

    cout <<setprecision(20)<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 6632
'use strict'

function Main(input) {
  const list = input.split("").map(x => Number(x));
  let total = 0;

  for(let i=0; i<list.length; i++) {
    total += list[i];
  }

  if(total === 1) {
    console.log(10);
  } else {
    console.log(total);
  }

}

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

Measured memory_bytes: 22076
N = int(input())
W = list(map(int, input().split()))
ans = 100000
s1 = 0
s2 = 0

for i in range(1, N):
    s1 = sum([x for x in W[:i]])
    s2 = sum([x for x in W[i:]])
    ans = min(ans, abs(s1-s2))

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MAXN 200000
using namespace std;
typedef long long ll;
int N,K;
ll H[MAXN];
int cmp(ll x,ll y)
{
    return x > y;
}
int main()
{
    cin>>N>>K;
    for(int i =0 ;i <N;i ++)
    {
        cin>>H[i];
    }
    sort(H,H+N,cmp);
    ll ret = 0;
    for(int i = N-1;i >= K;i --)
        ret += H[i];
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws Exception {
		int antenna[] = new int[5];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for(int i=0; i<antenna.length; i++) {
			antenna[i] = Integer.parseInt(br.readLine());
		}
		int k = Integer.parseInt(br.readLine());

		if(antenna[4] -antenna[0] > k) {
			System.out.println(":(");
		}else {
			System.out.println("Yay!");
		}
	}

}


Measured memory_bytes: 21332
'use strict'
const Main=input=>{
    const num=parseInt(input);
    let sum=0;
    for(let i=1;i<num+1;i++){
        if(!(i%3==0||i%5==0)){
            sum+=i;
        }
    }
    
    console.log(sum);
}

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

Measured memory_bytes: 35144
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;

map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int i = 0; i < INF; i++) {
		string str;
		cin >> str;
		int ans = 0;
		if (str == "0") break;
		for (int j = 0; j < str.size(); j++) {
			ans += (str.at(j) - '0');
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
#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 a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3) << endl;
    
    return 0;
}

Measured memory_bytes: 4284
#include <stdio.h>

typedef struct {
	char t, d;
} Query;

int n, q;
char grid[200005];
Query query[200005];

int simulation(char mode);

int main()
{
	int left_fall, right_fall;

	scanf("%d %d", &n, &q);
	scanf("%s", grid + 1);
	for (int i = 0; i < q; i++) {
		scanf(" %c %c", &query[i].t, &query[i].d);
	}

	left_fall = simulation('L');
	right_fall = simulation('R');

	printf("%d\n", right_fall - left_fall - 1);

	return 0;
}

int simulation(char mode)
{
	int position = (mode == 'L' ? 0 : n + 1);

	for (int i = q - 1; i >= 0; i--) {

		if (mode == 'L') {
			if (query[i].d == 'L' && query[i].t == grid[position + 1]) {
				position++;
			}
			else if (query[i].d == 'R' && query[i].t == grid[position]) {
				position--;
			}
		} else {
			if (query[i].d == 'L' && query[i].t == grid[position]) {
				position++;
			}
			else if (query[i].d == 'R' && position > 0 && query[i].t == grid[position - 1]) {
				position--;
			}
		}
	}

	return position;
}


Measured memory_bytes: 768
#!/usr/bin/env python3
import sys
from math import ceil


def solve(A: int, B: int):
    ans = 0
    outlet = 1
    while B > outlet:
        outlet += (A - 1)
        ans += 1
    print(ans)
    return


# Generated by 1.1.7.1 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 lli long long int
int main()
{
    lli n;
    cin>>n;
    lli dp[3][n],a[n],b[n],c[n];
    for(lli i=0;i<n;i++)
    {
    	cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    for(lli i=1;i<n;i++)
    {
    	dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
    	dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
    	dp[2][i]=c[i]+max(dp[0][i-1],dp[1][i-1]);
    }
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<endl;
    return 0;
}

Measured memory_bytes: 8264
S=input()
div=["maerd","remaerd","esare","resare"]
S=S[::-1]
judge=True
cnt=0
while cnt<len(S):
    can=False
    for j in range(4):
        d=div[j]
        if S[cnt:len(d)+cnt]==d:
            can=True
            cnt+=len(d)
    if not can:
        judge=False
        break
if judge:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include <iostream>

const long long mod = 1e9 + 7;
using namespace std;
long long a[10000];

int main() {
    long long n, k;
    cin >> n >> k;
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long sum = 0;
    for (long long i = 0; i < n; ++i) {
        long long before_i = 0, after_i = 0;
        for (long long j = 0; j < n; ++j) {
            if (i == j) continue;
            else {
                if (a[i] > a[j]) {
                    if (j < i) before_i++;
                    else after_i++;
                }
            }
        }
        sum += (after_i % mod) * (k * (k + 1)  / 2 % mod) % mod;
        sum += (before_i % mod) * (k * (k - 1) / 2 % mod) % mod;
    }
    cout << sum % mod << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
s = raw_input()

cnt =0
x =[0]
for i in xrange(n):
    if s[i] == 'I':
        cnt += 1
        x.append(cnt)
    elif s[i]  == 'D':
        cnt -= 1
        x.append(cnt)

print max(x)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
int const N = 1000006;
ll const M = 998244353;
long double const ep = .000000000000000001;
ll arr[N];
int main() {
	

	int a , x;
	cin >> a >> x;
	ll sum = 0 ; 
	for(int i = 0 ; i <a ; i++){cin >> arr[i];sum += arr[i];}
	if(sum == x){
		printf("%d\n", a);
		return 0;
	}
	if(x > sum){
		printf("%d\n", a - 1);
		return 0;
	}

	sort(arr , arr+ a);
	for(int i = 0 ; i < a ;i++){
		if(arr[i] <= x ){
			x -= arr[i];
		}else {printf("%d\n", i);return 0;}
	}
	return 0;	
}

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

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 100005;

bool cmp(pair<int,int> A,pair<int,int> B){
    return A.second < B.second;
}
int main()
{
    FastRead
    vector<pair<int,int>>v;
    int n;
    cin >> n;
    FOR(i,1,n)
    {
        int x , l;
        cin >> x >> l;
        v.push_back(mk(x - l,x + l));
    }
    sort(v.begin(),v.end(),cmp);
    int done = -2e9;
    int ans = 0;
    for(int i = 0;i < v.size();i++){
        if(v[i].first >= done){
            ans++;
            done = v[i].second;
        }
    }
    cout << ans << "\n";

}



Measured memory_bytes: 1400
from sys import stdin
import math

A, B, H, M = [int(x) for x in stdin.readline().rstrip().split()]

H %= 12

short = M*6
long = (H*60+M)/2.0

dif = abs(short-long)
angle = min(dif, 360 - dif)

length = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(angle)))

print(length)

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int) 3e5 + 7;
int n;
int dif;
int a[N];
int t[4 * N];

void upd(int v, int tl, int tr, int i, int x)
{
    if (tr < i || i < tl)
    {
        return;
    }
    if (tl == tr)
    {
        t[v] = x;
        return;
    }
    int tm = (tl + tr) / 2;
    upd(2 * v, tl, tm, i, x);
    upd(2 * v + 1, tm + 1, tr, i, x);
    t[v] = max(t[2 * v], t[2 * v + 1]);
}

int get(int v, int tl, int tr, int l, int r)
{
    if (tr < l || r < tl)
    {
        return 0;
    }
    if (l <= tl && tr <= r)
    {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(get(2 * v, tl, tm, l, r), get(2 * v + 1, tm + 1, tr, l, r));
}

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

    cin >> n >> dif;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int sol = 0;
    for (int i = 1; i <= n; i++)
    {
        int l = max(0, a[i] - dif);
        int r = min((int) 3e5, a[i] + dif);
        int dp = 1 + get(1, 0, (int) 3e5, l, r);
        upd(1, 0, (int) 3e5, a[i], dp);
        sol = max(sol, dp);
    }
    cout << sol << "\n";
}


Measured memory_bytes: 8928
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint N, M;
llint dp[305][305][305];
bool valid[305][305][305];

int main(void)
{
	cin >> N >> M;
	
	llint l, r, x;
	for(int k = 0; k < M; k++){
		cin >> l >> r >> x;
		for(int i = 0; i < r; i++){
			for(int j = 0; j < r; j++){
				if(i > j) continue;
				if(x == 3 && l > i)
					valid[i][j][r] = valid[i][r][j] = valid[j][i][r] = valid[j][r][i] = valid[r][i][j] = valid[r][j][i] = true;
				if(x == 2 && (l <= i || l > j))
					valid[i][j][r] = valid[i][r][j] = valid[j][i][r] = valid[j][r][i] = valid[r][i][j] = valid[r][j][i] = true;
				if(x == 1 && l <= j)
					valid[i][j][r] = valid[i][r][j] = valid[j][i][r] = valid[j][r][i] = valid[r][i][j] = valid[r][j][i] = true;
			}
		}
	}
	
	dp[1][0][0] = dp[0][1][0] = dp[0][0][1] = 1;
	for(int k = 1; k < N; k++){
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				if(valid[k][i][j]) dp[k][i][j] = 0;
				dp[k+1][i][j] += dp[k][i][j], dp[k+1][i][j] %= mod;
				dp[k][k+1][j] += dp[k][i][j], dp[k][k+1][j] %= mod;
				dp[k][i][k+1] += dp[k][i][j], dp[k][i][k+1] %= mod;
				
				if(valid[i][k][j]) dp[i][k][j] = 0;
				dp[k+1][k][j] += dp[i][k][j], dp[k+1][k][j] %= mod;
				dp[i][k+1][j] += dp[i][k][j], dp[i][k+1][j] %= mod;
				dp[i][k][k+1] += dp[i][k][j], dp[i][k][k+1] %= mod;
				
				if(valid[i][j][k]) dp[i][j][k] = 0;
				dp[k+1][j][k] += dp[i][j][k], dp[k+1][j][k] %= mod;
				dp[i][k+1][k] += dp[i][j][k], dp[i][k+1][k] %= mod;
				dp[i][j][k+1] += dp[i][j][k], dp[i][j][k+1] %= mod;
			}
		}
	}
	
	llint ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(!valid[N][i][j]) ans += dp[N][i][j], ans %= mod;
			if(!valid[i][N][j]) ans += dp[i][N][j], ans %= mod;
			if(!valid[i][j][N]) ans += dp[i][j][N], ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 248064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int s,w; cin >> s >> w;
    if(s<=w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 3660
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	a, b := scanInt(sc), scanInt(sc)
	if 0 < a {
		fmt.Println("Positive")
		return
	}
	if 0 <= b {
		fmt.Println("Zero")
		return
	}
	nums := b - a + 1
	if nums%2 == 0 {
		fmt.Println("Positive")
	} else {
		fmt.Println("Negative")
	}
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
//@@@@@@@@@@ JAI BAJRANG BALI @@@@@@@@@

// COMPILE BY:) NAMAN


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define maxn 10000001
#define endl "\n"
#define inf INT_MAX
#define vec vector <ll>
#define mps map <ll,ll>
#define ppl vector<pair<ll,ll>> 
#define fi first
#define si second
#define pr pair<ll,ll> 
#define mvec map<ll,vector <ll>>
#define all(v) v.begin(),v.end()
#define infi LLONG_MAX
#define pi 3.141592653
#define ninf INT_MIN
#define ninfi LLONG_MIN
#define lbn lower_bound
#define ubn upper_bound
#define memset(a,b) memset(a,(b),sizeof(a))
  
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    	cout<<k<<endl;
    else
    {
    	ll rem=k-a;
    	if(rem<=b)
    		cout<<a<<endl;
    	else
    	{
    		rem=rem-b;
    		cout<<a-rem<<endl;
    	}
    }

return 0;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

#define INF (1000000000)

int main()
{
    int N,M;

    cin >> N >> M;

    long long D[N];

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

    long long C[M];

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

    long long dp[M][2];

    dp[0][0]=C[0]*D[0];
    for(int i=1; i<M; ++i) dp[i][0]=min(dp[i-1][0],C[i]*D[0]);

    for(int town=1; town<N; ++town) {
        for(int day=0; day<M; ++day) {
            if(day<town) dp[day][town%2]=INF;
            else dp[day][town%2]=min(dp[day-1][town%2],dp[day-1][(town+1)%2]+C[day]*D[town]);
        }
    }

    cout << dp[M-1][(N-1)%2] << endl;



    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=2010;
const int Inf=1e9;
int n,tot=1,head[N<<1],vs,vt;
struct edge{int v,f,w,next;}e[N*20];

inline void add(int u,int v,int f,int w)
{
	e[++tot]=edge{v,f,w,head[u]};head[u]=tot;
	e[++tot]=edge{u,0,-w,head[v]};head[v]=tot;
}

int cur[N<<1];ll d[N<<1];bool inq[N<<1];
inline bool bfs()
{static queue<int>q;
	while(!q.empty())q.pop();
	fo(i,1,vt)d[i]=-1e16,cur[i]=inq[i]=0;
	q.push(vs);d[vs]=0;cur[vs]=head[vs];inq[vs]=1;
	while(!q.empty()){
		int u=q.front();q.pop();inq[u]=0;
		fe(i,u){
			int v=e[i].v;
			if(e[i].f&&d[v]<d[u]+e[i].w){
				d[v]=d[u]+e[i].w;
				if(!inq[v]){
					cur[v]=head[v];
					q.push(v),inq[v]=1;
				}
			}
		}
	}
	return d[vt]!=-1e16;
}
int vis[N],tim=0;
int dfs(int u,int a)
{
	if(u==vt||!a)return a;
	int ans=0;vis[u]=tim;
	for(int&i=cur[u];i;i=e[i].next){
		int v=e[i].v,f=e[i].f;
		if(f&&vis[v]!=tim&&d[v]==d[u]+e[i].w){
			f=dfs(v,min(f,a));
			if(!f)continue;
			e[i].f-=f;e[i^1].f+=f;
			ans+=f;a-=f;if(!a)break;
		}
	}
	return ans;
}

int main()
{
	n=rd();vs=n+n+5;vt=vs+1;
	fo(i,1,n){
		int x=rd(),y=rd(),z=rd();
		add(vs,i,z,0);
		add(i,n+n+1,Inf,x+y);
		add(i,n+n+2,Inf,x-y);
		add(i,n+n+3,Inf,y-x);
		add(i,n+n+4,Inf,-x-y);
	}
	fo(i,1,n){
		int x=rd(),y=rd(),z=rd();
		x=-x;y=-y;
		add(i+n,vt,z,0);
		add(n+n+1,n+i,Inf,x+y);
		add(n+n+2,n+i,Inf,x-y);
		add(n+n+3,n+i,Inf,y-x);
		add(n+n+4,n+i,Inf,-x-y);
	}
	ll ans=0;
	while(bfs()){
//		while(1){
			++tim;
			int f=dfs(vs,Inf);
			ans+=d[vt]*f;
//			if(!f)break;
//		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main {
	static int r;
	static int c;
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
      
        while(true){
        	 r = scan.nextInt();
        	 c = scan.nextInt();
        	if((r|c)==0)break;
        	int [][] os=new int[r][c];
        	
        	for(int i=0;i<r;i++)
        		for(int j=0;j<c;j++)
        			os[i][j]=scan.nextInt();
        	int max=0;
        	for(int i=0;i<Math.pow(2,r);i++){
        		int [] flip =new int[10];
        		for(int j=0;j<r;j++)
        			if((i>>j&1)==1)flip[j]=1;
        		int ans=0;
        		for(int j=0;j<c;j++){
        			int surf=0;
        			for(int k=0;k<r;k++)
        				if((os[k][j] ^ flip[k]) == 1)surf++;
        				if(surf<r - surf)
        					ans+=r - surf;
        				else ans+=surf;
        		
        		max = Math.max(ans,max);
        		}
        	}
        	System.out.println(max);
        }
    }
}

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

#define llint long long int

using namespace std;

int main(){
    int A, B, C;

    cin >> A >> B >> C;

    if(A == B && B != C || A == C && B != C || B == C && A != B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int n,m;
pint e[50];
struct UnionFind{
    int par[50],rank[50]; 
    void init(int n){
        for (int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    } 
    int find(int x){
        if (x==par[x]) return (x);
        return (par[x]=find(par[x]));
    }
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    } 
    bool same(int x, int y){
        return (find(x) == find(y));
    } 
};
int main(){
    cin>>n>>m;
    int a,b;
    rep(i,m){
        cin>>a>>b;
        e[i]=mp(a-1,b-1);
    }
    int ans=0;
    rep(i,m){
        UnionFind uf;
        uf.init(n);
        rep(j,m){
            if(i==j) continue;
            uf.unite(e[j].first,e[j].second);
        }
        rep(j,m){
            if(!uf.same(e[j].first,e[j].second)){
                ++ans;break;
                
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int road(int ax,int ay,int bx,int by){
	int answer=0;
	while(bx>ax&&by>ay){
		ax+=1;
		ay+=1;
		answer+=1;
	}
	while(bx<ax&&by<ay){
		ax-=1;
		ay-=1;
		answer+=1;
	}
	while(bx>ax){
		ax+=1;
		answer+=1;
	}
	while(by>ay){
		ay+=1;
		answer+=1;
	}
	while(bx<ax){
		ax-=1;
		answer+=1;
	}
	while(by<ay){
		ay-=1;
		answer+=1;
	}
	return answer;
}
int main() {
	int W,H,N,Sx[1000],Sy[1000],walk=0;
	cin >> W >> H >> N;
	for(int i=0;i<N;i++){
		cin >> Sx[i] >> Sy[i];
		if(i!=0) walk+=road(Sx[i-1],Sy[i-1],Sx[i],Sy[i]);
	}
	cout << walk << endl;
	return 0;
}

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

int main(){
    int N,W; cin>>N>>W;
    vector<int> w(N+1),v(N+1);
    rep(i,N) cin>>w[i+1]>>v[i+1];

    // vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
    ll dp[2][W+1];
    rep(i,2)rep(j,W+1) dp[i][j]=0;

    int i01=0;
    for(int i=1; i<=N; i++){
        i01 ^=1;
        for(int j=1; j<=W; j++){
            if(j-w[i]<0){
                dp[i01][j] = dp[i01^1][j];
                continue;
            }
            dp[i01][j] = max(dp[i01^1][j], dp[i01^1][j-w[i]]+v[i]);
        }
    }
    cout << dp[i01][W] << endl;

    // for(int i=0; i<=N; i++){
    //     for(int j=0; j<=W; j++){
    //         cerr << dp[i][j] << " ";
    //     }
    //     cerr << endl;
    // }
}


Measured memory_bytes: 5096
#include <stdio.h>
#include <ctype.h>

#define MAX_N 2000001
#define MAX_K 10001

char buf[MAX_N*5];

int getInteger();
void countingSort(int,int*);

int main(){
  int a,i;
  static int A[MAX_N];
  fread(buf,1,MAX_N*5,stdin);
  a = getInteger();
  for(i = 0 ; i < a ; i++){
    A[i] = getInteger();
  }
  countingSort(a,A);
  return 0;
}

int getInteger(){
  int res = 0;
  static int c = 0;
  while(isdigit(buf[c])){
    res *= 10;
    res += (buf[c++]-'0');
  }
  c++;
  return res;
}

void countingSort(int a,int *A){
  int i,C[MAX_K] = {0};
  static int B[MAX_N];
  
  for(i = 0; i < a;i++){
    C[A[i]]++;
  }
  for(i = 1;i < MAX_K;i++){
    C[i] += C[i-1];
  }
  for(i = a-1 ; i >= 0 ; i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
  for(i = 0;i < a;i++){
    printf("%d%c",B[i+1],i < a-1 ? ' ' : '\n');
  }
}



Measured memory_bytes: 26812
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

const int K = 30;
int x;
int n;
bool a[K + 3];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	x = 0;
	scanf("%d", &n);
	while(n--)
	{
		int y;
		scanf("%d", &y);
		x ^= y;
		int q = 0;
		while(((1 << q) & y) == 0) q++;
		a[q] = 1;
	}
	int ans = 0;
	for (int i = K; i >= 0; i--)
	{
		if (((x >> i) & 1) == 0) continue;
		if (!a[i])
		{
			printf("-1\n");
			return 0;
		}
		ans++;
		for (int j = 0; j <= i; j++)
			x ^= 1 << j;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int sum = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++)
			list.add(sc.nextInt());
		Collections.sort(list);
		for(int i = 0; i < k; i++)
			sum += list.get(i);
		System.out.println(sum);
	}
}


Measured memory_bytes: 38932
// ConsoleApplication4.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int ch['z'+1] = {0};
	for (int i = 0;s[i]!='\0'; i++)
	{
		ch[s[i]]++;
	}
	for (char i = 'a'; i <= 'z'; i++)
	{
		if (ch[i] == 0) {
			cout << i;
			return 0;
		}
	}
	cout << "None";
}



Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    int n,k,p[1001],i,j,sum;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int x;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(p[i]>p[j]){
                x=p[i];
                p[i]=p[j];
                p[j]=x;
            }
        }
    }
    sum=0;
    for(i=0;i<k;i++) sum+=p[i];
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 1708
qsort [] = []
qsort (n:xs) = qsort gteq ++ [n] ++ qsort lt
  where
    lt = [x| x <- xs, x < n]
    gteq = [x| x <- xs, x >= n]

main = do
  [_, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  print $ sum $ take k $ qsort (as::[Int])

Measured memory_bytes: 764
import java.util.*;

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

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		Character[] n = new Character[3];

		for (int i = 0; i < 3; i++) {
			n[i] = s.charAt(i);
		}
		if (Arrays.asList(n).contains('a') && Arrays.asList(n).contains('b') && Arrays.asList(n).contains('c')) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,ll>;
const ll inf=1000000000007;
const int mod=1000000007;


int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
};


int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,0,n) cin >> a[i];
  int val=a[0];
  rep(i,1,n){
    val=gcd(val,a[i]);
  }
  cout << val << endl;
  return 0;

}


Measured memory_bytes: 3780
class program
{
	static void Main()
	{
		bool test = true;
		string[] line1 = System.Console.ReadLine().Split(' ');
		string[] line2 = System.Console.ReadLine().Split(' ');
		string hozon;
		for(int z=0;z<int.Parse(line1[0]);z++){
			int max=0;
			int za = 0;
			for(int v=z;v<line2.Length;v++){
				if(max<=int.Parse(line2[v])){
					max = int.Parse(line2[v]);
					za = v;
				}
			}
			hozon = line2[z];
			line2[z] = max.ToString();
			line2[za] = hozon;
			
		}
		double soutoku = 0;
		for(int x=0;x<int.Parse(line1[0]);x++){
			soutoku = soutoku + int.Parse(line2[x]);
		}
		for(int y=0;y<int.Parse(line1[1]);y++){
			if(soutoku/(4.0*double.Parse(line1[1]))<=double.Parse(line2[y])){
				test = true;
			}else{
				test = false;
				break;
			}
		}
		if(test){
			System.Console.WriteLine("Yes");
		}else{
			System.Console.WriteLine("No");
		}
	}



}

Measured memory_bytes: 13140
/*                        
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************
   
   
   
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE 
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
 
*/     

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {
    
    FASTIO;
    
    ll a, b, c;
    cin >> a >> b >> c;
    
    if(b*c>=a) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
	return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int N, L;
int a[100000];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> L;
	rep(i, N) { cin >> a[i]; }
	bool ok = false;
	int idx = -1;
	rep(i, N - 1)if (a[i] + a[i + 1] >= L) {
		ok = true;
		idx = i + 1;
		break;
	}
	if (ok) {
		cout << "Possible" << endl;
		for (int i = 1; i < idx; i++) 
			cout << i << '\n';
		for (int i = N-1; i > idx ;i--) 
			cout << i << '\n';		
		cout << idx << endl;
	}
	else {
		cout << "Impossible" << endl;
	}


	return 0;
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

N = int(input())
A = list(map(int, input().split()))

## Logic

ans = 0
while True:
    for i in range(0,N):
        if A[i]%2==1:
            print(ans)
            sys.exit()
        else:
            A[i]=A[i]//2
            if i==N-1:
                ans+=1


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

string s, ans; int k;
int like[11];

bool solve(int pos, int big) {
	if(pos >= (int)s.size()) return true;
	if(big) {
		for(int i = 0; i < 10; i++) if(like[i]) {
			ans += (char)('0' + i);
			int got = solve(pos + 1, 1);
			return got;
		}
	}
	for(int i = s[pos] - '0'; i < 10; i++) if(like[i]) {
		ans += (char)('0' + i);
		int got = solve(pos + 1, i > s[pos] - '0');
		return got;
	}
	return false;
}

int main() {
	for(int i = 0; i < 10; i++) like[i] = 1;

	cin >> s >> k;
	while(k--) {
		int x; cin >> x;
		like[x] = 0;
	}
	if(solve(0,0)) cout << ans << "\n";
	else {
		ans = "";
		for(int i = 1; i < 10; i++) if(like[i]) {
			ans += (char)('0' + i);
			break;
		}
		solve(0,1);
		cout << ans << "\n";
	}
	return 0;
}

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


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  cout<<min(b/a,c);
}

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

int n, k, a, g, m = -1;
int main() {
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++) {
        scanf("%d", &a);
        g = __gcd(a, g);
        m = max(m, a);
    }
    if(k <= m && k % g == 0) printf("POSSIBLE");
    else printf("IMPOSSIBLE");
}


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


int main(){
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            ans++;
        }
    }

    if(ans<=1 || ans ==3){
        cout << ans << endl;
    }else{
        if(s[1]=='S'){
            cout << 1 << endl;
        }else{
            cout << ans << endl;
        }
    }
}



Measured memory_bytes: 3588
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let k: usize = sc.read();
    let mut ans: i64 = 0;
    for i in 1..k + 1 {
        for j in 1..k + 1 {
            for k in 1..k + 1 {
                ans += gcd(i as i64, gcd(j as i64, k as i64));
            }
        }
    }
    println!("{}", ans);
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2164