akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ff first
#define ss second

using namespace std;
typedef pair<int, int> pii;

priority_queue<pii> pq;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  pii aup, app;
  int k, t, a;
  cin >> k >> t;
  for(int i = 0; i < t; ++i){
    cin >> a;
    pq.push(pii(a, i));
  }
  a = -1;
  while(pq.size() > 1){
    aup = pq.top();pq.pop();
    if(a == aup.ss){
      app = pq.top();
      pq.pop();
      swap(aup, app);
      pq.push(app);
    }
    a = aup.ss;
    --(aup.ff);
    if(aup.ff != 0) pq.push(aup);
  }
  cout << (pq.top().ff - 1) << "\n";
  return 0;
}


Measured memory_bytes: 256
#pragma optimize GCC("Ofast")
#pragma comment(linker, "/STACK:1073741824")

#include<iostream>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<bool, bool> pbb;
typedef pair<ld, ld> pdd;

const int inf = (int)1e9 + 9;
const ll linf = (ll) 1e18;
const ld eps = 1e-7;
const int mod = (int) 1e9 + 7;

#define it(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

signed main()
{
	ios_base::sync_with_stdio(false);
	srand(time(0));
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vi a(n + 2);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i + 1];
	}
	int res = abs(a[0]);
	for (int i = 1; i < n + 2; i++)
	{
		res += abs(a[i] - a[i - 1]);
	}
	for (int i = 1; i < n + 1; i++)
	{
		cout << res - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i - 1]) << "\n";
	}
}

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

typedef long long ll;

int main()    
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    int dp[n] = {0};
    dp[1] = abs(a[1]-a[0]);

    for(int i=2;i<n;i++)
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    
    cout<<dp[n-1];
}

Measured memory_bytes: 4280
n, y = map(int, input().split())
ans = [-1]*3
for i in range(0, int(y/10000)+1):
    ty = y-10000*i
    tn = n-i
    for j in range(0, min(int(ty/5000)+1,tn+1)):
        tty = ty-5000*j
        ttn = tn-j
        if tty%1000 == 0 and ttn==tty//1000:
            print(i, j, tty//1000)
            exit()
print(-1, -1, -1)

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[] a = new int[n];
      int max = 0;
      int min = 10000;
      for(int i = 0;i < n;i++){
      	a[i] = sc.nextInt();
        max = Math.max(a[i],max);
        min = Math.min(a[i],min);
      }
      System.out.println(max-min);
    }
}

Measured memory_bytes: 21844
N = int(input())
Ts = list(map(int, input().split()))
As = list(map(int, input().split()))
c = 0
Hmax = [0]*N
Hmin = [1]*N
for i in range(N):
  T = Ts[i]
  Hmax[i] = T
  if T > c:
    Hmin[i] = T
    c = T
c = 0
for i in reversed(range(N)):
  A = As[i]
  Hmax[i] = min(Hmax[i], A)
  if A > c:
    Hmin[i] = max(Hmin[i], A)
    c = A
#print(Hmax)
#print(Hmin)
r = 1
for i in range(N):
  d = Hmax[i]-Hmin[i]+1
  if d < 0: d = 0
  r = r*d%1000000007
print(r)


Measured memory_bytes: 19136
package main

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

func main() {
	scan := bufio.NewScanner(os.Stdin)
	scan.Scan()
	scan.Scan()
	var in []int
	for _, c := range strings.Split(scan.Text(), " ") {
		num, _ := strconv.Atoi(c)
		in = append(in, num)
	}
	scan.Scan()
	scan.Scan()
	var in2 []int
	for _, c := range strings.Split(scan.Text(), " ") {
		num, _ := strconv.Atoi(c)
		in2 = append(in2, num)
	}

	var sum int
	for _, n := range in2 {
		for _, t := range in {
			if n == t {
				sum++
				break
			}
		}
	}

	fmt.Println(sum)
}



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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;


int main(){
    
    int H,A;
    cin>>H>>A;

    cout<<ceil((double)H/A)<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const ll MOD = 998244353;

ll add(ll x)
{
  return (x + MOD) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    ll n, s, ans = 0;
    cin >> n >> s;
    vi dp(3010, 0);
    for (int  i =0 ; i < n; i++)
    {
        ll a;
        cin >> a;
        for (int j = s; j >= a; j--)
            dp[j] = add(dp[j] + dp[j - a]);    // add the number of sequences iteratively for each previous element  
        dp[0] += 1;
        dp[a] += 1;
        ans = add(dp[s] + ans);
    }
    cout << (ans + MOD) % MOD << endl;
    return 0;
}


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

typedef long long ll;
const int MAXN = 55;

ll n, a, x[MAXN], mm[MAXN][MAXN][MAXN * MAXN];

ll dfs(int i, int cnt, int sum) {
	if (i == n) {
		if (cnt == 0)return 0;
		if (sum / cnt == a && (sum % cnt == 0)) {
			return 1;
		}
		return 0;
	}
	ll& ret = mm[i][cnt][sum];
	if (ret == -1)return ret = dfs(i + 1, cnt, sum) + dfs(i + 1, cnt + 1, sum + x[i]);
	return ret;
}

int main() {
	cin >> n >> a;
	for (int i = 0; i < n; i++)cin >> x[i];
	memset(mm, -1, sizeof mm);
	cout << dfs(0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 71680
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a1=new int[n];
		int[] a2=new int[n];
		int[] s1=new int[n];
		int[] s2=new int[n];
	    int ans=0;
		
		for(int i=0;i<n;i++){
          a1[i]=sc.nextInt();
        }
		for(int i=0;i<n;i++){
          a2[i]=sc.nextInt();
        }
		
		s1[0]=a1[0]; 
      	s2[n-1]=a2[n-1];
		for(int i=1;i<n;i++){
          s1[i]=s1[i-1]+a1[i];
        }
		for(int i=n-2;i>=0;i--){
          s2[i]=s2[i+1]+a2[i];
        }
		
		for(int i=0;i<n;i++){
          ans=Math.max(ans, s1[i]+s2[i]);
        }
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
city_point =[]
for i in range(N):
    c,p =input().split()
    city_point.append((c,int(p),i))

#sort
city_point.sort(key=lambda x: (x[0],-x[1]))
for i in city_point:
    print(i[2]+1)

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

int main()
{
   int N, T, A;
   cin >> N >> T >> A;
   vector<int> H(N);
   for (int i = 0; i < N; i++)  cin >> H[i];

   int ans = 0;
   double t = fabs(T - (H[0] * 0.006) - A);
   for (int i = 1; i < N; i++){
       double a = fabs(T - (H[i] * 0.006) - A);
       t = min (t, a);
       if(t == a)   ans = i;
   }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		char []ch = scan.next().toCharArray();
		int count = 0 ;
		for(int i = 1 ; i<ch.length ; i++) {
			if(ch[i]==ch[i-1]) {
				count++;
				if(ch[i-1] == '0')
					ch[i] = '1';
				else
					ch[i] = '0' ;
			}
		}
		System.out.println(count);
	}
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n;
    cin >> n;
    vector<vector<int>> x(n);
    vector<vector<int>> y(n);
    for(int i = 0; i < n; ++i){
        int m;
        cin >> m;
        x[i].resize(m);
        y[i].resize(m);
        for(int j = 0; j < x[i].size(); ++j){
            cin >> x[i][j] >> y[i][j];
            --x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); ++i){
        int cnt = 0;
        bitset<15> fl, fl2, fl3;
        fl3 = bitset<15>(i);
        for(int j = 0; j < n; ++j){
            if(i & (1 << j)){
                for(int k = 0; k < x[j].size(); ++k){
                    if(y[j][k])
                        fl.set(x[j][k]);
                    else
                        fl2.set(x[j][k]);
                }
                ++cnt;
            }
        }
        if((fl & fl3) == fl && (fl & ~fl3) == 0 && !(fl3 & fl2).any())
            chmax(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int h,w;
    cin>>h>>w;
    char arr[h][w];
    bool boo1=false,boo2=false;
    fo(i,0,h-1)fo(j,0,w-1)cin>>arr[i][j];
    int dp[h][w];
    for(int j=0;j<w;j++){if(arr[0][j]!='#' && boo1==false)dp[0][j]=1;else {dp[0][j]=0;boo1=true;}}
    for(int i=0;i<h;i++){if(arr[i][0]!='#' && boo2==false)dp[i][0]=1;else {dp[i][0]=0;boo2=true;}}
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++){if(arr[i][j]!='#'){dp[i][j]=(dp[i-1][j]%MD+dp[i][j-1]%MD)%MD;}else dp[i][j]=0;}
    }
    cout<<dp[h-1][w-1]<<endl;
return 0;}


Measured memory_bytes: 8468
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc100_a.cpp
 * time   : Thu Apr 30 21:25:20 2020
 * quest  : A - Happy Birthday!
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << (max(a, b) > 8 ? ":(" : "Yay!") << "\n";
  return 0;
}


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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

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

	int ans = 0;
	rep(i,n) {
		int masu = i + 1;
		if (masu % 2 == 0) continue;
		if (a[i] % 2 != 0) ans++;
	}
 	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N;
signed main(){
    cin >> N;
    int  ans = 0;
    for(int i = 1; i <= N; ++i){
        int p = N / i;
        ans += i * (1 + p) * p / 2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3592
def main():
    buf = input()
    S = buf
    target = 753
    min_diff = 999
    for i in range(len(S) - 2):
        num = int(S[i:i+3])
        diff = abs(num - target)
        if diff < min_diff:
            min_diff = diff
    print(min_diff)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  int x, t;
  std::cin >> x >> t;
  std::cout << (x - t < 0 ? 0 : x - t) << '\n';

  return;
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Dice {
	public int[] value;
	public Dice(String[] info, int size) {
		this.value = new int[size];
		for (int i = 0; i < size; i++) {
			this.value[i] = Integer.parseInt(info[i]);
		}
	}
}

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Dice dice = new Dice(br.readLine().split(" "), 6);
		String[] commands = br.readLine().split("");

		for (int i = 0; i < commands.length; i++) {
 		/*for (String command : commands) {*/
			int work = dice.value[0];
			if (commands[i].equals("N")) {
				dice.value[0] = dice.value[1];
				dice.value[1] = dice.value[5];
				dice.value[5] = dice.value[4];
				dice.value[4] = work;
			} else if (commands[i].equals("E")) {
				dice.value[0] = dice.value[3];
				dice.value[3] = dice.value[5];
				dice.value[5] = dice.value[2];
				dice.value[2] = work;
			} else if (commands[i].equals("W")) {
				dice.value[0] = dice.value[2];
				dice.value[2] = dice.value[5];
				dice.value[5] = dice.value[3];
				dice.value[3] = work;
			} else {
				dice.value[0] = dice.value[4];
				dice.value[4] = dice.value[5];
				dice.value[5] = dice.value[1];
				dice.value[1] = work;
			}
		}
		System.out.println(dice.value[0]);
	}
}

Measured memory_bytes: 24464
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve(){
		UL N; cin >> N;
		vector<UL> A(N); rep(i, N) cin >> A[i];
		rep(i, N) {
			if (i + 1 < A[i]) { cout << -1 << endl; return; }
			UL a = A[i];
			rep(j, a - 1) {
				UL p = i - j;
				swap(A[p - 1], A[p]);
			}
		}
		reverse(A.begin(), A.end());
		rep(i, N) cout << A[i] << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
import collections
import heapq
n=int(input())
a=[-int(item) for item in input().split()]
c = [item for item in list(collections.Counter(a).items()) if item[1]>1]
heapq.heapify(c)
#print(c)

if len(c)==0:
  print(0)
  exit()
if sum([item[1] for item in c])<4:
  print(0)
  exit()

x=heapq.heappop(c)
if c!=[]:
  y=heapq.heappop(c)
else:
  y=(0,0)
if x[1]>=4:
  print(x[0]*x[0])
else:
  print(x[0]*y[0])

Measured memory_bytes: 73624
#[allow(unused)]
use proconio::marker::*;
use proconio::{fastout, input};
#[allow(unused)]
use std::cmp::{max, min, Reverse};
#[allow(unused)]
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        x: [i64; 5],
    }

    for i in 0..5 {
        if x[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 2196
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int prev = sc.nextInt();
		int sum = 0;
		for (int i = 1; i < n; i++) {
			int x = sc.nextInt();
			sum += Math.min(x - prev, t);
			prev = x;
		}
		sum += t;
		System.out.println(sum);
	}
}


Measured memory_bytes: 60676
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        a: [i64; n+1],
        b: [i64; n],
    );

    let mut a = a;
    let mut b = b;

    let mut ans: i64 = 0;
    for i in 0..n {
        for j in i..i+2 {
            let tmp = min(b[i], a[j]);
            ans += tmp;
            b[i] -= tmp;
            a[j] -= tmp;
        }
    }
    println!("{}", ans);
}


fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 10620
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0543?year=2010

#include <bits/stdc++.h>

using namespace std;

int main() {
    int tot;

    while (cin >> tot, tot) {
        for (int i = 0; i < 9; ++i) {
            int a;
            cin >> a;
            tot -= a;
        }
        cout << tot << endl;
    }

    return 0;
}

/*
 *
 */


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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define dbg(x) cout << #x << "= " << x << endl;
typedef pair <int, int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = (1LL<<62)-1;
const ll mod = 1e9+7;
const int N = 2e5+5;

int n, a[N];

int  main(){
    ios::sync_with_stdio(false);
    cin>>n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        sum += a[i];
    }
    ll tmp = a[1], ans = INF;
    for(int i=2; i<=n; i++){
        ans = min(ans, abs(sum-tmp-tmp));
        tmp += a[i];
    }
    cout<<ans<<endl;
    return 0;
}


//    lower_bound()
//    __builtin_popcount()
//    ios::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    const double eps=1e-12;
//    #pragma comment(linker,"/STACK:102400000,102400000")



Measured memory_bytes: 1024
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B, K = rl()

print(max(A-K, 0), max(B-max(K-A,0),0))


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

#define V             vector
#define PQ            priority_queue

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll l;
    long double a,b,c,m=0.0;
    cin>>l;

    a=l/3.0;

    m=a*a*a;
    //cout<<fixed<<(long double)(a*b*c)<<endl;
    printf("%.10Lf", m);
    
/*
    for (ll a=1; a<=l-2; ++a)
        for (ll b=1; b<=l-1; ++b) {
            ll c=l-a-b;
            m = max(m, a*b*c);
        }
    cout<<m<<endl;
*/


}



Measured memory_bytes: 256
def main():
  H,W = map(int,input().split())
  S = [input() for _ in range(H)]
  
  dp = [[float('inf') for _ in range(W)] for _ in range(H)]
  if S[0][0] == '#':
    dp[0][0] = 1
  else:
    dp[0][0] = 0
  for i in range(H):
    for j in range(W):
      if j > 0:
        if S[i][j-1] == '.' and S[i][j] == '#':
          dp[i][j] = min(dp[i][j],dp[i][j-1]+1)
        else:
          dp[i][j] = min(dp[i][j],dp[i][j-1])
      if i > 0:
        if S[i-1][j] == '.' and S[i][j] == '#':
          dp[i][j] = min(dp[i][j],dp[i-1][j]+1)
        else:
          dp[i][j] = min(dp[i][j],dp[i-1][j])
  print(dp[H-1][W-1])

main()

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

int main() {
  int dp[100010];
  int n;
  cin >> n;
  dp[0] = 0;
  for(int i = 1;i <= n;i++){
    dp[i] = 100000;
    int p6 = 1,p9 = 1;
    while(i >= p6){
      dp[i] = min(dp[i-p6]+1,dp[i]);
      p6 *= 6;
    }
    while(i >= p9){
      dp[i] = min(dp[i-p9]+1,dp[i]);
      p9 *= 9;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
int n, a[205];
int main()
{
 	scanf("%d", &n);
  	for(int i=1; i<=2*n; i++) scanf("%d", a+i);
  	std::sort(a+1, a+2*n+1);
  	int ans = 0;
  	for(int i=1; i<=2*n; i+=2) ans += a[i];
  	printf("%d\n", ans);
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


int len(const vector<ll> &a, ll lb, ll ub) {
    return (int) (lower_bound(a.begin(), a.end(), ub) - lower_bound(a.begin(), a.end(), lb));
}


void solve(ll N, vector<ll> a, vector<ll> b) {
    int xr = 0;
    for (int i = 0; i < 29; i++) {
        vector<ll> A = a;
        vector<ll> B = b;
        for (auto &&x : A) x %= 2 << i;
        for (auto &&x : B) x %= 2 << i;
        sort(B.begin(), B.end());

        long long ans = 0;
        for (auto &&x : A) {
            ans += len(B, (1 << i) - x, (2 << i) - x);
            ans += len(B, (1 << i) + (2 << i) - x, (4 << i) - x);
        }
        xr |= (1 << i) * (ans % 2);
    }
    cout << xr << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    vector<ll> a(N - 1 + 1);
    vector<ll> b(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= N - 1; i++) {
        cin >> b[i];
    }
    solve(N, a, b);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 11636
// https://atcoder.jp/contests/abc045/tasks/abc045_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
import math
d,g = map(int,input().split())
lis = [list(map(int,input().split())) for _ in range(d)]
# print(list(itertools.product([0,1], repeat=d))) [(0, 0), (0, 1), (1, 0), (1, 1)]
count_list = []
for flag in itertools.product([0,1], repeat=d):
    tmp = g
    count = 0
    score_list = []
    kosuu_list = []
    for i,f in enumerate(flag):
        if f==1:
            count += lis[i][0]
            #print(lis[i][1],100*(i+1),lis[i][0],tmp)
            tmp -= (lis[i][1]+100*(i+1)*lis[i][0])
        else:
            score_list.insert(0,100*(i+1))
            kosuu_list.insert(0,lis[i][0]-1)
    #print(score_list)
    #print(kosuu_list)
    #print(lis[i][1],100*(i+1),lis[i][0],tmp)
    if tmp <= 0:
        count_list.append(count)
    else:
        for sss,kkk in zip(score_list,kosuu_list):
            if tmp <= 0:
                break
            elif sss*kkk >= tmp:
                count += math.ceil(tmp/sss)
                tmp -= sss*math.ceil(tmp/sss)
                break
            elif sss*kkk < tmp:
                count += kkk
                tmp -= sss*kkk
        if tmp <= 0:
            count_list.append(count)
    #print(flag)
#print(count_list)
print(min(count_list))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,i,j;
  cin>>n>>m;
  
  int k[n],kind[m]={},ans=0;
  
  for(i=0;i<n;i++){
    cin>>k[i];
    int a[k[i]];
    for(j=0;j<k[i];j++){
      cin>>a[j];
      kind[a[j]-1]++;
    }
  }
  
  for(i=0;i<m;i++){
    if(kind[i]==n)
      ans++;
    cerr<<kind[i];
    
  }
  cout<<ans;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define db double
#define zero(x) (fabs(x)<eps)
#define sgn(x) (zero(x)?0:((x)>0?1:-1))
const db eps=1e-10;
struct point{
    db x,y;
    point(){}
    point(db x,db y):x(x),y(y){}
    point operator + (point B){ return point(x+B.x,y+B.y); }
    point operator - (point B){ return point(x-B.x,y-B.y); }
    point operator * (db k){ return point(k*x,k*y); }
    db operator * (point B){ return x*B.y-y*B.x; }
    db operator ^ (point B){ return x*B.x+y*B.y; }
    bool operator < (point B){ return (y>0)!=(B.y>0)?y>0:((*this)*B)>0; }
};
db dis2(point A,point B){ return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y); }
struct line{
    point A,B;
    line(){}
    line(point A,point B):A(A),B(B){}
};
point projection(line l,point P){
    point dir=l.B-l.A; P=P-l.A;
    return dir*((P^dir)/dis2(l.A,l.B))+l.A;
}
point reflection(line l,point P){
    return projection(l,P)*2-P;
}
int direction(point P0,point P1,point P2){
    db det=(P2-P0)*(P1-P0); return sgn(det);
}
bool parallel(line l1,line l2){
    return zero((l1.B-l1.A)*(l2.B-l2.A));
}
bool orthogonal(line l1,line l2){
    return zero((l1.B-l1.A)^(l2.B-l2.A));
}
bool intersect(line l1,line l2){//
    int d1=direction(l1.A,l1.B,l2.A),d2=direction(l1.A,l1.B,l2.B);
    int d3=direction(l2.A,l2.B,l1.A),d4=direction(l2.A,l2.B,l1.B);
    if (d1*d2>0||d3*d4>0) return false;
    if (l1.A.x>l1.B.x) swap(l1.A.x,l1.B.x);
    if (l1.A.y>l1.B.y) swap(l1.A.y,l1.B.y);
    if (l2.A.x>l2.B.x) swap(l2.A.x,l2.B.x);
    if (l2.A.y>l2.B.y) swap(l2.A.y,l2.B.y);
    return !(l1.B.x<l2.A.x||l2.B.x<l1.A.x||l1.B.y<l2.A.y||l2.B.y<l1.A.y);
}
point cross_point(line l1,line l2){
    db s1=fabs((l2.B-l2.A)*(l1.A-l2.A)),s2=fabs((l2.B-l2.A)*(l1.B-l2.A));
    return l1.A+(l1.B-l1.A)*(s1/(s1+s2));
}
db dis(line l,point P){//
    point proj=projection(l,P);
    if (min(l.A.x,l.B.x)-eps<proj.x&&proj.x<max(l.A.x,l.B.x)+eps)
        if (min(l.A.y,l.B.y)-eps<proj.y&&proj.y<max(l.A.y,l.B.y)+eps)
            return sqrt(dis2(P,proj));
    return sqrt(min(dis2(P,l.A),dis2(P,l.B)));
}
db distance(line l1,line l2){
    if (intersect(l1,l2)) return 0;
    return min(min(dis(l1,l2.A),dis(l1,l2.B)),min(dis(l2,l1.A),dis(l2,l1.B)));
}
db area(point *a,int n){
    db ans=0;
    for (int i=2;i<=n-1;++i) ans+=(a[i]-a[1])*(a[i+1]-a[1])/2;
    return ans;
}
const int N=1e6+6;
point A[N];
int main(){
    int n; scanf("%d",&n);
    for (int i=1;i<=n;++i) scanf("%lf%lf",&A[i].x,&A[i].y);
    printf("%.1f\n",area(A,n));
}



Measured memory_bytes: 3252
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n;
    cin >> n;
    if(n < 4){
        cout << 1<<endl; return 0;
    }
    ll pivot = sqrt(n);
    repd(i,1,pivot+1){
        if(n%i == 0) {
            i = n/i;
            ll cnt = 0;
            while(i > 0){
                i /=10;
                cnt++;
            }
            cout << cnt << endl;
            return 0;
        }
    }
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
n = int(input())
buttons = [0 for _ in range(n)]
for i in range(n):
    buttons[i] = int(input())

light = buttons[0]
for i in range(n):
    if light == 2:
        print(i+1)
        break
    light = buttons[light-1]
else:
    print(-1)


Measured memory_bytes: 7080
#include <iostream>
#include <string>
using namespace std;
int n;
string s;

int main(){
	cin>>n>>s;
	int len = s.length();
	for(int i=0;i<len;i++){
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K,R,S,P; cin>>N>>K>>R>>S>>P;
	string T; cin>>T;

	int ans = 0;
	rp(i, 0, T.size()){
		if(T[i] == 'r') ans += P;//win:r->p
		else if(T[i] == 's') ans += R;//win:s->r
		else ans += S;//win:p->s

		if(i-K < 0) continue;

		if(T[i-K] == T[i]){//fore
			if(T[i] == 'r') ans -= P;//win:r->p -> draw: -p
			else if(T[i] == 's') ans -= R;//win:s->r -> draw: -r
			else ans -= S;//win:p->s -> draw: -s

			if(i+K >= T.size()) continue;

			if(T[i] == T[i+K])//back
				if(T[i] == 'r') T[i] = 's';//lose:r->s
				else if(T[i] == 's') T[i] = 'p';//lose:s->p
				else T[i] = 'r';//lose:p->r
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
char c[200000];
int n,q;
int s[200000];
bool flag[200000];
int l,r,ans;


int main()
{
    cin>>n>>q;
    for (int i=1; i<=n; ++i)
    {
        scanf("%c",&c[i]);
        while (!(c[i]>='A' && c[i]<='Z')) scanf("%c",&c[i]);
        s[i]=s[i-1];
        if (c[i]=='C' && c[i-1]=='A')
        {
            flag[i]=1;
            s[i]+=1;
        }
    }
    for (int i=1; i<=q; ++i)
    {
        scanf("%d %d",&l,&r);
        ans = s[r]-s[l-1];
        if (flag[l]) ans--;
        printf("%d\n",ans);
    }
    return 0;
}



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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	int n,k;
	cin >> n >> k;
//	vector<int> d(k);
//	vector<vector<int>> a(k,vector<int>());
	vector<int> ans(n);

	int d;
	rep(i, k) {
		cin >> d;
		vector<int> a(d);
		rep(j, d) {
			cin >> a[j];
			ans[a[j]-1] = 1;
		}
	}
	int anss = 0;
	rep(i, n) {
		if (ans[i] == 1)	anss++;
	}

	cout << n-anss << endl;


}

Measured memory_bytes: 3636
#include<bits/stdc++.h> 
using namespace std; 
 
 void print(vector<int> s)
 {
     for(int i=0;i<s.size();i++)
     {
         cout<<s[i];
     }
 }
 
int main()
{
    int a,b;
    cin>>a>>b;
    
    vector<int> s,t;
    
    for(int i=0;i<b;i++)
    {
        s.push_back(a);
    }
    
    for(int j=0;j<a;j++)
    {
        t.push_back(b);
    }
    
 
    if(lexicographical_compare(s.begin(),s.end(),t.begin(),t.end() ))
    {
        print(s);
    }
    
    else
    {
        print(t);
    }
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for(int i = 0; i < N; ++i)
    cin >> P[i];
  sort(P.begin(), P.end());
  int ans = 0;
  for(int i = 0; i < K; ++i)
    ans += P[i];
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, x;
  cin >> n >> x;
  vl a(n);
  ll sum=0;
  rep(i, n) {cin >> a[i]; sum += a[i];}
  if(x > sum) {cout << n-1 << newl; return 0;}
  sort(all(a));
  ll ans=0;
  rep(i, n) if(x>=a[i]) {x-=a[i]; ans++;} 
  cout << ans << newl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    repd(i, 1, N) {
        int candy = A[i] + A[i - 1];
        ans += max(0, candy - X);
        A[i] -= min(A[i], max(0, candy - X));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
typedef long long ll;
const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;

using namespace std;
    
struct s 
{
  string name;
  int score,id;
};

bool cmp(s &a ,s &b)
{
	if(a.name < b.name)
		  return true;

	else 
		{
			if(a.name == b.name and a.score > b.score)
				 return true;

			return false;
		}
}

int main()
{
  

ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector
 v;

int n;
cin >> n;
for(int i = 0 ; i < n ; i++)
	 {
	 	string name;
	 	int score;
	 	cin >> name >> score;
	 	v.push_back({name,score,i});
	 }

	sort(v.begin(),v.end(),cmp);
	

	for(int i = 0 ; i < n ; i++)
		{
			cout << v[i].id + 1<< '\n';
		}


}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int i,s,t;
    int input;
    while((input=getchar())!=EOF){//一文字読み込み
        if(input!='@'){
            putchar(input);//一文字ずつ出力
        }else{
            t=getchar();
            s=getchar();
            for(i='0';i<t;i++){
                putchar(s);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <deque>
using namespace std;
const int maxn = 5e5 + 5;
int a[maxn], N, Q;
int tree[maxn], flag[maxn], ans[maxn];
struct node
{
    int l, r, z;
} n[maxn];
bool cmp(node a, node b)
{
    if (a.r != b.r)
        return a.r < b.r;
    else
    {
        return a.l < b.l;
    }
}
int lowbit(int x)
{
    return x & -x;
}
void insert(int a, int b)
{
    for (int i = a; i <= N; i += lowbit(i))
    {
        tree[i] += b;
    }
}
int query(int x)
{
    int ans = 0;
    for (int i = x; i > 0; i -= lowbit(i))
        ans += tree[i];
    return ans;
}
int main()
{
    cin >> N >> Q;
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= Q; i++)
    {
        cin >> n[i].l >> n[i].r;
        n[i].z = i;
    }
    sort(n + 1, n + Q + 1, cmp);
    int k = 1;
    for (int i = 1; i <= Q; i++)
    {
        for (int j = k; j <= n[i].r; j++)
        {
            if (flag[a[j]])
            {
                insert(flag[a[j]], -1);
            }
                insert(j, 1);
                flag[a[j]] = j;
        }
        k = n[i].r + 1;
        ans[n[i].z] = query(n[i].r) - query(n[i].l-1);
      
    }
    for (int i = 1; i <= Q; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 17404
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  char x, y; cin >> x >> y;
  if (x < y) cout << '<' << '\n';
  else if (x == y) cout << '=' << '\n';
  else cout << '>' << '\n';
  return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define loop(i, n) for(int i = 0 ; i < n ; ++i)
#define LOOP(i, a, b) for(int i = a ; i < b ; ++i)
#define max3(a, b, c) max(a, max(b,c))
#define max4(a, b, c, d) max3(a, b, max(c, d))
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18
#define inf 1e9
#define MOD 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll n, k, v[101];
ll dp[3][100005], ps[100005];

int main() {
	_69e27;
	memset(dp, 0, sizeof(dp));
	cin >> n >> k;
	loop(i, n) cin >> v[i];
	int r = 1;
	loop(i, v[0]+1) dp[0][i] = 1;
	LOOP(i, 1, n)
	{
		ps[0] = 0;
		LOOP(j, 1, k+2) ps[j] = (dp[1-r][j-1] + ps[j-1])%MOD;
		loop(j, k+1) dp[r][j] = (ps[j+1]-ps[max(0LL, j-v[i])]+MOD)%MOD;
		r^=1;
	}
	cout << dp[r^1][k];
	return 0;
}

Measured memory_bytes: 3456
///Comentary AC
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int h, w; cin >> h >> w;
    string board[50];
    for (int i=0;i<h;++i) cin >> board[i];

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

    for (int i=0;i<h;++i){
        for (int j=0;j<w;++j){
            if (board[i][j]=='#') continue;

            int num=0;
            for (int d=0;d<8;++d){
                const int ni = i+dy[d];
                const int nj = j+dx[d];

                if (ni<0 || h<=ni) continue;
                if (nj<0 || w<=nj) continue;
                if (board[ni][nj]=='#') num++;
            }

            board[i][j] = char(num+'0');
        }
    }
    for (int i=0;i<h;++i) cout <<board[i] << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int X = int.Parse(cin.Read);
            int Y = int.Parse(cin.Read);
          
          	Console.WriteLine(X * Y);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

int main() {
	int n;
	while (cin >> n, n) {
		int suret[12];
		int cpy[12];
		for (int i = 0;i < n;i++)cin >> suret[i];

		int ans = 0;
		while (1) {
			for (int i = 0;i < n;i++) {
				int a = 0;
				for (int j = 0;j < n;j++) {
					if (suret[i] == suret[j])a++;
				}
				cpy[i] = a;
			}
			int flg = 1;
			for (int i = 0;i < n;i++) {
				if (suret[i] != cpy[i])flg = 0;
				suret[i] = cpy[i];
			}
			if (flg == 1)break;
			ans++;
		}
		cout << ans << endl;
		for (int i = 0;i < n;i++){
			cout << suret[i];
			if (i != n - 1)cout << ' ';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
d,g = map(int, input().split())
pc = []

for i in range(d):
    p,c = map(int, input().split())
    pc.append([p,c])
ans = 10**7
for i in range(2**d):
    tmp = 0
    cnt = 0
    r = list(range(1,d+1))
    for j in range(d):
        if(i>>j)&1==1:
            tmp += pc[j][0]*100*(j+1)+pc[j][1]
            cnt += pc[j][0]
            r.remove(j+1)
    if tmp<g:
        plus = max(r)
        n = min(pc[plus-1][0],-(-(g-tmp)//(plus*100)))
        cnt +=n
        tmp += n*plus*100
    if tmp>= g:
        ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  long long n,k;
  long long x[100005]={0};
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    x[a]+=b;
  }
  long long sum=0;
  for(int i=1;i<100005;i++){
    sum+=x[i];
    if(k<=sum){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
int main(void)
{
	unsigned long long n;
	std::cin >> n; 

	unsigned long long sum = 0;
	for(unsigned long long k=1;k<=n;++k)
	{
		unsigned long long i = n/k; // 等比級数の数
		sum += i*(i+1)/2*k;
	}
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
using namespace std;
const int mod = 1e9 + 7;
int f[200005], lp[200005], sp[200005], a[200005], n, in;
int main() {
	scanf("%d", &n), f[0] = 1;
	for(register int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for(register int i = 1; i <= n; ++i) {
		f[i] = f[i - 1];
		if(a[i + 1] == a[i]) continue; 
		(f[i] += sp[a[i]]) %= mod;
		(sp[a[i]] += f[in]) %= mod, in = i;
	}
	printf("%d", f[n]);
	return 0;
}

Measured memory_bytes: 2560
x, k, d = map(int, input().split())
if x < 0: x = -x
k_0 = x // d
if k <= k_0:
    print(x - d * k)
else:
    k = k - k_0
    if k % 2 == 0:
        print(x - d * k_0)
    else:
        print(d * (k_0 + 1) - x)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
int main()
{
    fastread;
    int T=1;
//    cin>>T;
    for(int qq=1;qq<=T;qq++)
    {
        ll s;
        cin>>s;
        ll a=1000000000;
        ll d=s/a+(s%a!=0);
        ll b=a*d-s;
        cout<<"0 0 "<<a<<' '<<b<<' '<<1<<' '<<d<<endl;
    }
    return 0;
}



Measured memory_bytes: 256