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

int main(){
  
  int s,w;
  cin>>s>>w;
  
  if (s>w){
    cout<<"safe"<<endl;
  }
  
  else {
    cout<<"unsafe"<<endl;
  }
  
  

  return 0;
}
  













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

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  // a^n
  static long pow(long a, long n) {
    long s = 1;
    while (n > 0) {
      if ((n & 1) == 1) {
        s *= a;
        s %= MOD;
      }
      n >>= 1L;
      a *= a;
      a %= MOD;
    }
    return s;
  }

  static final long[] x;
  static final long[] y;
  static final long MOD = 1_000_000_007L;

  static {
    long[] a = new long[200001];
    a[0] = 1;
    for (int i = 1; i <= 200000; ++i) {
      a[i] = a[i - 1] * i % MOD;
    }
    x = a;

    long[] b = new long[200001];
    for (int i = 0; i <= 200000; ++i) {
      b[i] = pow(a[i], MOD - 2L);
    }
    y = b;
  }

  long convi(int n, int r) {
    long ret = 1L;
    ret *= x[n];
    ret *= y[r];
    ret %= MOD;
    ret *= y[n - r];
    ret %= MOD;
    return ret;
  }

  void run() {
    int h = ni();
    int w = ni();
    int a = ni();
    int b = ni();

    long sum = 0;
    for (int i = b; i < w; ++i) {
      // nCr = n! * (r!)^-1 * ((n-r)!)^-1
      // iC(h-a-1) * (w-i)C
      sum += (convi(i + h - a - 1, i) * convi(w - 1 - i + a - 1, a - 1)) % MOD;
      sum %= MOD;
    }
    System.out.println(sum);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 12880
#include<bits/stdc++.h>
#define ll long long int
#define N 100010
using namespace std;
int main() 
{
	int r,d,x;
	cin>>r>>d>>x;
	vector<ll> n(10);
	n[0]=x;
	for(int i=1;i<=10;i++)
	{
		n[i]=r*n[i-1]-d;
		cout<<n[i]<<endl;
	}
	return 0;
}


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

int main()
{
    int E;
    int Y;
    cin >> E;
    cin >> Y;

    if(E ==  0)
    {
        if(1868 <= Y && Y <= 1911)  
        {
            cout << "M" << Y - 1867 << endl;
        }
        else if(1912 <= Y && Y <= 1925)
        {
            cout << "T" << Y - 1911 << endl;
        }
        else if(1926 <= Y && Y <= 1988)
        {
            cout << "S" << Y - 1925 << endl;
        }
        else if(1989 <= Y && Y <= 2016)
        {
            cout << "H" << Y - 1988 << endl;
        }
    }
    else if(E == 1)
    {
        cout << 1867 + Y << endl;
    }
    else if(E == 2)
    {
        cout << 1911 + Y << endl;
    }
    else if(E ==3)
    {
        cout << 1925 + Y << endl;
    }
    else if(E == 4)
    {
        cout << 1988 + Y << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
import math as mat
N = int(input())
A = int(mat.floor(N/100))
B = int(mat.floor((N-A*100)/10))
C = int(mat.floor(N-A*100-B*10))
if A == 7 or B == 7 or C == 7 :
    ans = str('Yes')
else:
    ans = str('No')

print(ans)

Measured memory_bytes: 9116
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


int V, E;
struct edge { LL to, cost; };
int start;
LL d[100100]; //距離
vector<edge> vec[100100];

void dijkstra() {
	for (int i = 0; i < 100100; i++)d[i] = HINF<LL>();
	priority_queue<pii, std::vector<pii>, std::greater<pii>> pq;
	d[start] = 0;
	pq.push(make_pair(d[start], start));//cost,to
	while (!pq.empty()) {
		pii p = pq.top();
		pq.pop();
		int i = p.second;
		if (d[i] < p.first)continue;
		for (int k = 0; k < vec[i].size(); k++) {
			edge e = vec[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(make_pair(d[e.to], e.to));
		}
	}
}

int n;

int main() {
	cin >> n;
	REP(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		vec[a].emplace_back(edge{ b,c });
		vec[b].emplace_back(edge{ a,c });
	}
	start = 0;
	dijkstra();
	LL maxpos = 0, maxnum = 0;
	REP(i, n) {
		if (d[i] > maxnum) {
			maxpos = i;
			maxnum = d[i];
		}
	}
	start = maxpos;
	dijkstra();
	LL ans = 0;
	REP(i, n)ans = max(ans, d[i]);
	cout << ans << endl;
}


Measured memory_bytes: 11868
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val coords = new Array[(Double, Double)](N)
  for (i <- 0 until N) {
    val x, y = in.next().toDouble
    coords(i) = (x, y)
  }

  def getDist(p1: (Double, Double), p2: (Double, Double)): Double = {
    import Math.{pow, sqrt}
    sqrt(pow(p1._1 - p2._1, 2) + pow(p1._2 - p2._2, 2))
  }

  def getValue(s: Double, g: Double, d: Double): Double = {
    val move = (s-g).abs * d

    if (s > g)
      s - move
    else
      s + move
  }

  var now = (500.0, 500.0)
  var d = 1.0
  while (d > 1e-7) {
    val (nx, ny) =
      coords
        .map(pos => (getDist(now, pos), pos))
        .sorted.reverse
        .head._2

    now = (getValue(now._1, nx, d), getValue(now._2, ny, d))
    d *= 0.999
  }

  val ans =
    coords
      .map(pos => getDist(now, pos))
      .sorted.reverse
      .head

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 52904
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a=0,b=0,men=0,syuu=0;
    scanf("%d %d",&a,&b);
    men = a*b;
    syuu = 2*a+2*b;
    printf("%d %d\n",men,syuu);
    return 0;
}



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

int main() {
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if((n-i-j)*10000+i*5000+j*1000==y){
        cout<<n-i-j<<" "<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
  
}


Measured memory_bytes: 256
def prime_factor(n):
    ass = set()
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.add(i)
            n = n//i
    if n != 1:
        ass.add(n)
    return ass

A,B = map(int, input().split())
num_set = set()

A_set = prime_factor(A)
B_set = prime_factor(B)

num_set = A_set.intersection(B_set)

#while True:
#    if(A%i==0 and B%i==0):
#        num_set.add(i)
#        A = A//i
#        B = B//i
#        if(coprime2(A,B)==1):
#            break
#    else:
#        i = i+1
print(len(num_set)+1)

Measured memory_bytes: 3064
while True:
    data = {}
    n = input()
    if n == 0:
        break
    for i in range(n):
        tmp = raw_input()
        tmp_data = tmp.split(" ")
        if i == 0:
            data.update({tmp_data[0] : int(tmp_data[1]) + int(tmp_data[2])})
        else:
            flag = False
            for j in data.iterkeys():
                if data[j] < int(tmp_data[1]) + int(tmp_data[2]):
                    flag = True
                if flag:
                    data.clear()
                    data.update({tmp_data[0] : int(tmp_data[1]) + int(tmp_data[2])})

    for key in data.iterkeys():
        print "%s %d" % (key, data[key])

Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


struct UnionFind {
    vector<int> size, parents;
    UnionFind(int n){
        size.resize(n,0);
        parents.resize(n,0);
        for(int i = 0; i < n; i++){
            makeTree(i);
        }
    }
    void makeTree(int x){
        parents[x] = x;
        size[x] = 1;
    }
    bool isSame(int x, int y){return findRoot(x) == findRoot(y);}
    void unite(int x, int y){
        x = findRoot(x);
        y = findRoot(y);
        if(x == y) return;//二重辺を防ぐ
        if(size[x] > size[y]){
            parents[y] = x;
            size[x] += size[y];
        }else{
            parents[x] = y;
            size[y] += size[x];
        }
    }
    int findRoot(int x){
        if(x != parents[x]){
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x){return size[findRoot(x)];}
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    int ans = n - 1;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a, --b;
        if(!uf.isSame(a, b)){
            uf.unite(a, b);
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4016
#include<iostream>
#include<string>
using namespace std;
 
int H,W;
char S[71][71];
string maxs,DP[100][100];
 
int main()
{
  while(1){
    cin>>W>>H;
    if(W==0&&H==0)break;
    maxs.erase(maxs.begin(),maxs.end());
    for(int i=1;i<H+1;i++){
      for(int j=1;j<W+1;j++){
    cin>>S[i][j];
    DP[i][j].erase(DP[i][j].begin(),DP[i][j].end());
      }
    }
    for(int i=1;i<H+1;i++){
      for(int j=1;j<W+1;j++){
        if(S[i][j]=='0' && DP[i-1][j].empty() && DP[i][j-1].empty())continue;
    if(S[i][j]>='0' && S[i][j]<='9'){
      if(DP[i-1][j].length()>DP[i][j-1].length())DP[i][j]=DP[i-1][j]+S[i][j];
      else if(DP[i-1][j].length()<DP[i][j-1].length())DP[i][j]=DP[i][j-1]+S[i][j];
          else if(DP[i-1][j]>DP[i][j-1])DP[i][j]=DP[i-1][j]+S[i][j];
      else DP[i][j]=DP[i][j-1]+S[i][j];
      if(maxs.length()<DP[i][j].length())maxs=DP[i][j];
          else if(maxs.length()==DP[i][j].length() && maxs<DP[i][j])maxs=DP[i][j];
    }
      }
    }
    cout<<maxs<<endl;
  }
  return 0;
}


Measured memory_bytes: 3224
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s[3];
	rep(i, 3) cin >> s[i];
	int pos = 0;
	int x[3];
	rep(i, 3) x[i] = 0;
	while (1) {
		if (x[pos] == (int)s[pos].size()) {
			cout << (char)('A' + pos) << endl;
			return 0;
		}
		int next = s[pos][x[pos]] - 'a';
		x[pos]++;
		pos = next;
	}
	return 0;
}

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

int main(){
  int w,h,p,x1,x2,y1,y2,n;
  bool road[21][21][21][21];
  cin >> n;
  while(n--){
    cin >> w >> h >> p;
    memset(road,true,sizeof(road));
    long int dp[21][21] = {{0}};
    while(p--){
      cin >> x1 >> y1 >> x2 >> y2;
      road[y1][x1][y2][x2] = false;
      road[y2][x2][y1][x1] = false;
    }

    for(int i=0;i<h;i++){
      if(road[i][0][i+1][0]) dp[i+1][0] = 1;
      else break;
    }
    for(int i=0;i<w;i++){
      if(road[0][i][0][i+1]) dp[0][i+1] = 1;
      else break;
    }

    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	if(road[i][j][i][j-1]) dp[i][j] += dp[i][j-1];
	if(road[i][j][i-1][j]) dp[i][j] += dp[i-1][j];
      }
    }
    if(dp[h][w] > 0) cout << dp[h][w] << endl;
    else cout << "Miserable Hokusai!\n";
  }
}

Measured memory_bytes: 1356
#include <stdio.h>
int main (int argc, char * argv[])
{
    int a,b,c,a1,sort;
    scanf("%d %d %d",&a,&b,&c);
    if(a>c){
        sort = a;
        a = c;
        c = sort;
//        printf("%d %d %d\n",a,b,c);
    }
    if(b>c){
        sort = b;
        b = c;
        c = sort;
//        printf("%d %d %d\n",a,b,c);

    }
    if(a>b){
        sort = a;
        a = b;
        b = sort;
//        printf("%d %d %d\n",a,b,c);

    }
    printf("%d %d %d\n",a,b,c);

    return 0;
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 1; i <= 10; ++i)
    {
        x = r * x - d;
        cout << x << '\n';
    }
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bit_count(i):

    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    i = (i + (i >> 4)) & 0x0f0f0f0f
    i = i + (i >> 8)
    i = i + (i >> 16)
    return i & 0x3f

N = INT()
A = []
for i in range(N):
    a = []
    for j in range(INT()):
        x, y = MAP()
        a.append((x-1, y))
    A.append(a)

def check(a):
    for x, y in a:
        if honest[x] == -1:
            honest[x] = y
            if y == 1:
                if not check(A[x]):
                    return False
        elif honest[x] != y:
            return False
    return True

ans = 0
for S in range(1<<N):
    honest = [-1] * N
    valid = True
    for i in range(N):
        if S & (1<<i):
            honest[i] = 1
    for i in range(N):
        if S & (1<<i):
            if not check(A[i]):
                valid = False
    if valid:
        ans = max(ans, bit_count(S))
print(ans)


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

string yaku(vector<int> v) {
    int num[13] = {};
    for (int x : v) num[x-1] ++;

    int c2 = 0, c3 = 0, c4 = 0;
    bool straight = false;
    for (int i=0; i<13; ++i) {
        c4 += (num[i] == 4);
        c3 += (num[i] == 3);
        c2 += (num[i] == 2);
        if (i+4 < 13) {
            straight |= (num[i] && num[i+1] && num[i+2] && num[i+3] && num[i+4]);
        }
    }
    straight |= (num[0] && num[9] && num[10] && num[11] && num[12]);

    if (straight) return "straight";
    if (c3 & c2) return "full house";
    if (c4) return "four card";
    if (c3) return "three card";
    if (c2 == 2) return "two pair";
    if (c2) return "one pair";
    return "null";
}

int main() {
    vector<int> v(5);
    char c;
    while (cin>>v[0]>>c>>v[1]>>c>>v[2]>>c>>v[3]>>c>>v[4]) {
        cout << yaku(v) << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		sc.close();

		int m = 2 * D + 1;
		System.out.println((int)Math.ceil((double)N / m));
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
int main()
{
int a, b, i;
scanf("%d %d",&a,&b);
if((a==1&&b!=1)||a>b&&b!=1)
{
    printf("Alice\n");
}
else if((b==1&&a!=1)|| b>a&&a!=1)
{
    printf("Bob\n");
}
else
{
    printf("Draw\n");
}
}

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

AB = [[int(v) for v in input().split()] for _ in range(N)]

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

index = 0
ans = 0 
count = 0
while True:
  a,b = AB[index]
  if count + b  >=  M:
    ans += (M-count) * a
    break
  else:
    count += b
    ans += a * b
    
  index += 1

print(ans)

Measured memory_bytes: 22760
X = int(input())

if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)


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

using namespace std;
 
int main() {
  long double a;
  long double b;
  long double ans;
  cin >> a >> b;
  long double i,d;
  d = modf(b, &i);
  ans += a*i;
  ans += a*d;
  cout << fixed << setprecision(0) << floor(ans) << endl;
}

Measured memory_bytes: 3848
import java.util.Scanner;
public class Main {
	public static int dfs(int total, int addv, int target, int n){ return n == 0 ? total == target ? 1 : 0 : addv > 9 ? 0 : dfs(total + addv, addv + 1, target, n - 1) + dfs(total, addv + 1, target, n); }
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(true){ int n = sc.nextInt(), s = sc.nextInt(); if(n == 0 && s == 0) break; System.out.println(dfs(0, 0, s, n)); }
		}
	}
}

Measured memory_bytes: 26288
<?php
fscanf(STDIN, "%d", $n);

while ($n--) {
  fscanf(STDIN, "%s", $o);
  fscanf(STDIN, "%s", $m);
  
  $o = strrev($o);

  for ($i = 0; $i < strlen($o); $i++) {
    $ch = $o[$i];
    if ($ch == 'J') {
      $m = substr($m, strlen($m) - 1) . substr($m, 0, strlen($m) - 1);
    } else if ($ch == 'C') {
      $m = substr($m, 1) . substr($m, 0, 1);
    } else if ($ch == 'E') {
      if (strlen($m) % 2) {
        $m = substr($m, (int)(strlen($m) / 2) + 1) . $m[(int)(strlen($m) / 2)] . substr($m, 0, (int)(strlen($m) / 2));
      } else {
        $m = substr($m, strlen($m) / 2) . substr($m, 0, strlen($m) / 2);
      }
    } else if ($ch == 'A') {
      $m = strrev($m);
    } else if ($ch == 'P') {
      for ($j = 0; $j < strlen($m); $j++) {
        if (is_numeric($m[$j])) {
          $m[$j] = (string)(((int)$m[$j] - 1 + 10) % 10);
        }
      }
    } else if ($ch == 'M') {
      for ($j = 0; $j < strlen($m); $j++) {
        if (is_numeric($m[$j])) {
          $m[$j] = (string)(((int)$m[$j] + 1) % 10);
        }
      }
    }
  }

  print $m . "\n";
}

Measured memory_bytes: 6644
#include<cstdio>
#include<set>
using namespace std;
int a,b,c;
struct node{
	int a,b,c;
	bool operator<(const node &t)const{
		return a==t.a?b==t.b?c<t.c:b<t.b:a<t.a;
	}
};
set<node> s;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	for(int ans=0;;++ans){
		if(a&1||b&1||c&1){
			printf("%d",ans); return 0;
		}
		if(s.count((node){a,b,c})){
			printf("-1"); return 0;
		}
		s.insert((node){a,b,c});
		int tmpa=(b+c)/2,tmpb=(a+c)/2,tmpc=(a+b)/2;
		a=tmpa; b=tmpb; c=tmpc;
	}
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair



int main(){
    int n;
    cin>>n;
    vector<int> a;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        a.push_back(k);
    }
    int count=0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){count++; a[i]=-1;}
    }
    cout<<count<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
map<string,int> mp;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		string s;
		cin>>s;
		mp[s]--;
	}
	int M=0;
	for(auto p=mp.begin();p!=mp.end();p++) M=max(M,p->second);
	cout<<M<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    int ans=10000000;
    for (int j=-100;j<=100;j++) {
        int sum=0;
        for (int l=0;l<n;l++) {
            sum+=(deq[l]-j)*(deq[l]-j);
        }
        if (ans>sum) {
            ans=sum;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+205;
int cnt[N];
void solve(){
	int n; 
	cin>>n; 
	for(int i=1;i<=n;i++){
		int x; 
		cin>>x; 
		cnt[x]++;
	}
	int ans = 0;
	for(int i=1;i<N;i++){
		if(cnt[i])ans+=cnt[i]-1;
	}
	if(ans&1)ans++;
	cout<<n-ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


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

int main(){
  int N,ans;
  cin >> N;
  for(int i = 0; i < N; i++){
  	int a,b = 0;
    cin >> a;
    while(a % 2 == 0){
    	b++;
        a = a / 2; 
    }
    if(i == 0){
      ans = b;
    }
    ans = min(b,ans);
  }
  cout << ans << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;

map<int,int> tr[2];
int n;

int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        int v;
        scanf("%d",&v);
        tr[i&1][v]+=1;
    }

    int m[2][2]={0,},t[2][2]={0,};
    int s=0;
    for(int i=0;i<2;i++) {
        int mx=0;
        for(auto &it:tr[i]) {
            if(m[i][0] < it.se) {
                t[i][1]=t[i][0]; t[i][0]=it.fi;
                m[i][1] = m[i][0]; m[i][0]=it.se;
            } else if(m[i][1]<it.se) {
                t[i][1]=it.fi;
                m[i][1]=it.se;
            }
        }
    }
    if(t[0][0]!=t[1][0]) printf("%d\n",n-(m[0][0]+m[1][0]));
    else printf("%d\n",n-max(m[0][0]+m[1][1], m[0][1]+m[1][0]));
    
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

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

  int H , C;
  cin >> H >> C;
   map<char, int> Cnt;
   for(int i = 0;i < H; i++) {
     for(int j = 0; j < C; j++) {
       char a;
       cin >> a;
       Cnt[a]++;
     }
   }
   dg1(Cnt);
   int need4 = 0 , need2 = 0;
   if(H % 2 == 0 && C % 2 == 0){
     need4 = (H * C) / 4;
   }
   else if(H % 2 && C % 2) {
     int x = (H * C) - (H + C - 1);
     need4 = x / 4;
     need2 = (int)H/2 + (int)C/2;
   }
   else {
     int x = H * C;
     if(H % 2 == 0) {
       need2 = H / 2;
       x -= H;
     }
     else {
       need2 = C/2;
       x -= C;
     }
     need4 = x / 4;
   }
   int have4 = 0;
   for(char i = 'a'; i <= 'z'; i++) {
     while(have4 < need4 && Cnt[i] >= 4) {
        have4 ++;
        Cnt[i] -= 4;
     }
   }
   int have2 = 0;
   for(char i = 'a'; i <= 'z'; i++) {
     while(have2 < need2 && Cnt[i] >= 2) {
       have2 ++;
       Cnt[i] -= 2;
     }
   }
   dg4(have4 , need4 , have2 , need2);
   if(have4 >= need4 && have2 >= need2){
     cout << "Yes" << '\n';
   } else{
     cout << "No" << '\n';
   }

}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
const int N = 301;
const int MOD = 998244353;
 
int n, k;
string s;
vector<int> v, suf;
int cache[N][N][N];
 
void add(int &a, int b)
{
	a += b;
	if(a >= MOD)
		a -= MOD;
}

int dp(int idx, int cur, int tot)
{
	if(tot > k)
		return 0;
	if(idx >= v.size())
		return (cur == 0);
	int &ans = cache[idx][cur][tot];
	if(ans != -1)
		return ans;
	ans = 0;
	int mx = v[idx] + k - tot;
	mx = min(mx, suf[idx]);
	for(int len = max(0, v[idx] - cur); len <= mx; len++)
		add(ans, dp(idx + 1, cur + len - v[idx], tot + max(0, len - v[idx])));
	return ans; 
}
 
int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin >> s >> k;
	while(s.size() && s.back() == '0')
		s.pop_back();
	reverse(s.begin(), s.end());
	while(s.size() && s.back() == '1')
		s.pop_back();
	reverse(s.begin(), s.end());
	int cnt = 0;
	n = s.size();
	k = min(k, n);
	v.push_back(0);
	int prv = 0;
	for(int i = 0; i < n; i++)
	{
		if(s[i] == '0')
		{
			if(i > 0 && s[i - 1] == '0')
				v.push_back(0);
			continue;
		}
		int j = i;
		while(j + 1 < n && s[j + 1] == s[i])
			j++;
		v.push_back(j - i + 1);
		cnt += j - i + 1;
		i = j;
	}
	suf = v;
	for(int i = (int)suf.size() - 2; i >= 0; i--)
		suf[i] += suf[i + 1];
	int ans = dp(0, 0, 0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 110204
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;
using ll = long long int;


int main(int argc, char *argv[])
{
	string a;
	int q;
	//input
	cin >> a;
	cin >> q;


	//calc
	bool flip = false;
	for (int q_index = 0; q_index < q; q_index++){
		char query_char;
		cin >> query_char;
		if (query_char == '1'){
			flip = !flip;
		}
		else if (query_char == '2'){
			char f;
			cin >> f;
			
			int push_back;
			push_back = (f - '1');
			push_back = flip ? 1 - push_back : push_back;

			string c;
			cin >> c;
			if (push_back){
				a += c;
			}
			else{
				a.insert(0, c);
			}
		}
	}


	//ans
	if (flip){
		reverse(a.begin(), a.end());
	}
	cout << a << endl;

	return 0;
}


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

const long long mod=1000000007LL;

int main(int argc, char const *argv[])
{
	int h,w,k;
	cin>>h>>w>>k;
	--k;
	int d[w]={};
	long long cnt[w][3]={},s=0LL;
	while (d[w-1]==0)
	{
		int f=1;
		for (int i = 0; i < w-1; ++i)
		{
			if (d[i]==1&&d[i+1]==1)
			{
				f=0;
			}
		}
		if (f)
		{
			++s;
			for (int i = 0; i < w; ++i)
			{
				++cnt[i][d[i]];
			}
		}
		int now=0;
		while (d[now]==1)
		{
			d[now]=0;
			++now;
		}
		d[now]=1;
	}
	long long dp[h+5][w+5]={};
	dp[0][0]=1LL;
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (j==0)
			{
				dp[i][j]+=dp[i-1][j]*cnt[j][0];
				dp[i][j]%=mod;
				dp[i][j]+=dp[i-1][j+1]*cnt[j][1];
				dp[i][j]%=mod;
			}
			else if (j==w-1)
			{
				dp[i][j]+=dp[i-1][j]*cnt[j-1][0];
				dp[i][j]%=mod;
				dp[i][j]+=dp[i-1][j-1]*cnt[j-1][1];
				dp[i][j]%=mod;
			}
			else
			{
				dp[i][j]+=dp[i-1][j]*(s-cnt[j-1][1]-cnt[j][1]);
				dp[i][j]%=mod;
				dp[i][j]+=dp[i-1][j-1]*cnt[j-1][1];
				dp[i][j]%=mod;
				dp[i][j]+=dp[i-1][j+1]*cnt[j][1];
				dp[i][j]%=mod;
			}
		}
	}
	cout<<dp[h][k]<<endl;
	return 0;
}


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

int main() {
	string s;
    cin >> s;
    if(s.size()>=4 && s.at(0)=='Y' && s.at(1)=='A' && s.at(2)=='K' && s.at(3)=='I'){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  int h,w;
  cin >> h >> w;
  int ans = W*H - ((W*h+w*H)-w*h);
  if(ans>0){
    cout << ans << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll n, m;

int main()
{
    cin>>n>>m;
    if (n == 1 || m == 1)
        cout<<1<<endl;
    else
        cout<<(n * m + 1) / 2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,x,y,a,b,c,d,t,r,sm=0;
	string s;
	
	cin >> m >> n;
	for(i=0;i<n;i++)
	{
		cin >> x;
		sm+=x;
	}
	cout << max(-1LL,m-sm);

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    string s;
    cin >> s;
    REP(i, s.length()){
        if(i % 2 == 0){
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	ll h, w, k;
	cin >> h >> w >> k;
	string g[h];
	for (int i = 0; i < h; ++i)
	{
		cin >> g[i];
	}
	ll mask1=1LL<<(h);
	ll mask2=1LL<<(w);
	ll ans=0;
	for (int i = 0; i < mask1; ++i)
	{
		for (int j = 0; j < mask2; ++j)
		{
			ll cnt=0;
			for (int k = 0; k < h; ++k)
			{
				if((i&(1LL<<k))==0LL)continue;
				for (int l = 0; l < w; ++l)
				{
					if((j&(1LL<<l))==0LL)continue;
					if(g[k][l]=='#')
					{
						cnt++;
					}
				}
			}
			// deb(cnt)
			ans+=(cnt==k);
		}
	}
	cout<<ans<<endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin>>T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

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

int main(){
  int H,W;
  cin>>H>>W;
  if(H==0||W==0){
    cout<<"##"<<endl;
    cout<<"##"<<endl;
  }
  else{
  for(int i=0;i<W+2;i++){
  cout<<"#";
  }
  cout<<endl;
  
  for(int i=0;i<H;i++){
  vector<char> h(W);
    for(int j=0;j<W;j++){
      cin>>h.at(j);
    }
    cout<<"#";
    for(int j=0;j<W;j++){
    cout<<h.at(j);
    }
    cout<<"#"<<endl;
  }
  
  for(int i=0;i<W+2;i++){
  cout<<"#";
  }
  cout<<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
using namespace std;
int n;
ld a[60];
ld ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	ans=a[1];
	for(int i=2;i<=n;i++)ans=(a[i]+ans)/2.0;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import Data.List
import Data.Ord

solve :: String -> String
solve [] = ""
solve (x:xs)
  | x == '1' = '9' : solve xs
  | x == '9' = '1' : solve xs
  | otherwise = x : solve xs

main :: IO ()
main = do
  line <- map read . words <$> getLine
  let [a, b, c] = sortOn Down line
  print $ a * 10 + b + c

Measured memory_bytes: 508
package main

import (
	"fmt"
)

func main() {
	var a, b, n int
	fmt.Scanf("%d %d %d", &a, &b, &n)
	answer := maxFloor(a, b, n)
	fmt.Println(answer)
}

func maxFloor(a, b, n int) int {
	m := min(b-1, n)
	return floor(a, b, m)
}

func floor(a, b, x int) int {
	s := a * x / b
	t := a * (x / b)
	return s - t
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


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

#define ll long long
int a[101010];
ll ans;

ll cnt2(int x)
{
	ll res = 0;
	while(x%2 == 0)
	{
		res++;
		x/=2;
	}
	return res;
}

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

	for(int i = 0;i < n;i++)
		ans+= cnt2(a[i]);

	cout << ans << endl;

	return 0;
}

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

template<typename T> struct SegTree {
  int sz;
  T init;
  function<T(T, T)> f;
  vector<T> data;
  SegTree() {}
  SegTree(int n, T init = INT_MAX, function<T(T, T)> f = [](T a, T b) { return min(a, b); })
    : data(set_data(n), init), init(init), f(f) {}

  int set_data(int n) {
    sz = 1;
    while (sz < n) sz <<= 1;
    return 2 * sz - 1;
  }
  void update(int k, T x) {
    k += sz - 1;
    data[k] = f(data[k], x);
    while (k > 0) {
      k = (k - 1) / 2;
      data[k] = f(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
  T query(int s, int t) { return query(s, t, 0, 0, sz); }
  T query(int s, int t, int k, int l, int r) {
    if (r <= s || t <= l) return init;
    if (s <= l && r <= t) return data[k];
    int m = (l + r) / 2;
    T vl = query(s, t, k * 2 + 1, l, m);
    T vr = query(s, t, k * 2 + 2, m, r);
    return f(vl, vr);
  }
};

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

  int n, q; cin >> n >> q;
  SegTree<int> st(n, 0, [](int a, int b) { return a + b; });
  for (int i = 0; i < q; ++i) {
    int com, x, y; cin >> com >> x >> y;
    if (com) {
      cout << st.query(x - 1, y) << endl;
    } else {
      st.update(x - 1, y);
    }
  }
  return 0;
}



Measured memory_bytes: 3784
# -*- coding: utf-8 -*-
inputData = input()
r, D, x2000 = map(int, inputData.split())

x = []


def dfx(r, D, xLast):
    ans = xLast * r - D
    x.append(ans)
    if (len(x)) < 10:
        dfx(r, D, ans)
    else:
        for i in range(len(x)):
            print(x[i])


x = dfx(r, D, x2000)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main(void){
	long x, k, d;
	scanf("%ld %ld %ld", &x, &k, &d);
	x = x < 0 ? -x : x;
	long res;
	if(x / d > k){
		printf("%ld\n", x - d * k);
	}else{
		if((k - x / d) % 2 == 0){
			printf("%ld\n", x % d);
		}else{
			printf("%ld\n", d - x % d);
		}
	}
	return 0;
}


Measured memory_bytes: 2148
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int q; cin >> q;
	vector<bool> prime(1001001, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i*i < 100001; ++i)
	{
		if (!prime[i])continue;
		for (int j = i + i; j < 100001; j += i)prime[j] = false;
	}
	vector<int> sum(100002, 0);
	rep(i, 100001)
	{
		sum[i + 1] = sum[i];
		if (i % 2 == 0)continue;
		if (prime[i] && prime[(i + 1) / 2])++sum[i + 1];
	}
	while (q--)
	{
		int l, r; cin >> l >> r;
		cout << sum[r + 1] - sum[l] << endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    long long n;
    scanf("%lld",&n);
    int ans=0;
    int flag=0;
    while(n>=10)
    {
        if(n%10!=9)
            flag=1;
        ans+=9;
        n=n/10;
    }
    if(flag)
        ans+=n-1;
    else
        ans+=n;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n;
    string s;
    cin >> n >> s;

    int red=0, blue=0;
    rep(i, s.length()){
        if(s[i] == 'R') red++;
        else blue++;
    }

    ans(red > blue);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N, M, cnt=0, i, sum=0;
    int A[200] = {};
    scanf("%d%d", &N, &M);
    for(i=0; i<N; i++){
        scanf("%d", &A[i]);
        sum += A[i];
    }
    double limit = sum / (4.0*M);
    for(i=0; i<N; i++){
        if(A[i] >= limit)cnt++;
    }
    if(cnt>=M){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <climits>
#include <math.h>
 
using namespace std;
typedef unsigned long ul;

int ceil_int(int a, int b) { return (a + (b - 1)) / b; }

int main() {
	int n, k;
	cin>>n>>k;
	cout<<ceil_int(n-1,k-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  int N; cin >> N;
  int K; cin >> K;

  deque<ll> q;
  ll sum = 0;
  ll max_sum = 0;

  REP(i, 0, N) {
    ll p; cin >> p;
    q.push_front(p);

    if (q.size() < size_t(K)) continue;
    if (q.size() == size_t(K)) {
      for (ll x : q) sum += x;
    } else {
      ll latest = q.front();
      ll oldest = q.back(); q.pop_back();
      sum -= oldest;
      sum += latest;
    }

    if (sum > max_sum) max_sum = sum;
  }

  printf("%f\n", double(max_sum + K) / 2);
}


Measured memory_bytes: 1920
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    if (T * S >= D) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3612
s=input()
t=input()
s=s+s#kyotokyoto
k=0
flag=False
for i in s:
  if k<=(len(t)-1) and i==t[k]:
    k+=1
  else:
    k=0
  if k==(len(t)-1):
    flag=True
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    std::cin >> n >> k;
    std::vector<int> h(n);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }
    sort(h.begin(),h.end());
    int ans=INT_MAX;
    for (int i = 0; i < n-k+1; i++) {
        int tmp=h[i+k-1]-h[i];
        if(tmp<ans){
            ans=tmp;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 1005;
const ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << a*(a-1)/2+b*(b-1)/2;
    return 0;
}


Measured memory_bytes: 256