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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 998244353; // 1e9 + 7
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    const Mod& operator+=(Mod b) { x = (x + b.x)%MOD; return *this; }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    const Mod& operator-=(Mod b) { x = (x - b.x + MOD)%MOD; return *this; }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    static ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
} 

void solve_test() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  vector<vector<Mod>> dp(c+1, vector<Mod>(d+1, 0));

  dp[a][b] = 1;
  for (int i = a; i <= c; ++i) {
    for (int j = b; j <= d; ++j) {
      if (j > b) {
        dp[i][j] += dp[i][j-1]*i;
      }
      if (i > a) {
        dp[i][j] += dp[i-1][j]*j;
      }
      if (j > b && i > a) {
        dp[i][j] -= dp[i-1][j-1]*(i-1)*(j-1);
      }
    }
  }
  cout << dp[c][d].x << endl;
}

void setup() {
}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve_test();
    }
}


Measured memory_bytes: 73676
import java.util.Scanner;

public class Main {

	public static long mod = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();

		int[][][][] dp = new int[N + 1][4][4][4];
		dp[0][3][3][3] = 1;

		// AGC,ACG,GAC,AG?C,A?GC
		// A=0, C=1, G=2, T=3
		for (int len = 1; len <= N; len++) {
			for (int c1 = 0; c1 < 4; c1++) {
				for (int c2 = 0; c2 < 4; c2++) {
					for (int c3 = 0; c3 < 4; c3++) {
						if (c1 == 0 && c2 == 2 && c3 == 1) {
							continue;
						}
						for (int c4 = 0; c4 < 4; c4++) {
							if (c2 == 0 && c3 == 2 && c4 == 1
									|| c2 == 0 && c3 == 1 && c4 == 2
									|| c2 == 2 && c3 == 0 && c4 == 1
									|| c1 == 0 && c2 == 2 && c4 == 1
									|| c1 == 0 && c3 == 2 && c4 == 1) {
								continue;
							}
							dp[len][c2][c3][c4] += dp[len - 1][c1][c2][c3];
							dp[len][c2][c3][c4] %= mod;
						}
					}
				}
			}
		}

		int ans = 0;
		for (int c1 = 0; c1 < 4; c1++) {
			for (int c2 = 0; c2 < 4; c2++) {
				for (int c3 = 0; c3 < 4; c3++) {
					ans += dp[N][c1][c2][c3];
					ans %= mod;
				}
			}
		}
		System.out.println(ans);
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        int a; cin >> vec.at(i);
    }
    int error = 1000000;
    for(int i = 0; i < n-1 ; i++){
        int sum_1 = 0, sum_2 = 0;
        for(int j = 0; j <= i; j++){
            sum_1 += vec.at(j);
        }
        for(int k = i+1; k < n; k++){
            sum_2 += vec.at(k);
        }
        if(abs(sum_1 - sum_2) < error) error = abs(sum_1 - sum_2);
    }

    cout << error << endl;

    return 0;
}


Measured memory_bytes: 3596
def LimitedTime(Array , T , N):
    MinC=1001
    for i in range (N):
            if Array[i][1]<=T:
               if Array[i][0]<MinC:
                   MinC=Array[i][0]
    if MinC==1001:
        return 'TLE'
    else:
        return MinC
                
                
                   
                   



TandN=list(map(int ,input().split()))
N=TandN[0]
T=TandN[1]
Array=[[int(j) for j in input().split()]for i in range(N)]
print(LimitedTime(Array , T ,N))

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
//        int a = sc.nextInt();
//        int b = sc.nextInt();
//        int c = sc.nextInt();
//        String s = sc.next();
//        Long x = sc.nextLong();
        String masterList[] = new String[n];
        String list[] = new String[n+1];
        int order[] = new int[n+1];

        for(int i=0;i<n;i++){
            masterList[i] = sc.next();
            list[i]=masterList[i];
            order[i]= i;
        }

        for(int i=1;i<=n;i++){
            for(int j=i-1;j>0;j--){
                for(int t=0;t<l;t++){
                    if(list[j-1].toCharArray()[t]==list[j].toCharArray()[t]){
                        continue;
                    }
                    if(list[j-1].toCharArray()[t]>list[j].toCharArray()[t]){
                        list[n]=list[j];
                        list[j]=list[j-1];
                        list[j-1]=list[n];
                        order[n]=order[j];
                        order[j]=order[j-1];
                        order[j-1]=order[n];
                    }
                    break;
                }
            }
        }
        for(int i=0;i<n;i++){
            System.out.print(masterList[order[i]]);
        }
        System.out.println("");
    }
}


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

int main() {
    int K;
    string S;

    cin >> K;
    cin >> S;

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0,K) << "..." << endl;
    }

}

Measured memory_bytes: 3524
def temp(x):
    return T - x * 0.006

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

def temp(x):
    return abs((T - x * 0.006) - A)

ans = list(map(temp, H))
print(int(ans.index(min(ans))) + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, flag=0;
  string s;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=="Y"){
      flag = 1;
      break;
    }
  }
  if(flag==1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {

        string[] NMstring = Console.ReadLine().Split(' ');
        int Nint = int.Parse(NMstring[0]);
        int Mint = int.Parse(NMstring[1]);
        string[] Astring = Console.ReadLine().Split(' ');
        int HWdays = 0;
        for(int i = 0; i < Mint; i++)
        {
            HWdays += int.Parse(Astring[i]);
        }
        int playdays = Nint - HWdays;
        if(playdays <= -1){
            playdays = -1;
        }
        Console.WriteLine(playdays);
    }
    

}



Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005,Mo=1000000007;
char s[105][105];
int n,m,q,a[MAXN],b[MAXN];
int main(){
	n=read(); m=read();
	printf("100 100\n");
	memset(s,0,sizeof(s));
	FOR(i,1,100)
		FOR(j,1,100) s[i][j]='.';
	FOR(i,1,50)
		FOR(j,1,100) s[i][j]='#';
	int x=1,y=1;
	FOR(i,2,n) {
		s[x][y]='.';
		if (y==99) x+=2,y=1; else y+=2;
	}
	x=100,y=1;
	FOR(i,2,m) {
		s[x][y]='#';
		if (y==99) x-=2,y=1; else y+=2;
	}
	FOR(i,1,100) {
		FOR(j,1,100) printf("%c",s[i][j]);
		printf("\n");
	}
	
	return 0;
}

/*
*/


Measured memory_bytes: 256
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

let left i = 2*i + 1

let right i = 2*i + 2

let to_pow_of_2 n =
  let rec doit i =
    if i >= n then i
    else doit (i * 2) in
  doit 1

let update (s : int array) n i x =
  let j = n + i - 1 in
  s.(j) <- x;
  let rec doit j =
    if j > 0 then begin
      let j = parent j in
      s.(j) <- if s.(left j) < s.(right j) then s.(left j) else s.(right j);
      doit j
    end in
  doit j

let find s n a b =
  let rec doit a b k l r =
    if r <= a || b <= l then 2147483647
    else if a <= l && r <= b then s.(k)
    else begin
      let v = doit a b (left k) l ((l + r) / 2) in
      let w = doit a b (right k) ((l + r) / 2) r in
      if v < w then v else w
    end in
  doit a b 0 0 n

let solve n q =
  let n = to_pow_of_2 n in
  let s = Array.make (2*n-1) 2147483647 in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split_on_char ' ' (read_line ())) with
      | 0 :: x :: y :: _ -> update s n x y
      | 1 :: x :: y :: _ -> Printf.printf "%d\n" (find s n x (y + 1))
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split_on_char ' ' (read_line ())) with
  | [n; q] -> solve n q
  | _ -> ()

Measured memory_bytes: 6580
#include<stdio.h>
int main()
{
	char X[5];
	scanf("%s",&X);
	
	if(X[0]=='A' && X[1]=='A' && X[2]=='B' || X[0]=='B' && X[1]=='B' && X[2]=='A')
	{
		printf("Yes");
	}
	if(X[0]=='A' && X[1]=='B' && X[2]=='A' || X[0]=='B' && X[1]=='A' && X[2]=='B')
	{
		printf("Yes");
	}
	if(X[0]=='B' && X[1]=='A' && X[2]=='A' || X[0]=='A' && X[1]=='B' && X[2]=='B')
	{
		printf("Yes");
	}
	if(X[0]=='A' && X[1]=='A' && X[2]=='A' || X[0]=='B' && X[1]=='B' && X[2]=='B')
	{
		printf("No");
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1736
import sys

sys.setrecursionlimit(10 ** 9)


def rec(vv):
    if p[vv] >= 0:
        return p[vv]

    res = 0
    for nv in g[vv]:
        res = max(res, rec(nv) + 1)
    p[vv] = res
    return res


N, M = map(int, input().split())
g = [[] for _ in range(N)]
p = [-1 for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

ans = 0
for v in range(N):
    ans = max(ans, rec(v))
print(ans)


Measured memory_bytes: 152924
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)


int main()
{
	ll n;
	cin >> n;
	ll ans = 100000000000000001;
	for (ll i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			if (i + (n / i) - 2 < ans)
			{
				ans = i + n / i - 2;
			}
		}
	}

	cout << ans << "\n";
	
	return 0;
}

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

bool exist(vector<int> array,int y,int n){
    array.push_back(y);
    int i = 0;
    while(array.at(i) != y) i++;
    return i == n;
}
int main(){
    int x,n;
    cin >> x >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++) cin >> array.at(i);
    if(exist(array,x,n)){
        cout << x << endl;
    }else{
        int idx = 0;
        while(true){
            idx++;
            if(exist(array,x-idx,n)){
                cout << x - idx << endl;
                break;
            }else if(exist(array,x+idx,n)){
                cout << x + idx << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3596
# coding: utf-8
# Here your code !
# -*- coding:utf-8 -*-
import sys

def init():
    data = []
    try:
        while(True):
            line = raw_input()
            if not line: break
            data.append(tuple(line.split(" ")))
    except EOFError:
        pass
    return data

def valid(n):
    return (1 <= n <= 100)

def main():
    hight, width = init().pop()
    hight = int(hight)
    width = int(width)
    if valid(hight) and valid(width):
        print "%d %d" % (hight*width, hight*2+width*2)
    else:
        print "Error / Invalid input (%d,%d)" % (hight, width)

if __name__ == '__main__':
    main()

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
  string a, b;
  cin >> a >> b;
  a = a + b;
  int l = stoi(a);
  for (int i = 0; i <= sqrt(l); i++)
  {
    if (i * i == l){
      cout << "Yes" << endl;
    return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


int main(){
 int AH ,BA, CH,DA;
  cin >> AH >> BA >>CH>>DA;
  while (AH > 0 || CH > 0){
    CH -= BA ;
    if (CH <= 0) { cout << "Yes";
                  return 0;}
    AH -= DA ;
    if (AH <= 0) { cout << "No";
                  return 0;}
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 51000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  if(N%2==1)Out(N/2+1);
  else Out(N/2);
}

Measured memory_bytes: 256
s = input()
k = int(input())

if len(set(s)) ==1:
  print(k*len(s) //2)
  exit(0)

is_same = False
b = ''
count = 0
tail = False
for c in s:
  if c == b and not is_same:
    count += 1
    is_same = True
  else:
    is_same = False
  b = c
else:
  if s[0] == s[-1]:
    cnt= 0
    for c in s:
      if c == s[0]:
        cnt += 1
      else:
        break
    for c in s[::-1]:
      if c == s[0]:
        cnt+=1
      else:
        break
    if cnt %2 ==0:
      tail = True
ans = count * k
if tail:
  ans += k-1
print(ans)

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int k; cin >> k;
    queue<ll> q;
    if (k <= 12) {
        cout << k << '\n';
        return 0;
    }

    for (int i = 1; i <= 9; ++i)
        q.push(i);

    int done = 0;
    while (true) {
        ll cur = q.front();
        q.pop();
        ++done;

        if (done == k) {
            cout << cur << '\n';
            break;
        }

        int d = cur % 10;
        if (d != 0)
            q.push((cur * 10) + d - 1);
        q.push((cur * 10) + d);
        if (d != 9)
            q.push((cur * 10) + d + 1);
    }
}

Measured memory_bytes: 1792
def test_eq(left, right)
  if left == right
    puts "."
  else
    puts [left, 'but', right]
    puts "x"
  end
end

LIMIT=100100
# 平方数かどうか
# @param Integer number 調べたい数
# @return Bool
def square_number?(number)
  # ? 入力値を受け取る
  # ? 入力値から平方数候補となる値の元を定義する
  # 値の元を二乗し平方数候補を生成する
  candidates = []
  i = 1
  while (i ** 2) < LIMIT
    candidates << i ** 2
    i += 1
  end 

  # 入力値と同じ値が平方数候補の中に存在するかチェックする
  candidates.include?(number)
end

input = 3
expected = false
# test_eq(square_number?(input), expected)

input = 4
expected = true
# test_eq(square_number?(input), expected)


number = gets.split.join('').to_i

# p square_number?(number)
s=(if square_number?(number)
  "Yes"
else
  "No" 
end)
puts s

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

typedef long long ll;

ll N;
vector<vector<ll>> Adj;
vector<ll> Road;
ll X, Y;

bool find_road(ll v, ll par) {
  Road.push_back(v);
  if (v == N - 1) return true;
  for (ll w : Adj[v]) {
    if (w == par) continue;
    if (find_road(w, v)) return true;
  }
  Road.pop_back();
  return false;
}
ll count(ll v, ll par, ll par2 = -1) {
  ll res = 1;
  for (ll w : Adj[v]) {
    if (w == par || w == par2) continue;
    res += count(w, v);
  }
  return res;
}
int main() {
  cin >> N;
  Adj.resize(N);
  for (ll i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    Adj[a].push_back(b);
    Adj[b].push_back(a);
  }
  assert(find_road(0, -1));
  assert(Road.front() == 0 && Road.back() == N - 1);
  for (ll i = 0; i < Road.size(); ++i) {
    ll c = count(Road[i], i > 0 ? Road[i - 1] : -1,
                 i < Road.size() - 1 ? Road[i + 1] : -1);
    (i < (Road.size() + 1) / 2 ? X : Y) += c;
  }
  cout << (X > Y ? "Fennec" : "Snuke") << endl;
  return 0;
}


Measured memory_bytes: 11252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

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

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

bool hargyaddo(int n)
{
    int s = 0, ck = n;
    while (ck)
    {
        s += ck % 10;
        ck /= 10;
    }

    return n % s == 0;
}

int main()
{
    int a, b;
    cin >> a >> b;

    int ans = 0;
    rep2(i, 1, 10)
    {
        rep(j, 10)
        {
            rep(k, 10)
            {
                int num = i * 10000 + j * 1000 + k * 100 + j * 10 + i;
                if (a <= num && num <= b)
                {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	new A().doIt();
    }
    class A{
    	char alf[] = {'y','u','i','o','p','h','j','k','l','n','m'};
    	int alength = alf.length;
    	boolean check(char c){
    		for(int i = 0;i < alength;i++){
				if(c == alf[i])return true;
			}
    		return false;
    	}
    	void doIt(){
    		while(true){
    			String str = sc.next();
    			if(str.equals("#"))break;
    			char ctr[] = str.toCharArray();
    			int length = str.length();
    			boolean left = false;
    			for(int i = 0;i < alength;i++)if(ctr[0] == alf[i])left = true;
    			int cnt = 0;
    			for(int i = 0;i < length;i++){
    				if(left){
    					if(!check(ctr[i])){
    						left = false;
    						cnt++;
    					}
    				}else{
    					if(check(ctr[i])){
    						left = true;
    						cnt++;
    					}
    				}
    			}
    			System.out.println(cnt);
    		}
    	}
    }
}

Measured memory_bytes: 27420
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[100005];

vector<int> dist(100005 , INT_MIN);
vector<int> vis(100005 , false);
vector<int> path(100005 , -1);

void bfs(int n){
	queue<int> q;	
	vis[1] = true;
	dist[1] = 0;
	q.push(1);

	while(!q.empty()){
		int temp = q.front();
		q.pop();

		for(int i : adj[temp]){
			if(vis[i] == false){
				path[i] = temp;
				q.push(i);
				dist[i] = dist[temp]+1;
				vis[i] = true;
			}	
		}
	}
}

int main(){
	int v , e;
	cin >> v >> e;

	for(int i =0 ; i < e ; i++){
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	bfs(1);

	bool ans = true;
	for(int i = 2 ; i <= v ; i++){
		if (dist[i] == INT_MIN){
			ans = false;
		} 
	}

	if (ans){
		cout << "Yes" << endl;
		for(int i = 2 ; i <= v ; i++){
			cout << path[i] << endl;
		}
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main(){
  int n;
  int r;
  int t;
  vector<int> target;
  vector<int> k;
  vector<vector<int>> result;
  
  cin >> n;
  
  for(int i=0;i<n;++i){
    cin>>r>>t;
    
    if(r==100)
      target.push_back(1);
    
    else if(r>100 && r<200){
      target.push_back(1);
      target.push_back(2);
    }
    else if(r==200)
      target.push_back(2);
    
    else if(r>200 && r<300){
      target.push_back(2);
      target.push_back(3);
    }
    else if(r==300)
      target.push_back(3);
    
    else if(r>300 && r<400){
      target.push_back(3);
      target.push_back(4);
    }
    
    else if(r==400)
      target.push_back(4);
    
    else if(r>400 && r<500){
      target.push_back(4);
      target.push_back(5);
    }
    else if(r==500)
      target.push_back(5);
    

    if(t==0 || t==30 || t==60 || t==90 || t==120 || t==150 || t==180){
      for(auto& i:target)
	i+=(t/6);
    }
    
    else{
      if(t>30 && t<60){
	for(auto& i:target)
	  i+=5;
      }
      
      else if(t>60 && t<90){
	for(auto& i:target)
	  i+=10;
      }
      
      else if(t>90 && t<120){
	for(auto& i:target)
	  i+=15;
      }
      
      else if(t>120 && t<150){
	for(auto& i:target)
	  i+=20;
      }
      
      else if(t>150 && t<180){
	for(auto& i:target)
	  i+=25;
      }
      
      for(auto i:target){
	k.push_back(i+5);
      }
      for(auto i:k)
	target.push_back(i);
    } 
 
    result.push_back(target);
    target.clear();
    k.clear();
  }
  
  for(int i=0;i<n;++i){
    bool flag=false;
    for(auto j:result[i]){
      if(flag==true)
	cout<<" ";
      cout<<j;
      if(flag!=true)
	flag=true;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3156
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pll = pair<LL, LL>;
using vi = vector<int>;
using vd = vector<double>;
using vvi = vector<vi>;
using vll = vector<LL>;

//==============================================

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

	
	int n;
	cin >> n;

	vi p(150);
	REP3(i, 1, n) {
		cin >> p[i - 1] >> p[i];
	}

	vvi m(150, vi(150));
	REP3(i, 1, n) m[i][i] = 0;
	REP3(l, 2, n) {
		REP3(i, 1, n - l + 1) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			REP3(k, i, j - 1) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}

	cout << m[1][n] << "\n";
	return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, T;//如果最多的蛋糕有n个 
	cin >> n >> T;//输入 
	int k = 0;//k就不用多说了吧，原题的变量 
	for(int i = 1; i <= T; ++i) {
		int a;
		cin >> a;
		k = max(k, a);
	}
	cout << max(k - 1 - (n - k), 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);

ll a[1003],b[1003];
int n;
ll dp[10004];

ll f(int h){
    if(h<=0){
        return 0;
    }
    ll &ret=dp[h];
    if(ret!=-1){
        return ret;
    }
    ret=INF;
    for(int i=0;i<n;i++){
        ret=min(ret,f(h-a[i])+b[i]);
    }
    return ret;
}

void solve(int T){
    memset(dp,-1,sizeof dp);
    int h;
    cin>>h>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    cout<<f(h);
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}




Measured memory_bytes: 4356
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;

main(){
    int n=in();
    vector<pii> v;
    rep(i,n){
        v.pb({in(),in()});
    }
    map<pii,int> m;
    int M=0;
    rep(i,n){
        rep(j,n){
            pii p={v[i].first-v[j].first,v[i].second-v[j].second};
            m[p]++;
            if(p.first!=0||p.second!=0)
            M=max(M,m[p]);
        }
    }
    cout<<n-M;
}



Measured memory_bytes: 384
A, B = map(int, input().split())
S = input()
flag = True
for i in range(A + B + 1):
	if i == A:
		if S[i] != '-':
			flag = False
	else:
		if S[i] == '-':
			flag = False

if flag:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 4
using namespace std;
int a[N];
int main(){
	scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]);
	a[1]=min(a[1],a[0]*2);
	a[2]=min(a[2],a[1]*2);
	a[3]=min(a[3],a[2]*2);
	int n;
	scanf("%d",&n);
	cout<<(long long)n/2*a[3]+(long long)(n&1)*a[2];
	return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	long K, X;
	cin >> K >> X;
	for (long i = X - (K - 1); i <= X + (K - 1); ++i)
	{
		cout << i;
		if (i == X + (K - 1))
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int max(int a,int b){
if(a>b)
    return a;
else
    return b;
}
int main()
{
char s[10];
int i;
int j;
int r;
int len;
int result=0;
gets(s);
len=strlen(s);
int posible;
for(i=0;i<len;i++){
    for(j=i;j<len;j++){
        posible=1;
        for(r=i;r<=j;r++){
            if(s[r]!='A' && s[r]!='T'&&s[r]!='C'&&s[r]!='G')
            posible=0;
        }
    if(posible)
        result=max(result,j-i+1);
    }

}

printf("%d",result);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int temp;
  temp = n%10;
  if(temp == 2||temp==4||temp==5||temp==7||temp==9){
  	cout<<"hon";
  }
  else if(temp==0||temp==1||temp==6||temp==8){
  	cout<<"pon";
  }else{
  	cout<<"bon";
  }
  return 0;
  
    
}

Measured memory_bytes: 3616
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq
import math

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

def det(a,b,c,d):
    return a * d - b * c
def solve_linear(a, b, c, d, v, w):
    # (a b)   (x)   (v)
    #  c d  *  y  =  w
    de = det(a, b, c, d)
    x = d * v - b * w
    y = -c * v + a * w
    x /= de
    y /= de
    return (x, y)
def dist2(x1, y1, x2, y2):
    return (x1 - x2) ** 2 + (y1 - y2) ** 2
eps = 1e-9

def main():
    N = ri()
    X = [0] * N
    Y = [0] * N
    for i in range(N):
        X[i], Y[i] = rip()
    
    mi = 1e12
    for i in range(N):
        for j in range(i+1,N):
            x1 = X[i]
            y1 = Y[i]
            x2 = X[j]
            y2 = Y[j]
            cx = (x1 + x2) / 2.0
            cy = (y1 + y2) / 2.0
            r2 = dist2(x1, y1, cx, cy)
            chk = True
            for k in range(N):
                chk &= (dist2(X[k], Y[k], cx, cy) < r2 + eps)
            #print(cx,cy,r2,chk)
            if chk:
                mi = min(mi, r2)
    
    for i in range(N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                x1 = X[i]
                y1 = Y[i]
                x2 = X[j]
                y2 = Y[j]
                x3 = X[k]
                y3 = Y[k]
                if det(x3-x1, y3-y1, x2-x1, y2-y1) == 0: continue
                # (x3 - cx)**2 + (y3 - cy)**2 == (x1 - cx)**2 + (y1 - cy)**2 
                # (x2 - cx)**2 + (y2 - cy)**2 == (x1 - cx)**2 + (y1 - cy)**2 
                #   <=>
                # 2*(x1 - x3) * cx + 2*(y1 - y3) * cy == x1**2 - x3**2 + y1**2 - y3**2
                # 2*(x1 - x2) * cx + 2*(y1 - y2) * cy == x1**2 - x2**2 + y1**2 - y2**2
                cx, cy = solve_linear(2*(x1-x3), 2*(y1-y3), 2*(x1-x2), 2*(y1-y2), 
                    x1**2 - x3**2 + y1**2 - y3**2,
                    x1**2 - x2**2 + y1**2 - y2**2)
                r2 = dist2(x1, y1, cx, cy)
                chk = True
                for k in range(N):
                    chk &= (dist2(X[k], Y[k], cx, cy) < r2 + eps)
                if chk:
                    mi = min(mi, r2)
    
    print(math.sqrt(mi))


if __name__ == "__main__":
    main()


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

int main()
{
    int h,n,a;
    cin>>h>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        h-=a;
    }
    if(h>0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int n;
	 cin>>n;
	 string s;
	 cin>>s;
	 int res=0;
	 int sum=0;
	 for(auto x:s)
	 {
	 	   if(x=='I')
	 	   	++sum;
	 	   else
	 	   	--sum;
	 	   res=max(res,sum);
	 }
	 cout<<res<<endl;
	}

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

void main() {
    int n = readln.chomp.to!int;
    int minv = readln.chomp.to!int;
    int maxv = -1_000_000_000;
    foreach (i; iota(1, n, 1)) {
        int l = readln.chomp.to!int;
        maxv = max(maxv, l - minv);
        minv = min(minv, l);
    }

    maxv.writeln;
}

Measured memory_bytes: 2024
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N;
	cin>>N;
	string W[100];
	rep(i,N)cin>>W[i];
	
	int diff=1,shi=1;
	rep(i,N)for(int j=i+1;j<N;j++){
		if(W[i]==W[j])diff=0;
	}
	rep(i,N-1){
		if(W[i].back()!=W[i+1].front())shi=0;
	}
	if(diff*shi)cout<<"Yes";
	else cout<<"No";
	
}

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

namespace B___Snake_Toy
{
    class Program
    {
        static void Main(string[] args)
        {
            var N_K = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ln = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
            int N = N_K[0], K = N_K[1];

            Console.WriteLine(ln.Where((e, i) => i < K).Sum());
        }
    }
}


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

import sys
import os

for s in sys.stdin:
    A = [0]
    v = float(s)
    A.append(v)

    for i in range(2, 10+1):
        if i % 2 == 0:
            v = 2 * A[i-1]
            A.append(v)
        else:
            v = A[i-1] / 3
            A.append(v)
    print(sum(A))

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

using namespace std;
typedef long long ll;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<pair<int, int>> apples;
    for (int i = 0; i < a; i++) {
        int p;
        cin >> p;
        apples.emplace_back(p, 0);
    }
    for (int i = 0; i < b; i++) {
        int p;
        cin >> p;
        apples.emplace_back(p, 1);
    }
    for (int i = 0; i < c; i++) {
        int p;
        cin >> p;
        apples.emplace_back(p, 2);
    }
    sort(apples.begin(), apples.end(), greater<>());

    int no = 0;
    ll ret = 0;
    for (auto now:apples) {
        switch (now.second) {
            case 0: {
                if (x > 0)ret += now.first, x--;
                break;
            }
            case 1: {
                if (y > 0)ret += now.first, y--;
                break;
            }
            case 2: {
                ret += now.first, no++;
                break;
            }
        }
        if (x + y <= no)break;
    }

    cout << ret << endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    string ans = "No";
    if (S[2] == S[3] && S[4] == S[5]) {
        ans = "Yes";
    }
    cout << ans << endl;
}

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

int main() {
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1;
	cin >> H2 >> M2;
	cin >> K;
	int T1 = 60 * H1 + M1;
	int T2 = 60 * H2 + M2;
	cout << T2 - T1 - K << endl;
	return 0;
}


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

char s[105];
int tab[30];

int main() {
  int n, m, cnt1 = 0, cnt2 = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i ++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j ++) tab[s[j] - 'a'] ++;
  }
  for (int i = 0; i < 26; i ++) {
    if (!tab[i]) continue;
    tab[i] %= 4;
    if (tab[i] == 1) cnt1 ++;
    else if (tab[i] == 2) cnt2 ++;
    else if (tab[i] == 3) {
      cnt1 ++;
      cnt2 ++;
    }
  }
  int max1 = 0, max2 = 0;
  if (n & 1) {
    if (m & 1) {
      max1 = 1;
      max2 = n / 2 + m / 2;
    }
    else max2 = m / 2;
  }
  else if (m & 1) max2 = n / 2;
  if (cnt1 > max1 || cnt2 > max2) puts("No");
  else puts("Yes");
  return 0;
}


Measured memory_bytes: 256
"use strict";

function main(input) {
  var lines = input.split('\n');
  var N = parseInt(lines[0]);
  var A = splitNum(lines[1]).slice(0, N);
  var B = splitNum(lines[2]).slice(0, N);
  var diffs = A.map(function (a, i) {
    return a - B[i];
  });
  diffs.sort(function (x, y) {
    return y - x;
  });
  var changed = diffs.map(function (_) {
    return false;
  });
  var source = 0;
  var target = N - 1;

  while (source < target) {
    var diff = diffs[target];

    if (diff >= 0) {
      //ok
      break;
    }

    if (diffs[source] >= -diff) {
      changed[source] = true;
      changed[target] = true;
      diffs[source] += diff;
      diffs[target] = 0;
      target--;
    } else {
      if (diffs[source] > 0) {
        changed[source] = true;
        changed[target] = true;
      }

      diffs[target] += diffs[source];
      diffs[source] = 0;
      source++;
    }
  }

  if (diffs[target] < 0) {
    console.log(-1);
  } else {
    console.log(changed.reduce(function (acc, v) {
      return acc + v;
    }, 0));
  }

  return;
}

function gcd(a, b) {
  if (a < b) return gcd(a, b);
  if (b === 0) return a;
  var r = a % b;
  return gcd(b, r);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


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

int main()
{
	string s;
	std::cin >> s;
	int a, b;
	a = s.find('A');
	b = s.find_last_of('Z');
	int rslt = b - a + 1;
	cout << rslt;

	return 0;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define endl "\n"
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
int main() {
    
    
    Imposter
    
    
	ll sum;
	cin>>sum;
	ll dp[sum+1];
	ll p=1e9 +7;
	f(sum+2) dp[i]=0;
	dp[0]=1;
	for(ll i=1;i<=sum;i++)
	{
	    for(ll j=3;j<=sum;j++)
	    {
	        if((i-j)>=0)
	        dp[i]=(dp[i]+dp[i-j])%p;
	    }
	}
	cout<<dp[sum]<<endl;
}

Measured memory_bytes: 3656
def prime_factors(n):       # 戻り値はiterable type
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i             # whileループを進めるごとにイテレータに値を貯め続ける
    if n > 1:
        yield n

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

data = set(prime_factors(A)) & set(prime_factors(B))
print(len(data) + 1)


Measured memory_bytes: 62680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<ll, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

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

int main(){
  string s;
  cin>>s;
  if(s[s.size()-1]=='s'){
    cout<<s<<"es"<<endl;
  }
  else{
    cout<<s<<"s"<<endl;
  }
}



Measured memory_bytes: 3600
x,n=map(int,input().split())
p=list(map(int,input().split()))
l=[i for i in range(-10,110)]
for i in p:
    l.remove(i)
ans=10**3
a=0
for k in reversed(l):
    z=min(ans,abs(x-k))
    if z==abs(x-k):
        a=k
        ans=z
print(a)

Measured memory_bytes: 9188
#include<stdio.h>
int z,n;
void quicksort(long int a[],int s,int t){
  if(s<t){
    long int i=s,j=t,p=a[(s+t)/2];
    while(1){
      while(a[i]<p)i++;
      while(p<a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int B(long int a[],long int k) {
    int l=-1,r=n,m;
    while (r-l>1){m=(r+l)/2;if(a[m]>=k)r=m;else l=m;}
    return r;
}
int main(){
  long int a[200000],b[200000],c[200000],i,r=0,k;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%ld",&a[i]);
  for(i=0;i<n;i++)scanf("%ld",&b[i]);
  for(z=1;z<30;z++){
    k=0;for(i=0;i<n;i++)c[i]=b[i]%(1<<z);quicksort(c,0,n-1);
    for(i=0;i<n;i++)k+=B(c,2*(1<<(z-1))-a[i]%(1<<z))-B(c,(1<<(z-1))-a[i]%(1<<z))+B(c,4*(1<<(z-1))-a[i]%(1<<z))-B(c,3*(1<<(z-1))-a[i]%(1<<z));
    r+=k%2<<(z-1);
  }
  printf("%ld",r);
}


Measured memory_bytes: 6376
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>
#pragma comment(linker, "/STACK:67108864")

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define ERASE(a) memset(a, -1, sizeof(a))
#define INF 2000000000
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;

vector<PII> a;

int dp[20005];

int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  int h,n,ai,bi;
  cin >>h>>n;
  FOR(i,n) {
    cin >> ai>>bi;
    a.push_back(MP(ai,bi));
  }

  FOR(i, 20005) dp[i]=INF;
  dp[0]=0;

  FOR(i, h) {
    if (dp[i]!=INF) {
      FOR(j,n) {
        dp[i+a[j].first] = min(dp[i+a[j].first], dp[i] + a[j].second);
        //cerr << "dp["<<i+a[j].first<<"]= " << dp[i+a[j].first] <<endl;
      }
    }
  }

  int ans = INF;
  for (int i=h;i<20005;i++)ans=min(ans,dp[i]);
  cout<<ans <<endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <memory>
#include <string>
#include <vector>

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

using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;

    int surface = h * w;
    int circumference = h * 2 + w * 2;
    cout << surface << " " << circumference << endl;
}




Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	string a, b, c;
	cin >> a >> b >> c;
	int player = 0;
	int A = 0, B = 0, C = 0;
	for (;;) {
		if (player == 0) {
			if (A == a.size()) {
				cout << "A" << endl;
				break;
			}
			switch (a[A]) {
			case 'a':player = 0; break;
			case 'b':player = 1; break;
			case 'c':player = 2; break;
			}
			A++;
		}
		if (player == 1) {
			if (B == b.size()) {
				cout << "B" << endl;
				break;
			}
			switch (b[B]) {
			case 'a':player = 0; break;
			case 'b':player = 1; break;
			case 'c':player = 2; break;
			}
			B++;
		}
		if (player == 2) {
			if (C == c.size()) {
				cout << "C" << endl;
				break;
			}
			switch (c[C]) {
			case 'a':player = 0; break;
			case 'b':player = 1; break;
			case 'c':player = 2; break;
			}
			C++;
		}
	}
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d,X[15][15],ans;
int main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)cin>>X[i][j];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			int dis=0;
			for(int k=1;k<=d;k++)dis+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			int p=sqrt(dis);
			if(p*p==dis)ans++;
		}
	cout<<ans;
	return 0;
}

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

using namespace std;

void task()
{
    char str[100];

    scanf(" %[^\n]", str);

    int len = strlen(str);

    bool flag=0;
    for(int i=0; i*2<len+2; i++){
        if(str[i]!=str[len-i-1]){
            cout<<"No"<<endl;
            return;
        }
    }
    int mid = (len-1)/2;
    for(int i=0; i<mid; i++){
        if(str[i]!=str[mid-i-1]){
            cout<<"No"<<endl; //cout<<"hi"<<endl;
            return;
        }
    }
    mid = (len+3)/2;
    for(int i=mid-1; i<len; i++){
        if(str[i]!=str[len-i-1]){
            cout<<"No"<<endl;
            return;
        }
    }

    cout<<"Yes"<<endl;
}

int main()
{
    task();

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[200010];
bool fl[2000010];
ll ma;
ll ans;
ll cnt[2000010];

int main()
{
  std::cin >> N;

  rep( i, N ) {
    std::cin >> A[i];

    chmax( ma, A[i] );

    ++cnt[A[i]];
  }

  rep( i, N ) if( !fl[A[i]] ) {
    for( ll j = 2; j*A[i] <= ma; ++j ) {
      fl[j*A[i]] = true;
    }
  }

  rep( i, N ) if( !fl[A[i]] && cnt[A[i]] == 1 )
    ++ans;

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 13932
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int x,y;
  scanf("%d%d",&x,&y);
  printf("%d\n",x+y/2);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 100005;
std::vector<int> t[maxn];

int main() {
	int n = input(), m = input();
	for(int i = 1; i <= n; i ++) {
		int a = input(), b = input();
		t[a].push_back(b);
	}
	std::priority_queue<int> q;
	int ans = 0;
	for(int i = 1; i <= m; i ++) {
		for(int x : t[i])
			q.push(x);
		if(not q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n,m;
    int a,b,c,d,s,i;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        s=0;
        if(a>=b)
        {
            for(i=1;i<=b;i++)
            {
                s+=c;
            }
            for(i=1;i<=a-b;i++)
            {
                s+=d;
            }
        }
        else
             for(i=1;i<=a;i++)
            s+=c;
        printf("%d\n",s);
    }
}


Measured memory_bytes: 128