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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> vvll;
typedef pair<ll, ll> pii;
typedef pair<string, ll> psi;
typedef pair<ll, string> pis;
typedef pair<ll, vll> plv;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define REP(i, a, b) for(ll i=ll(a);i<=ll(b);++i)
#define REPR(i, a, b) for(ll i=ll(a);i>=ll(b);--i)
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()

template<typename T>
T absolute(T a, T b) { return a >= 0 ? a : -a; }

template<typename T>
T sqr(T a) { return a * a; }

int main() {
    fastio
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]=tolower(s[k-1]);
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,s;
  cin>>a>>b>>s;
  s=a*b;
  if(a>=1&&a<=9&&b>=1&&b<=9)
  {
    cout<<s<<endl;
  }
  else
  {
    cout<<"-1"<<endl;
  }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<int> b(N);
    if (a.size() % 2 == 0) {
        int m = N / 2;
        int l = 1;
        int r = 0;
        rep(i, N) {
            if (i % 2 == 0) {
                b[m + r] = a[i];
                r++;
            } else {
                b[m - l] = a[i];
                l++;
            }
        }
    } else {
        int m = N / 2;
        int l = 0;
        int r = 1;
        rep(i, N) {
            if (i % 2) {
                b[m + r] = a[i];
                r++;
            } else {
                b[m - l] = a[i];
                l++;
            }
        }
    }

    rep(i, b.size()) cout << b[i] << " ";
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  double sum = 0;
  REP(i,n+1){
    if(i % 2 == 1) sum++;
  }

  cout << setprecision(10) << sum / n << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, k, x=1;
    scanf("%d %d", &n, &k);

    for(int i=0;i<n;i++){
        if((x*2)<(x+k)){
            x=x*2;
        }
        else{
            x=x+k;
        }
    }
    printf("%d\n", x);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;

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

        String s = sc.next();
        int ans = 0;
        int f = Integer.parseInt(s.substring(0, 2));
        int l = Integer.parseInt(s.substring(2, 4));
        //System.out.println(f);
        //System.out.println(l);
        if (1 <= f && f <= 12 && 1 <= l && l <= 12) {
            System.out.println("AMBIGUOUS");
        } else if (1 <= f && f <= 12) {
            System.out.println("MMYY");
        } else if (1 <= l && l <= 12) {
            System.out.println("YYMM");
        } else {
            System.out.println("NA");
        }
        
        
    }
}

Measured memory_bytes: 22740
import math
n =int(input())

x_can = n/1.08

if math.floor(math.floor(x_can)*1.08) ==  n:
    print(math.floor(x_can))

elif math.floor(math.ceil(x_can)*1.08) ==  n:
    print(math.ceil(x_can))
else:
    print(":(")

Measured memory_bytes: 3060
N = int(input())
f = [0]*(N+1)

def solve(amt):
    for x in range(1, amt):
        for y in range(1, amt):
            for z in range(1, amt):
                n = x*x + y*y + z*z + x*y + y*z + x*z
                if n <= N:
                    f[n] += 1
                else:
                    break

if N > 2:
    solve(int((N-2)**0.5)+1)

for n in range(1, N+1):
    print(f[n])

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

int main() {
	int N, M;
	cin >> N >> M;
	int64_t odd;
	if (N == 1) {
		if (M == 1) odd = 1;
		else odd = M - 2;
	} else if (M == 1) odd = N - 2;
	else odd = (int64_t)(N - 2) * (M - 2);
	cout << odd;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

各マスについて奇数回と偶数回のどっちになるか考える
ここで、奇数になる条件 == 裏になる条件
1. 自分の周囲にカードがなし (1,1)のみ
2. 自分の周囲にカードが2枚 (1, M)において端を除くM-2枚、(N,1)ならN-2枚
3. 自分の周囲にカードが4枚 無理じゃね
4. 自分の周囲にカードが6枚 無理じゃね
5. 自分の周囲にカードが8枚 要するに(N,M)において(N-2)(M-2)枚
これ以外は全て偶数枚 == 表
10^18より64bitに注意
*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int M = scanner.nextInt();
        int D = scanner.nextInt();

        int ans = 0;

        for(int m = 1; m <= M; m++) {
            for (int d = 1; d <= D; d++) {
                if(m == (d % 10) * (d / 10) && (d % 10) >= 2 && (d / 10) >= 2)  {
                    ans++;
                }
            }
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 21844
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
ll modpow(ll a, ll b, ll m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	ll memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
int n, k, c;
string s;
int a[200010], b[200010];
signed main() {
	cin >> n >> k >> c >> s;
	int now = 0;
	rep(i, n) {
		if (i)a[i] = a[i - 1];
		if (i < now)continue;
		if (s[i] == 'o') {
			a[i]++;
			now = i + c + 1;
		}
	}
	now = n - 1;
	for (int i = n - 1; i >= 0; i--) {
		if (i != n - 1)b[i] = b[i + 1];
		if (i > now)continue;
		if (s[i] == 'o') {
			b[i]++;
			now = i - c - 1;
		}
	}
	if (b[1] < k)cout << 1 << endl;
	REP(i, n - 1) {
		if (a[i - 1] + b[i + 1] < k) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4996
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();

    int minA = (int) Math.ceil(A * 100 / 8d);
    int minB = (int) Math.ceil(B * 100 / 10d);
    int min = Math.max(minA, minB);

    int maxA = (int) Math.ceil((A + 1) * 100 / 8d) - 1;
    int maxB = (int) Math.ceil((B + 1) * 100 / 10d) - 1;
    int max = Math.min(maxA, maxB);


    int ans = (min <= max) ? min : -1;
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 2000;

int main(){
    
    ll ans=0;
    ll mod = INF;
    ll a[maxn];
    ll t[maxn];
    ll s[maxn];
    ll n,k;
    
    cin >> n>>k;
    fill(a,a+n,0);
    fill(t,t+n,0);
    fill(s,s+n,0);
    rep(i,n){
        cin >> a[i];
    }
    
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i]>a[j]){
                if(i<j){
                    s[i]++;
                }
                t[i]++;
            }
        }
    }
    
    ll sum_1=0;
    ll sum_2=0;
    
    rep(i,n){
        sum_1 = (sum_1+s[i])%mod;
        sum_2 = (sum_2+t[i])%mod;
    }
    
    sum_1 = (sum_1*k)%mod;
    sum_2 = (sum_2*((k-1)*k/2%mod));
    ans = (sum_1+sum_2)%mod;
    
    
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
include Math
THETA = PI/3

def to_fs(v1, v2)
	"#{v1} #{v2}"
end

def koch(l,r,n)
	return if n==0
	d1 = {x: (2*l[:x] + r[:x])/3, y: (2*l[:y] + r[:y])/3}
	d2 = {x: (l[:x] + 2*r[:x])/3, y: (l[:y] + 2*r[:y])/3}
	top = {x: cos(THETA)*(d2[:x]-d1[:x]) + -sin(THETA)*(d2[:y]-d1[:y]) + d1[:x],
	       y: sin(THETA)*(d2[:x]-d1[:x]) + cos(THETA)*(d2[:y]-d1[:y]) + d1[:y]}
	koch(l, d1, n-1)
	puts to_fs(d1[:x], d1[:y])
	koch(d1, top, n-1)
	puts to_fs(top[:x], top[:y])
	koch(top, d2, n-1)
	puts to_fs(d2[:x], d2[:y])
	koch(d2, r, n-1)
end

n = gets.chomp.to_i
l={x: 0.0, y: 0.0}; r={x: 100.0, y: 0.0}
puts to_fs(l[:x], l[:y])
koch(l, r, n)
puts to_fs(r[:x], r[:y])



Measured memory_bytes: 7352
let string_to_list str =
  let rec loop i limit =
    if i = limit then []
    else (String.get str i) :: (loop (i + 1) limit)
  in
  loop 0 (String.length str)


let fwd arr_length n = if n = (arr_length - 1) then 0 else n+1
let prev arr_length n = if n = 0 then arr_length - 1 else n-1
let flip c = if c = 'S' then 'W' else 'S'
let print_chars arr = Array.iter (fun x -> Printf.printf "%c" x) arr; Printf.printf "\n"
           
let fill arr arr_length n by =
  if (arr.(n) == 'S' && by = 'o') || (arr.(n) == 'W' && by = 'x') then
    begin
      arr.(fwd arr_length n) <- arr.(prev arr_length n);
    end
  else
    begin
      arr.(fwd arr_length n) <- flip arr.(prev arr_length n);
    end    

let rec extend answers ans_length cursor ret = match answers with
  | [] -> ret
  | 'o'::rest ->
     fill ret ans_length cursor 'o';
     extend rest ans_length (cursor+1) ret
  | 'x'::rest ->
     fill ret ans_length cursor 'x';
     extend rest ans_length (cursor+1) ret
  | _ -> ret

let check arr arr_length by n =
  if (arr.(n) == 'S' && by = 'o') || (arr.(n) == 'W' && by = 'x') then
    arr.(fwd arr_length n) = arr.(prev arr_length n)
  else
    arr.(fwd arr_length n) <> arr.(prev arr_length n)

let make_list f t step =
  let rec make_list_inner c t lst =
    if c >= t then lst else make_list_inner (c+step) t (c::lst)
  in
  List.rev (make_list_inner f t [])

let check_all pos_ans length pairs =
  let checks = List.map (fun (x,y) -> check pos_ans length y x) pairs in
  List.fold_left (fun x y -> x && y) true checks

let array_make length a b =
  let ret = (Array.make length a) in
  ret.(length - 1) <- b;
  ret

let solve str =
  let str_list = (string_to_list str) in
  let length = List.length str_list in
  let pairs = List.combine (make_list 0 length 1) str_list in
  let pos_ans = extend str_list length 0 (array_make length 'S' 'S') in
  if check_all pos_ans length pairs then pos_ans else
    let pos_ans = extend str_list length 0 (array_make length 'S' 'W') in
    if check_all pos_ans length pairs then pos_ans else
      let pos_ans = extend str_list length 0 (array_make length 'W' 'W') in
      if check_all pos_ans length pairs then pos_ans else
        let pos_ans = extend str_list length 0 (array_make length 'W' 'S') in
        if check_all pos_ans length pairs then pos_ans else
          [||]
  
let () =
  let _ = read_int() in
  let str = read_line () in
  let ans = solve str in
  if ans = [||] then
    Printf.printf ("-1")
  else
    Array.iter (fun x -> Printf.printf "%c" x) ans;
  Printf.printf "\n"
;;


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a<b) {
    while(b>0) {
      cout << a;
      b--;
    }
    cout << endl;
  }
  else {
    while(a>0) {
      cout << b;
      a--;
    }
    cout << endl;
  }
  return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n = 0, i, flag = 0;
  int a[200];

  scanf(" %d", &n);
  for (i = 0;i < n; i++)
    scanf(" %d", &a[i]);
  while(1)
  {
    i = 0;
    while (a[i] % 2 == 0)
    {
      a[i] = a[i] / 2;
      i++;
    }
    if (i >= n)
      flag++;
    else
      break ;
  }
  printf("%d\n", flag);
  return (0);
}

Measured memory_bytes: 1728
n,m = map(int,input().split())

a = list(map(int,input().split()))

# c = [ i for i in a if i%2!=0 ]
# if len(c)!=0:
#     print(0)
#     exit()

b = list(map( lambda x : x//2 , a ))

# print(a)
# print(b)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])

#     if temp!=1:
#         arr.append([temp, 1])

#     if arr==[]:
#         arr.append([n, 1])

#     return arr

# chls = []
# for i in range(n):
#     f = factorization(a[i])
#     num2 = f[0][1]
#     chls.append(num2)
# if len(list(set(chls)))!=1:
#     print(0)
#     exit()

def count2inNumber(n):
    count = 0
    while n%2==0:
        n //= 2
        count += 1
    return count

chls = []
for i in range(n):
    count = count2inNumber(a[i])
    chls.append(count)
if len(list(set(chls)))!=1:
    print(0)
    exit()

from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

l = lcm_list(b)
# print(l)
# if l>m:
#     print(0)
#     exit()

pmax = (m-l) // (2*l)
# print(pmax)

ans = pmax + 1

print(ans)

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

int main(){
	int n;cin>>n;
	vector<int>height(n,0);
	for(int i=0;i<n;i++){
		cin>>height[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(height[1]-height[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(abs(height[i]-height[i-2])+dp[i-2],abs(height[i]-height[i-1])+dp[i-1]);
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 1024
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
if x not in p:
    print(x)
    exit()

for i in range(1, 10**9):
    if x-i not in p:
        print(x-i)
        break
    if x+i not in p:
        print(x+i)
        break


Measured memory_bytes: 9128
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}


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

int main()
{
    int x,y,z;
    while(cin>>x>>y>>z)
    {
        if(abs(y-x)>=abs(z-x))
        {
            cout<<"B"<<endl;
        }
        else cout<<"A"<<endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a;
    cin>>a;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==a){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
    }


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

black = (n-2)**2
left_most = n-1
down_most = n-1

L = [n-2] * n
D = [n-2] * n

for _ in range(q):
  x,c = list(map(int,input().split()))
  c -= 1
  
  if x==1:
    if c<left_most:
      for j in range(c, left_most):
        D[j] = down_most - 1
     
      left_most = c
    black -= D[c]
 
  if x==2:
    if c<down_most:
      for j in range(c, down_most):
        L[j] = left_most - 1
      
      down_most = c
    black -= L[c]
    

  #print(black)
print(black)

Measured memory_bytes: 72740
#include<iostream>
using namespace std;
int main(){
 int a, b, c;
 cin >> a >> b >> c;

 if( ( 1 <= a && a <= 10000 ) && ( 1 <= b && b <= 10000 ) && ( 1 <= c && c <= 10000 ) ){
  if( a > b ){
   int tmp1 = a;
   a = b;
   b = tmp1;
  }
  if( a > c ){
   int tmp2 = a;
   a = c;
   c = tmp2;
  }
  if( b > c ){
   int tmp3 = b;
   b = c;
   c = tmp3;
  }
 }

 cout << a << " " << b << " " << c << endl;
 return 0;
}

Measured memory_bytes: 3108
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int a,b,c,x;
	int count=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			for(int k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==x)
					count++;
			}
		}
	}
	cout<<count;
	return 0;
}

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

int main(){
    
    int a,b;
    char o;

    while(1){

        cin >> a >> o >> b;

        if(o == '+') cout << a + b << endl;
        else if(o == '-') cout << a - b << endl;
        else if(o == '*') cout << a * b << endl;
        else if(o == '/') cout << a / b << endl;
        if(o == '?') break;
    }

    return 0 ;
}

Measured memory_bytes: 3092
K, T = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

x = -1
for i in range(K):
    m1 = -1
    m2 = -1
    i1 = -1
    i2 = -1
    for j in range(len(a)):
        if a[j] > m1:
            i2 = i1
            i1 = j
            m2 = m1
            m1 = a[j]
        elif a[j] > m2:
            m2 = a[j]
            i2 = j
    if x != i1 and m1 > 0:
        a[i1] -= 1
        x = i1
    elif x != i2 and m2 > 0:
        a[i2] -= 1
        x = i2
    else:
        ans += 1
print(ans)


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

struct Node {
	int parent{-1};
	std::list<int> redges, edges;
	int edge_num{};
};

std::vector<Node> tree;
void dfs(int, int);

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	tree.resize(n);
	for (int i{}; i < n + m - 1; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		tree[a].edges.push_back(b);
		tree[a].edge_num++;
		tree[b].redges.push_back(a);
	}
	std::queue<int> zero_edges;
	for (int i{}; i < n; i++)
		if (!tree[i].edge_num)
			zero_edges.push(i);
	
	while (zero_edges.size())
	{
		int next{zero_edges.front()};
		zero_edges.pop();
		for (auto& e: tree[next].edges)
			if (tree[e].parent < 0)
				tree[e].parent = next;
		for (auto& e: tree[next].redges)
		{
			tree[e].edge_num--;
			if (!tree[e].edge_num)
				zero_edges.push(e);
		}
	}
	for (auto& e: tree)
		printf("%d\n", e.parent + 1);
	
	return 0;
}

Measured memory_bytes: 12160
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,a,b; cin >> n >> a >> b;
    cout << min(a,b) << " " << max(a + b - n, 0LL) << endl;
}

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

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  
  vector<int> tmp(N, 0);
  rep(i, N-1){
    if(S[i] == 'A' && S[i+1] == 'C'){
      tmp[i+1] = tmp[i] + 1;
    }
    else{
      tmp[i+1] = tmp[i];
    }
  }

  vector<int> ans;
  rep(i, Q){
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    ans.push_back(tmp[r] - tmp[l]);
  }

  rep(i, ans.size()){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1912
import functools
X = int(input())

@functools.lru_cache(maxsize=None)
def pow5(x):
    return x ** 5

@functools.lru_cache(maxsize=None)
def root5(x):
    i = 0
    while True:
        i5 = pow5(i)
        if x < i5:
            return None
        if i5 == x:
            return i
        i += 1

a = 0
while True:
    a5 = pow5(a)
    b = root5(a5 + X)
    if b is not None:
        print(-a, -b)
        break
    if a5 <= X:
        b = root5(X - a5)
        if b is not None:
            print(a, -b)
            break
    else:
        b = root5(a5 - X)
        if b is not None:
            print(a, b)
            break
    a += 1

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int ans=0,tot=0;
char a[N],b[N],c[N];
int main()
{
	cin>>a;
	int len=strlen(a);
	for(int i=0;i<len;i++)
	{
		if(i%2==1)
		{
			b[i]='0';
			c[i]='1';
		}
		else
		{
			b[i]='1';
			c[i]='0';
		}
	}
	for(int i=0;i<len;i++)
	{
		if(a[i]!=b[i])
		{
			ans++;
		}
	}
	for(int i=0;i<len;i++)
	{
		if(a[i]!=c[i])
		{
			tot++;
		}
	}
	cout<<min(ans,tot);
}

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

int main(int argc, const char * argv[]) {
    long long a,b,c;
    cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0){cout<<0<<endl;}
    else{
        cout<<min(b*c,(min(c*a,a*b)))<<endl;
    }
    
    return 0;
}


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

void score(int x){
    int n;
    int point[102];
    int ave = 0;

    n = x;
    for(int i=0;i<n;i++) cin >> point[i];
    sort(point,point+n);
    for(int i=1;i<n-1;i++){
        ave += point[i];
    }
    cout << ave / (n - 2) << endl;
}

int main(){
    int x;
    while(1){
        cin >> x;
        if(x == 0) break;
        score(x);
    }
    
    return 0;
}


Measured memory_bytes: 3020
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)
typedef long long ll;

int gcd(int x, int y) {
    int r = y % x;
    if (r == 0) return x;
    else return gcd(r, x);
}

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> ans(N);
    Rep(i, N) {
        int x;
        cin >> x;
        ans[i] = abs(X - x);
        if (i) ans[i] = gcd(ans[i - 1], ans[i]);
    }
    cout << ans[N - 1] << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

using namespace std;

typedef long long int llint;

const long long int INF = 1 << 30; //10^10
const llint MOD = 998244353;

inline void maxch(int& a, int b) {if (a < b) a = b;}

int bs(vector<int>& h, llint l, llint r,int a, int b) {
	//[l,r)
if (r - l <= 1) return r;

llint mid = l + (r - l) / 2;
llint t = mid, attcnt = 0;

rep(i,h.size()) {
  if(h[i] - t*b > 0) attcnt += (h[i]-t*b-1)/(a-b) + 1;
  if(attcnt > t) break;
}
  
if (attcnt > t) return bs(h, mid, r, a, b);
else return bs(h, l, mid, a, b);
}

int main() {
int n, a, b;
cin >> n >> a >> b;
vector<int> h(n);
int maxh = 0;
rep(i,n) {cin >> h[i]; maxch(maxh,h[i]); }

int l = 0, r = (maxh-1)/b + 1; 
cout << bs(h, l, r, a, b) << endl;
}


Measured memory_bytes: 640
def insert(tree,k):
    y = None
    x = tree
    z = {'key':k, 'parent':None, 'left':None, 'right':None}
    while x != None:
        y = x
        if x['key'] > k:
            x = x['left']
        else:
            x = x['right']
    z['parent'] = y
    if y == None:
        tree = z
    elif y['key'] > k:
        y['left'] = z
    else:
        y['right'] = z
    return tree

def middleorder(x):
    if x != None:
        middleorder(x['left'])
        print x['key'],
        middleorder(x['right'])

def preorder(x):
    if x != None:
        print x['key'],
        preorder(x['left'])
        preorder(x['right'])



tree = None
m = int(raw_input())
for i in range(m):
    c = raw_input().strip()
    if c[0] == 'i':
        tree = insert(tree, int(c[7:]))
    elif c[0] == 'p':
        print '',
        middleorder(tree)
        print
        print '',
        preorder(tree)
        print

Measured memory_bytes: 176748
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define MAX_N 400
#define INF 1e9
#define lt(a,b) (a-b < -EPS)
 
struct Point{
    double x,y;
 
    Point(){}
    Point(double x,double y) : x(x),y(y) {}
 
    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
    Point operator / (const double &k)const{ return Point(x/k,y/k); }
    bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};
 
double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double norm(const Point &p){ return dot(p,p); }
double abs(const Point &p){ return sqrt(norm(p)); }
 
double dist(const Point &a,const Point &b){
    return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}
 
istream &operator >> (istream &is,Point &p){
    return is >> p.x >> p.y;
}
 
typedef Point Vector;
 
struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};
 
int main(){
    int N;
    while(cin >> N, N){
	Point np(0,0);
	Vector v(0,1);
	vector<Point> p(N);
	for(int i = 0 ; i < N ; i++){
	    cin >> p[i];
	}
	double res = 0;
	bool visited[MAX_N] = {false};
	for(int i = 0 ; i < N ; i++){
	    int idx = -1;
	    double min = INF,d = INF;
	    for(int j = 0 ; j < N ; j++){
		if(visited[j]){ continue; }
		Vector v2 = p[j]-np;
		double angle = acos(dot(v,v2)/abs(v)/abs(v2));
		if(lt(angle,min)){
		    d = dist(np,p[j]);
		    min = angle;
		    idx = j;
		}else if(equal(angle,min)){
		    if(lt(dist(np,p[j]),d)){
			d = dist(np,p[j]);
			min = angle;
			idx = j;
		    }
		}
	    }
	    visited[idx] = true;
	    res += dist(np,p[idx]);
	    v = p[idx]-np;
	    np = p[idx];
	}
	printf("%.1f\n",res);
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N; vector<ll> a(N); rep(i, N){cin >> a.at(i);}
    ll ans = INF;
    rep2(i, -100, 101){
        ll tmp = 0;
        rep(j, N){tmp += (a.at(j) - i) * (a.at(j) - i);}
        if (tmp < ans){ans = tmp;}
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
N=int(input())
A = list(map(int, input().split()))
money=1000
stock=0
if A[0]<A[1]:
    stock=int(money/A[0])
    money=money-A[0]*stock
for i in range(1,N-1):
    if A[i-1]<A[i]:
        money=money+A[i]*stock
        stock=0
    if A[i]<A[i+1]:
        stock=int(money/A[i])
        money=money-A[i]*stock
money=money+A[N-1]*stock        
print(money)

Measured memory_bytes: 9160
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut prepre: usize = 0;
    let mut pre: usize = 0;
    for _i in 0..n {
        let mut current: usize = iterator.next().unwrap().parse().unwrap();
        if prepre > current {
            return String::from("No")
        }
        if pre > current {
            return String::from("No")
        }
        if current > pre {
            current -= 1;
        }
        prepre = pre;
        pre = current;
    }

    return String::from("Yes");
}


Measured memory_bytes: 6396
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        //var RGBN = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        //var S = Console.ReadLine();
        long ans = 0;
        long now = 0;
        var A = new long[N];
        var B = new long[N];
        for (int i = 0; i < N; i++)
        {
            var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            A[i] = AB[0];
            B[i] = AB[1];

            
        }

        for (int i = (int)N - 1; i >= 0; i--)
        {
            if ((A[i] + now) % B[i] != 0)
            {
                now += B[i] - (A[i] + now) % B[i];
            }
        }

        Console.WriteLine(now);

    }
        

    
}


Measured memory_bytes: 48472
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=2000+10,mo=1000000007;
int fac[maxn*maxn],inv[maxn*maxn];
int f[maxn][maxn];
int i,j,k,l,t,n,m,ans;
int qsm(int x,int y){
	if (!y) return 1;
	int t=qsm(x,y/2);
	t=(ll)t*t%mo;
	if (y%2) t=(ll)t*x%mo;
	return t;
}
int C(int n,int m){
	if (n<m||n<0) return 0;
	return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main(){
	scanf("%d%d",&n,&k);
	if (k==1){
		printf("1\n");
		return 0;
	}
	fac[0]=1;
	fo(i,1,n*k) fac[i]=(ll)fac[i-1]*i%mo;
	inv[n*k]=qsm(fac[n*k],mo-2);
	fd(i,n*k-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
	f[0][0]=1;
	fo(i,0,n)
		fd(j,n,0)
			if (f[i][j]){
				if (j) (f[i][j-1]+=f[i][j])%=mo;
				if (i<n) (f[i+1][j+1]+=(ll)f[i][j]*C((i+1)*k-j-2,k-2)%mo)%=mo;
			}
	ans=(ll)f[n][0]*fac[n]%mo;
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 46464
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String[] line=sc.nextLine().split(" ");
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i]=Integer.parseInt(line[i]);
		}
		for(int i=0;i<n;i++){
			int v=a[i];
			int j=i-1;
			while(j>=0 && a[j]>v){
				a[j+1]=a[j];
				j--;
			}
			a[j+1]=v;
			for(int k=0;k<n-1;k++){
				System.out.print(a[k]+" ");
			}
			System.out.println(a[n-1]);
		}
	}
}


Measured memory_bytes: 32436
#include <stdio.h>

int main(void)
{
    int n, y;
    int a, b, c, sum;
    int flag = 0;

    scanf("%d%d", &n, &y);

    for (a=0; a<=n; a++) {
        for (b=0; b<=n; b++) {
            c = n-(a+b);
            if (c>=0) {
                sum = 10000*a + 5000*b + 1000*c;
                if (sum==y) {
                    flag = 1;
                    goto abc;
                }
            }
        }
    }

abc:
    if (flag==0)    { a=b=c=-1; }

    printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <cmath>
#define ll long long
#define intinf 0x7f7f7f7f
#define llinf 0x7f7f7f7f7f7f7f7f
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define ALL(x) for(int i=head[x];i;i=e[i].u)
#define pii pair<int,int> 
#define mp make_pair
#define fi first
#define se second
using std::map;
using std::set;
using std::vector;
using std::bitset;
using std::sqrt;
using std::pair;
const int maxn=1e6+5;
int h,w,n;
int main() {
	scanf("%d %d %d",&h,&w,&n);
	int a=std::max(h,w);
	printf("%d",(n/a)+((n%a)!=0));
}

Measured memory_bytes: 128
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,e,f=map(float,e.split(','))
 z,w,q=complex(a,b),complex(c,d),complex(e,f)
 z+=(z-w)*(q-z).conjugate()/(z-w).conjugate()
 print(z.real,z.imag)


Measured memory_bytes: 5644
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
	int n, m; 
	cin >> n >> m;
	int l = -INF;
	int r = INF;
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		l = max(l, x);
		r = min(r, y);
	}
	int res = max(0, r - l + 1);
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>
using namespace std;
int A, B, C, D, E, F;
int dp[31][3007];
int cand[31];
int input(){
	cin>>A>>B>>C>>D>>E>>F;
	for(int i=0;i<31;i++ )
		for(int j=0;j<3007;j++ )
			dp[i][j] = 0;
	return 0;
}
int calc(){
	int li=(F-E)/100,lj=0,ni=0,nj=0;
	dp[0][0]=1;
	for(int i=0;i<=li;i++){
		if(dp[i][0]<=0) 
			continue; 
		ni=i+A;
		if(ni<=li)	
			dp[ni][0]=1; 
		ni=i+B;
		if(ni<=li)	
			dp[ni][0]=1; 
	}
	for(int i=0;i<=li;i++){
		lj=F-100*i;
		for(int j=0;j<=lj;j++){
			if(dp[i][j]<=0) 
				continue; 
			nj=j+C;
			if(100*i+nj<=F&&nj<=i*E) 
				dp[i][nj]=1; 
			nj=j+D;
			if(100*i+nj<=F&&nj<=i*E)
				dp[i][nj]=1; 
		}
	}
	return 0;
}
int main(){
	input();
	calc();
	for(int i=0;i<31;i++){
		int m=0;
		for(int j=0;i+j<=F&&j<=E*i;j++)
			if(dp[i][j])m=j; 
		if(m)cand[i]=m;
		else cand[i]=0;
	}
	int ci=A;
	for(int i=A+1;i<31;i++){
		if(cand[i]==0)continue; 
		if((i+cand[i])*100*cand[ci]<(ci+cand[ci])*100*cand[i])
			ci=i;
	}
	cout<<100*ci+cand[ci]<<" "<<cand[ci]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main () {
  long long N;
  cin >> N;
  
  long long ans = 0LL;
  for (long long i = 1; i <= N; ++i) {
    long long lastterm = (N / i) * i;
    long long firstterm = i;
    ans += (lastterm + firstterm) * (N / i) / 2LL;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int cnt[1000],H,W,quad,mid,cen;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>H>>W;
    //for (int i=0;i<=1000;i++) cnt[i]=0;
    for (int i=1;i<=H;i++) {
        string s;
        cin>>s;
        for (int j=0;j<s.length();j++) cnt[s[j] - 'a'] ++;
    }
    quad = (H/2) * (W/2);
    mid = (H%2)*(W/2) + (W%2)*(H/2);
    cen = (H%2) * (W%2);

    for (int i=0;i<=100;i++)
        if (cnt[i]!=0) {
           // cout<<cnt[i]<<" "<<i<<endl;
            while (cnt[i]>=4 && quad >0) {
                cnt[i]-=4;
                quad--;
            }
            while (cnt[i]>=2 && mid >0) {
                cnt[i]-=2;
                mid--;
            }
            while (cnt[i]>=1 && cen >0) {
                cnt[i]--;
                cen--;
            }
            if (cnt[i]>0) {
                cout<<"No";
                return 0;
            }
        }
    cout<<"Yes";
}


Measured memory_bytes: 256
n=int(input())
card=[[0 for i in range(3)] for j in range(n)]
for i in range(n):
    card[i][0],card[i][1],card[i][2]=map(int,input().split())
points=[0]*n
for i in range(3):
    chk=[]
    for j in range(n):
        chk.append(card[j][i])
    for j in range(n):
        if sum(card[j][i]==x for x in chk)==1:
            points[j]+=card[j][i]
for i in points:
    print(i)


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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    ll arr[5] = {0};
    for(ll i = 0; i < n; ++i){
        string s; cin >> s;
        if(s[0] == 'M'){
            arr[0]++;
        }
        if(s[0] == 'A'){
            arr[1]++;
        }
        if(s[0] == 'R'){
            arr[2]++;
        }
        if(s[0] == 'C'){
            arr[3]++;
        }
        if(s[0] == 'H'){
            arr[4]++;
        }
    }
    ll ans = 0;
    for(ll i = 0; i < 5; ++i){
        for(ll j = i + 1; j < 5; ++j){
            for(ll k = j + 1; k < 5; ++k)ans += arr[i] * arr[j] * arr[k];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int data[2];
    int judi;
    
    while(1)
    {
        scanf("%d %d",&data[0],&data[1]);
        if(data[0] == 0 && data[1] == 0)  break;
        judi = data[0] < data[1];
        printf("%d %d\n",data[1-judi],data[judi]);
    }
    
    return 0;
}



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

bool check(char c) {
  switch (c) {
    case 'A':
    case 'C':
    case 'G':
    case 'T':
      return true;
    default:
      return false;
  }
}

int main() {
  string S; cin >> S;
  int ans = 0, tmp = 0;
  for(int i = 0; i < S.size(); i++) {
    if(check(S[i])) tmp++;
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy";
    if (S == "Cloudy") cout << "Rainy";
    if (S == "Rainy") cout << "Sunny";
    cout << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<int> dijkstra(Graph &G, int start)
{
    vector<int> dist(G.size(), INT_INF);
    // pair(その時点での最短経路，頂点番号)
    priority_queue<P, vector<P>, greater<P>> que;
    dist[start] = 1;
    que.push(make_pair(dist[start], start));
    while (!que.empty())
    {
        int cost = que.top().first;
        int idx = que.top().second;
        que.pop();
        if (dist[idx] < cost)
            continue;

        for (auto e : G[idx])
        {
            if (dist[e.to] <= cost + e.weight)
                continue;
            dist[e.to] = cost + e.weight;
            que.push(make_pair(dist[e.to], e.to));
        }
    }
    return dist;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll K;
    cin >> K;

    Graph G(K);
    for (int i = 0; i < K; i++)
    {
        G[i].push_back({(i + 1) % K, 1});
        G[i].push_back({(i * 10) % K, 0});
    }

    vector<int> dist = dijkstra(G, 1);
    cout << dist[0] << endl;
    return 0;
}

// 以下のようなグラフを考え，最短経路問題を解く．
// ・頂点は0～K-1のK個　・頂点x->(x+1)%Kにコスト1の辺が出る　・頂点x->(x*10)%Kにコスト0の辺が出る．コスト1を持って頂点1からスタートし頂点0をゴールとする．この最短経路問題で解いているのは「modKがxであるすべての正整数の集合における各桁の和の最小値」である．つまり0～K-1の各頂点が「modKでxである正整数の集合」を表し，頂点1から頂点xまでの最短距離が「各桁の和の最小値」を表す．イメージとしては，「1」という数字からスタートしてその数に+1するか*10するかの遷移を繰り返しているという感じになる．頂点0が「modKが0であるすべての正整数の集合」すなわちKの正の倍数ということになるので，頂点0までのコストが解となる．


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

using namespace std;
const long long INF=1LL<<60;

int main(){
  long long n, m, R, d[209][209];
  vector<long long> r;
  cin >> n >> m >> R;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)d[i][j]=INF;
    d[i][i]=0;
  }
  for(int i=0;i<R;i++){
    long long rr;cin >> rr;
    rr--;
    r.push_back(rr);
  }
  for(int i=0;i<m;i++){
    long long a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  long long mn=INF;
  sort(r.begin(), r.end());
  do{
    long long sm=0;
    for(int i=0;i<R-1;i++)sm+=d[r[i]][r[i+1]];
    mn = min(mn , sm);
  }while(next_permutation(r.begin(), r.end()));
  cout << mn << endl;
}



Measured memory_bytes: 3900
N, K = map(int, input().split())

p = [int(x) for x in input().split()]
p = [(x + 1) / 2 for x in p]

S = [0 for _ in range(N + 1)]

for i in range(1, N + 1):
    S[i] = S[i - 1]
    S[i] += p[i - 1]

ans = 0
for i in range(N - K + 1):
    ans = max(ans, S[i + K] - S[i])

print(ans)

Measured memory_bytes: 24516
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		for(int i = 0 ; i < n ; i++) {
			int temp = sc.nextInt();
			if(!map.containsKey(temp)) {
			map.put(temp, 1);
			}
			else {
			map.put(temp,map.get(temp)+1);}
		}
		int [] arr = new int[100001];
		for(Entry<Integer, Integer> entry : map.entrySet()) {
		    Integer key = entry.getKey();
		    Integer value = entry.getValue();
		    arr[key] = value;
		}
		int [] n_arr = new int [100001];
		for(int i = 1 ; i < 100000 ; i ++) {
			n_arr[i] = arr[i-1] + arr[i] + arr[i+1];
		}
		int max = - 1;
		for(int i = 0 ; i < 100001 ; i++) {
			if(n_arr[i] > max) {
				max = n_arr[i];
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 59884
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int n;
    string s;
    cin >> n;
    cin >> s;
    if(n%2==1){
        cout << "No"<<endl;
    }else{
        string x = s.substr(0,s.size()/2);
        string y = s.substr(s.size()/2,s.size()-1);
        //cout <<x<<y<<endl;
        if(x==y)cout << "Yes"<<endl;
        else cout << "No"<<endl;
    }
    
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));
    bool ok = true;
    rep(i, n - 1){
        if (a[i] == a[i + 1]){
            ok = false;
            break;
        }
    }
    if (ok) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    	cin>>a[i];
  int l=0,h=n-1,ans=-1;
  int count=0,j=1;
    for(int i=0;i<n;i++)
      if(a[i]!=j)
        count++;
      else
        j++;
//  while(l<=h)
//  {
//    int  mid=(l+h)/2;
//   	if(count==mid)
//    {
//      ans=mid;
//      h=mid-1;
//    }
//    else if(count<mid)
//      h=mid-1;
//    else
//      l=mid+1;
//  }
	if(count==n)
		cout<<-1<<endl;
	else
  cout<<count<<endl;
  return 0;
}
      

Measured memory_bytes: 1024
from collections import deque
H, W = map(int, input().split())
q = deque()
A = []
for h in range(H):
    r = input()
    for w in range(W):
        if r[w] == "#":
            q.append([h, w])
    A.append([0 if s=="#" else -1 for s in r])

d = [[-1, 0], [0, -1], [0, 1], [1, 0]]
p = 0

while q:
    h, w = q.popleft()
    p = A[h][w]+1
    for dh, dw in d:
        nh = h+dh
        nw = w+dw
        if not (0 <= nh < H):
            continue
        if not (0 <= nw < W):
            continue
        if A[nh][nw] == -1:
            A[nh][nw] = p
            q.append([nh, nw])

print(p-1)

Measured memory_bytes: 166368
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	setprecision(10);
	dl a,b,x;cin>>a>>b>>x;
	dl xx=b*a*a/2.0;
	dl v=180.0;
	dl g=3.141592653589;
	dl gh=v/g;
	if(xx<x){
		dl z=b-x/(a*a);
		//cout<<z<<endl;
		dl an=atan(2.00*z/a);
		printf("%.10lf",an*gh);		
	}
	else{
		dl y=2.0*x/(a*b);
		//cout<<y<<endl;
		dl an=atan(b/y);
		printf("%.10lf",an*gh);	
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long int dp[11][11][11];
long int n,m,q;
long int ans=0;
void fun(long int ind,long int val,long int sum,vector<int> a)
{
    if(ind==n)
    {
        ans=max(ans,sum);
        return ;
    }
    if(val>m)
    return ;
    vector<int> b=a;
    for(long int i=val;i<=m;i++)
    {
        long int ss=sum;
         b.push_back(i);
         for(long int j=0;j<ind;j++)
         {
            ss+=dp[ind][j][i-b[j]];
         }
         fun(ind+1,i,ss,b);
         b.pop_back();
    }
}
int main()
{
  string s;
  cin>>s;
  if(s=="ABC")
  cout<<"ARC";
  else
  cout<<"ABC";
}


Measured memory_bytes: 3628