akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (int i = 1; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,m;
    cin >> n >> m;
    vector<ll> div = calc_divisor(m);
    sort(all(div));
    for(int i = sz(div) - 1; i >= 0; --i){
        if(n * div[i] <= m){
            print(div[i]);
            return 0;
        }
    }


}



Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main()
{
	int input;
	cin >> input;
	int h = input / 3600;
	int m = (input - h * 3600) / 60;
	int s = input - h * 3600 - m * 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1168
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	S := sc.nextRuneSlice()
	ans := 0
	before := S[0]
	for i := 1; i < len(S); i++ {
		if before == S[i] {
			ans++
			if S[i] == '0' {
				before = '1'
			} else {
				before = '0'
			}
		} else {
			before = S[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1408
def solve(table, H, W):
    def is_ok(row, col):
        if not table[row][col]:
            return True

        if row > 0 and table[row - 1][col] or row + 1 < H and table[row + 1][col]:
            return True
        if col > 0 and table[row][col - 1] or col + 1 < W and table[row][col + 1]:
            return True
        return False

    for row in range(H):
        for col in range(W):
            if not is_ok(row, col):
                return False
    return True


H, W = map(int, input().split())
table = []
for r in range(H):
    table.append(list(map(lambda x: x == "#", list(input()))))

print("Yes" if solve(table, H, W) else "No")


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void){
  int number;
  int taste_base;

  cin >> number >> taste_base;

  int min = taste_base;
  int max = taste_base + number - 1;

  int eat;

  if(max <= 0) eat = max;
  else if(min >= 0) eat = min;
  else eat = 0;

  int ans = (min + max) * (max - min + 1)/2 -eat;

  cout << ans << endl;

  return 0;
}

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

const int N = 1000 * 200 + 5;
long long n, q, num[N];
vector <long long> adj[N];
bool vis[N];

void dfs(int v) {
	vis[v] = true;
	for (auto u : adj[v])
		if (!vis[u]) 
			num[u] += num[v], dfs(u);
}

int main() {
	cin >> n >> q;
	for (long long i = 1, u, v; i < n; i++)
		cin >> u >> v, adj[u].push_back(v), adj[v].push_back(u);
	for (long long i = 0, a, b; i < q; i++)
		cin >> a >> b, num[a] += b;
	dfs(1);
	for (int i = 1; i <= n; i++)
		cout << num[i] << ' ';
	cout << endl;
}
	

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

using ll = long long;
const ll INF = 1e18;

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

/*
                    CCW

 -- BEHIND -- [a -- ON -- b] --- FRONT --

                    CW
 */
enum { CCW = +1, CW = -1, BEHIND = +2, FRONT = -2, ON = 0 };
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > eps)  return CCW;    // counter clockwise
    if (cross(b, c) < -eps) return CW;     // clockwise
    if (dot(b, c) < 0)      return BEHIND; // c--a--b on line
    if (norm(b) < norm(c))  return FRONT;  // a--b--c on line
    return ON;
}


namespace std {
    bool operator < (const P& a, const P& b) {
        return abs(real(a) - real(b)) > eps ? real(a) < real(b) : imag(a) < imag(b);
    }
}

G andrewScan(G ps){
    int N = ps.size(), k = 0;
    sort(ps.begin(), ps.end());
    G res(N*2);
    for(int i=0; i<N; i++) {
        while(k>=2 && ccw(res[k-2], res[k-1], ps[i])!=CCW) k--;
        res[k++] = ps[i];
    }
    int t = k+1;
    for(int i=N-2; i>=0; i--) {
        while(k>=t && ccw(res[k-2], res[k-1], ps[i])!=CCW) k--;
        res[k++] = ps[i];
    }
    res.resize(k-1);
    return res;
}

int n;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
int x[100010], y[100010];

using pii = pair<int,int>;
set<pii> S;

G g;

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

    cin >> n;
    rep(i,n-1){
        int k,d;
        cin >> k >> d;
        x[i+1] = x[k] + dx[d];
        y[i+1] = y[k] + dy[d];
    }
    rep(i,n){
        S.emplace(x[i],   y[i]);
        S.emplace(x[i]+1, y[i]);
        S.emplace(x[i],   y[i]+1);
        S.emplace(x[i]+1, y[i]+1);
    }
    g.clear();
    for(auto &p : S) g.emplace_back(p.first, p.second);
    g = andrewScan(g);
    int k = g.size();
    g.insert(g.end(), g.begin(), g.end());

    ld ans = INF;
    rep(i,k){
        P base = g[1+i] - g[0+i];
        base /= abs(base);
        ld min_x = +INF, max_x = -INF;
        ld min_y = +INF, max_y = -INF;
        rep(j,k){
            ld x = real(g[j+1]/base);
            ld y = imag(g[j+1]/base);
            min_x = min(min_x, x);
            min_y = min(min_y, y);
            max_x = max(max_x, x);
            max_y = max(max_y, y);
        }
        ld dx = max_x - min_x;
        ld dy = max_y - min_y;
        ans = min(ans, dx*dy);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 25624
#include<stdio.h>
#include<iostream>
#include<cctype>
using namespace std;
main(){
  char ch;
  int i;
  while(1){
    scanf("%c",&ch);
    if(islower(ch)){
      ch=toupper(ch);
    }
    else if(isupper(ch)){
      ch=tolower(ch);
    }
    if(ch == '\n')break;
    cout << ch ;
  }
  cout <<"\n";
}

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

int main()
{
    string s;
    cin >> s;
    string t;
    cin >> t;
    int c=0;
    rep(i, 3)
    {
        if (s[i]==t[i]) {
            c++;
        }
    }
    cout << c << endl;
}

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

namespace ConsoleApp15
{
    class Class367
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var dic = new Dictionary<string, int>();
            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                if (dic.ContainsKey(s))
                    dic[s]++;
                else
                    dic[s] = 1;
            }
            int M = int.Parse(Console.ReadLine());
            for(int i = 0; i < M; i++)
            {
                var t = Console.ReadLine();
                if (dic.ContainsKey(t))
                {
                    dic[t]--;
                }
                else
                    dic[t] = -1;
            }
            int ans = 0;
            foreach (var i in dic.Values)
            {
                ans = Math.Max(ans, i);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13152
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0

for j in range(n):
    ans+=B[j]
    if j>0:
        if A[j]-A[j-1]==1:
            ans+=C[A[j]-2]
print(ans)

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

using namespace std;

int main() {
  string s;
  int mx1 = 0, mx2 = 0;
  map<string, int> m;
  while (cin >> s) ++m[s];
  for (auto i : m) mx1 = max(mx1, i.second);
  for (auto i : m) mx2 = max(mx2, (int)i.first.size());
  for (auto i : m) {
    if (i.second == mx1) cout << i.first << " ";
  }
  for (auto i : m) {
    if ((int)i.first.size() == mx2) cout << i.first << endl;
  }
}

Measured memory_bytes: 2976
def main():
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    ctr = [0] * 60

    for x in A:
        *bit, = map(int, bin(x)[2:])
        bit.reverse()
        for j, b in enumerate(bit):
            i = (60 - 1) - j
            ctr[i] += b

    ans = 0
    d = 1 << (60 - 1)
    x = 0
    for j, cnt in enumerate(ctr):
        if (cnt < N - cnt) and (x + d <= K):  # フラグを立てた方が得する
            x += d
            ans += (N - cnt) * d
        else:
            ans += cnt * d
        d >>= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14620
#include<iostream>
#include<string>
#include<cmath>
#include <algorithm>
#include <stdio.h>



using namespace std;


int main()
{

  int N,C[1000],S[1000],F[1000]; 
  cin>>N;

  int ans[1000]={};

  for(int i=1;i<=N-1;i++){
    cin>>C[i]>>S[i]>>F[i];
  }

  for(int i=1;i<=N;i++){
    int time=0;
    for(int j=i;j<=N-1;j++){
      if(time<=S[j]){
	time=S[j]+C[j];
      }
      else if(time>S[j]){
	int wait=((time-1-S[j])/F[j]+1)*F[j];
	time=wait+S[j]+C[j];
      }
    }
    ans[i]=time;
  }

  for(int i=1;i<=N;i++)
    cout<<ans[i]<<endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll A, B;
	cin >> A >> B;
	if (A < B)swap(A, B);
	for (int i = 0; i < A; i++)cout << B;
	cout << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Char
import Data.List

digitsToNum :: [Int] -> Int
digitsToNum dig = foldl (\x y->x*10+y) 0 dig

solve :: [Int] -> IO ()
solve dig = do
    let nmin = digitsToNum $ sort dig
    let nmax = digitsToNum $ reverse $ sort dig
    print(nmax-nmin)

main :: IO ()
main = do
    n_dat<-readLn::IO Int
    str<-replicateM n_dat getLine
    mapM_ solve $ map (\x->map (\y->digitToInt(y)) x) str

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 998244353
int A[MAX];
int main()
{
    FILE *input=stdin;
    //input=fopen("in.txt","r");
    int t,T=1;
    //fscanf(input,"%d",&T);
    for(t=1; t<=T; t++)
    {
        int K,N,i,j,X,Y,k;
        fscanf(input,"%d %d %d",&N,&X,&Y);
        for(i=1;i<=N;i++)
        {
            A[i]=0;
        }
        int cycle=Y-X+1;
        int left=X-1,right=N-Y;
        for(i=1;i<=left+right+1;i++)
        {
            A[i]=A[i]+(left+right+2-i);
        }
        for(i=1;i*2<=cycle;i++)
        {
            if(i*2==cycle) A[i]=A[i]+cycle/2;
            else A[i]=A[i]+cycle;
        }
        A[1]--;
        for(i=X+1,j=Y-1;i<=j;i++,j--)
        {
            for(k=X-1;k>0;k--)
            {
                int dist_i=i-k;
                int dist_j=dist_i+1;
                A[dist_i]++;
                if(i!=j) A[dist_j]++;
            }
            for(k=Y+1;k<=N;k++)
            {
                int dist_j=k-j;
                int dist_i=dist_j+1;
                A[dist_j]++;
                if(i!=j) A[dist_i]++;
            }
        }
        for(i=1;i<N;i++)
        {
            printf("%d\n",A[i]);
        }
        if(t!=T) printf("\n");
    }
    fclose(input);
    return 0;
}


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

using namespace std;

int main() {
	int k, n; scanf("%d %d", &k, &n);
	vector<int> arr(n);
	for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
	vector<int> mdist(n);
	for (int i = 0; i < n - 1; ++i) mdist[i] = arr[i+1] - arr[i];
	mdist[n-1] = k - (arr[n-1] - arr[0]);
//	for (int x : mdist) printf("%d\n", x);
	printf("%d\n", k - *max_element(begin(mdist), end(mdist)));
	return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e8;
    
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 32;
    public static int[] Bit;
    public static final double pi = Math.acos(-1);

	public static void main(String[] args) {
		FastReader sc = new FastReader();
	       
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n+1];
		long[] pre = new long[n+1];
		for(int i=1;i<=n;++i) {
			a[i] = sc.nextInt();
			pre[i] = pre[i-1] + a[i];
		}
		Map<Long,Integer> map = new HashMap<>();
		add(map,0);
		long ans = 0;
		for(int i=1;i<=n;++i) {
			if(i >= k) delete(map,(pre[i-k]-i+k)%k);
			
			ans += map.getOrDefault((pre[i]-i)%k,0);
			add(map,(pre[i]-i)%k);
		}
		
		out.println(ans);
		
	out.close();
	}
	private static void add(Map<Long, Integer> map, long l) {
		// TODO Auto-generated method stub
		if(map.containsKey(l)) map.put(l, map.get(l)+1);
		else map.put(l, 1);
		
	}
	private static void delete(Map<Long, Integer> map, long l) {
		if(map.containsKey(l)) {
			if(map.get(l) == 1) map.remove(l);
			else map.put(l, map.get(l)-1);
		}
		
	}

	
	
	
	
}

Measured memory_bytes: 67012
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
 ll a,b,c,k;
 cin>>a>>b>>c;
 k=c-a-b;
 if(k>0 && k*k>4*a*b)
 {
     cout<<"Yes"<<endl;
 }else{
     cout<<"No"<<endl;
 }
}


Measured memory_bytes: 3608
import java.util.Scanner;
public class Main 
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int time = sc.nextInt()+sc.nextInt()+sc.nextInt()+sc.nextInt();
		System.out.println(time/60);
		System.out.println(time%60);
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define EPS 1.0e-8
#define MOD 1000000007
typedef long long ll;

ll N,M,K;
ll x[100010];
ll a[100010];
ll at[100010];
ll ans[100010];
ll T[100][100010];

int main(){
    
    cin>>N;
    REP(i,N)cin>>x[i];
    cin>>M>>K;
    REP(i,M)cin>>a[i];
    
    REP(i,N-1)at[i+1]=i+1;
    REP(i,M)swap(at[a[i]],at[a[i]-1]);
    
    REP(i,N-1)T[1][i+1] = at[i+1];
    REP(i,70)REP(j,N-1)T[i+2][j+1] = T[i+1][T[i+1][j+1]];
    
    /*REP(i,70){
        REP(j,5)cout<<T[i+1][j+1]<<" ";
        cout<<endl;
    }*/
    
    REP(i,N-1)at[i+1]=i+1;
    REP(i,64){
        if((K>>i)&1){
            REP(j,N-1)at[j+1] = T[i+1][at[j+1]];
        }
    }
    
    REP(i,N-1)ans[i+1]=x[i+1]-x[i];
    vector<double> aa(N);
    aa[0] = x[0];
    REP(i,N-1)aa[i+1] += ans[at[i+1]] + aa[i];
    
    REP(i,N)cout<<fixed<<setprecision(10)<<aa[i]<<endl;
    
    return 0;
}


Measured memory_bytes: 63104
package main

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

var count int
var sumN int

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	line1 := nextInt()
	count = line1[0]
	sumN = line1[1]

	for i := 0; i <= count; i++ {
		for j := 0; j <= count-i; j++ {
			k := count - (i + j)
			result := i*10000 + j*5000 + k*1000
			if result == sumN {
				fmt.Printf("%d %d %d", i, j, k)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}

// ------ Mathライブラリ ---------------------------------//
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func maxIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ------ Mathライブラリ ---------------------------------//

// ----- 標準入力用の関数 ----------------------------------//
var nextReader func() []string

func NewScanner() func() []string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	return func() []string {
		r.Scan()
		return strings.Fields(r.Text())
	}
}

func nextString() []string {
	return nextReader()
}

func nextInt() []int {
	var intArray []int
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.Atoi(v)
		intArray = append(intArray, i)
	}
	return intArray
}

func nextFloat64() []float64 {
	var floatArray []float64
	strArray := nextReader()
	for _, v := range strArray {
		f, _ := strconv.ParseFloat(v, 64)
		floatArray = append(floatArray, f)
	}
	return floatArray
}

// ------ 標準入力用の関数 ---------------------------------//

// ------ あまり使わない -----------------------------------//
func nextInt64() []int64 {
	var int64Array []int64
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.ParseInt(v, 10, 64)
		int64Array = append(int64Array, i)
	}
	return int64Array
}

// ------ あまり使わない -----------------------------------//


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>

#define ll long long
#define ld long double
#define REP(i,a,b) for(int i=a;i<b;i++)
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f first
#define s second
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double> 
#define pi acos(-1)
#define mod 1000000007

const int N = 1e5 + 5;

using namespace std;


int main() {

	HS
	int n;
	cin >> n;
	ll a[N], b[N], c[N],dp[N][4];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][1] = a[0], dp[0][2] = b[0], dp[0][3] = c[0];
	for (int i = 1; i < n; i++) {
		dp[i][1] = max(dp[i - 1][2] + a[i], dp[i - 1][3] + a[i]);
		dp[i][2] = max(dp[i - 1][1] + b[i], dp[i - 1][3] + b[i]);
		dp[i][3] = max(dp[i - 1][2] + c[i], dp[i - 1][1] + c[i]);
	}
	cout << max(dp[n - 1][1], max(dp[n - 1][2], dp[n - 1][3]));

	return 0;
}

Measured memory_bytes: 5760
//Hi =)) I'm T.A
#include <bits/stdc++.h>
#define nmax 200002
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pa pair<int,int>
#define ll long long
#define ld long double
#define reset(a,x) memset(a,x,sizeof(a))
#define task "built"

using namespace std;
const int MOD=1e9+7;

int n,cnt(0),root[nmax];
ll res(0);

struct on
{
    int u,v,w;
}b[nmax];

struct in
{
    int x,y,vt;
}a[nmax];

bool sx1(in a, in b)
{
    return a.x<b.x;
}

bool sx2(in a, in b)
{
    return a.y<b.y;
}

bool sx3(on a, on b)
{
    return a.w<b.w;
}

int getroot(int u)
{
    return root[u]?(root[u]=getroot(root[u])):u;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
   // freopen(task".inp","r",stdin);
   // freopen(task".out","w",stdout);
      cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y,a[i].vt=i;
    sort(a+1,a+1+n,sx1);
    for(int i=1;i<n;i++)
        b[++cnt]={a[i].vt,a[i+1].vt,a[i+1].x-a[i].x};
    sort(a+1,a+1+n,sx2);
    for(int i=1;i<n;i++)
    b[++cnt]={a[i].vt,a[i+1].vt,a[i+1].y-a[i].y};
    sort(b+1,b+2*n,sx3);
    for(int i=1;i<2*n;i++)
    {
        int p=getroot(b[i].u);
        int q=getroot(b[i].v);
        if(p!=q)
        {
            root[p]=q;
            res+=1ll*b[i].w;
        }
    }
    cout<<res;

    return 0;
}


Measured memory_bytes: 4480
import java.util.*;

public class Main{
        public static void main(String[] args){
                ArrayList<Integer> arr = new ArrayList<Integer>();
                Scanner scan = new Scanner(System.in);
                int n = scan.nextInt();
                for(int i = 0; i < n; i++){
                        int cmd = scan.nextInt();
                        switch(cmd){
                                case 0:
                                        arr.add(scan.nextInt());
                                        break;
                                case 1:
                                        System.out.println(arr.get(scan.nextInt()));
                                        break;
                                case 2:
                                        arr.remove(arr.size()-1);
                                        break;
                        }
                }
        }
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main()
{
    string S, T; cin >> S >> T;

    bool passed = false;
    for( int i = S.length() - 1; i >= 0; i-- )
    {
        bool ok = true;

        REP( j, T.length() )
        {
            int p = i + j;

            if( p < 0 || S.length() <= p )
            {
                ok = false;
                break;
            }

            if( S[p] != '?' && S[p] != T[j] )
            {
                ok = false;
                break;
            }
        }

        if( ok )
        {
            REP( j, T.length() )
            {
                S[i + j] = T[j];
            }
            passed = true;

            break;
        }
    }

    if( passed )
    {
        REP(i, S.length()) {
            if (S[i] == '?') S[i] = 'a';
        }

        cout << S << endl;
    }
    else
    {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(62):
    cnt=0
    for j in range(n):
        cnt+=(A[j]>>i)&1
    ans+=cnt * (n-cnt) *(2**i)%mod
print(ans%mod)

Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
const int MOD = 1000000007;

int main() {
  ll Ans = 0;  // 回答：
  int N; cin >> N; // 足場数２～10^5
  int K; cin >> K; // とび幅：1～100
  vector<int> H(N); // 足場の高さ
  rep(i,N){cin >> H.at(i);}

  vector<int> DP(N,1e9);  // 各足場への最小移動コスト
  DP.at(0) = 0;
  rep(i,N-1){
    rep1(j,K){
      if( i+j < N ) {
        DP.at(i+j) = min( DP.at(i+j) , DP.at(i)+ abs(H.at(i)-H.at(i+j)) );
      }
    }
  }

  cout << DP.at(N-1) << endl;
}



Measured memory_bytes: 1024
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
A.append(0)


ans = 0
tmp = 0
for a in A:
    if a == 0:
        ans += tmp//2
        tmp = 0
    else:
        tmp += a
print(ans)


Measured memory_bytes: 7072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	}
}


Measured memory_bytes: 26544
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include<bits/stdc++.h>

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define print(v) for(auto it=(v).begin();it!=(v).end();it++) {cout<<*it<<" ";}
#define ll long long
#define w(t) ll t;cin>>t;while(t--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
using namespace std;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}


int main()
{
    ll n;
    cin>>n;
    ll ans=1;
    bool f=true;
    ll a[n];
    ll k=1e18;
    bool zer=false;
    //cout<<k<<"\n";
    forn(i,n)
    {
        cin>>a[i];
        if(a[i]==0)
            zer=true;
    }
    if(zer)
    {
        cout<<0<<"\n";
        return 0;
    }
    forn(i,n)
    {
        if(a[i]<=1000000000000000000/ans)
            ans*=a[i];
        else{
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<ans<<"\n";


    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

long long gcd(long long x, long long y)
{
    while (y)
	{
		int tmp = x;
        x = y;
        y = tmp % y;
	}

	return x;
}

int main(void)
{
    long long a, b;

    cin >> a >> b;

	cout << a * b / gcd(a, b);
	return 0;
}


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

long long int to[2][214514] = {};
bool f[214514] = {};

int main() {

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

  string s;
  cin >> s;

  vector< vector< long long int > > v;

  for ( long long int i = 0; i < n; i++ ) {
    vector< long long int > vv;
    v.push_back( vv );
  }

  for ( long long int i = 0; i < m; i++ ) {

    long long int a, b;
    cin >> a >> b;
    a--;
    b--;

    v[a].push_back( b );
    v[b].push_back( a );
    to[ s[b] - 'A' ][a]++;
    to[ s[a] - 'A' ][b]++;

  }

  long long int cnt = n;

  queue< long long int > q;

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

    q.push( i );

  }

  while( q.size() > 0 ) {

    long long int k = q.front();
    q.pop();

    if ( to[0][k] > 0 && to[1][k] > 0 ) continue;
    if ( f[k] == true ) continue;

    f[k] = true;
    cnt--;

    long long int tt = s[k] - 'A';

    for ( long long int i = 0; i < v[k].size(); i++ ) {

      long long int p = v[k][i];
      to[ tt ][ p ]--;
      if ( to[ tt ][ p ] == 0 && f[p] == false ) q.push( p );

    }

  }

  if ( cnt > 0 ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;

}


Measured memory_bytes: 16240
x,y=map(int,input().split())
import math
xx=math.factorial(x)
yy=math.factorial(y)
if x==y:
    print(xx*yy*2%((10**9)+7))
elif abs(x-y)==1:
    print(xx*yy%((10**9)+7))
else:
    print(0)

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

const ll INF = 1001001001;
const ll mod = 1000000007;

int main(){
    ll k, a, b; cin >> k >> a >> b;
    ll ans = 0;
    if(a + 1 >= b){
        cout << k + 1 << endl;
        return 0;
    }
    else{
        if(k <= a){
            cout << 1 + k << endl;
            return 0;
        }
        else{
            ll cnt = k - (a - 1);
            ans = a;
            bool odd = (cnt % 2 == 1 ? true : false);
            if(!odd) ans += cnt / 2 * (b - a);
            else ans += (cnt - 1) / 2 * (b - a) + 1;
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    int N, cnt = 0;
    string s;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s;

        if (s == "A") cnt++;
        else cnt--;

        if (cnt < 0) break;
    }
    cout << (cnt == 0 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int N,M,x,ans=0;
    int y[1000];
    cin >> N ;
    vector<string>  blue(N);
    for(int i = 0; i < N; i++){
        cin >> blue[i];
        if(blue[i] == "Y"){
            goto four;
        }
    }

    cout << "Three" << endl;
    goto end;
    four:
    cout << "Four" << endl;
    end:
return 0;
    }

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b; cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3084
//Completed Binary Tree
#include<stdio.h>
#include<limits.h>

#define MAX 251

int main(){
	int i,h;
	int H[MAX];


	//input
	scanf("%d",&h);

	//init
	for(i=0;i<=MAX;i++){
		H[i]=INT_MAX;
	}

	for(i=1;i<=h;i++){
		scanf("%d",&H[i]);
	}


	//output
	for(i=1;i<=h;i++){
		printf("node %d: key = %d, ",i,H[i]);
		if(i==1){
			printf("left key = %d, right key = %d, \n",H[2*i],H[2*i+1]);
			continue;
		}
		if(i>=125){
			printf("parent key = %d, \n",H[i/2]);
			continue;
		}
		//Left child
		if(H[2*i]!=INT_MAX){

			//Rigth child
			if(H[2*i+1]!=INT_MAX){
				printf("parent key = %d, left key = %d, right key = %d, \n",H[i/2],H[2*i],H[2*i+1]);
			}
			else{
				printf("parent key = %d, left key = %d, \n",H[i/2],H[2*i]);
			}
		}
		else{
			printf("parent key = %d, \n",H[i/2]);
		}
	}
	return 0;
}



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

int main(){
    
    int H, W;

    while(true){
    cin >> H >> W;
    if((H==0)&&(W==0)) break;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << '#';
        }
        cout << endl;
    }
    cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String d = Integer.toString(N);
        int digits = 0;
        char[] t = d.toCharArray();
        for (int i = 0; i < t.length; i++) {
            digits += t[i] - '0';
        }
        boolean answer = (N % digits) == 0;
        System.out.println(answer ? "Yes" : "No");
    }
}


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

typedef long long ll;
const ll MOD=1000000007LL;

ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }


bool is_bad(int a, int b, int c, int d){
  if(      b==1&&c==2&&d==3){return true;}
  else if(      b==1&&c==3&&d==2){return true;}
  else if(      b==2&&c==1&&d==3){return true;}
  else if(a==1&&      c==2&&d==3){return true;}
  else if(a==1&&b==2&&      d==3){return true;}
  else {return false;}
}


ll solve(int N){
  ll dp[N+1][256][2];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0]=1;

  for (int i=0;i<N;++i){
    for (int a=0;a<4;++a){
      for(int b=0;b<4;++b){ 
        for(int c=0;c<4;++c){ 
          for (int d=0;d<4;++d){
            int abcd=((a*4+b)*4+c)*4+d;
            for (int e=0;e<4;++e){
              int bcde=((b*4+c)*4+d)*4+e;
              bool bad_=is_bad(b,c,d,e);
              for (int j=0;j<2;++j){
                (dp[i+1][bcde][bad_||j]+=dp[i][abcd][j])%=MOD;
              }
            }
          }
        }
      }
    }
  }
  
  ll ans=0;
  for (int i=0;i<256;++i){
    (ans+=dp[N][i][1])%=MOD;
  }
  ans=SUB(POW(4,N),ans);
  return ans;
}

int main(){
  int N;cin>>N;
  cout << solve(N)<<endl;
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  double N; cin >> N;
  vector<double> a(N); REP(i, N) cin >> a[i];
  double avg = accumulate(all(a), 0) / N;
  double ans = 0;
  double tmp = pow(10, 8);
  REP(i, N) {
    if(abs(avg - a[i]) < tmp) {
      ans = i;
      tmp = abs(avg - a[i]);
    }
  }
  cout << ans << endl;
}


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

#define all(x) x.begin(), x.end()

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> A(n);

    for(int i=0; i<n; i++){
        cin >> A[i].first;
        A[i].second = i+1;
    }

    sort(all(A));
    for(int i=0; i<n; i++)
        cout << A[i].second << " ";
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sz(a) (int)(a).size()
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
ll a[maxn], b[maxn], c[maxn];
ll cb[maxn];
void solve()
{
    int n; scanf("%d", &n);
    for (int i = 1 ; i <= n ; i ++) scanf("%lld", a+i);
    for (int i = 1 ; i <= n ; i ++) scanf("%lld", b+i);
    for (int i = 1 ; i <= n ; i ++) scanf("%lld", c+i);
    sort(b+1, b+1+n);
    sort(c+1, c+1+n);
    for (int i = 1 ; i <= n ; i ++) {
        int pos = upper_bound(c+1, c+1+n, b[i]) - c;
        if (pos > n) continue;
        cb[i] = n - pos + 1;
    }
    for (int i = 1 ; i <= n ; i ++) {
        cb[i] += cb[i-1];
    }
    ll ans = 0;
    for (int i = 1 ; i <= n ; i ++) {
        int pos = upper_bound(b+1, b+1+n, a[i]) - b;
        if (pos > n) continue;
        ans += cb[n] - cb[pos-1];
    }
    printf("%lld\n", ans);
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 3328
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;

long ceilDiv(long a, long b) {
	if (a >= 0) {
		return (a + b - 1) / b;
	}
	return a / b;
}

long floorDiv(long a, long b) {
	if (a < 0) {
		return (a - b + 1) / b;
	}
	return a / b;
}

void readNk(ref long n, ref long k) {
	auto nk = readln.chomp.split(" ");

	n = to!long(nk[0]);
	k = to!long(nk[1]);
}

void main() {
	long n, k;
	readNk(n, k);

	long[] a = readln.chomp.split(" ").map!(to!long).array;
	sort(a);
	auto sorted = assumeSorted(a);

	long ok = long.max / 2, ng = long.min / 2 + 1L;

	while (ok - ng > 1) {
		auto middle = (ok + ng) / 2;
		long num = 0;

		foreach (size_t i, e;a) {
			if (e < 0) {
				auto v = ceilDiv(-middle, -e);
				num += i - sorted[0..i].lowerBound(v).length;
			} else if (e == 0) {
				if (middle >= 0) {
					num += i;
				}
			} else {
				auto v = floorDiv(middle, e);
				num += i - sorted[0..i].upperBound(v).length;
			}
		}

		if (num >= k) {
			ok = middle;
		} else {
			ng = middle;
		}
	}

	writeln(ok);
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long D, long long T, long long S){
    if ((D + S - 1) / S <= T) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }

}

// 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)
int main(){
    long long D;
    scanf("%lld",&D);
    long long T;
    scanf("%lld",&T);
    long long S;
    scanf("%lld",&S);
    solve(D, T, S);
    return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		for(int i=1;;i++) {
			if(i*i > n) {
			System.out.println((i-1)*(i-1));
				break;
			}
		}
	}
}


Measured memory_bytes: 23380
// Zellerの公式

#include <iostream>
#include <cstring>
using namespace std;

string Day[] = {
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
};

void Day2004(int month, int day);

int main(void) {
    int month, day;
    
    while(cin >> month >> day) {
        if(month == 0 || day == 0) {
            break;
        }
        Day2004(month, day);
    }
}

void Day2004(int month, int day) {
    int y, m, d;
    int DayNumber;
    
    if(month == 1 || month == 2) {
        y = 2003;
        m = month + 12;
        d = day;
    } else {
        y = 2004;
        m = month;
        d = day;
    }
    
    DayNumber = 
        (y + (y / 4) - (y / 100) + (y / 400) + ((13 * m + 8) / 5) + d) % 7;
    
    cout << Day[DayNumber] << endl;
}


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

int main() {
  string s;
  cin >> s;
  int ans = 700;
  rep(i,3) {
    if (s[i] == 'o') ans += 100;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int mini = INT_MAX, maxi = INT_MIN;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mini = min(mini, a);
        maxi = max(maxi, a);
    }
    cout << maxi - mini;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
typedef pair<long long,long long> P;
long long n,d,a;
long long W;
long long ans;
long long x[200006];
long long h[200006];
long long delta[200006];
long long D;
vector<P > p;
int main()
{
    cin>>n>>d>>a;
    rep(i,n)
    {
        cin>>x[i]>>h[i];
        p.push_back(P(x[i],h[i]));
    }
    sort(p.begin(),p.end());
    rep(i,n)
    {
        x[i]=p[i].first;
        h[i]=p[i].second;
    }
    x[n]=20000000000;
    
    rep(i,n)
    {
        long long t=upper_bound(x,x+n,x[i]+2*d)-x;
        D+=delta[i];
        long long ww=W-D;
        if(h[i]-ww<=0)continue;
        long long kk=(h[i]-ww)/a;
        if((h[i]-ww)%a!=0)kk++;
        ans+=kk;
        W+=(kk*a);
        delta[t]+=(kk*a);
    }
    cout<<ans<<endl;
    return 0;
}

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

int lcs(string s, string t) {
  int n = s.size(), m = t.size();
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      dp[i + 1][j + 1] =
          max(dp[i][j] + (s[i] == t[j]), max(dp[i][j + 1], dp[i + 1][j]));
    }
  return dp[n][m];
}

int main(void){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        string s,t;cin>>s>>t;
        cout<<lcs(s,t)<<endl;
    }
    return 0;
}

Measured memory_bytes: 6784
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
    A.append(int(input()) - 1)

border_line = 0
points = [K]*N

for i in range(Q):
    points[A[i]] += 1
    border_line += 1

for j in range(N):
    if points[j] - border_line > 0:
        print('Yes')
    else:
        print('No')

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

int main() {
	int n,k;
	cin >> n>>k;
	vector<int> x(n);
	for (int i = 0; i < n; i++){
		cin >> x.at(i);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int sa = 0, sb = 0, s = 0;
		sa = abs(x.at(i));
		sb = abs(x.at(i) - k);
		s = min(sa, sb);
		sum += s*2;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<string,int> votes;
  int n;
  cin>>n;
  int maxvotes=-1;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    votes[s]++;
    maxvotes=max(maxvotes,votes[s]);
  }
  for(map<string,int>:: iterator it=votes.begin();it!=votes.end();it++){
    if(it->second==maxvotes)	cout<<it->first<<endl;
  }
  return 0;
}


Measured memory_bytes: 25216
#include<iostream>
using namespace std;
int main() {
	int x,i;
	x = 1;
	for (i = 1; ; i = i+1) {
		cin >> x;
		if (x < 1) {
			return 0;
		}	
		cout << "Case " <<i<<": "<<x<< endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	int k;
	cin>>k;
	string t="$"+s;
	int n=s.size();
	ll dp1[101][4]={0},dp2[101][4]={0};
	dp2[0][0]=1;
	for(int i=1; i<=n; i++)
	{
		int num=t[i]-'0';
		if(num==0)
		{
			dp1[i][0]=1;
			dp2[i][0]=0;
			for(int j=1; j<=k; j++)
			{
				dp1[i][j]=dp1[i-1][j]+dp1[i-1][j-1]*9;
				dp2[i][j]=dp2[i-1][j];
			}
		}
		else
		{
			dp1[i][0]=1;
			dp2[i][0]=0;
			for(int j=1; j<=k; j++)
			{
				dp1[i][j]=dp1[i-1][j]+dp1[i-1][j-1]*9+dp2[i-1][j]+dp2[i-1][j-1]*(num-1);
				dp2[i][j]=dp2[i-1][j-1];
			}
		}
	}
	ll ans=dp1[n][k]+dp2[n][k];
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 3648