akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int main(){
  ll n;
  std::cin >> n;
  std::vector<ll> x(101,0);
  rep(i,n){
    ll temp;
    std::cin >> temp;
    temp--;
    x[temp]++;
  }

  std::vector<ll> ans(101,-1);
  // // iに住む人がjに参加する

  rep(i,101){
    rep(j,101){
      ll temp=pow(i-j,2)*x[i];
      if(temp>=0){
        if(i-j==0)temp=0;
        if(ans[j]==-1)ans[j]=0;
        ans[j]+=temp;
      }
    }
  }

  // rep(i,10)std::cout << ans[i] << '\n';
  sort(ans.begin(),ans.end());
  rep(i,101)if(ans[i]!=-1){std::cout << ans[i] << '\n';break;}

  return 0;


}


Measured memory_bytes: 256
#include <iostream>//bit DP
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;

priority_queue<ll>U;
priority_queue<ll>D;
int main(){
  ll n;cin>>n;

  for(int i=0;i<n;i++){
    ll k;cin>>k;
    U.push(k-i);
    D.push(-k-i);

  }
  ll ans=0;
  while(U.size()>0&&D.size()>0){
    if(U.top()>D.top())U.pop();
    else if(U.top()<D.top())D.pop();
    else{
      ll a=0;ll b=0;ll t=U.top();
      while(U.size()>0&&U.top()==t){
        U.pop();
        a++;}
      while(D.size()>0&&D.top()==t){
        D.pop();
        b++;}
      ans+=(a*b);
    }
  }
cout<<ans<<endl;
}


Measured memory_bytes: 6572
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var NN = "No", YY = "Yes";
  var n = next();
  var up = [], ud = [], sum = 0, rest = 0;
  for(var i = 0; i < n; i++){
    var mn = 0, last = 0;
    var s = next(1);
    for(var j = 0; j < s.length; j++){
      if(s[j] === "(")last++;
      else{
        last--;
        if(last < mn)mn = last;
      }
    }
    sum += last;
    if(mn >= 0)rest += last;
    else if(last <= 0)up.push([-mn+last,last]);
    else ud.push([-mn,last]);
  }
  if(sum)return NN;
  ud.sort((a,b)=>a[0]-b[0]);
  for(var i = 0; i < ud.length; i++){
    if(ud[i][0] > rest)return NN;
    rest += ud[i][1];
  }
  up.sort((a,b)=>b[0]-a[0]);
  for(var i = 0; i < up.length; i++){
    var [mn,last] = up[i];
    if(mn-last > rest)return NN;
    rest += last;
  }
  return YY;
}

Measured memory_bytes: 130416
#include "bits/stdc++.h"
using namespace std;

#define print(n) cout  << n << "\n"

int main() {
	int n;
	cin >> n;
	vector<int>a;
	a.push_back(-1);
	for (int i = 0; i< n; i++) {
		int aa;
		cin >> aa;
		a.push_back(aa);
	}
	int nowButton = 1;
	int nowStep = 0;
	while (nowButton != 2 && nowStep <= n) {
		nowStep++;
		nowButton = a[nowButton];
	}
	if (nowStep > n) {
		nowStep = -1;
	}
	print(nowStep);

	return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main()
{
	int a[26]={0};
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		a[s[i]-'A']++;
	}
	int f=0;
	for(int i=0;i<26;i++){
		if(a[i]==2) f++;
	}	
	if(f==2) cout<<"Yes";
	else cout<<"No";
} 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <deque>

const int N = 1e3 + 5;
const int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

char s[N][N]; 
int n, m;
int stx, sty;
int edx, edy;

struct Point { int x, y; };
std::deque<Point> q;
int dis[N][N];
void bfs() {
	q.push_back({stx, sty});
	dis[stx][sty] = 0;
	while(!q.empty()) {
//		std::printf("--------------------------------\nq = { ");
//		for(const Point &p : q) std::printf("(%d, %d) ", p.x, p.y);
//		std::printf("}\n");
//		for(int i = 1; i <= n; i++)
//			for(int j = 1; j <= m; j++)
//				std::printf("%d%c", dis[i][j], j == m ? '\n' : ' ');
		int x = q.front().x, y = q.front().y;
		q.pop_front();
		for(int i = 0; i < 4; i++) {
			int dx = x + d[i][0], dy = y + d[i][1];
			if(1 <= dx && dx <= n && 1 <= dy && dy <= m && (dis[dx][dy] == -1 || dis[dx][dy] > dis[x][y]) && s[dx][dy] == '.') {
				dis[dx][dy] = dis[x][y];
				q.push_front({dx, dy});
			}
		}
		for(int i = x - 2; i <= x + 2; i++)
			for(int j = y - 2; j <= y + 2; j++)
				if(1 <= i && i <= n && 1 <= j && j <= m && (dis[i][j] == -1 || dis[i][j] > dis[x][y]) && s[i][j] == '.') {
					dis[i][j] = dis[x][y] + 1;
					q.push_back({i, j});
				}
	}
}

int main() {
	std::scanf("%d%d%d%d%d%d", &n, &m, &stx, &sty, &edx, &edy);
	for(int i = 1; i <= n; i++) std::scanf("%s", s[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			dis[i][j] = -1;
	bfs();
	std::printf("%d\n", dis[edx][edy]);
	return 0;
}

Measured memory_bytes: 9452
import sys
from collections import deque

input()
d = deque()
for l in sys.stdin:
	s = l.split()
	if s[0] == 'insert':
		d.appendleft(s[1])
	elif s[0] == 'delete':
		try: d.remove(s[1])
		except: pass
	elif s[0] == 'deleteFirst':
		d.popleft()
	elif s[0] == 'deleteLast':
		d.pop()
print(*d)


Measured memory_bytes: 69592
H, N = map(int,input().split())
A = list(map(int, input().split()))

A_sorted = sorted(A, reverse=True)


for attack in A_sorted:
	if N == 0:
		break
	H = H - attack
	N = N - 1

if H <= 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 13964
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            var n = list.Count;

            var dist = list.Distinct();
            foreach (var d in dist)
            {
                if (list.Count(x => x == d) == 1)
                {
                    Console.WriteLine(d);
                }
            }
        }
    }
}


Measured memory_bytes: 28220
//
//  main.cpp
//  TP1_1-C
//
//  Created by Saicj on 2015/07/13.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>

int main()
{

    int a,b;
    std::cin >> a >> b;
    std::cout << (a*b) << " " <<  2*(a+b) << "\n";
    return 0;
}

Measured memory_bytes: 1164
ABMAX = 10
L = 10**6

n, ma, mb = list(map(int, input().split()))
a, b, c = [0]*n, [0]*n, [0]*n
for i in range(n):
    a[i], b[i], c[i] = list(map(int, input().split()))

dp = [[[L for cb in range(n*ABMAX+1)] for ca in range(n*ABMAX+1)] for i in range(n+1)]
dp[0][0][0] = 0

for i in range(n):
    for ca in range(n*ABMAX+1):
        for cb in range(n*ABMAX+1):
            if dp[i][ca][cb] == L:
                continue
            
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]],
                                            dp[i][ca][cb]+c[i])

ans = L
for ca in range(1, n*ABMAX):
    for cb in range(1, n*ABMAX):
        if ca*mb == cb*ma:
            ans = min(ans, dp[n][ca][cb])

if ans == L: print(-1)
else: print(ans)

Measured memory_bytes: 61268
#include<iostream>
#include<math.h>
#include <iomanip>
using namespace std;

int main(){
    double N, K;
    cin >> N >> K;

    double s;
    s = 1.0 / N;
    //cout << s << endl;

    double ans = 0.0;
    int cou = 0;

    if(K <= N){
        for(int i = 1; i <= int(K); i++){
            int u = i;
            cou = 0;
            for(int j = 0; j < int(N); j++){
                if(u < int(K)){
                    u *= 2;
                    cou++;
                }else{
                    //cout << cou << endl;
                    break;
                }
            }
            ans += s * pow(0.5, cou);
        }
        double z = N - K; 
        s = z / N;
            ans += s;
        
    }else{
        for(int i = 1; i <= int(N); i++){
            int u = i;
            cou = 0;
            for(int j = 0; j < int(K); j++){
                if(u < int(K)){
                    u *= 2;
                    cou++;
                }else{
                    //cout << cou << endl;
                    break;
                }
            }
            ans += s * pow(0.5, cou);
        }

    }

    cout << setprecision(13) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,counter=0;
int main() {
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=0;i<n;i++){
        if(((i+1)% 2 == 1) && (a.at(i)%2==1)){
            counter++;
        }
    }cout << counter << endl;
    return 0;
}


Measured memory_bytes: 3596
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n: usize = input.next();
    let x: i64 = input.next();
    let mut a: Vec<i64> = vec![0;n];
    for i in 0..n {
        a[i] = input.next();
    }
    let mut t: Vec<i64> = vec![i64::max_value();n];
    let mut v = i64::max_value();
    for i in 0..n {
        let mut s: i64 = 0;
        for j in 0..n {
            let k = if j < i { a[n + j - i] } else { a[j - i] };
            if t[j] > k {
                t[j] = k;
            }
            s += t[j];
        }
        if v > s + i as i64 * x {
            v = s + i as i64 * x;
        }
    }
    println!("{}", v);
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] l = new int[m][2];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < 2; j++) {
                l[i][j] = sc.nextInt();
            }
        }
        int[] nn = new int[n+1];
        for (int i = 0; i < m; i++) {
            int s = l[i][0];
            int e = l[i][1];
            for (int j = s; j < e + 1; j++) {
                nn[j]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < nn.length; i++) {
            if(nn[i] == m) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62180
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T1, typename... T2>
void in(const T1 H, const T2... T) {
    std::cin >> (H); in(T...);
}

template <typename T1, typename T2>
std::ostream& operator>>(std::ostream& is, const std::pair<T1, T2>& v) {
    return is >> v.first >> v.second;
}

template <typename T>
std::ostream& operator>>(std::ostream& is, const std::vector<T>& v) {
    for (T& i: v) is >> i;
    return is;
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n; ++i) os << v[i] << (i == n - 1 ? "" : " ");
    return os;
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    std::string s; in(s);
    std::string last, curr;
    int k = 0;
    for (char c: s) {
        curr += c;
        if (curr != last) {
            last = curr;
            curr = "";
            ++k;
        }
    }
    out(k);
    return 0;
}


Measured memory_bytes: 1228
import Data.Array (Array, listArray, accumArray, (!))
import Data.List (sortOn, sortBy)


import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.MArray
import Control.Monad.ST (ST, runST)
import Control.Monad (when)


type UnionFind s = (STUArray s Int Int, STUArray s Int Int)

inituf :: (Int,Int) -> ST s (UnionFind s)
inituf (s,t) = (,) <$> newListArray (s,t) [s..] <*> newArray (s,t) 1

find :: UnionFind s -> Int -> ST s Int
find uf@(par,_) x = do
  p <- readArray par x
  if p==x then return x
  else do
    p' <- find uf p
    writeArray par x p'
    return p'

same :: UnionFind s -> Int -> Int -> ST s Bool
same uf x y = (==) <$> find uf x <*> find uf y

union :: UnionFind s -> Int -> Int -> ST s Int
union uf@(par,siz) x y = do
  px <- find uf x
  py <- find uf y
  when (px/=py) $ do
    sx <- readArray siz px
    sy <- readArray siz py
    writeArray par py px
    writeArray siz px (sx+sy)
  return px

size :: UnionFind s -> Int -> ST s Int
size (par,siz) x = readArray par x >>= readArray siz


type T a = (a,a)
f :: [a] -> T a
f [x,y] = (x,y)

permu n 0 = 1
permu n k = n * permu (n-1) (k-1)

choice n k = permu n k `div` permu k k

solv n m xs
  = runST $ do
    uf <- inituf (1,n)
    go uf (reverse xs) (choice n 2)
  where
    go :: UnionFind s -> [T Int] -> Int -> ST s [Int]
    go uf [] _ = return []
    go uf ((a,b):xs) c = do
      ga <- find uf a
      gb <- find uf b
      if ga==gb then (c:) <$> go uf xs c
      else do
        sa <- size uf ga
        sb <- size uf gb
        union uf a b
        let c' = c - sa*sb
        (c:) <$> go uf xs c'


main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  xs <- map (f.map read.words) . lines <$> getContents :: IO [T Int]
  putStr . unlines . map show . reverse $ solv n m xs


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

int main() {
  int s1, s2, s3, ans;
  cin >> ans;
  s1 = ans / 100;
  s2 = ( ans - s1 * 100 ) / 10;
  s3 = ans - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  int ans = 0;
  int sum = 0;
  rep(i, N) {
    int x; cin >> x;
    ans += sum * x;
    sum += x;
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vec h(N);
    REP(i,0,N) cin >> h[i];

    ASC(h);
    ll m = INF;
    REP(i,0,N-K+1) m = MIN(m,h[i+K-1]-h[i]);
    PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 3980
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K



int main(){
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll MIN = min(x,y);
    ll MAX = max(x,y);
    ll min_num = min(a,b);
    ll max_num = max(a,b);
    ll num;
    if(a>c&&b>c){
        num = ((max_num-c)+(min_num-c))*MIN;
    }else{
        num = ((max_num-c)-(c-min_num))*MIN;
    }
    ll ans = a*x+b*y;
    ans = min(ans,ans-num);
    cout << min(ans,MAX*c*2) << endl;
}


Measured memory_bytes: 256
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

bool judge(string x, string y) {
	int i = 0;
	while (x[i]) {
		i++;
	}
	if (x[i - 1] == y[0]) {
		return true;
	}
	return false;
}

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if (judge(a, b)) {
		if (judge(b, c)) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}



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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<char>> A(N, vector<char>(N));
  vector<vector<char>> B(M, vector<char>(M));

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B.at(i).at(j);
    }
  }


  for (int l = 0; l <= N-M; l++) {
    for (int k = 0; k <= N-M; k++) {
      bool flag=true;
      for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
          if (A.at(i+l).at(j+k)!=B.at(i).at(j)){
            flag=false;
          }
        }
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
package main

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

const (
	maxN = 55
)

var board [maxN]string
var H, W int

func main() {
	fsc := NewFastScanner()
	H, W = fsc.NextInt(), fsc.NextInt()

	for i := 0; i < H; i++ {
		board[i] = fsc.Next()
	}
	result := [maxN][maxN]int{}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if board[i][j] != '#' {
				cnt := 0
				for y := -1; y <= 1; y++ {
					for x := -1; x <= 1; x++ {
						ny := i + y
						nx := j + x
						if ny < 0 || ny >= H || nx < 0 || nx >= W {
							continue
						}
						if board[ny][nx] == '#' {
							cnt++
						}
					}
				}
				result[i][j] = cnt
			} else {
				result[i][j] = -1
			}
		}
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if result[i][j] == -1 {
				fmt.Print("#")
			} else {
				fmt.Print(result[i][j])
			}
		}
		fmt.Println()
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int rectCount = 0;
        int rhombusCount = 0;
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            String[] values = line.split(",");
            int a = Integer.parseInt(values[0]);
            int b = Integer.parseInt(values[1]);
            int c = Integer.parseInt(values[2]);
            if (a == b) {
                rhombusCount++;
            } else if (a * a + b * b == c * c) {
                rectCount++;
            }
        }
        out.println(rectCount);
        out.println(rhombusCount);
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a[3][3];
  rep(i, 0, 3) rep(j, 0, 3) {
    cin >> a[i][j];
  }

  rep(i, 0, 103) rep(j, 0, 103) rep(k, 0, 103) {
    int bi = a[0][0] - i, bj = a[0][1] - i, bk = a[0][2] - i;
    if(a[1][0] - j != bi || a[2][0] - k != bi) continue;
    if(a[1][1] - j != bj || a[2][1] - k != bj) continue;
    if(a[1][2] - j != bk || a[2][2] - k != bk) continue;
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    string s;
    cin>>s;

    if(s=="ABC")cout<<"ARC\n";
    else cout<<"ABC";
}


Measured memory_bytes: 3560
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int neko[10000] = {};
	int s = 0;
	cin >> s;
	int number = 1;
	neko[s]++;
	for (int i = 2; i < 1000030; i++) {
		number++;
		if (s % 2 == 0) {
			s = s / 2;
			neko[s]++;
		}
		else {
			s = 3 * s + 1;
			neko[s]++;
		}
		if (neko[s] == 2) {
			cout << number;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int h,w,i,j,k,c,ans = 0;cin >> h >> w;
  int my[h][w],mh[w][h];char s[h][w];
  for(i=0;i<h;i++){
    c = 0;
    for(j=0;j<w;j++){
      cin >> s[i][j];
      if(s[i][j]=='.') c++;
      else{
        my[i][j] = -10000;
        for(k=j-1;k>=j-c;k--) my[i][k] = c;
        c = 0;
      }
    }
    for(k=w-1;k>=w-c;k--) my[i][k] = c;
  }
  for(i=0;i<w;i++){
    c = 0;
    for(j=0;j<h;j++){
      if(s[j][i]=='.') c++;
      else{
        mh[i][j] = -10000;
        for(k=j-1;k>=j-c;k--) mh[i][k] = c;
        c = 0;
      }
    }
    for(k=h-1;k>=h-c;k--) mh[i][k] = c;
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++) ans = max(ans,my[i][j]+mh[j][i]);
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,a[400000];
  cin >> n;
  for(int i = 0; i < 3*n; i++)
    cin >> a[i];
  
  sort(a,a+3*n,greater<int>());
  
  long sum = 0;
  for(int i = 1; i < 2*n; i++) {
    sum += a[i];
    i++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 4716
#include <iostream>
#include <string>

using namespace std;
	
	
class Hoge{
			int N;
			int* pcost;
			int* pvalue;
			
			int itemp0,imax;
		
		public:
			Hoge(){
			
			pcost=new int[100];
			pvalue=new int[100];
			imax=0;
			
			
			}
			
			
		void input();
		void checkmax();			
		
		
		int getimax() const{return imax;}

			

									
		virtual ~Hoge(){	
					delete[] pcost;
					delete[] pvalue;
					
					//cout<<"pyama is erased."<<endl;
						}
};



void Hoge::input(){
		
					cin>>N;
					for (int icount=0;icount<N;icount++)
					cin>>pvalue[icount];
					for (int icount=0;icount<N;icount++)
					cin>>pcost[icount];
					}
					
					
void Hoge::checkmax(){
	
				for (int icount=0;icount<N;icount++){
					itemp0=pvalue[icount]-pcost[icount];
							if(itemp0>0){
							
													imax=imax+itemp0;
												
										}
									
									
								}//end for
						}//end function

int main()
{
	int imax;
	Hoge* ph0=new Hoge();
	ph0->input();
	ph0->checkmax();
	imax=ph0->getimax();
	cout<<imax<<endl;
	delete ph0;
	
}

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

int main() {
    int t, d;
    cin >> t >> d;
    int count = 0;
    while (t--) {
        int x, y;
        cin >> x >> y;
        if (sqrt(pow(x, 2) + pow(y, 2)) <= d) ++count;
    }
    cout << count;
}

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

int main() {
	int n, arr[200005];
	long long ans = 0;
	scanf("%d", &n);
	for(int i = 0;i < n;i++) scanf("%d", &arr[i]);
	sort(arr, arr+n);
	queue<int> q;
	q.push(arr[n - 1]);
	int j = n - 2;
	while(j >= 0){
		ans += (long long) q.front();
		q.push(arr[j]);
		q.push(arr[j]);
		q.pop();		
		j--;
	}printf("%lld\n", ans);
	return 0;
}
//ios_base::sync_with_stdio(false);


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
string S;
ll mo=1000000007;
ll dp[3030][3030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>S;
	
	int CR=0,CL=0;
	int B[2]={};
	dp[0][0]=1;
	while(M--) {
		int L,R;
		cin>>L>>R;
		L--,R--;
		while(CL<L) {
			if(CL==CR) B[S[CR++]=='1']++;
			FOR(i,3001) if(dp[CL][i]) {
				if(i<B[0]) (dp[CL+1][i+1]+=dp[CL][i])%=mo;
				if(CL-i<B[1]) (dp[CL+1][i]+=dp[CL][i])%=mo;
			}
			CL++;
		}
		while(CR<=R) B[S[CR++]=='1']++;
	}
	while(CL<N) {
		if(CL==CR) B[S[CR++]=='1']++;
		FOR(i,3001) if(dp[CL][i]) {
			if(i<B[0]) (dp[CL+1][i+1]+=dp[CL][i])%=mo;
			if(CL-i<B[1]) (dp[CL+1][i]+=dp[CL][i])%=mo;
		}
		CL++;
	}
	
	cout<<dp[CL][B[0]]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 12672
import sys
n, y = map(int, input().split())

flg = False
for i in range(n + 1):
    for j in range(n + 1):
        if n - (i + j) >= 0:
            if 1000 * (n - (i + j)) + 5000 * j + 10000 * i == y:
                flg = True
                print(str(i) + ' ' + str(j) + ' ' + str(n - (i + j)))
                sys.exit()
if not flg:
    print('-1 -1 -1')

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N,T;
  cin>>N>>T;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) cin >> v[i];
  vector<ll> M(N);
  ll t = 0;
  for(ll i = N-1; i >= 0; i--) {
    chmax(t,v[i]);
    M[i]=t;
  }
  map<ll,ll> m;
  for(int i = 0; i < N; i++){
    m[M[i]-v[i]]++;
  }
  ll ans = 0LL;
  for(auto x:m) ans=x.second;
  cout<<ans<<endl;
}

Measured memory_bytes: 8064
/*
      author  : nishi5451
      created : 12.08.2020 21:51:32
*/

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


int main(){
    ll a,b,x;
    ll ans;
    cin >> a >> b >> x;
    if(a==0){
        if(b==0) ans=1;
        else ans = b/x+1;
    }
    else{
        ans = b/x-(a-1)/x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
s = 0
m = 10000000000
flag = False
for i in range(n):
  a,b = list(map(int,input().split()))
  s += a
  if a != 0 and a > b and m > b:
    m = b
  if a != b:
    flag = True
if flag:
  print(s - m)
else:
  print(0)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;

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

  MInt ans(0);
  vector<MInt> dp(k + 1);
  for (int i = k; i >= 1; i--) {
    dp[i] = Pow(MInt(k / i), static_cast<long long>(n));
    for (int j = i * 2; j <= k; j += i) {
      dp[i] -= dp[j];
    }

    ans += dp[i] * MInt(i);
  }

  cout << ans.Get() << '\n';

  return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int a, b;
int main() {
    DAU
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    for (int i = 1; i <= b; ++i)
        cout << a;
    PLEC
}


Measured memory_bytes: 256
#coding: utf-8

inputInt = int(input())
oriInput = inputInt
counter = 0

for i in range(0, 10):
    if inputInt >= 10**(9-i):
        i1 = int(inputInt / 10**(9-i))
        counter += i1
        inputInt = inputInt - (10**(9-i))*i1

if oriInput % counter == 0:
    print ("Yes")
else:
    print ("No")

Measured memory_bytes: 3060
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int count=0;
        String word=sc.nextLine();
        word=word.toLowerCase();
        String sent="";
        while(sc.hasNext()){
            sent=sc.next();
            if(sent.equals("END_OF_TEXT")) break;
            sent=sent.toLowerCase();
            if(sent.equals(word))
                count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquestring;
typedef priority_queue<int> priqueint;
typedef priority_queue<ll> priquell;
typedef priority_queue<char> priquechar;
typedef priority_queue<string,vector<string>,greater<string>> rpriquestring;
typedef priority_queue<int,vector<int>,greater<int>> rpriqueint;
typedef priority_queue<ll,vector<ll>,greater<ll>> rpriquell;
typedef priority_queue<char,vector<char>,greater<char>> rpriquechar;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

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

void next(vector<int> &use){
    bool ans=true;
    int cnt=0;
    while(ans){
        use[cnt]++;
        if(use[cnt]<=2)ans=false;
        else use[cnt]=0;
        cnt++;
    }
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
  
  vector<bool> pri(1000001,true);
  rep2(i,2,1000001){
    if(!pri[i])continue;
    for(int j=2*i;j<=1000001;j+=i)pri[j]=false;
  }
  queue<int> pr;
  rep2(i,2,1000001){
    if(pri[i])pr.push(i);
  }
  
  ll n;cin >> n;
  if(n==1){cout << 0 << endl;return 0;}
  ll ans=0;
  int p;
  while(!pr.empty()){
    p=pr.front();pr.pop();
    if(p*p>n)break;
    ll j=p;
    while(n%j==0){
      n/=j;j*=p;ans++;
    }
    while(n%p==0)n/=p;
  }
  if(n!=1)ans++;
  cout << ans << '\n';
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);

}

class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<ll> A(N);

        rep(i, 0, N) cin >> A[i];

        ll g = A[0];
        for (int i = 1; i < N; ++i) {
            g = gcd(g, A[i]);
        }

        cout << g << endl;

    }
};


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

    Solve().solve();


    return 0;
}


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

using namespace std;
using ll = long long;

int N, M;
vector<vector<int> > graph;
vector<int> dp;

int rec(int v) {
  if (dp[v] != -1) {
    return dp[v];
  }
  int res = 0;
  for (auto nv : graph[v]) {
    res = max(res, rec(nv) + 1);
  }
  return dp[v] = res;
}

int main() {
  cin >> N >> M;
  graph.assign(N, vector<int>());
  dp.assign(N, -1);

  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph[x].push_back(y);
  }
  int res = 0;
  rep(v, N) { res = max(res, rec(v)); }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 10928
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import random
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    ans=0
    for i in range(10**6):
        k=random.randint(0,N)
        ans=max(ans,f(A,B,k))
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 78492
#include<iostream>
using namespace std;
struct EDGE{
	int u,v,w;
}e[65];
int cnt=0;
void add(int u,int v,int w){
	e[++cnt]=(EDGE){u,v,w};
}
int l;
int main(){
	cin>>l;
	int tmp=l,v=0;
	while(tmp){
		v++;
		tmp/=2;
	}
	for(int i=1;i<v;i++){
		add(i,i+1,0);
		add(i,i+1,1<<(v-i-1));
	}
	tmp=1<<(v-1);
	for(int i=v-1;i>=1;i--){
		if(l&(1<<(i-1))){
			add(1,v-i+1,tmp);
			tmp+=1<<(i-1);
		}
	}
	cout<<v<<" "<<cnt<<endl;
	for(int i=1;i<=cnt;i++){
		cout<<e[i].u<<" "<<e[i].v<<" "<<e[i].w<<endl;
	}
}

Measured memory_bytes: 3608
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 998244353;
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}
var BIT = (function(){
  function f(n){return new BIT(n);}
  function BIT(n){
    this.a = Array(n+1).fill(0);
  }
  BIT.prototype.add = function(x,i){
    for(;i<this.a.length;i+=i&-i)this.a[i]+=x;
  };
  BIT.prototype.get = function(i){
    for(var r=0;i;i-=i&-i)r+=this.a[i];
    return r;
  };
  return f;
})();

console.log(main());
function main(){
  var n = o.a();
  var x = o.m(n).sort((a,b)=>a[1]-b[1]);
  var p2 = [1]; p2.length = n+1;
  for(var i = 0; i < n; i++){
    x[i][1] = i+1;
    p2[i+1] = p2[i] << 1;
    if(p2[i+1] >= mod)p2[i+1] -= mod;
  }
  x.sort((a,b)=>a[0]-b[0]);
  var bitL = BIT(n), bitR = BIT(n);
  var xy = xArray(0,n,4);
  for(i = 0; i < n; i++){
    xy[i][2] = bitL.get(x[i][1]);
    xy[i][3] = i-xy[i][2];
    bitL.add(1,x[i][1]);
  }
  for(i = n; i--;){
    xy[i][1] = bitR.get(x[i][1]);
    xy[i][0] = n-i-1-xy[i][1];
    bitR.add(1,x[i][1]);
  }
  var ans = abmod(n,p2[n-1]);
  for(i = 0; i < n; i++){
    var t = xy[i];
    ans += abmod(p2[t[3]]-1,p2[t[1]]-1,p2[t[0]],p2[t[2]]);
    ans += abmod(p2[t[0]]-1,p2[t[2]]-1,p2[t[1]]+p2[t[3]]-1);
  }
  return ans%mod;
}

Measured memory_bytes: 124036
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class TaskB {
        static final String YES = "Yes";
        static final String NO = "No";

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            long d = in.nextLong();
            if (a < b || d < b) {
                out.println(NO);
                return;
            }
            long g = gcd(b, d);
            long worst = g - a % g;
            if (c >= b - worst) {
                out.println(YES);
            } else {
                out.println(NO);
            }
        }

        private long gcd(long p, long q) {
            while (q > 0) {
                long t = p % q;
                p = q;
                q = t;
            }
            return p;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int Sum(int N){
  int ans = 0;
  while (N > 0){
    ans += N % 10; N /= 10;
  }
  return ans;
}

int main(){
  int N; cin >> N;
  if (N % Sum(N) == 0) Yes();
  else No();

  return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if(m <= n*2){
            System.out.println(m/2);
        }else{
            m -= n*2;
            System.out.println(n+m/4);
        }
    }
}

class Point{
    double x,y;
    public Point(double x, double y){
        this.x = x;
        this.y = y;
    }
}
class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 20692