akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  int n, k;
  cin>>n>>k;
  cin>>s;
  vector<int> len;
  int i = 0;
  while (i < n) {
    int j = i;
    while (i < n && s[i] == s[j]) {
      ++i;
    }
    len.push_back(i - j);
  }
  if (len.size() <= 2 * k + 1) {
    cout<<n - 1<<endl;
    return 0;
  }
  int acc[len.size()+1];
  acc[0] = 0;
  for (int i=0; i<len.size(); i++) {
    acc[i+1] = acc[i] + len[i];
  }
  int ans = 0;
  for (int i=0; i+2*k+1<len.size()+1; i++) {
    int tmp = 0;
    if (i != 0) {
      tmp = acc[i-1] - (i - 1);
    }
    tmp += acc[i+2*k+1] - acc[i] - 1;
    if (i != len.size()) {
      tmp += acc[len.size()] - acc[i+2*k+1] - (len.size() - i - 2 * k - 1);
    }
    ans = max(tmp, ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1272
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

ll pow_mod(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) (res *= a) %= MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

int n, k;
vector<ll> q;
ll dp[2000];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	scanf("%d%d", &n, &k);
	
	for (int i=1; i<=(int) sqrt(n); i++) {
		if (n % i == 0) {
			q.pb(i);
			if (i * i != n) q.pb(n / i);
		}
	}
	
	sort(q.begin(), q.end());
	dp[0] = k;
	
	for (int i=1; i<q.size(); i++) {
		dp[i] = pow_mod(k, (q[i] + 1) / 2);
		for (int j=0; j<i; j++) {
			if (q[i] % q[j] == 0) {
				dp[i] = (dp[i] - dp[j] + MOD) % MOD;
			}
		}
	}
	
	ll ans = 0;
	for (int i=0; i<q.size(); i++) {
//		cout << q[i] << " " << dp[i] << endl;
//		cout << dp[i] << endl;
		if (q[i] % 2) {
			(ans += dp[i] * q[i]) %= MOD;
		}
		else {
			(ans += dp[i] * (q[i] / 2ll)) %= MOD;
		}
	}
	
	printf("%lld", ans);

	return 0;
}


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

int main(){
  vector<string> vec(3);
  for(string &x:vec){
	cin>>x;
  }
  for(int i=0;i<3;i++){
	transform(vec[i].begin(),vec[i].end(),vec[i].begin(),::toupper);
    cout<<vec[i].at(0);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;

const int N = 6e5 + 5;
int t;

int main()
{
	int a, b, c, k;
	while (cin >> a >> b >> c >> k)
	{
		if (a + b >= k)cout << min(a,k)<< endl;
		else
		{
			int re = k - a - b;
			cout << a - re << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

typedef struct{
  int t,b,n,w,s,e;
}dice;

typedef struct{
  int x,y;
  int cost;
  dice d;
}state;


main(){
  int h,w;
  while(cin>>h>>w,h|w){
    int cost[h][w][6*6];
    rep(i,h)rep(j,w)rep(k,36)cost[i][j][k]=INT_MAX;

    dice td;
    td.t=1;
    td.b=6;
    td.s=2;
    td.n=5;
    td.e=3;
    td.w=4;

    int pen[h][w];
    rep(i,h)rep(j,w)cin>>pen[i][j];
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;

    queue<state> Q;
    state tstate={sx,sy,0,td};
    Q.push(tstate);
    cost[sx][sy][4]=0;

    int ans=INT_MAX;

    while(!Q.empty()){
      tstate=Q.front();Q.pop();

      int cx=tstate.x,cy=tstate.y;
      int ccost=tstate.cost;
      dice cd=tstate.d;
      if(ccost>ans)continue;
      if(cx==gx && cy==gy){
	ans=ccost;
	continue;
      }

      rep(i,4){
	int nx=cx+dx[i],ny=cy+dy[i];
	if(nx<0 || ny<0 || h<=nx || w<=ny)continue;
	dice nd=cd;
	int t=nd.t;
	switch(i){
	case 0://e
	  nd.t=nd.w;
	  nd.w=nd.b;
	  nd.b=nd.e;
	  nd.e=t;
	  break;
	case 1://s
	  nd.t=nd.n;
	  nd.n=nd.b;
	  nd.b=nd.s;
	  nd.s=t;
	  break;
	case 2://w
	  nd.t=nd.e;
	  nd.e=nd.b;
	  nd.b=nd.w;
	  nd.w=t;
	  break;
	case 3://n
	  nd.t=nd.s;
	  nd.s=nd.b;
	  nd.b=nd.n;
	  nd.n=t;
	  break;
	}
	int ncost=ccost+nd.b*pen[nx][ny];
	int dst=(nd.t-1)*6+nd.n-1;
	if(cost[nx][ny][dst]<=ncost)continue;
	cost[nx][ny][dst]=ncost;
	tstate.x=nx;
	tstate.y=ny;
	tstate.cost=ncost;
	tstate.d=nd;
	Q.push(tstate);
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 960
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
s=[0]*(n+1)
for i in range(n):s[i+1]=s[i]+a[i]
d=defaultdict(int)
for i in range(n+1):d[s[i]]+=1
r=0
for v in d.values():
  r+=int(v*(v-1)/2)
print(r)

Measured memory_bytes: 41752
STRI = input()
DICT = STRI.split()
A=int(DICT[0])
B=int(DICT[1])
K=int(DICT[2])

cA = A
cB = B

if A+B <= K:
    cA = 0
    cB = 0
else:
    if A >= K:
        if A == K:
            cA = 0
        elif A > K:
            cA = A - K
    else:
        cA = 0
        if A+B <= K:
            cA = 0
            cB = 0
        else:
            cB = B - (K - A)

print(cA,cB)

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

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println(1);
            return;
        }
        for (int i = 0; i < n; i++) {
            int tmp = (i + 1) * (i + 1);
            if (tmp > n) {
                System.out.println(i * i);
                return;
            }
        }
    }
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long long INF=1LL<<60;
const long double PI=3.1415926535897932;

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define umap unordered_map
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())


//pow
template<typename Num>
constexpr Num mypow(Num a, long long b) {
    if(b==0)return 1;
    if (a==0)return 0;
    Num x = 1;
    while (b > 0) {
        if(b & 1)x*=a;
        a*=a;
        b >>= 1;
        }
    return x;
}

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

    struct UnionFind {
        vector<int> par;
    
        UnionFind(int n) : par(n, -1) { }
    
        int root(int x) {
            if (par[x] < 0) return x;
            else return par[x] = root(par[x]);
        }
    
        bool issame(int x, int y) {
            return root(x) == root(y);
        }
    
        bool merge(int x, int y) {
            x = root(x); y = root(y);
            if (x == y) return false;
            if (par[x] > par[y]) swap(x, y); // merge technique
            par[x] += par[y];
            par[y] = x;
            return true;
        }
    
        int size(int x) {
            return -par[root(x)];
        }
    };

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,m,k;
        cin>>n>>m>>k;
        UnionFind F(n);
        vector<map<ll,ll>> ng(n);
        rep(i,m){
            ll a,b;
            cin>>a>>b;
            a--;b--;
            F.merge(a,b);
            ng[a][b]++;
            ng[b][a]++;
        }
        rep(i,k){
            ll c,d;
            cin>>c>>d;
            c--;d--;
            if(F.issame(c,d)){
                ng[c][d]++;
                ng[d][c]++;
            }
        }
        rep(i,n){
            cout<<F.size(i)-Size(ng[i])-1<<" ";
        }
        cout<<endl;
    }

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

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

		long x = -1, M = -1, t;
		for (int i = 0; i < n; i++)
		{
			if ((t = Math.Abs(a[i])) > M)
			{
				x = i;
				M = t;
			}
		}

		var r = new string[0].ToList();
		if (a[x] >= 0)
		{
			for (int i = 1; i < n; i++)
			{
				while (a[i - 1] > a[i])
				{
					a[i] += a[x];
					r.Add($"{x + 1} {i + 1}");
				}
				if (a[i] > a[x]) x = i;
			}
		}
		else
		{
			for (int i = n - 2; i >= 0; i--)
			{
				while (a[i] > a[i + 1])
				{
					a[i] += a[x];
					r.Add($"{x + 1} {i + 1}");
				}
				if (a[i] < a[x]) x = i;
			}
		}

		Console.WriteLine(r.Count);
		Console.WriteLine(string.Join("\n", r));
	}
}


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

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int K, N;
	cin >> N >> K;
	map<int, int> mp;

	int types = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (mp[a] == 0) ++types;
		mp[a]++;
	}
	vector<int> vec;
	for (auto iter = mp.begin(); iter != mp.end(); ++iter) {
		vec.push_back(iter->second);
	}

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

	int count = 0;
	int i = 0;
	for (; K < types; --types) {
		count += vec[i];
		++i;
	}


	cout << count << endl;
	return 0;
}

Measured memory_bytes: 13596
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

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

int main() {
    int x = read();
    int lcm = x * 360 / gcd(x, 360);
    cout << lcm / x << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<stack>
#include<map>
using namespace std;

#define N 1000

#define id(x,y) ((y)*(N+2)+(x))
int parent[(N+2)*(N+2)];
class UnionFind {
	
public:
	void init() {
		for(int i=0; i<N+2; ++i) {
			for(int j=0; j<N+2; ++j) {
				parent[id(j,i)] = id(j,i);
			}
		}
	}
	int find(int x) {
		if(parent[x]==x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		if(find(x)==find(y)) return;
		if(find(x)<find(y)) {
			parent[find(y)] = parent[find(x)];
		}else {
			parent[find(x)] = parent[find(y)];
		}
	}
	bool alone(int x) {
		return find(x)==x;
	}
	bool same(int x, int y) {
		return find(x)==find(y);
	}
};

typedef pair<int, int> P;

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

int main() {
	int w, h, tx[1000], ty[1000], gx, gy, n, ans;
	char map[N+2][N+2];
	UnionFind uf;
	stack<P> s;
	while(cin >> w >> h) {
		for(int i=0; i<h+2; ++i) for(int j=0; j<w+2; ++j) map[i][j] = '#';
		for(int i=1; i<=h; ++i) {
			for(int j=1; j<=w; ++j) {
				cin >> map[i][j];
				if(map[i][j]=='t') {
					gx = j; gy = i;
				}
			}
		}
		uf.init();
		for(int i=1; i<=h; ++i) {
			for(int j=1; j<=w; ++j) {
				if(map[i][j]!='#'&&uf.alone(id(j,i))) {
					s.push(P(j, i));
					while(!s.empty()) {
						int x = s.top().first, y = s.top().second; s.pop();
						for(int k=0; k<4; ++k) {
							if(map[y+dy[k]][x+dx[k]]!='#'&&!uf.same(id(x,y), id(x+dx[k],y+dy[k]))) {
								uf.unite(id(x,y), id(x+dx[k],y+dy[k]));
								s.push(P(x+dx[k],y+dy[k]));
							}
						}
					}
				}				
			}
		}
		ans = -1;
		cin >> n;
		for(int i=0; i<n; ++i) {
			cin >> tx[i] >> ty[i];
			tx[i]++; ty[i]++;
		}
		if(uf.same(id(1,1), id(gx,gy))) ans = 0;
		else for(int i=0; i<n; ++i) {
			if(map[ty[i]][tx[i]]!='#') continue;
			map[ty[i]][tx[i]] = '.';
			for(int k=0; k<4; ++k) {
				if(map[ty[i]+dy[k]][tx[i]+dx[k]]!='#') {
					uf.unite(id(tx[i],ty[i]), id(tx[i]+dx[k],ty[i]+dy[k]));
				}
			}
			if(uf.same(id(1,1), id(gx,gy))) {
				ans = i+1; break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10152
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >>b;
    cout << max(max(a+b,a*b),a-b) << endl;
    
}

Measured memory_bytes: 256
n,k=map(int,input().split())
min_s=10**18

while True:
    if n<k:
        n=abs(n-k)
    n=n%k
    if n>min_s:
        break
    min_s=min(n,min_s)
    if min_s==0:
        break
print(min_s)  

Measured memory_bytes: 9168
object Main extends App {

  override def main(args: Array[String]): Unit = {
    val n = io.StdIn.readLine.toInt
    
    val list = (1 to n).map(_ => io.StdIn.readLine.split(' ')).map(i => new Dice(i(0),i(1),i(2),i(3),i(4),i(5))).toIndexedSeq

    val pairs = for(i <- (0 until n ); j <- (i+1 until n)) yield { (list(i),list(j)) }

    val cond = pairs.exists(p => p._1.isSame(p._2))
    
    if(cond) println("No")
    else println("Yes")
  }

  case class Dice(top: String, south: String, east: String, west: String, north: String, buttom: String) {

    def toNorth: Dice = {
      new Dice(south, buttom, east, west, top, north)
    }
    def toSouth: Dice = {
      new Dice(north, top, east, west, buttom, south)
    }
    def toEast: Dice = {
      new Dice(west, south, top, buttom, north, east)
    }
    def toWest: Dice = {
      new Dice(east, south, buttom, top, north, west)
    }
    def rotRight: Dice = {
      new Dice(top, east, north, south, west, buttom)
    }
    def rotLeft: Dice = {
      new Dice(top, west, south, north, east, buttom)
    }

    def getAsTop(toTop: String): List[Dice] =  List(
        if (top == toTop) List(this) else List.empty,
        if (south == toTop) List(toNorth) else List.empty,
        if (north == toTop) List(toSouth) else List.empty,
        if (west == toTop) List(toEast) else List.empty,
        if (east == toTop) List(toWest) else List.empty,
        if (buttom == toTop) List(toEast.toEast) else List.empty
        ).flatten

    def getAsSouthByRot(toSouth: String): List[Dice] = List(
        if (south == toSouth) List(this) else List.empty,
        if (north == toSouth) List(rotLeft.rotLeft) else List.empty,
        if (west == toSouth) List(rotLeft) else List.empty,
        if (east == toSouth) List(rotRight) else List.empty
        ).flatten

    def getAsTopAndSouthIs(top: String, south: String): List[Dice] = {
        getAsTop(top).flatMap(_.getAsSouthByRot(south))
    }
    
    def isSame(target :Dice) : Boolean = {
        getAsTopAndSouthIs(target.top, target.south).exists(rot => rot == target)
    }

  }

}

Measured memory_bytes: 52876
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,m;
    in>>n>>m;
    cout<<(n==m?"Yes":"No")<<endl;
}

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

#define sl1(a)  scanf("%lld",&a)

int main(){
    long long n,ans=0ll;
    sl1(n);
    for (long long  i=1;i<=n;i++)  ans+=(n-1)/i;
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  int ans = 11111111;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (b <= t)
      ans = min(ans, a);
  }
  if (ans > 100000)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
  return 0;
}


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

int main(int argc, char *argv[])
{
	char str1[4];
	char str2[4];
	char str3[4];

	cin >> str1 >> str2 >> str3;

	cout << str1[0] << str2[1] << str3[2] << endl;

	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


class Node(object):
    def __init__(self):
        self.id = None
        self.parent = -1
        self.childs = None


def preorder_walk(data, index, out):
    node = data[index]
    out.append(node.id)
    for cidx in node.childs:
        if cidx >= 0:
            preorder_walk(data, cidx, out)


def inorder_walk(data, index, out):
    cid = data[index].childs[0]
    if cid >= 0:
        inorder_walk(data, cid, out)
    out.append(data[index].id)
    cid = data[index].childs[1]
    if cid >= 0:
        inorder_walk(data, cid, out)


def postorder_wark(data, index, out):
    node = data[index]
    for cidx in node.childs:
        if cidx >= 0:
            postorder_wark(data, cidx, out)
    out.append(node.id)


n = int(stdin.readline())
#assert 1 <= n <= 25
data = [Node() for _ in range(n)]
for _ in range(n):
    idx, left, right = (int(s) for s in stdin.readline().split())
    data[idx].id = idx
    data[idx].childs = [left, right]
    for c in data[idx].childs:
        if c >= 0:
            data[c].parent = idx

start = None
for node in data:
    if node.parent == -1:
        start = node.id
        break

for name, func in (('Preorder\n', preorder_walk),
                   ('Inorder\n', inorder_walk),
                   ('Postorder\n', postorder_wark)):
    out = []
    func(data, start, out)
    print(name, *out)

Measured memory_bytes: 4344
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int K = 33;
const int N = 100;

vector<int> cur;
int used[N + 1];
int cnt = 0;
ll ans = 0;
int a[N + 1];

void go(int pos) {
    ll loc = 0;
    fore(i, 1, N) if (!used[i]) loc += a[i];
    fore(i, 34, 50) {
        ll here = 0;
        if (!used[i]) here += a[i];
        if (!used[2 * i]) here += a[2 * i];
        if (here < 0) loc -= here;
    }
    setmax(ans, loc);
    for (int i = pos; i <= K; ++i) {
        if (used[i]) continue;
        cur.push_back(i);
        for (int j = i; j <= N; j += i)
            ++used[j];
        go(i + 1);
        cur.pop_back();
        for (int j = i; j <= N; j += i)
            --used[j];
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    //go(1);
    //cout << cnt << '\n';
    int n;
    cin >> n;
    fore(i, 1, n) cin >> a[i];
    fore(i, 51, 100) if (a[i] < 0) a[i] = 0;
    go(1);
    cout << ans << '\n';
}


Measured memory_bytes: 384
n = int(input())
s = [input() for i in range(n)]
AC = 0
WA = 0
TLE = 0
RE = 0
for j in range(n):
  if s[j] == 'AC':
    AC += 1
  elif s[j] == 'WA':
    WA += 1
  elif s[j] == 'TLE':
    TLE += 1
  else:
    RE += 1
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Measured memory_bytes: 79124
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    double t,x;
    cin >> t >> x;
  double ans = t/x;
    
    //処理
    //出力
    cout << ans << ENT;
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct UnionFind {
    UnionFind(int n) : p(n, -1) {}
    int root(int u) {
        return p[u] < 0 ? u : p[u] = root(p[u]);
    }
    int size(int u) {
        return -p[root(u)];
    }
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    void unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v];
        p[v] = u;
    }
    vector<int> p;
};

struct P {
    int c[2];
};

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

    int n;
    cin >> n;

    constexpr int M = 1e5;
    UnionFind uf(M * 2);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        uf.unite(x, M + y);
    }

    vector<P> p(M * 2, { 0, 0 });
    for (int j = 0; j < M * 2; j++) {
        p[uf.root(j)].c[j >= M]++;
    }

    ll s = 0;
    for (int j = 0; j < M * 2; j++) {
        s += (ll)p[j].c[0] * p[j].c[1];
    }
    cout << s - n << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; --i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;


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

    double r; cin >> r;
    Dcout(2*M_PI*r);

    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// UnionFindの実装
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }

    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        //要素数の少ない方を多い方に繋げる
        if(data.at(y) < data.at(x)) swap(x, y);
        data.at(x) += data.at(y);
        data.at(y) = x;
        return true;
    }

    // ある要素がどの集合に属しているかを返す
    int root(int x) {
        // 根に直接つなぎ直す
        return data.at(x) < 0 ? x : (data.at(x) = root(data.at(x)));
    }

    // ある集合の大きさを答える
    int size(int x) {
        return -data.at(root(x));
    }

    // ある二つの要素が同じ集合か判定
    bool same(int x, int y) {
        x = root(x); y = root(y);
        return x == y;
    }
};


int n, m;
vector<int> x(100100, 0);
vector<int> y(100100, 0);
vector<int> z(100100, 0);
vector<int> A(100100, 0);

int main() {
    cin >> n >> m;
    UnionFind tree(n);
    for(int i = 0; i < m; ++i) {
        cin >> x.at(i) >> y.at(i) >> z.at(i);
        x.at(i)--; y.at(i)--;
        tree.merge(x.at(i), y.at(i));
    }

    int ans = 0;
    set<int> rcnt;
    for(int i = 0; i < n; ++i) {
        rcnt.insert(tree.root(i));
    }

    ans += rcnt.size();
    cout << ans << endl;
}

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

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

int gcds(vector<int> x){
	int a = x[0];
	for(int i = 1; i < (int)x.size(); i++)
	{
		a = gcd(a, x[i]);
	}
	return a;	
}

int main(){

	int n, X;
	cin >> n >> X;
	vector<int> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
		x[i] = abs(x[i] - X);
	}

	int ans = gcds(x);

	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int N;
int K;
int change=0;
int renzoku = 0;

signed main(void) {
    cin >> N >> K;
    char now;
    cin >> now;
    rep(i,N-1){
        char a;
        cin >> a;
        if(a==now){
            renzoku++;
        }else{
            change++;
            now = a;

        }
    }

    if(K*2 <= change){
        cout << renzoku + K*2 << endl;
    }else{
        cout << N-1 << endl;
    }

    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


using T = long double;
using P = complex<T>;

auto dot(P a, P b) { return real(conj(a)*b); }
auto cross(P a, P b) { return imag(conj(a)*b); }
auto cross(P a, P b, P c) { return cross(b-a, c-a); }

int sgn(auto x) { return (x > 0) - (x < 0); }


#ifdef LOCAL
#include "pretty_debug.h"
#else
#define debug(...) //ignore
#endif

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
  int n,l;
  cin>>n>>l;
  vector<ll> t(n);
  rep(i,0,n) cin>>t[i];

  P ans = 0;
  T cnt = 0;
  rep(i,0,n) rep(j,1,n) {
    ll t0 = t[i];
    ll t1 = t[(i+j)%n];
    T arg = (t0+t1)/(2.0*l);
    P p = polar<T>(1,2*M_PI*arg);
    if(t1 < t0) p = -p;
    T coeff = n-j-1;
    ans += p * coeff;
    cnt += coeff;
  }
  debug(cnt, n*(n-1)*(n-2)/6.0);
  ans /= cnt/3.0;
  cout << setprecision(14);
  cout << real(ans) << " " << imag(ans) << endl;
}


Measured memory_bytes: 256
S = input()
 
cnt = len(S) - 1 #数字の間の数
 
ans = 0
 
for i in range(2 ** cnt):
  sign = [""] * cnt
  for j in range(cnt):
    if ((i>>j)&1):
      sign[j] = "+"
            
  formula = ""      
  for k in range(cnt):
    formula += S[k] + sign[k]
  formula += S[cnt]   
  ans += eval(formula)
print(ans)

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

int main()
{
    int N;
    ll H;
    cin >> N >> H;
    int a[N+3], b[N+3];
    for(int i = 0; i < N; ++i) scanf("%d %d", &a[i], &b[i]);

    sort(a, a + N, [](int &x, int &y){ return x > y;});
    sort(b, b + N, [](int &x, int &y){ return x > y;});
    
    ll cnt = 0;
    ll am = a[0];
    for(cnt = 0; cnt < (ll)N; ++cnt) {
        if(H <= 0) { cout << cnt << endl; return 0; }
        if(b[cnt] < am) break;
        H -= b[cnt];
    }
    if(H >= 0)  cnt += (H % am != 0) ? H/am + 1 : H/am; 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]

  MOD = 10^9+7
   
  s10 = 1 
  s9 = 1
  s8 = 1  
  for i in 1:N
    s10 = mod(s10*10,MOD)
    s9 = mod(s9*9,MOD)
    s8 = mod(s8*8,MOD)
  end
  println(mod(s10 - 2s9 + s8, MOD))
end

main()


Measured memory_bytes: 190396
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
    string str;
    cin>>str;
    if(str=="ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
}

Measured memory_bytes: 3572
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=200010,P=998244353;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
#include<queue>
struct cqz{int x,i;};
priority_queue<int,vector<int>,greater<int> >q;
ll ans,rea[N],reb[N],res;int n,X,Y,Z,a[N],b[N],c[N],id[N];
bool cmp(int i,int j){return a[i]-b[i]>a[j]-b[j];}
int main(){
	int i,k;
	X=read();Y=read();Z=read();
	n=X+Y+Z;
	for(i=1;i<=n;i++)
		a[i]=read(),b[i]=read(),c[i]=read(),ans+=c[i],id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(i=1;i<=n;i++){
		rea[i]=rea[i-1];k=id[i];
		if((int)q.size()<X){
			q.push(a[k]-c[k]);
			rea[i]+=a[k]-c[k];
		}else{
			if(a[k]-c[k]>q.top()){
				rea[i]-=q.top();
				q.pop();q.push(a[k]-c[k]);
				rea[i]+=a[k]-c[k];
			}
		}
	}
	while(q.size())q.pop();
	for(i=n;i;i--){
		reb[i]=reb[i+1];k=id[i];
		if((int)q.size()<Y){
			q.push(b[k]-c[k]);
			reb[i]+=b[k]-c[k];
		}else{
			if(b[k]-c[k]>q.top()){
				reb[i]-=q.top();
				q.pop();q.push(b[k]-c[k]);
				reb[i]+=b[k]-c[k];
			}
		}
	}
	res=-ans;
	for(i=X;n-i>=Y;i++)
		res=max(res,rea[i]+reb[i+1]);
	write(ans+res);puts("");
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) if (scanf("%d", &v)<1);
#define in_s(v) if (scanf("%s", v)<1);
#define out(v) printf("%d\n", v)
const int S = 1, W = 2, EMPTY = -1;

int main() {
  int N; in(N);
  char s[N]; in_s(s);

  int v[N];
  rep(first, 2) rep(second, 2) {
    fill(v, v+N, EMPTY);
    v[0] = first ? W : S;
    v[1] = second ? W : S;
    bool matched = true;
    rep(i, N) {
      int l = i, mid = (i+1)%N, r = (i+2)%N;
      if (s[mid] == 'o' && v[mid] == S || s[mid] == 'x' && v[mid] == W) {
        if (v[r] == EMPTY)
          v[r] = v[l];
        else if (v[r] != v[l]) {
          matched = false;
          break;
        }
      } else {
        if (v[r] == EMPTY)
          v[r] = v[l] == S ? W : S;
        else if (v[r] == v[l]) {
          matched = false;
          break;
        }
      }
    }
    if (matched) {
      rep(i, N)
        printf("%c", v[i] == S ? 'S' : 'W');
      printf("\n");
      return 0;
    }
  }
  printf("-1\n");

  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main()
{
    char s1[100],s2[100],s3[100];
    scanf("%s %s %s",&s1,&s2,&s3);
    s1[0]=(s1[0]-32);
    s2[0]=(s2[0]-32);
    s3[0]=(s3[0]-32);
    printf("%c%c%c\n", s1[0],s2[0],s3[0]);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;

typedef long long ll;

int main(){
	ll n,a,b;

	scanf("%lld%lld%lld", &n, &a, &b);

	ll s = a+b;
	ll ans = (n/s)*a;
	n = n%s;

	ans += min(n,a);

	printf("%lld\n", ans);

	return 0;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  ll n,a,ans;
	cin >> n;
	for(ll i=0;i<5;i++){
		cin >> a;
		if(i==0)ans=a;
		else ans = min(ans,a);
	}
	if(n%ans == 0) cout << n/ans + 4;
	else cout << n/ans + 5;
	return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var pList = Enumerable.Range(1, N)
                .Select(_ => int.Parse(Console.ReadLine()));

            var max = 0;
            var total = 0d;
            foreach (var p in pList)
            {
                max = Math.Max(max, p);
                total += p;
            }

            total -= max * 0.5;

            Console.Write(total);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
 
void solve()
{
	ll n;
	cin>>n;
	vector<ll> a(n),cnt(1e6,0);
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	ll ans=0;
	for(int i=1;i<1e6;i++)
	{
		ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
	}
	cout<<ans;
	return;
}
int main()
{
	fast;
	int q;
	q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 11908
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <queue>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<int> a(n);
    REP(i, 0, n) {
        cin, a[i];
    }
    sort(a.rbegin(), a.rend());
    queue<P> q;
    q.emplace(a[0], 1);

    ll ans = 0;
    int index = 1;
    while (index < n) {
        auto [x, c] = q.front();
        q.pop();
        REP(i, 0, c) {
            if (index >= n) break;
            ans += x;
            dump(a[index], index, c, x, i);
            q.emplace(a[index], 2);
            index++;
        }
    }
    print(ans);

    return 0;
}


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

void solve(long long N)
{
    long long res = 0;

    long long max = static_cast<long long>(sqrt(static_cast<double>(N)));
    for (int i = max; i >= 0; i--)
    {
        if (N % i == 0)
        {
            res = (N / i - 1) + (i - 1);
            break;
        }
    }

    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
long long ans;
long long c[510],s[510],f[510],n;
int main(){
	cin>>n;
	for(int i=1;i<n;i++)cin>>c[i]>>s[i]>>f[i];
	for(int i=1;i<=n;i++){
	  for(int j=i;j<n;j++){
	    if(ans<s[j])ans=s[j];
	    else if((ans-s[j])%f[j])ans+=(f[j]-(ans-s[j])%f[j]);
	    ans+=c[j];
	    }
	   cout<<ans<<endl;
	   ans=0;
	}
	return 0;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

// -----------------------------------------------------------------------------

const int N = 2e5 + 5, A = 1e9;
int n, a[N]; ll k;
int x, y;

ll f(ll v) {
    ll ret = 0;
    int b = 0;
    for (int i = 0; i < x; ++i) {
        while (b != n && ll(1) * a[i] * a[b] >= v) ++b;
        while (b != 0 && ll(1) * a[i] * a[b - 1] < v) --b;
        ret += max(i - b, 0);
    }
    for (int i = x; i < y; ++i) {
        if (v > 0) ret += i;
    }
    for (int i = y; i < n; ++i) {
        while (b != n && ll(1) * a[i] * a[b] < v) ++b;
        while (b != 0 && ll(1) * a[i] * a[b - 1] >= v) --b;
        ret += min(i, b);
    }
    return ret;
}

void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    x = lower_bound(a, a + n, 0) - a;
    y = upper_bound(a, a + n, 0) - a;
    ll r = ll(1) * A * A + 1, l = -r;
    while (l + 1 < r) {
        ll m = (l + r) >> 1;
        ll n_less = f(m);
        if (n_less < k) l = m;
        else r = m;
    }
    cout << l << '\n';
}


int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}


Measured memory_bytes: 1024
n = list(map(int,input().split()))

order = input()
a1, a2, a3, a4, b1, b2 = 1, 5, 6, 2, 3, 4 

#print(a1, a2, a3, a4, b1, b2)
#print(order)
for i in order:
    if i == 'N':
        a_1 = a4
        a_2 = a1
        a_3 = a2
        a_4 = a3
        b_1 = b1
        b_2 = b2
        a1, a2, a3, a4, b1, b2 = a_1, a_2, a_3, a_4, b_1, b_2
        #print(a1, a2, a3, a4, b1, b2)
    elif i == 'S':
        a_1 = a2
        a_2 = a3
        a_3 = a4
        a_4 = a1
        b_1 = b1
        b_2 = b2
        a1, a2, a3, a4, b1, b2 = a_1, a_2, a_3, a_4, b_1, b_2
        #print(a1, a2, a3, a4, b1, b2)
    elif i == 'E':
        a_1 = b2
        a_2 = a2
        b_1 = a1
        a_3 = b1
        b_2 = a3
        a_4 = a4
        a1, a2, a3, a4, b1, b2 = a_1, a_2, a_3, a_4, b_1, b_2
        #print(a1, a2, a3, a4, b1, b2)
    else:
        a_1 = b1
        b_1 = a3
        a_3 = b2
        b_2 = a1
        a_2 = a2
        a_4 = a4
        a1, a2, a3, a4, b1, b2 = a_1, a_2, a_3, a_4, b_1, b_2
        #print(a1, a2, a3, a4, b1, b2)
        
print(n[int(a1)-1])




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

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

int ans =0;
int anss =0;
int count=0;

for(int i=0;i<3;i++){
  if(s[i]=='R'&&count==0) ans +=1;
  else if(s[i]=='S') count +=1;
  else if(s[i]=='R'&&count!=0) anss +=1;
}

int answer = max(ans,anss);

cout << answer <<endl;

}


Measured memory_bytes: 3620
import numpy as np

h, n = map(int, input().split())
ab = np.array([list(map(int, input().split()))for _ in range(n)])

a, b = ab[:, 0], ab[:, 1]
dp = np.zeros(h+1, dtype=np.int)
for i in range(1, h+1):
    dp[i] = np.min(dp[np.maximum(i-a, 0)] + b)

print(dp[h])


Measured memory_bytes: 14532
# -*- coding: utf-8 -*-
#ARC082C
import copy
import sys
import math

n = int(input())
tmp = input().split()
hoge1 = list(map(lambda a: int(a), tmp))
tmp = input().split()
hoge2 = list(map(lambda a: int(a), tmp))

#print(hoge1)
#print(hoge2)


total=0
for i in range(0,n):
	total+=hoge1[i]
	hoge1[i]=total

total=0
for i in range(0,n):
	total+=hoge2[n-1-i]
	hoge2[n-1-i]=total

maxtotal=0
for i in range(0,n):
	maxtotal=max(maxtotal,hoge1[i]+hoge2[i])


#print(hoge1)
#print(hoge2)
print(maxtotal)


Measured memory_bytes: 3444
def balance(N: int, W: list)->int:
    S = [0] * (N+1)  # W の累積和
    sumW = sum(W)  # W の総和

    for i, w in enumerate(W):
        S[i+1] = S[i] + w

    min_diff = float('inf')
    for i in range(1, N):
        S1 = S[i]
        S2 = sumW-S[i]

        min_diff = min(min_diff, abs(S1-S2))

    return min_diff


if __name__ == "__main__":
    N = int(input())
    W = [int(s) for s in input().split()]

    ans = balance(N, W)
    print(ans)


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val mod = 1000000007L
    val N = readInputLine().toInt()
    var ans = 1L
    
    for (i in 1..N) {
        ans *= i
        ans %= mod
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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


int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> commondiv;
    vector<ll> divsum;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            divsum.push_back(i + n / i);
        }
    }
    ll ans = *min_element(divsum.begin(), divsum.end());
    ans -= 2;
    cout << ans << endl;

}

Measured memory_bytes: 256
# Problem B - Exactly N points(Code Festival)

# input
N = int(input())

# initialization
ans_list = []
check_sum = 0

# count
for i in range(1, N+1):
    check_sum += i
    ans_list.append(i)
    if check_sum>=N:
        tmp_sum = sum(ans_list)
        remove_num = check_sum - N
        if remove_num in ans_list:
            ans_list.remove(remove_num)
        break

# output
for a in ans_list:
    print(a)


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int n, t;
    cin >> n >> t;

    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    map<int, int> mp;
    set<int> st;
    for (int i = 0; i < t; i++) {
        mp[v[i]]++;
        st.insert(v[i]);
    }
    cout << *st.begin();
    if (t < n)
        cout << " ";
    for (int i = t; i < n; i++) {
        mp[v[i - t]]--;
        mp[v[i]]++;
        st.insert(v[i]);
        if (mp[v[i - t]] == 0) {
            st.erase(v[i - t]);
        }
        cout << *st.begin();
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 77780
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 int n,k;
 cin >> n >> k;
 VI p(n);
 rep(i,n){
     cin >> p.at(i);
 }
 sort(p.begin(),p.end());
 int cst=0;
 rep(i,k){
     cst+=p.at(i);
 }
 cout << cst << endl;

}



Measured memory_bytes: 3604
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read()
{
	int l = 0, f = 1;
	char a = getchar();
	for (; a < '0' || a > '9'; a = getchar())
		if (a == '-') f = -1;
	for (; a >= '0' && a <= '9'; a = getchar())
		l = l*10+a-48;
	return l*f;
}
const int N = 55;
struct Point
{
	int x, y;
}stu[N], co[N];
int n, m;
int main(int argc, char const *argv[])
{
	n = read(), m = read();
	for (int i = 1; i <= n; ++i) stu[i].x = read(), stu[i].y = read();
	for (int i = 1; i <= m; ++i) co[i].x = read(), co[i].y = read();
	for (int i = 1; i <= n; ++i)
	{
		int id, mn = 1<<30;
		for (int j = 1; j <= m; ++j)
		{
			if (mn > abs(stu[i].x-co[j].x)+abs(stu[i].y-co[j].y))
			{
				mn = abs(stu[i].x-co[j].x)+abs(stu[i].y-co[j].y);
				id = j;
			}
		}
		printf("%d\n", id);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

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

	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d}) << "\n";
	return 0;
}

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

signed main(){
  int n,k;cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  while(k--){
    vector<int> w(n+1,0);
    for(int i=0;i<n;i++){
      int l=max(0,i-v[i]),r=min(n-1,i+v[i]);
      w[l]++;w[r+1]--;
    }
    for(int i=0;i<n;i++)v[i]=w[i],w[i+1]+=w[i];
    bool ok=1;
    for(int i=0;i<n;i++)ok&=v[i]==n;
    if(ok)break;
  }
  for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl;
}


Measured memory_bytes: 4844