akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
h,w = map(int, input().split())
grid = []
for i in range(h):
    grid.append(list(input()))
#色が変わるところでコスト
inf = 10**9
#x,y渡すと、（ｈ、ｗ）に入ってるかどうか判定
#graph => そこまでの距離を保存した二次元配列　grid=>与えられた迷路
adjacent_list = [[] for i in range(h*w+1)]
for i in range(h):
    for j in range(w):
        if i == (h-1) and j == (w-1):
            continue
        if j != (w-1):
            if grid[i][j] != grid[i][j+1] and grid[i][j] == '#':
                adjacent_list[w*i + (j + 1)].append([w*(i) + (j + 2), 1])
            else:
                adjacent_list[w*i + (j + 1)].append([w*(i) + (j + 2), 0])
        if i != (h-1):
            if grid[i][j] != grid[i+1][j] and grid[i][j] == '#':
                adjacent_list[w*i + (j + 1)].append([w*(i + 1) + (j + 1), 1])
            else:
                adjacent_list[w*i + (j + 1)].append([w*(i + 1) + (j + 1), 0])
finished = set()
def dfs(node,cost):
    finished.add(node)
    for i in adjacent_list[node]:
        if dist[node] + i[1] < dist[i[0]]:
            dist[i[0]] = dist[node] + i[1]
            dfs(i[0],i[1])
dist = [inf for i in range(h*w+1)]
dist[1] = 0
dfs(1,0)
if grid[-1][-1] == '#':
    dist[-1] += 1
print(dist[-1])



Measured memory_bytes: 7656
n=int(input())
li=[0]*n
for i in range(n):
    li[i]=int(input())
fl=0
ans=0
if li[0]!=0:
    fl+=1
for i in range(n-1):
    if li[i]>=li[i+1]:
        ans+=li[i]
    if li[i+1]-li[i]>1:
        fl+=1
if fl>0:
    print(-1)
else:
    print(ans+li[n-1])
        


Measured memory_bytes: 12916
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
while(sc.hasNext()){
	int a=sc.nextInt();
	int b=sc.nextInt();
	int x=Math.max(a, b);
	int y=Math.min(a, b);
	int temp;
	for(;;){
	temp=y;y=x%y;x=temp;if(y==0)break;
	}
	System.out.println(x);
}
    }
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll gcd(ll a,ll b){
	if(a < b)swap(a,b);
	return (b==0?a:gcd(b,a%b));
}

int main(){
	
	ll n,x;cin >> n >> x;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	sort(ALL(v));
	ll ans = abs(x-v[0]);
	REP(i,n-1){
		ans = gcd(ans,abs(v[i]-v[i+1]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

func sign(i int) int {
	if i == 0 {
		return 1
	}
	return -1
}
func s(i int) string {
	if i == 0 {
		return "+"
	}
	return "-"
}
func to_i(from int) int {
	return from - int('0')
}

func main() {
	var a, b, c, d int
	fmt.Scanf("%c%c%c%c", &a, &b, &c, &d)
	a = to_i(a)
	b = to_i(b)
	c = to_i(c)
	d = to_i(d)

	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				if a+sign(i)*b+sign(j)*c+sign(k)*d == 7 {
					fmt.Printf("%d%s%d%s%d%s%d=7\n", a, s(i), b, s(j), c, s(k), d)
					return
				}
			}
		}
	}
}


Measured memory_bytes: 512
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define INF 1000000000000000

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();
    
pll arr[1010];

int main() {
    ios_base::sync_with_stdio(false);

    ll h, n;
    cin >> h >> n;

    for(int i = 0; i < n; i++) {
        cin >> arr[i].F >> arr[i].S;
    }

    ll dp[10010];
    for(int i = 1; i <= 10000; i++) dp[i] = INF;
    dp[0] = 0;

    for(ll i = 1; i <= h; i++) {
        for(int j = 0; j < n; j++) {
            dp[i] = min(dp[i], dp[max(0LL, i - arr[j].F)] + arr[j].S);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 384
/*
AizuOnline A0141
Hamming Numbers
*/
#include <stdio.h>

long int power(int x,int y)
{if(y < 1)
  return(1);
 else
  return( x * power(x,y-1));

}

log_tei(long int x,int tei)
{
  if(x < tei)
    return(0);
  else
    return(1+log_tei(x/tei,tei));
}


long int hamming(long int m,long int n)
{
  int c5,c3,c2;
  long int cnt,product;

  cnt = 0;
  for(c5=log_tei(n,5);c5>=0;c5--)
    for(c3 =log_tei(n/power(5,c5),3);c3>=0;c3--)
      for(c2= log_tei(n/power(5,c5)/power(3,c3),2);c2>=0;c2--)
        {
          product = power(5,c5)*power(3,c3)*power(2,c2);
          if(product < m)
            break;
          /* printf("%ld\n",product);*/
          cnt ++;
        }
  return(cnt);
}


main()
{
long int from,to;

  while(EOF != scanf("%ld",&from))
    {
      if(from == 0)
        break;
       scanf(" %ld",&to);
      printf("%d\n",hamming(from,to));
    }

return(0);
}

Measured memory_bytes: 0
N = int(input())
X = str(input())
F = [0] * N

def calc_f(n:int)->int:
    global F
    x = n
    res = 0
    while 0 < x:
        if F[x] != 0:
            res += F[x]
            break
        pop = bin(n).count('1')
        x %= pop
        res += 1
    F[n] = res

# 前処理 N以下のF値テーブル
for i in range(1, N):
    calc_f(i)

# ビット反転すると初期の1の個数に対して+1または-1どちらか
pop_ini = X.count('1')
pp = pop_ini + 1  # pop_plus
pm = pop_ini - 1  # pop_minus

# 2進の各桁をppとpmで割った値のテーブル
ap = [0] * N  # arr_plus
am = [0] * N  # arr_minus
for i in range(N):
    ap[i] = pow(2, N-1-i, pp)
    if 0 < pm:
        am[i] = pow(2, N-1-i, pm)

# 所与のXで計算、ベースになる値
fp = 0  # f_plus
fm = 0  # f_minus
for i in range(N):
    if X[i] == '1':
        fp = (fp + ap[i]) % pp
        if 0 < pm:
            fm = (fm + am[i]) % pm

# 各桁を反転した場合では差分更新のみ
for i in range(N):
    ans = 1
    if X[i] == '1':
        if 0 < pm:
            v = (fm + pm - am[i]) % pm
        else:
            ans = 0
            v = 0
    else:
        v = (fp + ap[i]) % pp
    if 0 < v:
        ans += F[v]
    print(ans)

Measured memory_bytes: 26600
package main

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

const MAX int = 2e6 + 1
const INFINT int = 2e9 + 1
var A []int = make([]int, MAX)
var N int
var outBuffer bytes.Buffer


func heapIncreaseKey(i, key int) {
	if key < A[i] {
		return
	}
	A[i] = key
	for ; i>1 && A[i/2]<A[i]; {
		A[i], A[i/2] = A[i/2], A[i]
		i = i/2
	}
}

func insertKey(key int) {
	N ++
	A[N] = -1*INFINT
	heapIncreaseKey(N, key)
}

func heapExtractMAX() int{
	if N < 1 {
		return -1 * INFINT
	}
	max := A[1]
	A[1] = A[N]
	N--
	maxHeapify(1)
	return max
}

func maxHeapify(i int) {
	l := 2 * i
	r := 2 * i + 1
	var largest int
	if l <= N && A[l] > A[i] {
		largest = l
	} else {
		largest = i
	}
	if r <= N && A[r] > A[largest] {
		largest = r
	}

	if largest != i {
		A[i], A[largest] = A[largest], A[i]
		maxHeapify(largest)
	}
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N = 0
	for {
		cmd := nextStr(scanner)
		switch cmd {
		case "insert":
			num := nextInt(scanner)
			insertKey(num)
		case "extract":
			outBuffer.WriteString(fmt.Sprintf("%d\n", heapExtractMAX()))
		case "end":
			fmt.Printf("%s", outBuffer.String())
			return
		}
	}
	
}


Measured memory_bytes: 36020
import java.util.Scanner;

public class Main {

	private void doIt() {
		Scanner sc = new Scanner(System.in);
		while(true){
			String input = sc.next();
			if(input.equals("0"))
				break;
			int len = input.length();
			int a = 0,b=0;
			for(int i =1; i < len; i++){
				char now = input.charAt(i);
				if(now == 'A'){
					a++;
				}
				else{
					b++;
				}
			}
			if(a > b){
				a++;
			}
			else{
				b++;
			}
			System.out.println(a + " " + b);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

public static partial class Program
{
    public static void Main()
    {
        var nk = CRL().ArrayLongs();
        var n = nk[0];
        var k = nk[1];
        var array = new List<KeyValuePair<long, long>>();
        for (int i = 0; i < n; i++)
        {
            var ab = CRL().ArrayLongs();
            var a = ab[0];
            var b = ab[1];
            array.Add(new KeyValuePair<long, long>(a, b));
        }

        array = array.OrderBy(x => x.Key).ToList();
        for (int i = 0; i < n; i++)
        {
            k -= array[i].Value;
            if (k <= 0)
            {
                CWL(array[i].Key);
                return;
            }
        }
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToLong(this string str) => long.Parse(str);
    private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToLong();
    //テンプレここまで
}


Measured memory_bytes: 27444
A = list(input()[::-1])
B = list(input()[::-1])
C = list(input()[::-1])
turn = 'a'
while True:
    if turn == 'a':
        if not A:
            print('A')
            break
        turn = A.pop()
    elif turn == 'b':
        if not B:
            print('B')
            break
        turn = B.pop()
    else:
        if not C:
            print('C')
            break
        turn = C.pop()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		int D = sc.nextInt();
		int N = sc.nextInt();

		if(N==100) {
			N=N+1;
		}
		
		for(int i=0;i<D;i++) {
			N=N*100;
		}
		
		System.out.println(N);
		
	}
}


Measured memory_bytes: 23380
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Backfront
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int qs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int pi;
    scanf("%d", &pi);
    pi--;
    qs[pi] = i;
  }
  //for (int i = 0; i < n; i++) printf("%d ", qs[i]); putchar('\n');

  int maxk = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && qs[j] > qs[j - 1]) j++;
    int k = j - i;
    if (maxk < k) maxk = k;
    i = j;
  }

  printf("%d\n", n - maxk);
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    const int sz=n;
    int h[sz];
    for(int i=0;i<n;++i) cin >> h[i];
    int cnt=0,max=0;
    for(int i=0;i<n-1;++i){
        if(h[i]<h[i+1]) cnt=0;
        else ++cnt;
        if(max<cnt) max=cnt;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}
//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(9);
    }
} All_init;


int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c){
        cout<<"Yes"<<endl;
    }
    else if(a==c&&a!=b){
        cout<<"Yes"<<endl;
    }
    else if(c==b&&a!=c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    fflush(stdout);

    int n;
    int a,b,c;
    static deque<pair<int,int> > e[100003];
    static ll w[100003] = {};
    int q,k;
    int x,y;


    Scd(n);
    Rep(i,n-1){
        Scd3(a,b,c);
        e[a].push_back(make_pair(b,c));
        e[b].push_back(make_pair(a,c));
    }
    Scd2(q,k);
    int tmp = k;
    deque<int> s;
    int to;
    s.push_back(k);
    while( !s.empty() ){
        tmp = s.front();
        while( !e[tmp].empty() ){
            to = e[tmp].front().first;
            if( !w[to] && to != k ){
                s.push_back( to );
                w[to] = w[tmp] + e[tmp].front().second;
            }
            e[tmp].pop_front();
        }
        //printf ("*%d:%llu\n", s.front() , w[s.front()] );
        s.pop_front();
    }

    Rep(i,q){
        Scd2(x,y);
        printf ("%llu\n", w[x] + w[y] );
    }

    return 0;
}



Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
int main()
{
        long long a,b,c;
        scanf("%lld %lld %lld",&a,&b,&c);
        if(a+b>=c)
        {
                printf("%lld",b+c);
        }
        else if(a+b<c)
        {
                printf("%lld",a+b+b+1);
        }
        return 0;
} 


Measured memory_bytes: 256
def main():
    from collections import defaultdict

    N = int(input())
    S = input()

    L, R = S[:N], S[N * 2 - 1:N - 1:-1]

    def make_counter(s: str) -> defaultdict(int):
        ret = defaultdict(int)
        for bit in range(1 << N):
            red, blue = '', ''
            for j in range(N):
                if (bit >> j) & 1:
                    red += s[j]
                else:
                    blue += s[j]

            ret[red + '_' + blue] += 1
        return ret

    ld = make_counter(L)
    rd = make_counter(R)

    print(sum(ld[key] * rd[key] for key in ld))


if __name__ == '__main__':
    main()


Measured memory_bytes: 90080
#include<iostream>
#include<algorithm>
using namespace std;
bool mas(int x,int y){
  if(x<0||x>1000000) return false;
  if(y<0||y>1000000) return false;
  return true;
}
int main(){
  int m,n;
  while(cin>>m,m){
    int x[m],y[m];
    for(int i=0;i<m;i++) cin >> x[i] >> y[i];
    cin >> n;
    int rx[n],ry[n];
    for(int i=0;i<n;i++) cin >> rx[i] >> ry[i];
    int a;
    for(int i=m-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(x[j]<x[j+1]){
	  a = x[j];
	  x[j] = x[j+1];
	  x[j+1] = a;
	  a = y[j];
	  y[j] = y[j+1];
	  y[j+1] = a;
	}
      }
    }
    for(int i=m-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(y[j]<y[j+1]&&x[j]==x[j+1]){
	  a = x[j];
	  x[j] = x[j+1];
	  x[j+1] = a;
	  a = y[j];
	  y[j] = y[j+1];
	  y[j+1] = a;
	}
      }
    }
    for(int i=n-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(rx[j]<rx[j+1]){
	  a = rx[j];
	  rx[j] = rx[j+1];
	  rx[j+1] = a;
	  a = ry[j];
	  ry[j] = ry[j+1];
	  ry[j+1] = a;
	}
      }
    }
    for(int i=n-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(ry[j]<ry[j+1]&&rx[j]==rx[j+1]){
	  a = rx[j];
	  rx[j] = rx[j+1];
	  rx[j+1] = a;
	  a = ry[j];
	  ry[j] = ry[j+1];
	  ry[j+1] = a;
	}
      }
    }
    for(int i=0;i<n;i++){
      int dx = rx[i] - x[0];
      int dy = ry[i] - y[0];
      int j = 1;
      int k = i+1;
      bool ok = false;
      while(k<n){
	if(!mas(dx+x[j],dy+y[j])) break;
	if(dx+x[j]!=rx[k]||dy+y[j]!=ry[k]) k++;
	if(dx+x[j]==rx[k]||dy+y[j]==ry[k]){
	  j++;
	  k++;
	}
	if(j>=m){
	  ok = true;
	  break;
	}
      }
      if(ok){
	cout << dx << ' ' << dy << endl;
	break;
      }
    }
  }
  return 0;
}

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

int main()
{
    int n,k;
    std::cin >> n >> k;
    int numbers = 1;
    for(int i = 0; i < n; i++){
        if(i==0) numbers *= k;
        else numbers *= k-1;
    }
    std::cout << numbers << std::endl;
}



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

using ll = long long;

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

  int x[50], y[50];
  int xx[50], yy[50];
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    xx[i] = x[i];
    yy[i] = y[i];
  }

  sort(xx, xx+n);
  sort(yy, yy+n);

  ll ans = 1LL*(xx[n-1]-xx[0])*(yy[n-1]-yy[0]);
  for(int l = 0; l < n; l++){
    for(int r = l+1; r < n; r++){
      for(int b = 0; b < n; b++){
        for(int t = b+1; t < n; t++){
          int num = 0;
          for(int i = 0; i < n; i++){
            if(xx[l] <= x[i] && x[i] <= xx[r] && yy[b] <= y[i] && y[i] <= yy[t]){
              num++;
            }
          }
          if(num >= k) ans = min(ans, 1LL*(xx[r]-xx[l])*(yy[t]-yy[b]));
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define int long long 

int32_t main()
{
    int a,b;
    cin>>a>>b;
    if(a > 12)
    {
        cout<<b;
    }
    else if(a > 5)
    {
        cout<<b/2;
    }
    else
    {
        cout<<0;
    }
    
    return 0;
}

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

q = int(input())
for i in range(q):
    op =  list(map(int, input().split(' ')))
    if op[0] == 0:
        min = float('inf')
        for num in nums[op[1]: op[2]]:
            if num < min: min = num
        print(min)
    elif op[0] == 1:
        max = -float('inf')
        for num in nums[op[1]: op[2]]:
            if num > max: max = num
        print(max)



Measured memory_bytes: 5632
import sys
n = int(input())
info = [0] * n
for i in range(n):
    x, l = map(int, input().split())
    info[i] = [x+l, x, l]

info.sort()
ans = 1
right = info[0][1] + info[0][2]
for i in range(1, n):
    if right <= info[i][1] - info[i][2]:
        ans += 1
        right = info[i][1] + info[i][2]
print(ans)

Measured memory_bytes: 23276
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define MP  make_pair
using namespace std;
typedef long long ll;

int vx[]={1,0,-1,0},vy[]={0,1,0,-1};

int main(){
    int n;
    scanf("%d",&n);
    int a,b,c,d;
    int sco[100];
    for(int i=0;i<n;i++){
        sco[i]=0;
    }
    for(int i=0;i<n*(n-1)/2;i++){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        a--;b--;
        if(c>d) sco[a]+=3;
        else if(d>c) sco[b]+=3;
        else if(c==d){
            sco[a]++;
            sco[b]++;
        }
    }
    for(int i=0;i<n;i++){
        int rank=1;
        for(int j=0;j<n;j++){
            if(sco[j]>sco[i]) rank++;
        }
        printf("%d\n",rank);
    }
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

int main() {
	for (;;) {
		int n, m, a; cin >> n >> m >> a;
		if (n == 0) break;
		vector< pair<int, i_i> > hpq(m);
		for (int i = 0; i < m; i++)
			cin >> hpq[i].first >> hpq[i].second.first >> hpq[i].second.second;
		sort(hpq.begin(), hpq.end());
		reverse(hpq.begin(), hpq.end());
		for (int i = 0; i < m; i++) {
			int p = hpq[i].second.first, q = hpq[i].second.second;
			if (a == p) a = q;
			else if (a == q) a = p;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
#define MIN(a,b) (a<b)?a:b
#define MAX(a,b) (a>b)?a:b
#define EMIN(a,b) (a<=b)?a:b
#define EMAX(a,b) (a>=b)?a:b
#define REP(a,b) for(int i=0; i<a; i++)
#define RREP(a,b) for(int j=0; j<a; j++)

#define MAX_RANGE 1000000000LL
typedef long long LL;

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

    LL res = 1;
    for(LL i=1; i*i <= N; i++)
    {
        res = i;
    }

    std::cout << res*res;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 int main(){
	 int a,b,c;
	 scanf("%d %d %d",&a,&b,&c);
	 
	 if(a<b){
		 if(b<c){
			printf("Yes\n");
		 }
		 else{
			 printf("No\n");
		 }
	 }
	 else{
		 printf("No\n");
	 }
	 return 0;
 }

Measured memory_bytes: 580
#include<iostream>
#include<string.h>
using namespace std;
long long n,k;
long long a[1000110],c[1000010],d[1000010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>k;
		long long sum=0;
	sum=(k+1)*k/2;
	sum-=k;
	sum%=1000000007;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	memset(c,0,sizeof(c));
	memset(d,0,sizeof(d));
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			if(a[i]>a[j]){
				c[i]++;
			}
		}
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){
				d[i]++;
			}
		}
	}
 
	long long ans=0;
//	cout<<sum<<endl;
	for(int i=0;i<n;i++){
//		cout<<c[i]<<"   "<<d[i]<<endl;
		ans+=(c[i]*sum);
		ans%=1000000007;
		ans+=(d[i]*(sum+k));
		ans%=1000000007;
	}
	cout<<ans<<endl;
	return 0;

}

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

int main()
{
    ll h,w;
    cin >> h >> w;
    if(h == 1 || w == 1)
        cout << 1 << endl;
    else
        cout << (w+1)/2*((h+1)/2) + w/2*(h/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    int x = stoi(s);
    int y = x%100;
    x/=100;

    if(1<=x && x<=12 && 1<=y && y<=12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if(1<=x && x<=12){
        cout << "MMYY" << endl;
    }else if(1<=y && y<=12){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


vll pt(3);

ll rev(vll& v, ll index){
  ll sz=v.size();
  ll res=LLINF;
  if(sz==0)
    return res;

  REP(bits,(1<<sz)){
    ll nl=0;
    ll now=-10;
    vll rest;
    REP(i,sz){
      if((bits>>i)&1){
        nl+=v[i];
        now+=10;
      }
      else
        rest.push_back(v[i]);
    }

    if(nl==0)
      continue;
    now+=abs(nl-pt[index]);

    if(index<=1)
      now+=rev(rest,index+1);
    res=min(now,res);
  }

  return res;
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  REP(i,3)cin>>pt[i];
  vll l(8);
  REP(i,n)cin>>l[i];

  ll ans=rev(l,0);
  cout<<ans<<endl;



}



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

int main() {
	int a;
	cin>>a;
	int c[1000000];
	c[a]=1;
	int  t;
	for(int i=0;;i++){
		t=i;
		if(a%2==1)a=3*a+1;
		else a=a/2;
		if(c[a]==1)goto end;
		else c[a]=1;
	}
	end:cout<<t+2;
	
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

string S, T;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> S >> T;

  cout << T << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    rep(i,q){
        int t;
        cin >> t;
        if (t == 1){
            rev = !rev;
        }else {
            int f;
            string c;
            cin >> f >> c;
            if (f == 1){
                if (rev) s += c;   
                else s = c + s;
            }else{
                if (rev) s = c + s;
                else s += c;   
            }
        }
    }
    if (rev) reverse(all(s));
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 4688
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  int m = 0, a = 0, r = 0, c = 0, h = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M') m++;
    if (s[0] == 'A') a++;
    if (s[0] == 'R') r++;
    if (s[0] == 'C') c++;
    if (s[0] == 'H') h++;
  }
  ll ans = 1LL * m * a * (r + c + h) + 1LL * m * r * (c + h) + 1LL * m * c * h + 1LL * a * r * (c + h) + 1LL * a * c * h + 1LL * r * c * h;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
print((N +1)//2)


Measured memory_bytes: 25572
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve()
{
    COMinit();
    IN(n, k);
    if (n <= k) k = n - 1;
    ll s = 1;
    reps(j, 1, k + 1)
    {
        s = (s + COM(n - 1, j) * COM(n, j)) % MOD;
    }
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a * 100 + b * 10 + c) % 4 == 0)
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }
    return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

char start;
char trump;
string card[4][13];

int suit(char arg){
	if(trump==arg)
		return 2;
	else if(start==arg)
		return 1;
	else
		return 0;
}

int number(char arg){
	switch(arg){
		case 'A':
			return 1;
		case 'T':
			return 10;
		case 'J':
			return 11;
		case 'Q':
			return 12;
		case 'K':
			return 13;
		default:
			return arg-'0';
	}
	return 0;
}

inline int judge(int i,int a,int b){
	int an=number(card[a][i][0]);
	int ac=suit(card[a][i][1]);
	int bn=number(card[b][i][0]);
	int bc=suit(card[b][i][1]);
	if(ac==bc){
		if(an==1)
			return a;
		if(bn==1)
			return b;
		if(an>bn)
			return a;
		else
			return b;
	}else{
		if(ac>bc)
			return a;
		else
			return b;
	}
	return 0;
}

int proceed(int i,int d){
	int res=d;
	string s=card[d][i];
	start=card[d][i][1];
	for(int j=1;j<=3;++j){
		int cur=(d+j)%4;
		res=judge(i,res,cur);
	}
	return res;
}

int main(void){
	while(cin >> trump){
		if(trump=='#')
			break;
		rep(i,4)rep(j,13) cin >> card[i][j];
		int ns=0,ew=0,d=0;
		rep(i,13){
			int res=proceed(i,d);
			if(res&1)
				ew++;
			else
				ns++;
			d=res;
		}
		if(ew>ns)
			cout << "EW" << " " << ew-6 << endl;
		else
			cout << "NS" << " " << ns-6 << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include    <stdio.h>

int main(void)
{
  int s, h, m;

  scanf("%d", &s);
  h = s / 3600;
  m = s % 3600 / 60;
  printf("%d:%d:%d\n", h, m, s % 3600 % 60);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int K;
	cin >> K;
	// >> 
	int even = K / 2;
	int odd = even + (K%2); 
	
	
	cout << (even*odd);
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
vector<int>g[100000];
queue<int>fe;
queue<int>sn;
int n, u, v, t, k;
int d[100000];
int x, y;
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &u, &v);
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	fe.push(0);
	d[0] = 1;
	sn.push(n - 1);
	d[n - 1] = -1;
	t = 2;
	x = 1;
	y = 1;
	while (x + y < n) {
		k = fe.size();
		for (int i = 0; i < k; i++) {
			u = fe.front();
			fe.pop();
			for (int j = 0; j < g[u].size(); j++) {
				if (d[g[u][j]] == 0) {
					d[g[u][j]] = d[u] + 1;
					fe.push(g[u][j]);

					x++;
				}
			}
		}
		k = sn.size();
		for (int i = 0; i < k; i++) {
			u = sn.front();
			sn.pop();
			for (int j = 0; j < g[u].size(); j++) {
				if (d[g[u][j]] == 0) {
					d[g[u][j]] = d[u] - 1;
					sn.push(g[u][j]);
					y++;
				}
			}
		}
	}
	if (x > y)printf("Fennec\n");
	else printf("Snuke\n");
}

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

int main(){
    string s;
    cin >> s;
    string ans = "AC";
    if (s.front() != 'A'){
        ans = "WA";
    }
    int cnt = 0;
    int c = 1000;
    for (int i = 2;i < s.size() - 1;i++){
        if (s[i] == 'C'){
            cnt++;
            c = i;
        }
    }
    if (cnt != 1){
        ans = "WA";
    }

    if (ans != "WA"){
        for (int i = 1;i < s.size();i++){
            if(i == c){
                continue;
            }
            else{if (!(s[i] >= 'a' && s[i] <= 'z')){
                ans = "WA";
                break;
            }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#if __cplusplus > 199711L      /* C++11 */
#include <unordered_map>
#include <unordered_set>
#include <forward_list>
#include <array>
#endif                         /* C++11 */
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/




int sg(char ch)
{
  if( ch == '+' )
    {
      return 1;
      
    }
  return -1;
  
}




int main()
{
  //IOS; /* making cin faster */
  string S;

  CIN(S);
  int cnt = 0;
  
  REP(i,SIZ(S))
    {
      cnt += sg(S[i]);
      
    }

  PRINTD(cnt);
  
  
  

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (H, W) = readLongs()
  if (H == 1L || W == 1L) {
    println(1)
    return
  }
  var ans = 0L
  if (H % 2 == 1L && W % 2 == 1L) {
    ans = (H * W + 1) / 2
  } else {
    ans = H * W / 2
  }
  println(ans)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map(Integer::parseInt)
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 37728
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void solve()
{
    int n,h[100005],dp[100005]={0};
    cin>>n;
    rep(i,n)
    cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[n-1];
}
int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    solve();
    return 0;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define vi vector<ll>
const int N = 1e9 + 5;
ll t[24][60] = {0};
void solve() {
	ll k, a, b;
	cin >> k >> a >> b;
	if (a % k == 0) {
		cout << "OK";
		return;
	}
	ll rem = a % k;
	rem = k - rem;
	a = a + rem;
	
	if (a <= b) cout << "OK";
	else cout << "NG";


}
int main() {

	FASTIO;


	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

int gcd(int a, int b){
    if(a < b) swap(a, b);
    return (a % b ? gcd(b, a % b) : b);
}

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

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

    vector<int> L(n), R(n);
    L[0] = A[0];
    R[n - 1] = A[n - 1];
    for(int i = 0; i < n - 1; i++){
        if(i == 0) L[i + 1] = gcd(A[i], A[i + 1]);
        else L[i + 1] = gcd(L[i], A[i + 1]);
    }

    for(int i = n - 1; i >= 1; i--){
        if(i == n - 1) R[i - 1] = gcd(A[i], A[i - 1]);
        else R[i - 1] = gcd(R[i], A[i - 1]);
    }

    int maxi = 1;
    for(int i = 0; i < n; i++){
        if(i == 0){
            maxi = max(maxi, R[i + 1]);
        }else if(i == n - 1){
            maxi = max(maxi, L[i - 1]);
        }else if(i == 1){
            maxi = max(maxi, gcd(A[i - 1], R[i + 1]));
        }else if(i == n - 2){
            maxi = max(maxi, gcd(A[n - 1], L[i - 1]));
        }else{
            maxi = max(maxi, gcd(L[i - 1], R[i + 1]));
        }
    }

    cout << maxi << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>
#define maxn 200005
using namespace std;
int L[maxn], R[maxn], ans;
int ch[30];
char s[maxn];

int main() {    
    scanf( "%s", s );
    int len = strlen( s );
    int now = 26;
    R[0] = len - 1;
    for( int i = len - 1; i >= 0; i -- ) {
        if( !ch[s[i] - 'a'] ) {
            now --;
            ch[s[i] - 'a'] = 1;
            if( !now ) {
                L[ans] = i;
                ans ++;
                R[ans] = i - 1;
                now = 26;
                memset( ch, 0, sizeof( ch ) );
            }
        }
    }
    L[ans] = 0;
    int l = 0;
    char now_ans;
    for( int i = ans; i >= 0; i -- ) {
        int now = 26;
        memset( ch, 0, sizeof( ch ) );
        for( int j = l; j <= R[i]; j ++ ) {
        	ch[s[j] - 'a'] = 1;
		}
        for( int j = 0; j < 26; j ++ ) {
        	if( !ch[j] ) {
            	printf( "%c", j + 'a' );
            	now_ans = j + 'a';
            	break;
        	}
		}
        for( int j = l; j < len; j ++ ) {
        	if( s[j] == now_ans ) {
            	l = j + 1;
            	break;
        	}
		}
    }
}

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

int main()
{

    string s1,s2,s3;

    cin >> s1 >> s2;
    s3 = s1+s2;


   int b = atoi(s3.c_str());

   int p = sqrt(b);
   if(p * p == b)
        printf("Yes\n");

    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int a,b,c;
  cin >> a >> b >> c;
  
  if(a == b) cout << c << endl;
  else if(a == c) cout << b << endl;
  else cout << a << endl;

 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	string s;
	cin >> s;
	int a, b, c, d;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	int ans = 0;
	REP(i, 16){
		int x2 = 2 * ((i >> 1) % 2) - 1;
		int x3 = 2 * ((i >> 2) % 2) - 1;
		int x4 = 2 * ((i >> 3) % 2) - 1;
		if((a + b * x2 + c * x3 + d * x4) == 7) ans = i;
	}
	char a2 = (((ans >> 1) % 2) == 1 ? '+' : '-');
	char a3 = (((ans >> 2) % 2) == 1 ? '+' : '-');
	char a4 = (((ans >> 3) % 2) == 1 ? '+' : '-');
	cout << a << a2 << b << a3 << c << a4 << d << "=7" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int mt,fst=0,snd=0,trd=0;
	while(scanf("%d",&mt)!=EOF){
		if(mt>fst){
			trd=snd;
			snd=fst;
			fst=mt;
			continue;
		}else if(mt<=fst&&mt>snd){
			trd=snd;
			snd=mt;
			continue;
		}else if(mt<=snd&&mt>trd){
			trd=mt;
			continue;
		}
	}
	printf("%d\n%d\n%d\n",fst,snd,trd);
    return 0;
}

Measured memory_bytes: 600
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			// Aの数字と数のマップ
			Map<Integer, Integer> map = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				int number = scanner.nextInt();
				map.put(number, map.getOrDefault(number, 0) + 1);
			});
			System.out.println(map.entrySet().stream().filter(entry -> 0 != (entry.getValue() & 1)).count());
		}
	}
}


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

int main() {
 	int n; cin >> n;
  	vector<int> a(n);
  	for (int& i : a) cin >> i;
  	sort(a.begin(), a.end());
  	
  	double cur = a[0];
  	for (int i = 1; i < n; i++) {
      	cur = (cur + a[i]) / 2.0;
    }
  	
  	cout << cur << endl;
}

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

int main(){
   int K,X;
   cin >> K >> X;
   int k = K - 1;
   int kk = k + K;
   int x = X - k;
   for(int i=0;i<kk;i++){
       cout << x << " ";
       x++;
   }
   return 0;
}

Measured memory_bytes: 3568
from itertools import combinations as cc
l = []
n,k = map(int, input().split())
xs,ys = set(),set()
t = 10**24
for _ in range(n):
  x,y = map(int, input().split())
  xs.add(x)
  ys.add(y)
  l.append((x,y))
xs = sorted(list(xs))
ys = sorted(list(ys))
for xl,xr in cc(xs,2):
  for yl,yr in cc(ys,2):
    cnt = 0
    for x,y in l:
      if xl<=x<=xr and yl<=y<=yr:
        cnt += 1
      if cnt >= k:
        s = (xr-xl)*(yr-yl)
        if t > s:
          t = s
print(t)

Measured memory_bytes: 48604