akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
// ll mod=998244353;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin>>n>>k;
	ve<ll>ar(n+1);
	lr(n){
		cin>>ar[i+1];
	}
	ll dp[n+1]={0};
	for(ll i=n-1;i>=1;i--){
		dp[i]=INF;
		for(ll j=i+1;j<=min(n,i+k);j++){
			dp[i]=min(abs(ar[j]-ar[i])+dp[j],dp[i]);
		}
	}
	cout << dp[1] << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main() {
	
	int R;
	cin>>R;
	if(R<1200)cout<<"ABC"<<endl;
	else if(R<2800)cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;

	return 0;
}


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

int main(){
	int r, c;
	cin >> r >> c;

	int **Data = new int*[r+2]();
	for(int i=0; i < r+2; i++){
		Data[i] = new int[c+2]();
	}

	int *rowsum = new int[r+2]();
	int *colsum = new int[c+2]();
	int sum = 0;

	// Input Data
	for(int n=1; n<=r; n++){
		for(int m=1; m<=c; m++){
			cin >> Data[n][m];
		}
	}

	// Output Data
	for(int rn=1; rn<=r; rn++){
		for(int cn=1; cn<=c; cn++){
			cout << Data[rn][cn] << " ";
			rowsum[rn] += Data[rn][cn];
			colsum[cn] += Data[rn][cn];
		}
		cout << rowsum[rn] << endl;
	}
	for(int cn=1; cn<=c; cn++){
		cout << colsum[cn] << " ";
		sum += colsum[cn];
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,amari=9,time=0,zero=0;
    rep(i,5){
        cin>>a;
        if(a%10==0){
            zero++;
            time+=a;
        }else{
            amari=min(amari,a%10);
            time+=a/10*10+10;
        }
    }
    if(zero==5) cout<<time;
    else cout<<time+amari-10;
}

Measured memory_bytes: 3632
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2084
def f(a, b):
    str_a = str(a)
    len_a = len(str_a)
    str_b = str(b)
    len_b = len(str_b)

    return len_a if len_a > len_b else len_b

N = int(input())

min = 10**10
max_iter = 10 ** (len(str(N))//2 + 1)

for i in range(1, max_iter):
    a = i
    if N % a == 0:
        b = int(N / a)
    else:
        continue

    ret = f(a, b)
    if min > ret:
        min = ret
        if min <= len(str(N))//2:
            break

print(min)


Measured memory_bytes: 9160
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HN = Sarray();
            var H = HN[0];
            var N = HN[1];
            var dp = Enumerable.Repeat(long.MaxValue / 2, (int)H + 1).ToArray();
            dp[0] = 0;
            for (var i = 0; i < N; ++i)
            {
                var AB = Sarray();
                var A = AB[0];//攻撃力
                var B = AB[1];//消耗
                for (var h = 0; h < H; ++h)
                {
                    var dmg = Min(H, h + A);
                    var cst = dp[h] + B;
                    dp[dmg] = Min(dp[dmg], cst);
                    if (-1 == dp[dmg]) dp[dmg] = cst;
                }
            }
            WriteLine(dp[H]);
            //Out.Flush();
        }
    }
}

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

int main() {
  int n,a=0,b=0,cnt=0;
  cin >> n;
  vector<int> v(n),p(n),q(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    v[i]=i+1;
  }
  for(int i=0;i<n;i++) cin >> q[i];
  do {
    cnt++;
    if(p==v) a = cnt;
    if(q==v) b = cnt;
  } while (next_permutation(v.begin(),v.end()));
  cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n,k;
    cin >> n >> k;
    if(n % k == 0){
        P(0);
    }else{
        P(1);
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]

n = int(input())

l = [[False] * 3 for _ in range(3)]

for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                l[i][j] = True

ans = "No"

for i in range(3):
    if l[i][0] and l[i][1] and l[i][2]:
        ans = "Yes"
    if l[0][i] and l[1][i] and l[2][i]:
        ans = "Yes"

if l[0][0] and l[1][1] and l[2][2]:
    ans = "Yes"
if l[0][2] and l[1][1] and l[2][0]:
    ans = "Yes"

print(ans)

Measured memory_bytes: 38384
using System;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Collections.Generic;

//

namespace Kyoupro
{
    class Program
    {
        
        static void Main(string[] args)
        {    
            int count=0;
            int count2=0;

            //整数の数を取得
            int N = int.Parse(Console.ReadLine());

            //空白区切り一行
            var nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
           
            if(nums.All(x=> x%2==0))//全て偶数なら実行
            {
                count = 10000;
               
               foreach(var n in nums)
               {
                   count2=0;
                   int a = n;
                   while(a%2==0)
                   {
                       a/=2;
                       count2++;
                   }
                   //小さい方をとる
                    count = Math.Min(count,count2);
               }
                
                
                
            }

            Console.WriteLine(count);
                       
        }
    }
}

Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:59:14 2020
"""

import sys
#import numpy as np
import itertools
sys.setrecursionlimit(10 ** 9)

N, M, Q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(Q)]

A = itertools.combinations_with_replacement([i for i in range(1,M+1)],N)

ans = 0
for l in A:
    tmp = 0
    for a,b,c,d in abcd:
        if l[b-1] - l[a-1] == c:
            tmp += d
    ans = max(ans, tmp)
print(ans)



Measured memory_bytes: 9116
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> ls(N);
  F0R(i, N) {
    cin >> ls[i];
  }
  sort(rrng(ls));
  i64 best = 1e9;
  // pow(4,N)
  F0R(bits, 1 << (N * 2)) {
    i64 mp = 0;
    int a = 0, b = 0, c = 0;
    F0R(i, N) {
      switch ((bits >> (i * 2)) & 3) {
      case 1:
        if (a) mp += 10;
        a += ls[i];
        break;
      case 2:
        if (b) mp += 10;
        b += ls[i];
        break;
      case 3:
        if (c) mp += 10;
        c += ls[i];
        break;
      }
    }
    if (!a || !b || !c) continue;
    mp += abs(A - a) + abs(B - b) + abs(C - c);
    chmin(best, mp);
  }
  cout << best;
}
#endif


Measured memory_bytes: 3640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i64>();

    let (n, k, q) = (line[0], line[1], line[2]);

    let mut scores : Vec<i64> = vec![k;n as usize];

    for _ in 0..q{
        let a: usize = read_as_vec()[0];
        scores[a-1] += 1;
    }

    for i in 0..n as usize{
        if scores[i] > q{
            println!("Yes");
        }else{
            println!("No");
        }
    }
}


Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define INF 1e+9
using namespace std;

typedef pair<double,int> P;

int n,cnt = 0;
double x[100000],r[100000],lft,rit;

double calc(double tx){
	double mi = INF;
	for(int i = 0;i < n;i++){
		mi = min(mi,sqrt(r[i] * r[i] - (tx - x[i]) * (tx - x[i])));
	}
	return mi;
}

int main(){
	vector<P> vec;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x[i] >> r[i];
		vec.push_back(P(x[i] - r[i],-(i + 1)));
		vec.push_back(P(x[i] + r[i],i + 1));
	}
	sort(vec.begin(),vec.end());
	for(int i = 0;i < vec.size();i++){
		if(vec[i].second < 0){
			cnt++;
			if(cnt == n) lft = vec[i].first;
		}
		else{
			cnt--;
			if(cnt == n - 1) rit = vec[i].first;
		}
	}
	for(int i = 0;i < 100;i++){
		double t1 = (lft * 2.0 + rit) / 3.0,t2 = (lft + rit * 2.0) / 3.0;
		if(calc(t1) < calc(t2)) lft = t1;
		else rit = t2;
	}
	printf("%.5lf\n",calc(rit));
	return 0;
}

Measured memory_bytes: 8160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>

using namespace std;

int main()
{
    string s;
    getline(cin, s);

    for (int i = 0; i < s.size(); i++)
    {
        if (isalpha(s.at(i)))
        {
            if (islower(s.at(i)))
            {
                s.at(i) = toupper(s.at(i));
            }
            else
            {
                s.at(i) = tolower(s.at(i));
            }
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(){
    int c = 0, h = 0;
    int s1, s2, t;
    char a, b;
    while(cin >> s1 >> a >> s2 >> b >> t)
    {
        if(((s1 * s1) + (s2 * s2)) == t * t) c++;
        if(s1 == s2) h++;
    }
    cout << c << endl;
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	static public void main(String[] args) {

		int[] intArray = new int[3];

		Scanner scan = new Scanner(System.in);
		for (int i = 0; i < 3; i++) {
			intArray[i] = scan.nextInt();
		}
		scan.close();

		int max = 0;
		for (int i = 0; i < 3; i++) {
			if (max < intArray[i]) {
				max = intArray[i];
			}
		}
		int count = 0;

		while (intArray[0] != max || intArray[1] != max || intArray[2] != max) {
			count++;
			int maxCount = 0;
			for (int i = 0; i < 3; i++) {
				if (max == intArray[i]) {
					maxCount++;
				}
			}

			if (maxCount == 1) {
				for (int i = 0; i < 3; i++) {
					int target = intArray[i];
					if (target != max) {
						intArray[i] = ++target;
					}
				}
			} else {
				for (int i = 0; i < 3; i++) {
					int target = intArray[i];
					if (target != max) {
						intArray[i] = target + 2;
						if (max < target + 2) {
							max = target + 2;
						}
						break;
					}
				}
			}
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int a,b,c,x,y = 0;

		Scanner scan = new Scanner(System.in);
		a = Integer.parseInt(scan.next());
		b = Integer.parseInt(scan.next());
		c = Integer.parseInt(scan.next());
		x = Integer.parseInt(scan.next());
		y = Integer.parseInt(scan.next());

/*		for(int i=x;i>=0;i--) {
			int sumx = (a * i) + (x - i)*2*c;
			System.out.println(sumx);
		}
		System.out.println("--------");

		for(int j=y;j>=0;j--) {
			int sumy = (b * j) + (y - j)*2*c;
			System.out.println(sumy);
		}*/

		int num_max = 0;
		if(x > y) {
			num_max = x;
		}else {
			num_max = y;
		}

		int sum = 0;
		for(int i=0;i<=num_max;i++) {

			int sum1 = (x - i)*a;
			int sum2 = (y -i)*b;
			int sum3 = 2*i*c;

			if(sum1 < 0) {
				sum1 = 0;
			}
			if(sum2 < 0) {
				sum2 =0;
			}

			int suma = sum1 + sum2 + sum3;
			if (sum == 0) {
				sum = suma;
			}else if(suma < sum) {
				sum = suma;
			}

		}
		System.out.println(sum);
	}
}

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

const ll MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int p[300000];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&p[i]);
	int cnt=0;
	int Min=INT_MAX;
	rep(i,n){
		if(Min>=p[i])cnt++;
		Min=min(Min,p[i]);
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<vi> vvi;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

int main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = INF;
    rep(i,n)if(s[n-1-i] == '<'){
        ans = min(ans,i);
        break;
    }
    rep(i,n)if(s[i] == '>'){
        ans = min(ans, i);
    }
    cout << n - ans << endl;
}



Measured memory_bytes: 3332
import Foundation

let N = readLine()!.components(separatedBy:" ").map{Int($0)!}
var A = N[2] / N[1]
let a = N[2] % N[1]
var B = N[0] / N[3]
let b = N[0] % N[3]
if(a > 0){
  A += 1
}
if(b > 0){
  B += 1
}
if(A <= B){
  print("Yes")
}else{
  print("No")
}

Measured memory_bytes: 14072
#include<cstdio>
int a[200050],b[200050];
struct que1{
	int q[200050],h,r;
	inline void init(){
		h=1;r=0;
	}
	inline void push(int x){
		while(h<=r&&x>q[r])--r;
		q[++r]=x;
	}
	inline void pop(int x){if(x==q[h])++h;}
}Q;
struct que2{
	int q[200050],h,r;
	inline void init(){
		h=1;r=0;
	}
	inline void push(int x){
		while(h<=r&&x<q[r])--r;
		q[++r]=x;
	}
	inline void pop(int x){if(x==q[h])++h;}
}q;
int main(){
	int n,k,i,cnt=1,ans=1;
	bool f;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	for(b[1]=1,i=2;i<=n;++i)if(a[i]>a[i-1])b[i]=b[i-1];
	else b[i]=++cnt;
	Q.init();q.init();
	for(i=1;i<=k;++i)Q.push(a[i]),q.push(a[i]);
	f=b[k]==b[1];
	for(;i<=n;++i){
		Q.pop(a[i-k]);q.pop(a[i-k]);
		if(q.q[q.h]<a[i-k]||a[i]<Q.q[Q.h])if(b[i]==b[i-k+1])if(!f){++ans;f=1;}
		else;
		else ++ans;
		Q.push(a[i]);q.push(a[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge { ll to, cost; };
ll inf = 1e18;

ll V, E, r;
vector<P> G[100010];
ll d[100010];

void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, inf);
    d[s] = 0;
    que.push(P(0, s));
    
    while (!que.empty()) {
        P p = que.top();  que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            P e = G[v][i];
            if (d[e.first] > d[v] + e.second) {
                d[e.first] = d[v] + e.second;
                que.push(P(d[e.first], e.first));
            }
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;

    set<int> s;
    V = n;
    for (int i = 0; i < n; i++) s.insert(i);

    for (int i = 0; i < m; i++) {
        ll l, r, c;
        cin >> l >> r >> c;

        l--;  r--;
        G[l].emplace_back(r, c);
        //G[r].emplace_back(l, c);
        decltype(s)::iterator it = s.lower_bound(l);
        while (it != s.end() && *it < r) {
            //G[*it].emplace_back(*it + 1, 0);
            G[*it + 1].emplace_back(*it, 0);
            it = s.erase(it);
        }
    }

    dijkstra(0);
    cout << (d[n - 1] == inf ? -1 : d[n - 1]) << endl;

}

Measured memory_bytes: 10104
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X):
    if X == 1 or X == 2*N-1:
        print('No')
        return

    a = list(range(1, 2*N))
    if N == 2:
        if a.index(X) != 1:
            print('No')
            return

    else:
        ci = 2*N//2 - 1
        xi = a.index(X)
        a[xi], a[ci] = a[ci], a[xi]

        if X != 2*N-2:
            xm1i = a.index(X-1)
            a[xm1i], a[ci-1] = a[ci-1], a[xm1i]

            xp1i = a.index(X+1)
            a[xp1i], a[ci-2] = a[ci-2], a[xp1i]

            xp2i = a.index(X+2)
            a[xp2i], a[ci+1] = a[ci+1], a[xp2i]
        else:
            xm1i = a.index(X+1)
            a[xm1i], a[ci-1] = a[ci-1], a[xm1i]

            xp1i = a.index(X-1)
            a[xp1i], a[ci-2] = a[ci-2], a[xp1i]

            xp2i = a.index(X-2)
            a[xp2i], a[ci+1] = a[ci+1], a[xp2i]

    print('Yes')
    for v in a:
        print(v)


def main():
    N, X = read_int_n()
    slv(N, X)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 998244353;

int main() {
    int k; cin >> k;
    queue<ll> q;
    rep(i, 9) q.push(i+1);
    rep(i, k-1) {
        ll num = q.front(); q.pop();
        int lowest = num % 10;
        if (lowest != 0) q.push(num*10 + lowest-1);
        q.push(num*10 + lowest);
        if (lowest != 9) q.push(num*10 + lowest + 1);
    }

    cout << q.front() << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
		long long a, b;
		int sum, x[1000], cnt = 1;
		scanf("%lld%lld", &a, &b);
		for(int i = 1;;i++)
		{
			a = a *2;
			if(a <= b) cnt++;
			else break;
		}
		printf("%d\n", cnt);
		return 0;


	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define maxn 100000
using namespace std;
long long n, a[maxn+5];

long long solve(int flag){
    long long sum = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(flag > 0 && sum <= 0){
            cnt += 1-sum;
            sum = 1;
        }
        else if(flag < 0 && sum >= 0){
            cnt += sum+1;
            sum = -1;
        }
        flag *= -1;
    }
    return cnt;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long cnt_p = 0, cnt_n = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    //cnt_p
    cnt_p = solve(1);
    //cnt_n
    cnt_n = solve(-1);
    cout << min(cnt_p, cnt_n);

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>

using namespace std;
//author_name:
//date://
//title:
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define eb emplace_back
#define mp make_pair
//tsurune
typedef pair<int,int> pii;
typedef unsigned int uint;

int main(){
	int a,b,c;
	cin>>a>>b;
	if((a-b)%2==0) cout<<(a+b)/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define NONE -1

void push(int n, int stack[], int* counter){
	stack[*counter] = n;
	(*counter)++;
}

void pop(int stack[], int* s_counter, int pop_log[], int* p_counter){
	int n;
	n = stack[(*s_counter)-1];
	(*s_counter)--;
	push(n, pop_log, p_counter);
}

int main(void){
	int stack[MAX];
	int pop_log[MAX];
	int i,n;
	int s_counter= 0;
	int p_counter = 0;
	for(i = 0; i < MAX; i++){
		stack[i] = NONE;
	}
	while(1){
		if(scanf("%d",&n) == EOF){break;}
		if(n == 0){pop(stack,&s_counter,pop_log,&p_counter);}
		else{push(n,stack,&s_counter);}
	}
	for(i = 0; i < p_counter; i++){
		printf("%d\n",pop_log[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;

#define N 100005
const int mod = 1e9 + 7;
#define ll long long

ll s[N];
ll diff[N];
int conInd[N][2];
int nextInd[N][2];
int ret[N];

int add(int x, int y) {
	int ret =( x + y) % mod;
	ret = (ret + mod) % mod;
	return ret;
}
vector<pair<int, int> >v[N][2];
void solve() {
	int n; scanf("%d %lld %lld", &n,&diff[0],&diff[1]);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &s[i]);
	}
	s[0] = -1e18;
	s[n + 1] = 3e18;
	++n;
	for (int i = n; i>=0; --i) {
		conInd[i][0] = conInd[i][1] = i;
		if (i + 1 <= n ) {
			for (int j = 0; j < 2; ++j) {
				if (s[i + 1] - s[i] >= diff[j]) {
					conInd[i][j] = conInd[i + 1][j];
				}
			}
		}
	}

	int dp[2] = { 1,1 };
	ret[1] = 2;
	priority_queue<pair<int, int> ,vector<pair<int,int> >,greater<pair<int,int> > >pq[2];
	pq[0].push(make_pair(conInd[1][1]+1, 1));
	pq[1].push(make_pair(conInd[1][0]+1, 1));
	//printf("%d\n", conInd[1][0]);
	for (int i = 2; i <= n; ++i) {
		for (int j = 0; j < 2; ++j) {
			while (v[i][j].size() > 0) {
				pq[j].push(v[i][j].back());
				dp[j] = add(dp[j], v[i][j].back().second);
				v[i][j].pop_back();
			}
		}
		int tmp[2];
		tmp[0] = dp[0], tmp[1] = dp[1];
		if (i == n) {
			printf("%d\n", add(tmp[0], tmp[1]));
			return;
		}

		for (int j = 0; j < 2; ++j) {
			while (!pq[j].empty()) {
				if (pq[j].top().first <= i) {
					dp[j] = add(dp[j], -pq[j].top().second);
					pq[j].pop();
				}
				else {
					break;
				}
			}
		}

		for (int j = 0; j < 2; ++j) {
			int l = i + 1, r = n, mid;
			while (l < r) {
				mid = (l + r) / 2;
				if (s[mid] - s[i - 1] >= diff[j ^ 1]) {
					r = mid;
				}
				else {
					l = mid + 1;
				}
			}
			if (conInd[i][j] + 1 <l) {
				continue;
			}
			else {
				v[l][j^1].push_back(make_pair(conInd[i][j] + 1, tmp[j]));
			}
		}
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 16232
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	b, _ := strconv.Atoi(sc.Text())

	l := []int{a + b, a - b, a * b}
	sort.Ints(l)

	fmt.Println(l[2])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
int pre[200000 + 5] ,suff[200000 + 5] ;
 
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
   
  while (tc--)
  {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int a[n + 1];
    for (int i = 0; i < n + 1; i++)
    {
      a[i] = i;
    }
    pre[0] = 0;
    for (int i = 1; i < n+1; i++)
    {
      pre[i] = a[i] + pre[i - 1];
      pre[i] %= mod;
    }
    suff[n] = n ;
    for (int i = n-1; i >= 0; i--)
    {
      suff[i] = suff[i + 1] + a[i];
      suff[i] %= mod;
    }
    for (int i = k; i <= n; i++)
    {
      ans +=suff[n-i+1]-pre[i-1]+1;
      ans%=mod;
      if(ans<0){
        ans += mod;
      }
    }
    ans++;
    ans %= mod;

    cout << ans << endl;
  }

  return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> inv(M + 1);
    inv[1] = 1;
    for(unsigned long i{2}; i <= M; ++i)inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
    unsigned long ans{1}, tmp{1};
    for(unsigned long i{1}; i <= N; ++i){
        (tmp *= N - i + 1) %= MOD;
        (tmp *= inv[i]) %= MOD;
        (tmp *= M - N + i) %= MOD;
        (ans = MOD + tmp - ans) %= MOD;
    }
    cout << ans * tmp % MOD << endl;
    return 0;
}

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

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


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var M = cin.ReadInt;

            var ans = (1900 * M + 100 * (N - M)) * Pow(2, M);
            WriteLine(ans);
        }


        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: 11220
#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    cout << a * a << '\n';
    return 0;
}


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

int main ()
{
  int n; string s, s2;
  cin >> n; cin >> s;

  if (n%2) cout << "No" << endl;
  else
  {
    for (int i = 0; i < n/2; i++)
    {
      s2[i] = s[i];
    }

    int i = 0;
    int j = n/2;

    while (s2[i] == s[j] && i < n/2)
    {
      i++; j++;
    }

    if (i == n/2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }

int fastmod(int base,int exp){
	if(exp==0) return 1;
	else if(exp%2==0){
		int ans=fastmod(base,exp/2);
		return (ans%mod*ans%mod)%mod;
	}
	else return (fastmod(base,exp-1)%mod*base%mod)%mod;
}

int32_t main(){
		
	fast;
	int n; cin >> n;
	int ar[n];

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

	int sum = 0;

	for(int i=60;i>=0;i--){
		int mask = 1LL << i;
		int one= 0 , zero = 0;
		for(int j=0;j<n;j++){
			bool set = ar[j]&mask;
			if(set) one++;
			else zero++;
		}
		int curr_sum = ((zero%mod * one%mod)%mod * fastmod(2,i))%mod;
		sum+=curr_sum;
		sum%=mod;
	}

	cout << sum << '\n';

	return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int[] nums = new int[a];
        for (int i = 0; i < a; i++) {
            nums[i] = Integer.parseInt(sc.next());
        }
        int cnt = 0;
        while (true) {
            boolean existOdd = false;
            for (int i = 0; i < a; i++) {
                if (nums[i] % 2 != 0) existOdd = true;
            }
            
            if (existOdd) break;
            
            for (int i = 0; i < a; i++) {
                nums[i] = nums[i] / 2;
            }
            cnt++;
        }
        
        System.out.println(cnt);
        
    }
}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int  X = sc.nextInt();
		int  Y = sc.nextInt();
		int  Z = sc.nextInt();

		int w = X;
		X= Y;
		Y = w;

		w = X;
		X= Z;
		Z = w;

		System.out.print(X+" ");
		System.out.print(Y+" ");
		System.out.print(Z);

		}
	}







Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 1234567;

int cnt[N];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    cnt[u]++;
    cnt[v]++;
  }
  for (int i = 1; i <= n; i++) cout << cnt[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+10;
int a[maxn];

int main()
{
    int n, k;
    sc(n); sc(k);
    for(int i = 1; i <= n; i++)sc(a[i]);
    int ans = INF;
    for(int i = 1; i+k-1 <= n; i++){
        if(a[i] < 0 && a[i+k-1] < 0)ans = min(ans, -a[i]);
        else if(a[i] < 0 && a[i+k-1] >= 0)ans = min(ans, -a[i]+a[i+k-1]+min(-a[i], a[i+k-1]));
        else ans = min(ans, a[i+k-1]);
    }
    printf("%d\n", ans);
    return 0;
}




Measured memory_bytes: 640
#include<iostream>

using namespace std;

int A,B,C,D;

int main(void) {
    cin>>A>>B>>C>>D;

    if(A+B == C+D) {
        cout<<"Balanced"<<endl;
    } else if(A+B > C+D) {
        cout<<"Left"<<endl;
    } else {
        cout<<"Right"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[200010];
  long long i,l,c=0,b[30]={};
  scanf("%s",s);
  for(l=0;s[l];l++)b[s[l]-'a']++;//printf("a\n");
  for(i=0;i<26;i++){
    if(b[i])c+=(b[i]-0)*(b[i]-1)/2;
  }//printf("%lld %lld\n",c,l);
  printf("%lld\n",l*(l-1)/2-c+1);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <functional>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

int solve(vector<bool> clock){
    int ans = 24 ;
    int temp = 1 ;
    for (int i = 1; i < 24; i++)
    {
        if (clock.at(i) == 1)
        {
            ans = min(ans,temp) ;
            temp = 1 ;
        }else
        {
            temp ++ ;
        }
        
    }
    ans = min(ans,temp) ;
    return ans ;
}

int main(){
    int n ;
    cin >> n ;
    vector<int> t(13,0) ;
    int d ;
    for (int i = 0; i < n; i++)
    {
        cin >> d ;
        t.at(d) ++ ;
    }
    if (t.at(0) > 0 || t.at(12) > 1)
    {
        cout << 0 << endl ;
        return 0 ;
    }
    for (int i = 1; i < 12; i++)
    {
        if (t.at(i) > 2)
        {
            cout << 0 << endl ;
            return 0 ;
        }
        
    }
    vector<bool> clock(24,0) ;
    vector<int> choice(0) ;
    clock.at(0) = 1 ;
    for (int i = 1; i < 12; i++)
    {
        if (t.at(i) == 1)
        {
            choice.push_back(i) ;
        }else if (t.at(i) == 2)
        {
            clock.at(i) = 1 ;
            clock.at(24-i) = 1 ;
        }
        
        
    }
    if (t.at(12) == 1)
    {
        clock.at(12) = 1 ;
    }
    int ans = 0 ;
    for (int bit = 0; bit < pow(2,choice.size()) - 0.1; bit++)
    {
        for (int i = 0; i < choice.size(); i++)
        {
            if (bit &(1 << i))
            {
                clock.at(24 - choice.at(i)) = 1 ;
            }else
            {
                clock.at(choice.at(i)) = 1 ;
            }
            
            
        }
        ans = max(ans,solve(clock)) ;
        for (size_t i = 0; i < choice.size(); i++)
        {
            clock.at(choice.at(i)) = 0 ;
            clock.at(24 - choice.at(i)) = 0 ;
        }
        
        
    }
    cout << ans << endl ;
    
}

Measured memory_bytes: 4108
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	var counter [10][10]int

	for i := 1; i <= n; i++ {
		dd := 0
		for d := i; d > 0; d /= 10 {
			dd = d
		}
		counter[dd][i%10]++
	}
	var ans int64
	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			ans += int64(counter[i][j]) * int64(counter[j][i])
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

s = read().decode().rstrip()

ans = len(s)


for i in range(97, 97+26):
    c = chr(i)
    cnt = 0
    acc = s
    while len(acc) != acc.count(c):
        s_ = ""
        for j, _ in enumerate(acc):
            if j == len(acc)-1:
                break
            if acc[j:j+2].count(c) > 0:
                s_ += c
            else:
                s_ += acc[j]
        cnt += 1
        acc = s_
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

ll N;
ll A[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];
    if(N==1){
        cout<<A[0]/2<<endl;
        return 0;
    }

    ll ans=0;
    ll x=A[0];
    repn(i,N-1){
        x+=A[i];
        ans+=x/2;
        x%=2;
        if(A[i]==0) x=0;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
n = int(input())
# A = list(map(int, input().split()))
tasks = []
for i in range(n):
    a, b = map(int, input().split())
    tasks.append((b, a, i))

tasks.sort()

current = 0

for b, a, _ in tasks:
    current += a
    if current > b:
        break
else:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 46576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cinn(a) for(auto &_k:(a)) cin >> _k
#define coutt(a) for(auto &_k:(a)) cout << _k << ' '
inline int cint() { int temp; cin>>temp; return temp; }
int c[5002][5002];
int main(){
    int i(0), n, mx(0); string s; cin >> n >> s;
    for (int j=i+1; j<n; j++) c[i][j]=(s[i]==s[j]);
    for (int i=1; i<n; i++){
        for (int j=i+1; j<n; j++) {
            c[i][j] = (c[i - 1][j - 1] + 1)*(s[i] == s[j] && j - i > c[i - 1][j - 1]);
            mx=max(mx,c[i][j]);
        }
    }
    cout << mx;
}

Measured memory_bytes: 96768
#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int ans = 0;
  int v[n];
  for (int i = 0 ; i < n; i ++){
    scanf("%d",&v[i]);
  }
  int c[n];
  for (int i =0; i < n ; i ++){
    scanf("%d",&c[i]);
  }
  for (int i = 0 ; i < n; i ++){
    if(v[i]-c[i] > 0){
      ans = ans + v[i] - c[i];
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int k;
	scanf("%d",&k);
	int ma = max(a,b);
	ma = max(ma,c);
	int ans = 0;
	if (ma == a)
	{
		for (int i = 1;i <= k;i++)
		{
			a *= 2;
		}
	}
	else if (ma == b)
	{
		for (int i = 1;i <= k;i++)
		{
			b *= 2;
		}
	}
	else if (ma == c)
	{
		for (int i = 1;i <= k;i++)
		{
			c *= 2;
		}
	}
	ans = a + b + c;
	printf("%d\n",ans);
	return 0;
}

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

int main(int argc, char** argv){
  int a, b, c, d, e;
  int k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
int main(){
	ll n,t,a,T=1,A=1;
	scanf("%lld",&n);
	FOR(i,0,n){
		scanf("%lld %lld",&t,&a);
		ll tt = (T%t == 0 ? T/t : T/t+1);
		ll aa = (A%a == 0 ? A/a : A/a+1);
		ll max = tt > aa ? tt : aa;
		T = t * max;
		A = a * max;
	}
	printf("%lld\n",T+A);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast_io()  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	fast_io();
	ll t=1; //cin>>t;
	while(t--){
	    ll n; cin>>n;
	    cout<<ceil(n/1000.0)*1000-n;
		
	    
	}
	return 0;
}


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

int main(){
  int H,W,N;
  cin >> H >> W >> N;

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

  // 入力
  vector<int> a(N),b(N);
  set< pair<int,int> > s; // 黒マス判定用
  set< pair<int,int> > used; // 調査済み判定用
  for(int i=0;i<N;i++){
    cin >> a[i] >> b[i];
    s.insert(make_pair(a[i],b[i]));
  }

  ll ans[10];
  for(int i=0;i<10;i++) ans[i] = 0;

  // 黒マスについて探索
  for(int i=0;i<N;i++){

    // 黒マス中心の3x3マスの調査 3x3にならないマス 調査済みマスはスルー
    for(int j=0;j<9;j++){
      int cx = b[i]+dx[j], cy = a[i]+dy[j];
      if(cx<2||W-1<cx||cy<2||H-1<cy) continue;
      if(used.count(make_pair(cy,cx)) == 1) continue;

      // 3x3マスの調査 黒マスのカウント
      int tmp=0;
      for(int k=0;k<9;k++){
        int nx = cx + dx[k], ny = cy + dy[k];
        if(s.count(make_pair(ny,nx)) == 1)tmp++; // 黒マスであればカウント
        if(k == 8){
          used.insert(make_pair(cy,cx)); // 調査済みマスに追加
          ans[tmp]++;
        }
      }
    }
  }

  ll sum = 0;
  for(int i=0;i<10;i++) sum += ans[i];
  printf("%lld\n",((ll)H-2) * ((ll)W-2) - sum );
  for(int i=1;i<10;i++){
    printf("%lld\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 47872
def solve(x, y):
    res = 0
    res += max(0, (4-x) * 10**5)
    res += max(0, (4-y) * 10**5)
    res += 4 * 10**5 * int(x==1 and y==1)
    return res

x, y = map(int, input().split())
print(solve(x, y))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll K) {
  cout << K/2 * ((K+1)/2)  << endl;
}

int main() {
  ll K;
  cin >> K;
  solve(K);
  return 0;
}


Measured memory_bytes: 256