akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import deque
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, u: "List[int]", v: "List[int]", w: "List[int]"):
    G = [[] for _ in range(N)]
    for ui, vi, wi in zip(u, v, w):
        ui -= 1
        vi -= 1
        G[ui].append((vi, wi))
        G[vi].append((ui, wi))
    color = [-1] * N
    color[0] = 0
    q = deque([0])
    while q:
        s = q.popleft()
        for t, wi in G[s]:
            if color[t] >= 0:
                continue
            color[t] = (color[s] + wi) % 2
            q.append(t)
    for colori in color:
        print(colori)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    w = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(N, u, v, w)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47848
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,m;
	cin >> n;
	vector<ll>d(n);
	rep(i, n)cin >> d[i];
	cin >> m;
	vector<ll>t(m);
	rep(i, m)cin >> t[i];
	unordered_map<ll, ll>kindD,kindT;
	rep(i, n) kindD[d[i]]++;
	rep(i, m) kindT[t[i]]++;
	rep(i, m) {
		if (kindT[t[i]] > kindD[t[i]])return cout << "NO" << endl,0;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 19912
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int A, B, C;
int MAX;
int ans;

int main(){
	cin >> A >> B >> C;
	MAX = max(A, B);
	MAX = max(MAX, C);
	ans = A + B + C;
	ans = ans - MAX;
	MAX = MAX * 10;
	ans = ans + MAX;

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

int main(){
    int A[10000], B[10000], count = 0;
    while(1){
        int H, W;
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        A[count] = H;
        B[count] = W;
        count++;
    }

    rep(i, 0, count){
        rep(j, 0, B[i]) printf("#");
        printf("\n");
        rep(y, 1, A[i] - 1){
            printf("#");
            rep(x, 0, B[i] - 2) printf(".");
            printf("#\n");
        }
        rep(j, 0, B[i]) printf("#");
        printf("\n\n");
    }

    return 0;
}



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


const int MAX_N = 100;

int H[MAX_N];

int main()
{
	int N, res = 0;

	scanf("%d", &N);
	
	for(int i = 0; i < N; ++i)
	{
		scanf("%d", H + i);
		bool t = true;

		for(int j = 0; j < i; ++j)
		{
			if(H[j] > H[i])
			{
				t = false;
				break;
			}
		}

		res += t;
	}
	
	printf("%d\n", res);


	return 0;
}

Measured memory_bytes: 256
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var A = intShift();
  var B = strShift();
  
  var s = 0;
  
  for(var i = 0; i < A; i++){
  	if(B[i] == ".")s++;
  }
  var min = s;
  for(var i = 0; i < A; i++){
  	if(B[i] == "."){
    	s--;
    }else{
    	s++;
    }
    min = Math.min(min,s);
  }
  
  return ~~min;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
5
#.##.
`);

Measured memory_bytes: 7500
program main
  implicit none
  integer(8) :: n, k, mi, ma, md, i
  integer(8), allocatable :: a(:)
  read *, n, k
  allocate (a(n))
  read *, a(:)
  call quicksort(a)

  ! 積がthres以下になるペアがk個以上ある最小のthres
  mi = -2 * 10_8 ** 18  ! NG
  ma = 2 * 10_8 ** 18  ! OK
  do i = 1, 70
    md = mi + (ma - mi) / 2
    if (isok(md)) then
      ma = md
    else
      mi = md
    end if
    if (ma - mi <= 1) exit
  end do

  print "(i0)", ma

  contains

  logical function isok(x)
    ! 積がx以下になるペアがk個以上ある
    integer(8), intent(in) :: x
    integer(8) :: i, cnt, jmin, jmax, count_j, mi, ma, md, j
    cnt = 0
    jmax = n
    if (x < 0) then
      jmin = 1
    else
      jmin = n + 1
    end if
    do i = 1, n - 1
      if (a(i) >= 0) then
        ! a(i) * a(j) <= x となる最大のj > iを求める
        jmax = max(jmax, i)
        do while (jmax > i)
          if (a(jmax) * a(i) > x) then
            jmax = jmax - 1
          else
            exit
          end if
        end do
        count_j = jmax - i
      else
        ! a(i) * a(j) <= x となる最小のj > iを求める
        jmin = max(jmin, i + 1)
        if (x < 0) then
          do while (jmin <= n)
            if (a(jmin) * a(i) > x) then
              jmin = jmin + 1
            else
              exit
            end if
          end do
          count_j = n - (jmin - 1)
        else
          ! do while (jmin > i)
          !   if (a(jmin - 1) * a(i) > x) then
          !     jmin = jmin - 1
          !   else
          !     exit
          !   end if
          ! end do
          ! count_j = n - (jmin - 1)
          mi = i  ! ng
          ma = n + 1  ! ok
          do j = 1, 30
            md = mi + (ma - mi) / 2
            if (a(i) * a(md) <= x) then
              ma = md
            else
              mi = md
            end if
            if (ma - mi <= 1) exit
          end do
          count_j = n - (ma - 1)
        end if
      end if
      cnt = cnt + count_j
    end do
    isok = (cnt >= k)
  end function isok

  recursive subroutine quicksort(a)
    integer(8), intent(inout) :: a(:)
    integer(8) :: pivot, i, j, k, tmp, n
    real(8) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1_8, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


Measured memory_bytes: 2432
a = int(input())

biao = dict()

for i in range(1, a+1):
    i = str(i)
    if i[0] not in biao:
        biao[i[0]] = {i[-1] : 1}
    else:
        if i[-1] not in biao[i[0]]:
            biao[i[0]][i[-1]] = 1
        else:
            biao[i[0]][i[-1]] += 1

count = 0
for i in range(1, 10):
    for j in range(1, 10):
        try:
            i = str(i)
            j = str(j)
            count += biao[i][j] * biao[j][i]
        except:
            pass

print(count)

Measured memory_bytes: 40940
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p = lambda x: print(x)


a,b = MI()
if a%2 != b%2:
    p("IMPOSSIBLE")
else:
    p(int((a+b)/2))

Measured memory_bytes: 3064
void reverse(char str[])
{
	int i,j,x;
	char revstr[1000];
	i=0;
	while(str[i]!='\0'){
		i++;
	}
	x=i;
	j=0;
	for(i=i-1;i>=0;i--,j++){
		revstr[j]=str[i];
	}
	revstr[j]='\0';
	int n;
	for(n=0;n<x;n++){
		str[n]=revstr[n];
	}
}
#include<stdio.h>
main(){
	char str[1000];
	scanf("%999s",str);
	reverse(str);
	printf("%s\n",str);
	return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

class Solver {
  public:
    bool solve() {
        string A; cin >> A;
        ll N = A.size();
        map<char, int> cnt;        
        ll dec = 0;
        rep(i, N) {
            dec += cnt[A[i]]++;
        }
        ll ans = N * (N - 1) / 2;
        cout << ans - dec + 1 << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	vector<int> dp(n, INF);

	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) {
			chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}

	out(dp[n - 1]);

	return 0;
}

Measured memory_bytes: 1024
A=input()
N=len(A)
#全組み合わせの中から回文であるものを引く
sm=(N*(N-1))//2
sm+=1

x=dict()
for i in range(N):
    s=A[i]
    if s in x:
        x[s]+=1
    else:
        x[s]=1

val=0
for idx in x:
    v=x[idx]
    val+=(v*(v-1))//2

ans=sm-val
print(ans)

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

using ll = long long;

int main() {
    string s, out;
    cin >> s;

    for (ll n = 0; n < s.size(); n += 2) {
        out.push_back(s[n]);
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
typedef unsigned long long int llu;

int main(void) {
  llu s = 0;
  int n, r[4000], g[4000], b[4000], rl = 0, gl = 0, bl = 0, fi, si, ti, d;
  char c;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%c", &c);
    if (c == 'R') {
      r[rl] = i;
      rl++;
    } else if (c == 'G') {
      g[gl] = i;
      gl++;
    } else {
      b[bl] = i;
      bl++;
    }
  }

  fi = 0;
  si = 0;
  for (int i = 0; i < rl; i++) {
    ti = 0;
    for (int j = fi; j < gl; j++) {
      if (g[j] < r[i]) {
        fi = j;
        continue;
      }
      d = g[j] - r[i];
      for (int k = ti; k < bl; k++) {
        if (b[k] < g[j]) {
          ti = k;
          continue;
        }
        if (b[k] - g[j] != d) {
          s++;
        }
      }
    }
    ti = 0;
    for (int j = si; j < bl; j++) {
      if (b[j] < r[i]) {
        si = j;
        continue;
      }
      d = b[j] - r[i];
      for (int k = ti; k < gl; k++) {
        if (g[k] < b[j]) {
          ti = k;
          continue;
        }
        if (g[k] - b[j] != d) {
          s++;
        }
      }
    }
  }

  fi = 0;
  si = 0;
  for (int i = 0; i < gl; i++) {
    ti = 0;
    for (int j = fi; j < rl; j++) {
      if (r[j] < g[i]) {
        fi = j;
        continue;
      }
      d = r[j] - g[i];
      for (int k = ti; k < bl; k++) {
        if (b[k] < r[j]) {
          ti = k;
          continue;
        }
        if (b[k] - r[j] != d) {
          s++;
        }
      }
    }
    ti = 0;
    for (int j = si; j < bl; j++) {
      if (b[j] < g[i]) {
        si = j;
        continue;
      }
      d = b[j] - g[i];
      for (int k = ti; k < rl; k++) {
        if (r[k] < b[j]) {
          ti = k;
          continue;
        }
        if (r[k] - b[j] != d) {
          s++;
        }
      }
    }
  }

  fi = 0;
  si = 0;
  for (int i = 0; i < bl; i++) {
    ti = 0;
    for (int j = fi; j < rl; j++) {
      if (r[j] < b[i]) {
        fi = j;
        continue;
      }
      d = r[j] - b[i];
      for (int k = ti; k < gl; k++) {
        if (g[k] < r[j]) {
          ti = k;
          continue;
        }
        if (g[k] - r[j] != d) {
          s++;
        }
      }
    }
    ti = 0;
    for (int j = si; j < gl; j++) {
      if (g[j] < b[i]) {
        si = j;
        continue;
      }
      d = g[j] - b[i];
      for (int k = ti; k < rl; k++) {
        if (r[k] < g[j]) {
          ti = k;
          continue;
        }
        if (r[k] - g[j] != d) {
          s++;
        }
      }
    }
  }

  printf("%llu\n", s);
}

Measured memory_bytes: 1764
data1 = input()
data2 = input()

count = 3 -1
sw = 0
i = 0
j = len(data2)-1
while i <= count:
    if data1[i] == data2[j]:
        sw += 1
    i += 1
    j -= 1
if sw == 3:
    print("YES")
else:
    print("NO")

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

typedef long long int ll; 

int main(void)
{
	char x;
	cin >> x;

	if(x-'A'>=0 && x-'A'<26)
		cout << "A\n";
	else
		cout << "a\n";



	return 0;
}

Measured memory_bytes: 3632
/**
 *    author:  tourist
 *    created: 04.01.2020 02:49:37       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = min(a[i], k);
  }
  sort(a.begin(), a.end());
  const int N = 5010;
  vector<bitset<N>> pref(1);
  pref[0][0] = 1;
  for (int i = 0; i < n; i++) {
    pref.push_back(pref.back() | (pref.back() << a[i]));
  }
  vector<bitset<N>> suf(1);
  suf[0][0] = 1;
  for (int i = 0; i < n; i++) {
    suf.push_back(suf.back() | (suf.back() << a[n - 1 - i]));
  }
  int low = 0, high = n;
  while (low < high) {
    int mid = (low + high) >> 1;
    int y = k - 1;
    bool has = false;
    for (int x = 0; x <= k - 1; x++) {
      if (pref[mid][x]) {
        y = max(y, k - 1 - x);
        while (suf[n - 1 - mid][y] == 0) {
          --y;
        }
        if (x + y >= k - a[mid]) {
          has = true;
          break;
        }
      }
    }
    if (!has) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  cout << low << '\n';
  return 0;
}


Measured memory_bytes: 13868
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	K, X := nextInt(), nextInt()
	if 500*K >= X {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a in A:
    B.append(-a)
B.sort()

while M > 0:
    M -= 1
    now = heapq.heappop(B)
    now = (now+1) // 2
    heapq.heappush(B, now)
print(-sum(B))


Measured memory_bytes: 64408
N,M = map(int,input().split())

PY = [[0,0,0,0] for i in range(M)] #index,p,y,number

for m in range(M):
    PY[m][0] = m
    PY[m][1],PY[m][2] = map(int,input().split())

PY.sort(key=lambda x:x[2])
cnt = [0]*(N+1)

for m in range(M):
    cnt[PY[m][1]] += 1
    PY[m][3] = cnt[PY[m][1]]

PY.sort(key=lambda x:x[0])

for m in range(M):
    print(str(PY[m][1]).zfill(6) + str(PY[m][3]).zfill(6))

Measured memory_bytes: 29836
l, r = gets.chomp.split.map(&:to_i)
MOD = 2019
if l / MOD < r / MOD || l % MOD == 0
  puts "0"
  exit
end

res = MOD
(l % MOD).step((r - 1) % MOD) do |i|
  (i + 1).step(r % MOD) do |j|
    rem = (i * j) % MOD
    res = rem if res > rem
    break if res <= 1
  end
end
puts res

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 301;

int n, k, dp[N][N][N], mod = 998244353;
string s;

int solve(int idx, int i, int skipped, int t){
    if(t > k) return 0;
    if(idx == n) return skipped == 0;
    int &ret = dp[idx][skipped][t];
    if(ret != -1) return ret;
    ret = 0;
    // 0
    int j = i;
    while(j >= 0 && s[j] != '0') j--;
    if(j != -1){
        int sp = i - j;
        ret += solve(idx + 1, j - 1, skipped + sp, t + sp);
        if(ret >= mod) ret -= mod;
    }
    // 1
    if(s[i] == '1') ret += solve(idx + 1, i - 1, skipped, t);
    else if(skipped > 0) ret += solve(idx + 1, i, skipped - 1, t);
    if(ret >= mod) ret -= mod;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> s >> k;
    n = s.size();
    cout << solve(0, n - 1, 0, 0) << endl;
}


Measured memory_bytes: 110140
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[][102],int b[][102],int x,int y,int gx,int gy,int c){  
  if(a[x][y]!=c)
    return 0;
  if(x==gx&&y==gy)
    return 1;
  if(b[x][y])
    return 0;
  b[x][y]=1;
  if(f(a,b,x-1,y,gx,gy,c))
    return 1;
  if(f(a,b,x,y-1,gx,gy,c))
    return 1;
  if(f(a,b,x+1,y,gx,gy,c))
    return 1;
  if(f(a,b,x,y+1,gx,gy,c))
    return 1;
  return 0;
}
int main(){
  int i,j,k;
  int a[102][102],b[102][102],w,h,sx,sy,gx,gy,n;
  while(cin>>w>>h&&w+h){
    cin>>sx>>sy>>gx>>gy>>n;
    memset(a,0,sizeof(a));
    for(i=0;i<n;i++){
      int p,q,r,s;
      cin>>p>>q>>r>>s;
      for(j=0;j<2+2*q;j++)
	for(k=0;k<2+2*!q;k++)
	  a[r+k][s+j]=p;
    }
    if(a[sx][sy]!=a[gx][gy])
      cout<<"NG"<<endl;
    else if(a[sx][sy]==0)
      cout<<"NG"<<endl;
    else{
      memset(b,0,sizeof(b));
      if(f(a,b,sx,sy,gx,gy,a[sx][sy]))
	cout<<"OK"<<endl;
      else
	cout<<"NG"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll t,n,b,m;
	cin>>m>>n;
	if(m<2 && n<2)cout<<0<<"\n";
	else
	cout<<(m*(m-1)/2)+(n*(n-1)/2)<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define mod 1000000007

int main(){
	int n,i;
	int c[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&c[i]);
	long long dp[200000]={0};
	long long dpdp[200001]={0};
	dp[0]=1;
	dpdp[c[0]]=1;
	for(i=1;i<n;i++){
		dp[i]=dp[i-1];
		if(c[i]!=c[i-1])dp[i]+=dpdp[c[i]];
		dp[i]%=mod;
		if(c[i]!=c[i-1])dpdp[c[i]]=dp[i];
		dpdp[c[i]]%=mod;
	}
	printf("%lld\n",dp[n-1]);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

bool is_prime(int n){
    if(n < 2){
        return false;
    }
    for(int i = 2; i < (int)sqrt(n) + 1; i++){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
  int Q; cin >> Q;
  vector<int> s2017(100010,0);
  for(int i = 1; i < 100000; i++){
      if(i % 2 == 1 && is_prime(i) && is_prime((i+1)/2) ){
          s2017.at(i) = 1;
      }
  }
  vector<int> s(100010,0);
  for(int i = 0; i < 100000; i++){
      s.at(i+1) = s.at(i) + s2017.at(i); 
  }
  
  for(int q = 0; q < Q; q++){
      int l,r; cin >> l >> r;
      cout << s.at(r+1) - s.at(l) << endl;
  }
}



Measured memory_bytes: 1408
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int a;
int b;

void input() {
  cin >> a >> b;
}

void solve() {
  ll ans = (1ll * a * b + 1) / 2;

  if (a == 1 || b == 1)
    ans = 1ll;

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=110;
const int INF=(1e9);
int n,m,d[maxn][maxn],cnt[maxn][maxn];
int e[maxn][maxn],v[maxn],F[maxn][maxn];
set<int> g[maxn][maxn];
int f(int x) {
	if (x%m==0) return x/m;
	return x/m+1;
}
int s,t,cur[40010];
int level[40010],tot=1;
int flow[40010];
int S[maxn],T[maxn];
int head[40010],nxt[40010];
int to[40010],num[maxn][maxn];
queue<int> q;
void Add_edge(int a,int b,int c) {
	tot++; nxt[tot]=head[a];
	head[a]=tot; to[tot]=b; flow[tot]=c;
}
void add_edge(int a,int b,int c) {
	Add_edge(a,b,c);
	Add_edge(b,a,0);
}
bool bfs() {
	q=queue<int>();
	memset(level,-1,sizeof(level));
	for (int i=1;i<=t;i++) cur[i]=head[i];
	q.push(s);
	level[s]=0;
	while (!q.empty()) {
		int a=q.front(),b; q.pop();
		for (register int i=head[a];i;i=nxt[i]) {
			b=to[i];
			if (flow[i]>0&&level[b]==-1) {
				level[b]=level[a]+1;
				q.push(b);
			}
		}
	}
	return level[t]!=-1;
}
int dfs(int x,int rest) {
	if (x==t) return rest;
	int used=0;
	for (register int i=cur[x];i;i=nxt[i]) {
		cur[x]=i;
		int y=to[i];
		if (flow[i]>0&&level[y]==level[x]+1) {
			int tflow=dfs(y,min(flow[i],rest-used));
			used+=tflow;
			flow[i]-=tflow;
			flow[i^1]+=tflow;
			if (rest-used==0) break;
		}
	}
	if (!used) level[x]=-1;
	return used;
}
int main() {
	//freopen("1.txt","r",stdin);
	//freopen("1.out","w",stdout);
	read(n); read(m);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++) {
		read(d[i][j]);
		F[i][j]=f(d[i][j]);
		cnt[i][F[i][j]]++;
		g[i][F[i][j]].insert(j);
	}
	
	/*for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) printf("%2d ",F[i][j]);
		printf("\n");
	}*/
	s=n+n+1,t=s+1;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=n;j++) {
			num[i][j]=tot+1;
			add_edge(i,j+n,cnt[i][j]);
		}
	}
	for (int i=1;i<=n;i++)
		S[i]=tot+1,add_edge(s,i,1),
		T[i]=tot+1,add_edge(i+n,t,1);
	for (int j=1;j<=m;j++) {
		int ans=0,y;
		while (bfs()) ans+=dfs(s,INF);
		for (int i=1;i<=n;i++)
		for (int k=1;k<=n;k++) {
			if (cnt[i][k]!=flow[num[i][k]]) {
				//if (j==3) printf("%d %d\n",i,k);
				y=*g[i][k].begin();
				e[i][j]=d[i][y];
				g[i][k].erase(y);
				cnt[i][k]--;
				flow[num[i][k]]=cnt[i][k];
				flow[num[i][k]^1]=0;
				break;
			}
		}
		
		for (int i=1;i<=n;i++)
			flow[S[i]]=1,flow[S[i]^1]=0,
			flow[T[i]]=1,flow[T[i]^1]=0;
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) printf("%d ",e[i][j]);
		printf("\n");
	}
	for (int j=1;j<=m;j++) {
		for (int i=1;i<=n;i++) {
			for (int k=1;k<=n;k++)
				if (f(e[k][j])==i) {
					d[i][j]=e[k][j]; break;
				}
		}
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) printf("%d ",d[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2048
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(), l = scanner.nextInt();
		String[] ss = new String[n];
		String ans = "";
		for (int i = 0; i < n; i++) {
			ss[i] = scanner.next();
		}
		Arrays.sort(ss);
		
		for (int i = 0; i < ss.length; i++) {
			ans += ss[i];
		}
		System.out.println(ans);
		scanner.close();
	}
}

Measured memory_bytes: 23380
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
x = (a1 - b1) * t1
y = (a2 - b2) * t2
p, q = x // abs(x), y // abs(y)
#print(x, y)
if x + y == 0:
    print('infinity')
else:
    l, r = 0, 10 ** 40 + 1
    ans = 0
    while r - l > 1:
        m = (l + r) // 2
        t = (x + y) * m
        if (t - y < 0) ^ (t <= 0):
            l = m
        else:
            r = m
    ans += l
    l, r = 0, 10 ** 40 + 1
    while r - l > 1:
        m = (l + r) // 2
        t = (x + y) * m
        if (t + x <= 0) ^ (t < 0):
            l = m
        else:
            r = m
    ans += l
    print(ans)


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

int main(){
  string s;
  int q;
  cin >> s >> q;
  deque<char> s_2;
  int l=s.size();
  //cout << l << endl;
  for(int i=0;i<l;i++){
    s_2.push_back(s[i]);
  }
  vector<int> t(q);
  vector<int> f(q);
  int count=0;
  for(int i=0;i<q;i++){
    cin >> t[i];
    if(t[i]==1){
      //reverse(s.begin(),s.end());
      count+=1;
    }else{
      cin >> f[i];
      char x;
      cin >> x;
      //cout << x << endl;
      if((f[i]+count)%2==0){
        s_2.push_back(x);
      }else{
        s_2.push_front(x);
      }
    }
  }
  if(count%2==1){
    reverse(s_2.begin(),s_2.end());
  }
  int l_1=s_2.size();
  //cout << l_1 << endl;
  for(int i=0;i<l_1;i++){
    cout << s_2[i];
  }
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
int a[N];
int b[N];
bool inQ[N];
int Q[N];
int L, R;
ll ans = 0;
int n;

void solve(int id) {
	int p = id - 1, q = id + 1;
	if (p < 0) p += n;
	if (q >= n) q -= n;
	int k = (b[id] - a[id]) / (b[p] + b[q]);
	if (k <= 0) return;
	ans += k;
	b[id] -= (b[p] + b[q]) * k;
	solve(p);
	solve(q);
}

inline void putInQ(int id) {
	if (inQ[id]) return;
	int p = id - 1, q = id + 1;
	if (p < 0) p += n;
	if (q >= n) q -= n;
	if (b[id] < a[id] + b[p] + b[q]) return;
	inQ[id] = 1;
	Q[R++] = id;
	if (R == N) R = 0;
}

int main()
{
//	freopen("in28.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (int i = 0; i < n; i++) {
//		putInQ(i);
		solve(i);
	}
/*	
	while(L != R) {
		int id = Q[L++];
		if (L == N) L = 0;
		inQ[id] = 0;
		int p = id - 1, q = id + 1;
		if (p < 0) p += n;
		if (q >= n) q -= n;
		int k = (b[id] - a[id]) / (b[p] + b[q]);
		if (k <= 0) continue;
		ans += k;
		b[id] -= k * (b[p] + b[q]);
		putInQ(p);
		putInQ(q);
	}
*/	
	for (int i = 0; i < n; i++)
		if (a[i] != b[i]) {
			printf("-1\n");
			return 0;
		}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
#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<P> Graph;

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

  int n;
  string s,t;
  cin >> n >> s >> t;
  
  int i = 0;
  ll ans;
  int check;

  if(s[i] == t[i]){
    ans = 3;
    check = 1;
    i++;
  }
  else{
    ans = 6;
    check = -1;
    i += 2;
  }

  while(i<n){
    if(s[i] == t[i]){
      if(check == 1){
        ans *= 2;
        ans %= MOD;
      }
      check = 1;
      i++;
    }
    else{
      if(check == 1){
        ans *= 2;
        ans %= MOD;
      }
      else{
        ans *= 3;
        ans %= MOD;
      }
      check = -1;
      i += 2;
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	split := strings.Split(s, "")
	length := len(split)
	middle := strconv.Itoa(len(split[1:length-1]))
	
	fmt.Println(split[0] + middle + split[length-1])
}


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

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

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        A[a - 1].push_back(b - 1);
        A[b - 1].push_back(a - 1);
    }

    int counter = 0;
    for (int i = 0; i < N; i++)
    {
        int flg = true;
        for (int j : A[i])
        {
            if (H[j] >= H[i])
            {
                flg = false;
                break;
            }
        }
        if (flg)
        {
            counter++;
        }
    }

    cout << counter << endl;
}

Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main()
{
 	char ch;
 	int n,i;
 	string s,a="Yes";
 	cin>>n;
 	cin>>s;
 	ch=s[s.size()-1];
 	mp[s]=1;
 	for(i=1;i<n;i++)
 	{
 		cin>>s;
 		if(mp.find(s)==mp.end()&&s[0]==ch)
 		{
 			mp[s]=1;
 			ch=s[s.size()-1];
 			if(a=="No") a="No";
		 	a=="Yes";
	    }
	    else
	    {
	    	a="No";
		}
	}	
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll mod = static_cast<ll>(1e9) + 7;

bool isOK(const string& s)
{
    const ll n = s.size();

    rep (i, n)
    {
        if (s[i] != s[n - i - 1]) { return false; }
    }

    const ll n2 = (n - 1) / 2;

    rep (i, n2)
    {
        if (s[i] != s[n2 - i - 1]) { return false; }
    }

    const ll n3 = (n + 3) / 2;

    rep (i, n - n3)
    {
        if (s[i + n3 - 1] != s[n - i - 1]) { return false; }
    }

    return true;
}

int main()
{
    string s;
    cin >> s;

    cout << (isOK(s) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a;
    cin >> a;
    cout << (3.14 * a * a) / 3.14;
    return 0;
}

Measured memory_bytes: 3732
#include<cmath>
#include<cstdio>
int main()
{
	long long n;
	scanf("%lld",&n);
	long long sqr=(long long)sqrt(n);
	for(long long i=sqr;i>=1;i--){
		if(n%i==0){
			printf("%lld\n",i-1+n/i-1);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, t=0;
	cin >> a >> b;
	c=b;
	do
	{
		c/=10;
		t++;
	}while(c!=0);
	for (int i=1;i<=t; i++) 
	{
		a*=10;
	}
	a+=b;
	if (int(sqrt(a))==sqrt(a))
	{
		 cout << "Yes" << endl;
	}	 
	else
	{
		 cout << "No" << endl;
	}	 
	return 0;
}


Measured memory_bytes: 256
list1 = []
list2 = []

time = 0
for n in range(6):

    list1.append(int(input()))

list2 = list1[1:]

time = (list1[0] // min(list2))

if (list1[0] % min(list2)) != 0:
    time += 1

time += 4

print int(time)


Measured memory_bytes: 2568
n = gets.to_i

s = Hash.new(0)
n.times do
  c = gets.chomp[0]
  s[c] += 1 if %w(M A R C H).include?(c)
end


ans = 0
if s.keys.size >= 3
  s.keys.combination(3) do |c|
    ans += s[c[0]] * s[c[1]] * s[c[2]]
  end
end
puts ans


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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=100+5;
s64 f(s64 x,s64 y)
{
	s64 ans=0;
	while(x)
	{
		s64 _y=y%x;
		ans+=(y-_y)*2;
		y=x;x=_y;
	}
	return ans-y;
}

int main()
{
	//freopen("1.in","r",stdin);
	s64 n,x;
	cin>>n>>x;
	cout<<n+f(x,n-x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int R, C, N;
	cin >> R >> C >> N;
	vector<pair<int, int>> P1, P2, P3, P4;
	rep(i, N) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (((a == 0 || a == R) || (b == 0 || b == C)) && ((c == 0 || c == R) || (d == 0 || d == C))) {
			if (a == 0) P1.pb(mp(b, i));
			else if (b == C) P2.pb(mp(a, i));
			else if (a == R) P3.pb(mp(C - b, i));
			else P4.pb(mp(R - a, i));
			if (c == 0) P1.pb(mp(d, i));
			else if (d == C) P2.pb(mp(c, i));
			else if (c == R) P3.pb(mp(C - d, i));
			else P4.pb(mp(R - c, i));
		}
	}
	sort(P1.begin(), P1.end());
	sort(P2.begin(), P2.end());
	sort(P3.begin(), P3.end());
	sort(P4.begin(), P4.end());

	int k = 1;
	int OK = 1;
	int A[100000] = {};
	for (auto p : P1) {
		if (!A[p.second]) {
			A[p.second] = k;
			k++;
		}
		else {
			k--;
			if (A[p.second] != k) OK = 0;
		}
	}
	for (auto p : P2) {
		if (!A[p.second]) {
			A[p.second] = k;
			k++;
		}
		else {
			k--;
			if (A[p.second] != k) OK = 0;
		}
	}
	for (auto p : P3) {
		if (!A[p.second]) {
			A[p.second] = k;
			k++;
		}
		else {
			k--;
			if (A[p.second] != k) OK = 0;
		}
	}
	for (auto p : P4) {
		if (!A[p.second]) {
			A[p.second] = k;
			k++;
		}
		else {
			k--;
			if (A[p.second] != k) OK = 0;
		}
	}

	if (OK) co("YES");
	else co("NO");

	Would you please return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException{
		try{
			BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
			String chain=br.readLine();
			
			for(int i=chain.length()-1; i>=0;i--){
				System.out.print(chain.charAt(i));
	        }
	        System.out.println("");
		}catch (IOException e) {
                     System.out.println(e);
                }
	}
}

Measured memory_bytes: 24076
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
//using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 300005;
/*template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

int main()
{
    int n;
    cin>>n;
    vector<string>vec(n);
    for(int i=0;i<n;i++){cin>>vec[i];}
    sort(all(vec));
    cout<<"AC x "<<count(all(vec),"AC")<<endl;
    cout<<"WA x "<<count(all(vec),"WA")<<endl;
    cout<<"TLE x "<<count(all(vec),"TLE")<<endl;
    cout<<"RE x "<<count(all(vec),"RE")<<endl;
}



Measured memory_bytes: 6424
#include <stdio.h>
#include <string.h>

int main(void) {
	char hanazawa_kana[1024];
	while (scanf("%1023s", hanazawa_kana) == 1 && strcmp(hanazawa_kana, "0") != 0) {
		int horie_yui = 0;
		char *noto_mamiko;
		for (noto_mamiko = hanazawa_kana; *noto_mamiko != '\0'; noto_mamiko++) {
			horie_yui += *noto_mamiko - '0';
		}
		printf("%d\n", horie_yui);
	}
	return 0;
}




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

using ull = unsigned long long;
using sll = signed long long;

auto process() {
	ull N, x;
	std::cin >> N >> x;

	std::vector<ull> vec;
	for (ull i{}; i < N; i++) {
		ull tmp{};
		std::cin >> tmp;
		vec.emplace_back(tmp);
	}
	std::sort(std::begin(vec), std::end(vec));

	ull c{ 0 };
	auto it = std::begin(vec);
	auto end_ = std::end(vec);
	while (it != end_) {
		if (*it <= x) {
			x -= *it;
			c++;
//			std::cout <<c<<","<< *it << "\n";
		}
		it++;
	}
	auto res = 
		c == vec.size()&& 0<x ? c - 1 : c;
	std::cout << res << std::endl;
}

int main() {
//	while (true) {
		process();
//	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = (result * x)%MOD;
    x=(x*x)%MOD;
    n >>= 1;
  }
  return result%MOD;
}

int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  ll i,j;
  cin >> i >> j;
  if(j-i+1>=2019){
    cout << 0;
    return 0;
  }
  ll res = INF;
  for(ll k = i ; k<=j ; k++){
    for(ll l=k+1 ; l<=j ; l++){
      res = min(res , (k*l)%2019);
    }
  }
  cout << res;
}

Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 02 - 08 - 20  |
// Atcoder BC 174|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define lim 1000007
#define vi vector<int>
typedef long long int ll;

ll bit[lim];

void upd(int pos,int val){
	while(pos < lim){
		bit[pos] += val;
		pos += (pos&(-pos));
	}
}

ll gans(int pos){
	ll sum = 0;
	while(pos > 0){
		sum += bit[pos];
		pos -= (pos&(-pos));
	}
	return sum;
}
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,q;
  cin >> n >> q;
  int lst[n + 1];
  memset(lst,-1,sizeof(lst));
  int a[n],fen[n];
  for(int i = 0;i < n;i++){
	cin >> a[i];
	fen[i] = abs(lst[a[i]]);
	lst[a[i]] = i + 2;
  }
  vector<pair<int,int>> ql,qr; int le[q];
  int ans[q];
  memset(ans,0,sizeof(ans));
  for(int i = 0;i < q;i++){
	int l,r;
	cin >> l >> r;
	le[i] = l;
	l--,r--;
	ql.push_back({l,i});
	qr.push_back({r,i});
  } 
  sort(ql.begin(),ql.end());
  sort(qr.begin(),qr.end());
  int qlp =0 ,qlr = 0;
  for(int i = 0;i < n;i++){
	while(qlp < q && ql[qlp].first == i){
		int val = le[ql[qlp].second];
		ans[ql[qlp].second] -= gans(val);
		qlp++;
	}
	upd(fen[i],1);
	while(qlr < q && qr[qlr].first == i){
		int val = le[qr[qlr].second];
		ans[qr[qlr].second] += gans(val);
		qlr++;
	} 
  }
  //cout << "\n";
  for(int i = 0;i < q;i++) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 24876
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

long long modpow(long long a, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  mint ans=0;
  mint tmp=modpow(2,n,mod);

  ans = tmp - 1;
  
  //comb
  mint comb=1;
  for(int i=0; i<b; i++){
    comb *= (n-i);
    comb /= (i+1);
    if(i+1==a){ ans -= comb; }
  }
  ans -= comb;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

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

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

    // int pre2[105] = {};

    int ans = 0;
    rep(i, 100){
        int d1 = i/10;
        int d2 = i%10;

        int tmp = -1;
        int tmp2 = -1;
        rep(j, n){
            if(ctoi(s[j])==d1){
                tmp = j;
                break;
            }
        }
        if(tmp==-1) continue;
        for (int k = tmp+1; k < n; k++)
        {
            if(ctoi(s[k])==d2){
                tmp2 = k;
                break;
            }
        }

        if(tmp2==-1) continue;
        set<char> sc;
        for (int j = tmp2+1; j < n; j++){
            sc.insert(s[j]);
        }
        // printf("%d %d\n", i, sc.size());
        ans += sc.size();
    }


    // cout << ans << endl;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

vi g[50];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    for(int i=1;i<=n;i++){
        cout<<g[i].size()<<endl;
    }

    return 0;
}


Measured memory_bytes: 3660