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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t / a) << ln;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
ll arr[200000+9];
int main(){
    M();
    int n;
    cin>>n;
    ll tot=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        tot+=arr[i];
    }
    ll pre=0;
    ll mi=1e16;
  //  cout<<tot<<endl;
    for(int i=0;i<n;i++){
        pre+=arr[i];
        ll lf=pre;
        ll rg=tot-pre;

        ll ans=llabs(lf-rg);
      //  cout<<lf<<" "<<rg<<" "<<ans<<endl;
        mi=min(mi,ans);
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 1792
import sys
import random
import itertools
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n = int(input())
s = [input() for i in range(n)]
ans = 0
for i in s:
    ans += i.count("AB")
a = 0
b = 0
ba = 0
for i in s:
    if i[0] == "B" and i[-1] == "A":
        ba += 1
    elif i[0] == "B":
        b += 1
    elif i[-1] == "A":
        a += 1
if ba > 0:
    ans += ba-1
    if b > 0:
        b-=1
        ans += 1
    if a >0:
        a -= 1
        ans += 1
    ans += min(a,b)
else:
    ans += min(a,b)
print(ans)


Measured memory_bytes: 45016
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	r := make([]int, 0, n)
	g := make([]int, 0, n)
	b := make([]int, 0, n)
	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			r = append(r, i+1)

		} else if s[i] == 'G' {
			g = append(g, i+1)

		} else {
			b = append(b, i+1)
		}
	}

	ans := 0
	ans += f(r, g, b)
	ans += f(r, b, g)
	ans += f(g, r, b)
	ans += f(g, b, r)
	ans += f(b, r, g)
	ans += f(b, g, r)
	fmt.Println(ans)
}

func f(r, g, b []int) int {
	ret := 0
	for i := 0; i < len(r); i++ {
		for j := 0; j < len(g); j++ {
			if r[i] >= g[j] {
				continue
			}
			ret += len(b) - sort.Search(len(b), func(k int) bool { return b[k] > g[j] })
			same := sort.Search(len(b), func(k int) bool { return b[k] >= g[j]+g[j]-r[i] })
			if same < len(b) && b[same] == g[j]+g[j]-r[i] {
				ret -= 1
			}
		}
	}
	return ret
}


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

typedef long long ll;

int main() {
    int N, M;
    ll K, A, B;
    cin >> N >> M >> K;
    vector<ll> AS(N + 1, 0), BS(M + 1, 0);
    rep(i, N) {
        cin >> A;
        AS[i + 1] = AS[i] + A;
    }
    rep(i, M) {
        cin >> B;
        BS[i + 1] = BS[i] + B;
    }
    int ans = 0;
    for (int i = 0; i <= N; i++) {
        if (AS[i] > K) break;
        int j = upper_bound(BS.begin(), BS.end(), K - AS[i]) - BS.begin();
        ans = max(ans, i + j - 1);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6364
#include<stdio.h>
int main(void)
{
	int N, p[10];
	int max = 0,wa=0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		wa += p[i];
		if (p[i] > max) {
			max = p[i];
		}
	}
	wa -= max;
	max /= 2;
	wa += max;
	printf("%d", wa);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll a, s, d, f, g;
	cin >> a >> s >> d >> f >> g;
	if (a == 0)
		cout << 1;
	else if (s == 0)
		cout << 2;
	else if (d == 0)
		cout << 3;
	else if (f == 0)
		cout << 4;
	else if (g == 0)
		cout << 5;
	cout << endl;

	return 0;
}

Measured memory_bytes: 3640
import math
from functools import reduce
answer=0
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K=int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            #print(i,j,k)
            answer+=gcd(i,j,k)
                
                
print(answer)

Measured memory_bytes: 69660
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N, W = map(int, input().split())
    w = [0]
    v = [0]
    for i in range(N):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)

    dp = []
    for i in range(N + 1):
        dp.append([0] * (W + 1))

    for i in range(1, N + 1):
        for j in range(1, W + 1):
            dp[i][j] = dp[i - 1][j]
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
    print(dp[N][W])

if __name__ == '__main__':
    main()


Measured memory_bytes: 156792
MOD = 10 ** 9 + 7

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0


N, K = map(int, input().split())

K = min(K, N - 1)

F = Factorial(N + 1, MOD)

ans = 0
for k in range(K + 1):
    tmp = F.comb(N, k) * F.factorial(N - 1) * F.ifactorial(N - 1 - k) * F.ifactorial(k)
    ans += (tmp % MOD)
    ans %= MOD

print (ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  int ans = 0;
  bool f = true;
  while(f){
    f = false;
    int memo = 1000;
    int res = 0;
    for(int i = 0; i < n; i++){
      if(v[i] != 0){
        if(v[i] < memo){memo = v[i];}
        f = true;
      }
      else{
        for(int j = res; j < i; j++){
          if(memo != 1000){v[j] -= memo;}
        }
        if(memo != 1000){ans += memo;}
        memo = 1000;
        res = i+1;
      }
      if(i == n-1 && v[i] != 0){
        for(int j = res; j < n; j++){
          if(memo != 1000){v[j] -= memo;}
        }
        if(memo != 1000){ans += memo;}
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

char s[1<<17];

int main()
{
  scanf("%s", s);
  int n = (int) strlen(s);

  int mojpap = n / 2;
  int njpap = 0;

  for (int i=0; i<n; i++)
    if (s[i] == 'p')
      njpap++;

  printf("%d\n", mojpap - njpap);

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        int inptCount = int.Parse(Reader.ReadLine());
        long[] arrA = new long[inptCount];
        long[] arrB = new long[inptCount];

        for(int i=0; i<inptCount; i++) {
            long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
            arrA[i] = inpt[0];
            arrB[i] = inpt[1];
        }

        long ans = 0;
        for(int i=arrA.Length-1; i>=0; i--) {
            if((arrA[i] + ans) % arrB[i] == 0) {
                continue;
            }
            long must = arrB[i] - ((arrA[i] + ans) % arrB[i]);
            ans+=must;
        }
        Console.WriteLine(ans);
    }

    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


3
3 5
2 7
9 4


";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


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

int main(void){
    int N, L;
    cin >> N >> L;
    int a[N];
    for(int i = 0; i < N; i++){
        a[i] = L + i;
    }
    int min = 0;
    int sum = 0;
    for(int j = 0; j < N; j++){
        if(abs(a[j]) < abs(a[min])){
            min = j;
        }
        sum += a[j];
    }
    cout << sum - a[min] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const int MAXN = 1010;
const ll INF = 1e14;

int n;
ll x[MAXN], y[MAXN];
char mode[4] = {'L', 'R', 'U', 'D'};
int du[4] = {-1, 1, 1, -1};
int dv[4] = {-1, 1, -1, 1};

void solve() {
  int parity = (x[0] + y[0]) & 1;
  for (int i=0;i<n;i++) {
    if (parity != ((x[i] + y[i]) & 1)) {
      cout << -1 << endl;
      return;
    }
  }

  vector<ll> arms;
  for (int i=38;i>=0;i--) {
    arms.push_back(1LL << i);
  }
  if (parity == 0) {
    arms.push_back(1LL);
  }

  cout << arms.size() << endl;
  for (int i=0;i<arms.size();i++) {
    cout << arms[i] << " ";
  }
  cout << endl;

  for (int i=0;i<n;i++) {
    ll u = x[i] + y[i];
    ll v = x[i] - y[i];
    for (int j=0;j<arms.size();j++) {
      ll minDist = INF;
      int direction;
      for (int k=0;k<4;k++) {
        ll nu = u - du[k] * arms[j];
        ll nv = v - dv[k] * arms[j];
        if (minDist > abs(nu) + abs(nv)) {
          minDist = abs(nu) + abs(nv);
          direction = k;
        }
      }
      u = u - du[direction] * arms[j];
      v = v - dv[direction] * arms[j];
      cout << mode[direction];
    }
    cout << endl;
  }
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> x[i] >> y[i];
  }
  solve();
}


Measured memory_bytes: 256
package main
import (
    "fmt"
)
    
func main(){
    var N int
    fmt.Scan(&N)
    var ans int
    div := N/3
    for i:=3;div>1;i+=2{
        div = N/i
        mod := N%i
        if mod ==0 {
            continue
        }
        if mod%div==0{
            ans += i+(mod-div)/div
        }
        i+=mod/div-1
    }
    fmt.Println(ans)
}


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

int main(){
  int A ,B,C,D;
  cin >> A >> B>>C>>D;
  while(1){
    C = C-B;
    if(C<=0) {cout<<"Yes" <<endl;
              break;
             }
     A = A-D;
    if(A<=0) {cout<<"No" <<endl;
              break;}
    
  }
  
    
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int gcd(int a, int b)
{
    int x, y;

    if (a > b){
        x = a;
        y = b;
    } else {
        x = b;
        y = a;
    }

    while (y > 0) {
        int buf = x % y;
        x = y;
        y = buf;
    }

    return x;
}

int main()
{
    int a, b;

    cin >> a >> b;

    cout << gcd(a, b) << endl;

    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a==c)cout<<"No\n";
    else if(a!=b&&b!=c&&a!=c)cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ostream>

int main(int argc, char *argv[]) {
  int H, W;
  std::cin >> H >> W;
  char s[52][52]{};
  int count[52][52]{};
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) {
      char c;
      std::cin >> c;
      s[i][j] = c;
      if (c == '#') {
        ++count[i + 1][j];
        ++count[i + 1][j + 1];
        ++count[i][j + 1];
        ++count[i - 1][j];
        ++count[i - 1][j - 1];
        ++count[i][j - 1];
        ++count[i + 1][j - 1];
        ++count[i - 1][j + 1];
      }
    }

  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) {
      if (s[i][j] == '#')
        std::cout << '#';
      else
        std::cout << count[i][j];
      if (j == W)
        std::cout << std::endl;
    }
}


Measured memory_bytes: 256
#from random import randint
import numpy as np


#@njit
def f(h,w,m,ins):
    yp = np.zeros(h,dtype=np.int)
    xp = np.zeros(w,dtype=np.int)
    #yp[:,1] = np.arange(h)
    #xp[:,1] = np.arange(w)
    ans = 0
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 1
    ypm = yp[yp.argmax()]
    xpm = xp[xp.argmax()]
    yps = np.where(yp == ypm)[0].tolist()
    xps = np.where(xp == xpm)[0].tolist()
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans


if False:
    while True:
        h,w = randint(1,10**5*3),randint(1,10**5*3)
        m = randint(1,min(h*w,10**5*3))
        ins = [(randint(1,h),randint(1,w)) for i in range(m)]
        ans = f(h,w,m,ins)
        print(ans)
else:
    h,w,m = map(int,input().split())
    ans = f(h,w,m,[tuple(map(int,input().split())) for i in range(m)])
    print(ans)


Measured memory_bytes: 144488
import java.io.IOException;
import java.util.Scanner;

public class Main {

	static int count = 0;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		mergeSort(a, 0, n);
		printArrays(a, n);
		System.out.println(count);
	}

	public static void merge(int a[], int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int L[] = new int[n1 + 1];
		int R[] = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			L[i] = a[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = a[mid + i];
		}
		L[n1] = 1000000000;
		R[n2] = 1000000000;

		for (int i = 0, j = 0, k = left; k < right; k++) {
			count++;
			if (L[i] <= R[j]) {
				a[k] = L[i];
				i++;
			} else {
				a[k] = R[j];
				j++;
			}
		}
	}

	public static void mergeSort(int a[], int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(a, left, mid);
			mergeSort(a, mid, right);
			merge(a, left, mid, right);
		}
	}

	public static void printArrays(int a[], int n) {
		for (int i = 0; i < n - 1; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println(a[n - 1]);
	}
}



Measured memory_bytes: 170596
#include <stdio.h>
#include <stdint.h>

void printn(const char c, const uint32_t n) {
    uint32_t i;
    for (i = 0; i < n; i++) putchar(c);
    putchar('\n');
}

int main(void) {
    uint32_t H, W;
    uint32_t y;

    scanf("%u %u\n", &H, &W);
    printn('#', W+2);
    for (y = 0; y < H; y++) {
        uint32_t x;
        putchar('#');
        for (x = 0; x < W; x++) {
            putchar(getchar());
        }
        getchar(); /* line break */
        putchar('#');
        putchar('\n');
    }
    printn('#', W+2);
    
    return 0;
}



Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a1 := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a1[i])
	}
	a2 := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a2[i])
	}

	max := 0
	for i := 0; i < n; i++ {
		sum := 0
		right := n - i
		for left := 0 ; left < right; left++ {
			sum += a1[left]
		}
		right--
		for ;right < n; right++ {
			sum += a2[right]
		}
		if max < sum {
			max = sum
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 1780
n = int(input())
a = list(map(int, input().split()))

x, y = 0, sum(a)
ans = abs(a[0] - (sum(a) - a[0]))
for i in range(n - 1):
    x += a[i]
    y -= a[i]
    ans = min(ans, abs(x - y))

print(ans)


Measured memory_bytes: 24832
n, sum = map(int, input().split())
for x in range(n + 1):
    for y in range(n - x + 1):
        if x * 10000 + y * 5000 + (n-x-y) * 1000 == sum:
            print(x, y, n-x-y)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 40684
#include <cstdio>
#include <string.h>

using namespace std;

int main()
{
	char in[81];
	char tht[3][10] = {"the","this","that"};
	int len;
	bool end;

	while(gets(in)){
		len = strlen(in);
		end = false;
		for(int i = 0; i < 26; i++){
			for(int j = 0; j < len; j++){
				if(in[j] >= 'a' && in[j] <= 'z'){
					if(in[j] == 'z'){
						in[j] = 'a';
					}
					else{
						in[j]++;
					}
				}
			}
			for(int c = 0; c < 3; c++){
				if(strstr(in,tht[c]) != NULL){
					printf("%s\n",in);
					end = true;
					break;
				}
			}
			
			if(end){
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 928
#include <iostream>
using namespace std;
 
int main(void){
	int x,y;
	while(1) {
 		cin >> x >> y ;
		if ( x == 0 && y == 0 ) break;
		if (x < y){
		cout << x << " " << y << endl;
		}else{
		cout << y << " " << x << endl;
		}
	}
	return 0;
} 

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

int main() {
    string yohou;
    string real;
    int count ;
    count = 0;
    cin >> yohou ;
    cin >> real;
    rep(i,3){
        if(yohou.at(i) == real.at(i)){
            count += 1;
        }
    }
    cout << count << endl;

    }

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

int main(void){
	double a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	vector<double> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	v.push_back(d);
	v.push_back(e);
	sort( v.begin(), v.end(), greater<double>() );
	cout << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' << v[3] << ' ' << v[4] << endl;
	return 0;
}

Measured memory_bytes: 0
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

h, w = nm()
a = [['#'] + list(map(str, sys.stdin.readline().split())) + ['#'] for _ in range(h)]
a.insert(0, ['#' for _ in range(w + 2)])
a.append(['#' for _ in range(w + 2)])
for i in range(h + 2):
    print(''.join(a[i]))


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
#define LL long long
#define maxn 200005

using namespace std;

const LL mod=998244353;
int n,v[maxn<<2],q,a[maxn];
LL mp[11][maxn],M[maxn<<2];

void Init()
{
    for (int i=1;i<=9;i++)
    {
        mp[i][0]=0;
        for (int j=1;j<=n;j++)
            mp[i][j]=(mp[i][j-1]*10+i)%mod;
    }
    mp[10][0]=1;
    for (int i=1;i<=n;i++) mp[10][i]=mp[10][i-1]*10%mod;
}

inline void push_down(int n,int L,int R)
{
    v[n<<1]=v[n];
    v[n<<1|1]=v[n];
    int mid=(L+R)>>1;
    M[n<<1]=mp[v[n]][mid-L+1];
    M[n<<1|1]=mp[v[n]][R-mid];
    v[n]=-1;
}
/*
void build(int n,int L,int R,int p)
{
    if (L==R)
    {
        M[p]=1;
        return;
    }
    int mid=(L+R)>>1;
    if (p<=mid) build(n<<1,L,mid,p);
    else build(n<<1|1,mid+1,R,p);
    M[n]=M[n<<1]*M[]
}*/

void Insert(int n,int L,int R,int l,int r,int k)
{
    //if (~v[n] && v[n]==k) return ;
    if (~v[n] && L!=R) push_down(n,L,R);
    if (l<=L && R<=r)
    {
        v[n]=k; M[n]=mp[k][R-L+1];
        return;
    }
    int mid=(L+R)>>1;
    if (l<=mid) Insert(n<<1,L,mid,l,r,k);
    if (r>mid) Insert(n<<1|1,mid+1,R,l,r,k);
    M[n]=M[n<<1]*mp[10][R-mid]%mod + M[n<<1|1];
    if (M[n]>=mod) M[n]%=mod;
    return ;
}

LL solve(int n,int L,int R)
{
    if (~v[n])
        return M[n];

    LL ret=0;
    int mid=(L+R)>>1;
    ret=solve(n<<1,L,mid)*mp[10][R-mid]%mod;
    ret=(ret+solve(n<<1|1,mid+1,R));
    if (ret>=mod) ret%=mod;
    return ret;
}

int main()
{
    memset(v,-1,sizeof(v));
    scanf("%d%d",&n,&q);
    Init();
    Insert(1,1,n,1,n,1);
    while (q--)
    {
        int l,r,d;
        scanf("%d%d%d",&l,&r,&d);
        Insert(1,1,n,l,r,d);
        printf("%lld\n",M[1]);
    }
    return 0;
}


Measured memory_bytes: 26620
#n, m = gets.chomp.split.map(&:to_i)
#ary = []; n.times { cakes << gets.chomp.split.map(&:to_i).to_a } 
#def cb(i);	i==1 ? 1 : -1;end
n = gets.chomp.to_i
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
a = {}
a[2]=0
a[3]=0
a[5]=0
a[7]=0
a[11]=0
a[13]=0
a[17]=0
a[19]=0
a[23]=0
a[29]=0
a[31]=0
a[37]=0
a[41]=0
a[43]=0
a[47]=0
ans = 0

2.step(n, 1) { |i|
  memo = i
  primes.each do |prime|
  	while (memo % prime == 0) do
  	  memo = memo/prime
  	  a[prime] += 1
  	end
  	break if memo == 1
  end
}

over74 = a.select {|aa, v| v >73 }
over24 = a.select {|aa, v| v >23 }
over14 = a.select {|aa, v| v >13 }
over4 = a.select {|aa, v| v > 3 }
twos  = a.select {|aa, v| v == 2 || v== 3}
ofs = over4.size

ans += ofs*(ofs-1)*(ofs-2)/2
ans += ofs*(ofs-1)/2 * twos.size # 5 5 3 , 3が^2の時、と3が^5のときで分ける
ans += over14.size * ofs - over14.size
ans += over24.size * (twos.size + ofs) - over24.size
ans += over74.size

puts ans


Measured memory_bytes: 1788
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
#define debegin printf("debug\nbegin\n")
#define deend printf("debug\nend\n")
#define isfind printf("find\n")
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************	
const int maxn=1e2+5,inf=1e9;
int n;
int f[maxn][11];
int main(){
	f[0][0]=0;rep(i,1,9)f[0][i]=-inf;
	rread(n);
	rep(i,1,n){
		int x;rread(x);
		rep(now,0,9){
			int last=((now-x)%10+10)%10;
			f[i][now]=max(f[i-1][now],f[i-1][last]+x);
		}
	}
	f[n][0]=0;
	int ans=-inf;
	rep(i,0,9)ans=max(ans,f[n][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    //freopen("input.txt", "r", stdin);
    int x, res;
    cin >> x;
    if (x >= 400 && x < 600)
        res = 8;
    else if (x < 800)
        res = 7;
    else if (x < 1000)
        res = 6;
    else if (x < 1200)
        res = 5;
    else if (x < 1400)
        res = 4;
    else if (x < 1600)
        res = 3;
    else if (x < 1800)
        res = 2;
    else
        res = 1;
    cout << res;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[200005],i,j,n,res=0;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>a[i];
    for(i=1; i<=n; i++)
    {
        if(a[a[i]]==i&&a[i]!=0&&a[a[i]]!=0)
        {
            res++;
            a[i]=0;
            a[a[i]]=0;
        }


    }

    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

long long table[200][64];

int main() {
  int N;
  long long t = 0;

  cin >> N;

  for (int j = 3; j <= N; j++) {
    for (int k = 0; k < 256; k++) {
      int l1 = k % 4, l2 = k % 16, l3 = k % 64, t1 = k / 64, t2 = k / 16, t3 = k / 4, m2 = l3 / 4;

      if (j == 3) table[j][l3] = !(l3 == 6 || l3 == 9 || l3 == 33);
      else {
        if (t1 == 0 && l2 == 9 ||
            t2 == 2 && l1 == 1 ||
            l3 == 6 || l3 == 9 || l3 == 33) continue;
        table[j][l3] = (table[j][l3] + table[j - 1][t3]) % 1000000007;
      }
    }
  }

  for (int i = 0; i < 64; i++) t = (t + table[N][i]) % 1000000007;

  cout << t << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char map[505][505];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };

vector<ll>to[200005];
vector<int>ans;

int main() {
	int n, q;
	cin >> n >> q;
	int a, b;
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n);
	int p, x;
	for (int j = 0; j < q; j++) {
			cin >> p >> x;
			p--;
			ans[p] += x;
	}
	queue<ll>que;
	vector<ll>pre(n, -1);
	pre[0] = -2;
	que.push(0);
	while (!que.empty()) {
		int x = que.front();
		que.pop();
		for (int id : to[x]) {
			if ( pre[id] != -1)continue;
			ans[id] += ans[x];
			pre[id] = x;
			que.push(id);
		}
	}

	for (int i = 0; i < n; i++) {
			cout << ans[i] <<" ";
	}
		cout << endl;
		return 0;
}

Measured memory_bytes: 18672
#!/usr/bin/env python3

def main():
    s = input()
    m = int(s[5:7])
    d = int(s[8:10])
    if m * 100 + d <= 430:
        print("Heisei")
    else:
        print("TBD")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
M(int*a){return*a-*1[&a];}n,T[9999][2];j,m,s;main(i){for(;~scanf("%d",&n);qsort(T,n,8,M),n&&printf("%d\n%d\n%d\n",1[*T],T[1][1],T[n-2][1]))for(i=n;i--;)for(scanf("%d",T[i]+1),*T[i]=0,j=4;j--;*T[i]+=m*60+s)scanf("%d%d",&m,&s);}

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

int Abs(int num){
    if(num<0)num*=-1;
    return num;
}

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

    int n;
    cin>>n;
    vector<int> x(n),y(n),h(n);
    int ansx=-1,ansy=-1,ansh=-1;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>h[i];
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int H=-1;
            bool f=true;
            for(int k=0;k<n;k++){
                if(h[k]==0)continue;
                int tmp=Abs(x[k]-i)+Abs(y[k]-j)+h[k];
                if(H==-1)H=tmp;
                else if(H!=tmp)f=false;
            }
            if(f){
                bool ff=true;
                for(int k=0;k<n;k++){
                    int num=max(0,H-Abs(x[k]-i)-Abs(y[k]-j));
                    if(num!=h[k])ff=false;
                }
                if(ff){
                    ansx=i;
                    ansy=j;
                    ansh=H;
                }
            }
        }
    }

    cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int b[maxn];
int lowbit(int x){return x&(-x);}
void update(int x,int v){
    for(int i=x;i<maxn;i+=lowbit(i))b[i]+=v;
}
int query(int x){
    int ans=0;
    for(int i=x;i>0;i-=lowbit(i))ans+=b[i];
    return ans;
}
int gs[maxn],x,n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        gs[x]++;
        if(gs[x]==3)gs[x]=1;
    }
    int l=1,r=1e5,ans=0;
    for(int i=1;i<=1e5;i++){
        if(gs[i]==1){
            ans++;update(i,1);
        }
    }
    while(l<r){
        while(gs[l]!=2&&l<r)l++;
        while(gs[r]!=2&&l<r)r--;
        if(l<r){
            ans+=2;gs[l]--;gs[r]--;
        }
        else{
            break;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define rep(i,N) For(i,0,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))

int main(){
  ll i,j,N,H,W,f,ans=0;
  cin>>N;
  vec v(N);
  rep(i,N)cin>>v[i];
  vsort(v);
  rep(i,N){
    For(j,i+1,N){
      H=upper_bound(all(v),v[j]-v[i])-v.begin();
      W=lower_bound(all(v),v[j]+v[i])-v.begin();
      f=0;
      if(H<=i&&i<W)f++;
      if(H<=j&&j<W)f++;
      ans+=max(W-H-f,0LL);
    }
  }
  cout<<ans/3<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
n = 0
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 != 0 and A[i]%5 != 0:
            n = 1

if n == 0:
    print('APPROVED')
elif n == 1:
    print('DENIED')

Measured memory_bytes: 9128
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    
    int c;
    c = a*b;
    if (c % 2 == 1){
        printf("Odd");
    }else{
        printf("Even");
    }
    
    return 0;
}

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

using namespace std;

int main()
{
    //freopen("frog.inp","r",stdin);
    int j,i,k;
    long long int n, t = 0, tong;
    long long int h[100000], s[100000];
    cin >> n >> k;
    for (i = 1; i <= n; i++) cin >> h[i];
    s[1] = 0;
    s[2] = abs(h[2] - h[1]);
    for (i = 3; i <= n; i++)
    {
       tong = s[i-1]+abs(h[i]-h[i-1]);
        for (j = i-2; j >= max(1,i-k); j--)
        {
            tong = min(s[j] + abs(h[j] - h[i]), tong);
        }
        s[i] = tong;
    }
     cout << s[n] << endl;
     return 0;
}


Measured memory_bytes: 1792
#pragma region 
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<string>
typedef long long ll;
template <typename T>void read(T &x){x=0;char ch=getchar();ll f=1;while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}x*=f;}
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
#pragma endregion
const int maxn = 2e5 + 5;
ll a[maxn],b[maxn],c[maxn];
int main() {
    IO;
    int n;
    cin >> n;
    for (int i = 1; i <= n;++i) {
        cin >> a[i];
        b[i] = i - a[i];
        c[i] = i + a[i];
    }
    map<ll, ll> mp;
    ll ans = 0;
    for (int i = 1; i <= n;++i) {
        ans += mp[b[i]];
        mp[c[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 30964
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[n-i-1]);
}
printf("%d",a[0]);
for(int i=1;i<n;i++){
printf(" %d",a[i]);
}
printf("\n");
}

Measured memory_bytes: 2740
fn main() {
    let (A, B) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut splitted = s.split_whitespace();
        (
            splitted.next().unwrap().to_string(),
            splitted.next().unwrap().to_string(),
        )
    };

    let mut aup = 0;
    let mut amake = "".to_string();
    for c in A.chars() {
        if aup > 0 {
            aup = aup * 10;
        }
        if c == '.' {
            aup = 1;
            continue;
        }
        amake.push(c);
    }
    if aup == 0 {
        aup = 1;
    }

    let mut bup = 0;
    let mut bmake = "".to_string();
    for c in B.chars() {
        if bup > 0 {
            bup = bup * 10;
        }
        if c == '.' {
            bup = 1;
            continue;
        }
        bmake.push(c);
    }
    if bup == 0 {
        bup = 1;
    }

    println!(
        "{}",
        amake.parse::<i128>().unwrap() * bmake.parse::<i128>().unwrap() / (aup * bup)
    );
}

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

int main(){
    string s;
    cin>>s;
    if(s[s.length()-1]!='s'){
        s.push_back('s');        
    }
    else{
        s.push_back('e');
        s.push_back('s');
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int keta(int a) {
	int res = 0;
	while (a > 0) {
		a /= 10;
		res++;
	}
	return res;
}


int L, A, B, M;

int po(int a, int p) {
	if (p == 0)return 1;
	int res = po(a, p / 2);
	res = (res * res) % M;
	if (p & 1) {
		res = (res * a) % M;
	}
	return res;
}

int calc(int z, int c) {
	if (c == 0)return 0;
	if (c == 1)return 1;

	int res = calc(z, c / 2);


	res = (res + (res * po(z, c / 2))) % M;

	if (c & 1) {
		res = (res + po(z, c - 1)) % M;
	}
	return res;
}

int calc2(int z, int c) {
	if (c == 0)return 0;
	if (c == 1)return 0;

	int res = calc2(z, c / 2);

	res = (res + (res * po(z, c / 2))) % M;


	res = (res + (( ((c / 2) % M) * po(z, c / 2)) % M) * calc(z, c / 2)) % M;



	if (c & 1) {
		res = (res + ((c - 1) % M) * po(z, c - 1)) % M;
	}
	return res;
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> L >> A >> B >> M;


	vector<int> X(20, 0);
	for (int i = 1; i <= 19; i++) {

		int ok = L;
		int ng = -1;
		while (ok - ng > 1) {
			int m = (ok + ng) / 2;
			int a = A + B * m;

			if (keta(a) >= i) {
				ok = m;
			}
			else {
				ng = m;
			}


		}
		X[i] = ok;
	}

	int b = 1;
	int la = L;
	int res = 0;
	int AA = A % M;
	int BB = B % M;
	for (int i = 19; i >= 0; i--) {
		int cnt = la - X[i];
		if (cnt > 0) {
			int z = po(10, i);
			int t = (AA + BB * ((la - 1) % M)) % M;




			int diff = 0;

			diff = (diff + t * calc(z, cnt)) % M;

			diff = (diff - BB * calc2(z, cnt)) % M;

			if (diff < 0)diff += M;


			diff = (diff*b) % M;

			res = (res + diff) % M;

			b = (b * po(po(10, cnt), i)) % M;
		}
		la = X[i];
	}
	/*cerr << calc2(2, 2) << endl;
	cerr << calc2(2, 3) << endl;
	cerr << calc2(2, 4) << endl;
	cerr << calc2(2, 5) << endl;*/

	cout << res << endl;



}

Measured memory_bytes: 256
def resolve():
    (N,T)=(int(i) for i in input().split())

    dishes=[[int(i) for i in input().split()] for _ in range(N)]
    dishes.sort()
    dpt=[[-1 for i in range(T+1)] for _ in range(N+1)]

    dpt[0][0]=0

    for i in range(N):
        for j in range(T):
            dpt[i+1][j]=max(dpt[i+1][j],dpt[i][j])
            dpt[i+1][min(T,j+dishes[i][0])]=max(dpt[i+1][min(T,j+dishes[i][0])],dpt[i][j]+dishes[i][1])
        dpt[i+1][T]=max(dpt[i+1][T],dpt[i][T])




    print(max(dpt[-1]))
#    for i in dpt:
#        print(i)

if __name__ == "__main__":
#    unittest.main()
    resolve()

Measured memory_bytes: 123992
// Levensthein distance レーベンシュタイン距離
// Edit distance 編集距離
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
using V = vector<int>;
constexpr array<int, 4> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
constexpr int INF = 1234567890, MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
// constexpr int INF2 = 1000000000000000000LL+7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int ceil(int a, int b) { return (a + b - 1) / b; }
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    // 編集距離
    // 文字列Sを操作して文字列Tにするのにかかるコスト
    // 操作とは以下
    // 💙 1文字挿入
    // 💙 1文字削除
    // 💙 1文字置換

    string s, t;
    cin >> s >> t;

    // dp[i][j]: Si Sのi文字目までと Tj Tのj文字目までの編集距離
    // i = 0,1,...,|S|
    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
    // 空文字からTのi文字目までをつくるなら i回文字挿入すればいい
    for (int i = 0; i <= t.size(); i++)
        dp[0][i] = i;
    // Sのi文字目までから空文字をつくるなら i回文字削除すればいい
    for (int i = 0; i <= s.size(); i++)
        dp[i][0] = i;

    for (int i = 1; i <= s.size(); i++)
    {
        for (int j = 1; j <= t.size(); j++)
        {
            // コストは Si, Tj-1 のコスト+1 Siに文字を挿入している
            const int cost_insert = dp[i][j - 1] + 1;
            // コストは Si-1, Tj のコスト+1  Si-1の文字を削除している
            const int cost_delete = dp[i - 1][j] + 1;
            // コストは Si-1, Tj-1 のコスト+1 s[i]==t[j]ならば置換しないので1たさない
            const int cost_replace = dp[i - 1][j - 1] + (s[i-1] != t[j-1]);

            dp[i][j] = min(cost_insert, min(cost_delete, cost_replace));
        }
    }

    cout << dp[s.size()][t.size()] << endl;
}



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

int main() {
  string s;
  int C = 0;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'R') {
      C++;
    }
  }
  string SS="RSR";
  if (C == 2 && s == SS) {
    C = 1;
  }
  
  cout << C << endl;
}


Measured memory_bytes: 3628
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    vector<pair<string,ll>> vec(n);
    map<pair<string,ll>,ll> mp;
    rep(i,n){
        string s;
        ll p;
        cin>>s>>p;
        vec[i]={s,-p};
        mp[{s,-p}]=i+1;
    }
    sort(all(vec));
    rep(i,n){
        cout<<mp[{vec[i].F,vec[i].S}]<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int maxn = 2e5 + 10;
int N, M, K, A[maxn], B[maxn];
LL sumA[maxn], sumB[maxn];
int main()
{
    scanf("%d %d %d", &N, &M, &K);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d", &A[i]);
        sumA[i] = sumA[i-1] + A[i];
    }
    for(int i = 1; i <= M; i++)
    {
        scanf("%d", &B[i]);
        sumB[i] = sumB[i-1] + B[i];
    }
    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        if(sumA[i] > K)
            break;
        int p = upper_bound(sumB + 1, sumB + M + 1, K - sumA[i]) - sumB - 1;
        ans = max(ans, i + p);
    }
    for(int i = 1; i <= M; i++)
    {
        if(sumB[i] > K)
            break;
        int p = upper_bound(sumA + 1, sumA + N + 1, K - sumB[i]) - sumA - 1;
        ans = max(ans, i + p);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 8496
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int N;
  cin>>N;
  int K;
  cin>>K;
  int mid = N/2;
  if(N%2) mid++;
  REP(i,K){
    int x,y;
    cin>>x>>y;
    if(x>mid) x = N+1 -x;
    if(y>mid) y = N+1 -y;
    int l = min(x,y);
    if(l%3==0) cout<<3<<endl;
    else if(l%3==1) cout<<1<<endl;
    else if(l%3==2) cout<<2<<endl;
  }

  return 0;
}

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

int main() {
	string s;
  	cin>>s;
  	rep(i,s.size()){
     	if(s[i]==',') s[i]=' ';
      	cout<<s[i];
    }
  	cout<<endl;
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

int main(){
	ll H;
	cin>>H;
	ll ans = 0, curr_n = 1;
	while(H){
		ans += curr_n;
		curr_n=curr_n<<1;
		H=H>>1;
	}
	cout<<ans<<"\n";
	return 0;
}

/*
4
2 2
1 1 1 1

2
1 1

3
1 1
*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<unordered_map>
#include<map>
#include<set>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define nl cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int x, n;
	cin >> x >> n;

	int a[102] = {0};

	loopi(0, n)
	{
		int b;
		cin >> b;

		a[b] = 1;
	}

	loopi(0, 101)
	{
		if (a[x - i] == 0)
		{
			cout << x - i;
			break;
		}
		if (a[x + i] == 0)
		{
			cout << x + i;
			break;
		}
	}



	return 0;
}

Measured memory_bytes: 3692
//ThakurAnurag
//TemplateCode

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long int
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define fo2(i,a,n) for(ll i=n;i>=a;i--)
#define endl "\n"
#define sp " "
#define f first
#define s second
#define pb push_back
#define buffer ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define init(arr,val) memset(arr,val,sizeof(arr))
#define vecl(v) vector<ll> v
#define vecs(v) vector<string> v
#define vecp(v) vector < pair <ll,ll> > v

int main()
{
	ll x,n;
	cin>>x>>n;

	ll arr[n];
	bool flag[102];
	init(flag,false);
	fo(i,0,n){
		cin>>arr[i];
		flag[arr[i]] = true;
	}
	ll j=0;
	bool flag2 = true;
	while(x+j<=101 && x-j>=0){
		if(!flag[x-j]){
			cout<<x-j;
			flag2 = false;
			break;
		}
		else if(!flag[x+j]){
			cout<<x+j;
			flag2 = false;
			break;	
		}
		else
			j++;
	}
	return 0;
}

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

int main() {

	ll n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	ll x = 0;
	ll cnt = n;
	while (true) {
		if (cnt % 2 == 1) x += a[cnt];
		else x -= a[cnt];
		cnt--;
		if (cnt == 0) break;
	}
	cout << x << " ";
	ll x_now;
	ll x_prev = x / 2;
	for (int i = 2; i <= n; i++) {
		x_now = a[i - 1] - x_prev;
		cout << 2 * x_now << " ";
		x_prev = x_now;
	}	 
	return 0;
}

Measured memory_bytes: 3736