akhauriyash/Code-Regression huggingface dataset:
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        int N = nextInt();
        String S = next();

        String ans = "";
        for(int i=0; i<S.length(); i++){
            int n = al.indexOf(S.charAt(i));
            n = n+N >= al.length() ? n+N-al.length() : n+N;

            ans += al.charAt(n);
        }

        println(ans);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 148148
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X, Y;
    cin >> N >> X >> Y;
    --X, --Y;
    vector<int> ans(N, 0);
    rep(i, 0, N) {
        rep(j, i + 1, N) {
            ++ans[min({j - i, abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(X - j)})];
        }
    }
    rep(k, 1, N) {
        cout << ans[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n = 0, r = 0, c = 1;
  scanf("%d %d ",&n,&r);
  while(n>=r){
      if(n%r!=0){ n -= n%r; }
      n /= r;
      c++;
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 128
S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")


Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    n,wn=MI()
    dp=[0]*(wn+1)
    for _ in range(n):
        v,w=MI()
        for i in range(wn):
            if i+w>wn:break
            dp[i+w]=max(dp[i+w],dp[i]+v)
    print(dp[-1])

main()



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

int main() {
  int N, M; cin >> N >> M;
  int l = 1, r = N - 1;
  for (int i = 0; i < M; i++) {
    if (N % 2 == 0 && i == (N - 2) / 4) r--;
    cout << l << " " << r << endl;
    l++; r--;
  }
}


Measured memory_bytes: 3620
import java.util.Scanner

object Main extends App {
  def readALine(c:Int, ac:List[Int]):List[Int] =
    if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
    if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  val sc = new Scanner(System.in)
  val n = sc.nextInt

  def mod60(n:Int):(Int, Int) = (n/60, n%60)
  
  val (hm,   sec) = mod60(n)
  val (hour, min) = mod60(hm)
  
  println(s"$hour:$min:$sec")

}


Measured memory_bytes: 44988
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node a);
Node treeMaximum(Node a);
Node treeSearch(Node u, int k);
Node treeSuccessor(Node a);
void treeDelete(Node a);
void insert(int k);
void inorder(Node u);
void preorder(Node u);
int main(){
       int n,i,x;
       char com[20];
       scanf("%d",&n);
       
       for(i = 0 ; i<n; i++){
	 scanf("%s",com);
	 
	 if(com[0] == 'f'){
	 scanf("%d",&x);
	 Node t = treeSearch(root,x);
	 if(t!=NIL)printf("yes\n");
	 else{
	   printf("no\n");
       }
	 
       }
       else if(com[0] == 'i'){
	 scanf("%d",&x);
	 insert(x);
       }
       else if(com[0] == 'p'){
	 inorder(root);
	 printf("\n");
	 preorder(root);
	 printf("\n");
	 
       }
       else if(com[0] == 'd'){
	 scanf("%d",&x);
	 treeDelete(treeSearch(root,x));
       }
     }
     return 0;
   }



Node treeMinimum(Node a){
  while(a->left!=NIL){
    a = a->left;
  }
  return a;
}

Node treeMaximum(Node a){
  while(a->right!=NIL){
    a = a->right;
  }
  return a;
}

Node treeSearch(Node u, int k){
  while(u!=NIL && k != u->key){
    if(k < u->key)u= u->left;
    else{
      u=u->right;
    }
  }
    return u;
  }


Node treeSuccessor(Node a){
  if(a->right != NIL) return treeMinimum(a->right);
  Node y;
  y = a->p;
  while(y != NIL && a == y->right){
    a = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node a){
  Node y;
  Node x;
  if(a->left ==NIL || a->right==NIL)y=a;
  else{
    y = treeSuccessor(a);
  }
  if(y->left!=NIL)x = y->left;
  else {
    x = y->right;
  }

    if(x != NIL)x->p = y->p;
  if(y->p == NIL)root = x;
  else if(y==y->p->left) y->p->left = x;
  else{
    y->p->right = x;
  }
  if(y!=a)a->key = y->key;
}


 void insert(int k){
   Node y = NIL;
   Node x = root;
   Node z;

   z = malloc(sizeof(struct node));
   z ->key = k;
   z ->left = NIL;
   z ->right = NIL;

   while(x!= NIL){
     y= x;
     if(z->key < x->key) x= x->left;
   else{
     x = x->right;
 }
   }
     z->p = y;

     if(y == NIL) root =z;
     else if(z->key < y->key) y->left = z;
     else {
       y ->right =z;
     }
 }


 void inorder(Node u){
   if(u != NIL){
     inorder(u->left);
     printf(" %d", u->key);
     inorder(u->right);
   }
   else{
     return;
   }
 }

   void preorder(Node u){
     if(u!=NIL){
       printf(" %d",u->key);
       preorder(u->left);
       preorder(u->right);
     }
     else{
       return;
     }
   }



Measured memory_bytes: 20448
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
typedef pair<int,int> P; //cap,cost
typedef tuple<int,int,string> T;//R,C,w/e
map<int,P> G[100*100+200+2];

int main(){
    int n;
    cin>>n;
    int W[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++) cin>>W[i][j];
    int E[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++) cin>>E[i][j];
    vector<string> F(n),ANS(n,string(n,'.'));
    for(auto &f:F) cin>>f;
    int C[n][n];
    int mincost = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(F[i][j]=='o'){
                C[i][j]=-E[i][j];
                mincost+=E[i][j];
            }else{
                C[i][j]=W[i][j];
            }
        }
    }
    int row[n],col[n];
    for(int i=0;i<n;i++){
        row[i]=n*n+i;
        col[i]=n*n+n+i;
    }
    int s=n*n+2*n, t=n*n+2*n+1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            G[row[i]][i*n+j]=P(1,C[i][j]);
            G[i*n+j][row[i]]=P(0,-C[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            G[i*n+j][col[j]]=P(1,0);
            G[col[j]][i*n+j]=P(0,0);
        }
    }
    for(int i=0;i<n;i++){
        G[s][row[i]]=P(1,0);
        G[row[i]][s]=P(0,0);

    }
    for(int j=0;j<n;j++){
        G[col[j]][t]=P(1,0);
        G[t][col[j]]=P(0,0);
    }
    int V=n*n+2*n+2;
    int dist[V],prev[V];
    for(int f=0;f<n;f++){
        fill(dist,dist+V,10000000);
        fill(prev,prev+V,-1);
        dist[s]=0;
        bool update=true;
        while(update){
            update=false;
            for(int v=0;v<V;v++){
                if(dist[v]==10000000) continue;
                for(auto e:G[v]){
                    int to,cap,cost;
                    to=e.first;
                    tie(cap,cost)=e.second;
                    if(!cap) continue;
                    if(dist[to]>dist[v]+cost){
                        dist[to]=dist[v]+cost;
                        prev[to]=v;
                        update=true;
                    }
                }
            }
        }
        mincost+=dist[t];
        for(int v=t;v!=s;v=prev[v]){
            G[prev[v]][v].first=0;
            G[v][prev[v]].first=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(!G[row[i]][i*n+j].first){
                ANS[i][j]='o';
            }
        }
    }
    // for(int i=0;i<n;i++)cout<<F[i]<<endl;
    // cout<<endl;
    // for(int i=0;i<n;i++)cout<<ANS[i]<<endl;
    // cout<<endl;
    vector<T> O;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(F[i][j]=='o'&&ANS[i][j]=='.'){
                O.emplace_back(i,j,"erase");
            }
            if(F[i][j]=='.'&&ANS[i][j]=='o'){
                O.emplace_back(i,j,"write");
            }
        }
    }
    cout<<mincost<<endl;
    cout<<O.size()<<endl;
    for(auto o:O){
        int r,c;
        string we;
        tie(r,c,we)=o;
        cout<<r+1<<' '<<c+1<<' '<<we<<endl;
    }

    return 0;
}

Measured memory_bytes: 6340
N = int(input())
x = []
hp = []
xa = 0
hpsum = 0

x = [int(e) for e in input().split()]
for i in range(N):
    xa += x[i]



xa = xa / N

if xa % 1 < 0.5:
    xa = int(xa / 1)
elif xa % 1 >= 0.5:
    xa = int(xa / 1 + 1)

for j in range(N):
    hp.append((x[j]-xa)*(x[j]-xa))
    hpsum += hp[j]

print(int(hpsum))

Measured memory_bytes: 9092
#include <cstdio>
#include <vector>

using namespace std;

#define long long long

typedef pair<int, int> pii;
#define fi first
#define se second

const long MOD = 1e9+7;
const int N = 302;

int n, m;
long f[N][N][N];
vector<pii> cond[N];

int Get(int i, int j, int k, int l)
{
    if (l <= k) return 3;
    if (l <= j) return 2;
    if (l <= i) return 1;
    return 0;
}

void Solve()
{
    long res = 0;
    f[0][0][0] = 1;
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= i; ++j)
            for (int k = 0; k <= j; ++k)
            {
                for (pii u: cond[i])
                    if (Get(i, j, k, u.fi) != u.se) f[i][j][k] = 0;
                
                f[i][j][k] %= MOD;
                if (i < n)
                {                    
                    f[i+1][j][k] += f[i][j][k];
                    f[i+1][i][k] += f[i][j][k];
                    f[i+1][i][j] += f[i][j][k];
                }
                else 
                    res += f[i][j][k];
            }
    printf("%lld",res % MOD);
}

int main()
{
    scanf("%d %d", &n, &m);
    while (m--)
    {
        int l, r, x;
        scanf("%d %d %d", &l, &r, &x);
        cond[r].push_back({l, x});
    }
    Solve();
    return 0;
}

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

int main() {
    ll N, K;
    cin >> N >> K;

    vector<pair<int, int>> A(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        A[i] = make_pair(x, y);
    }

    sort(A.begin(), A.end(), [](const auto &a, const auto &b) {
        return a.first < b.first;
    });

    ll bsum = 0;
    rep(i, N) {
        int a = A[i].first;
        int b = A[i].second;

        bsum += b;
        if (bsum >= K) {
            cout << a << endl;
            break;
        }
    }
}

Measured memory_bytes: 3960
if __name__ == "__main__":
    n, k = input().split()
    hate = input() if k == 1 else [x for x in input().split()]
    like = [str(x) for x in range(0, 10) if str(x) not in hate]

    found = False
    while not found:
        for i in range(len(n)):
            if len(like) < len(hate):
                if i == len(n) - 1 and n[i] in like:
                    found = True
                    break
                elif n[i] not in like:
                    break
            else:
                if i == len(n) - 1 and n[i] not in hate:
                    found = True
                    break
                if n[i] in hate:
                    break
        if not found:
            n = str(int(n) + 1)
    print(n)


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d %d", $A, $B);

if ($A + 10 >= $B) {
    for ($i = $A; $i <= $B; $i++) {
        if (!isset($ans)) {
            $ans = $i;
        } else {
            $ans = $ans ^ $i;
        }
    }
    echo $ans;
    exit;
}

$x = divceil($A, 4) * 4;
$y = intdiv($B, 4) * 4;

function divceil($dividend, $divisor) {
    return intdiv($dividend, $divisor) + ($dividend % $divisor !== 0);
}

for ($i = $A; $i < $x; $i++) {
    // echo "A " . $i . PHP_EOL;
    if (!isset($ans)) {
        $ans = $i;
    } else {
        $ans = $ans ^ $i;
    }
}

for ($i = $y; $i <= $B; $i++) {
    // echo "B " . $i . PHP_EOL;
    if (!isset($ans)) {
        $ans = $i;
    } else {
        $ans = $ans ^ $i;
    }
}

echo $ans;


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF (1e9+7)

using namespace std;

int tetra[200];
int odd_tetra[200];
int tetracount[1000000];
int oddcount[1000000];

int dfs(int target){
  if(target == 0) return 0;
  if(tetracount[target] != 0) return tetracount[target];
  int res = INF;
  REP(i, 200){
    if(tetra[i] > target) continue;
    if(tetra[i] == 0) break;
    res = min(res, dfs(target - tetra[i]) + 1);
  }
  tetracount[target] = res;
  return res;
}

int odddfs(int target){
  if(target == 0) return 0;
  if(oddcount[target] != 0) return oddcount[target];
  int res = INF;
  REP(i, 200){
    if(odd_tetra[i] > target) continue;
    if(odd_tetra[i] == 0) break;
    res = min(res, odddfs(target - odd_tetra[i]) + 1);
  }
  oddcount[target] = res;
  return res;
}

int main(){
  REP(i, 200) tetra[i] = i * (i+1) * (i+2) / 6;
  int cnt = 0;
  REP(i, 200) if(tetra[i] % 2) odd_tetra[cnt++] = tetra[i];
  sort(tetra, tetra+200, greater<int>());
  sort(odd_tetra, odd_tetra+200, greater<int>());
  int n;
  while(cin >> n and n) cout << dfs(n) << " " << odddfs(n) << endl;
  return 0;
}

Measured memory_bytes: 10628
#include <iostream>


using namespace std;
bool z[300];
int ans[300][300];
int main(){
  int h,w,k;cin>>h>>w>>k;
  char mp[h][w];
  
  for(int i = 0; h > i; i++){
    for(int j = 0;w > j; j++){
      cin>>mp[i][j];
      if(mp[i][j] == '#')z[i] = true;
    }
  }
  int nw = 1;
  for(int i = 0; h > i; i++){
    if(!z[i])continue;
    bool yet = false;
    for(int j = 0; w > j; j++){
      if(mp[i][j] == '#'){
        if(yet)nw++;
        yet = true;
      }
      ans[i][j] = nw;
      int m = 1;
      while(ans[i-m][j] == 0 && i-m >= 0){
        ans[i-m][j] = nw;
        m++;
      }
    }
    nw++;
  }
  bool gre = (ans[0][0] == 2);
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      if(ans[i][j] == 0)ans[i][j] = ans[i-1][j];
      cout << ans[i][j]-gre;
      if(j+1 != w)cout << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
from collections import deque

def bfs():
    d = [[-1] * C for i in range(R)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([])
    que.append((sy, sx))
    d[sy][sx] = 0

    while que:
        p = que.popleft()

        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            if 0<=nx<C and 0<=ny<R and maze[ny][nx] != '#' and d[ny][nx]== -1:
                que.append((ny, nx))
                d[ny][nx] = d[p[0]][p[1]] + 1
    
    Max_d = 0
    for d1 in d:
        Max_d = max(Max_d, max(d1))

    return Max_d



R, C = map(int, input().split())
maze = [list(input()) for _ in range(R)]
ans = 0

for i in range(R):
    for j in range(C):
        if maze[i][j] == ".":
            sy = i
            sx = j
            ans = max(ans, bfs())

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <chrono>

using namespace std;

unsigned int xor32(){
    static unsigned int y = 2463534242;
    y = y ^ (y << 13); y = y ^ (y >> 17);
    return y = y ^ (y << 5);
}

int main(){
    int D; cin >> D;
    vector<int> c(26, 0);
    for(auto& t : c) cin >> t;
    vector s(D, vector(26, 0));
    for(auto& v : s){
        for(auto& t : v) cin >> t;
    }
    vector<int> last(26, 0);
    vector<set<int>> days(26);
    for(int i=0;i<26;i++){
        days[i].insert(0);
        days[i].insert(D+1);
    }
    vector<int> select(D+1, -1);
    long long score = 0;
    for(int i=1;i<=D;i++){
        int t = -1;
        long long best = 0;
        for(int j=0;j<26;j++){
            long long cur = s[i-1][j];
            for(int k=0;k<26;k++){
                if(j==k) continue;
                cur -= c[k] * (i - last[k]);
            }
            if(t == -1 || best < cur){
                t = j;
                best = cur;
            }
        }
        days[t].insert(i);
        select[i] = t;
        last[t] = i;
        score += best;
    }
    const double startTemp = 50;
    const double endTemp = 5;
    auto res = select;
    double bestScore = score;
    auto start = chrono::system_clock::now();
    const double tl = 1900;
    while(true){
        auto cur = chrono::system_clock::now();
        auto time = chrono::duration_cast<chrono::milliseconds>(cur-start).count();
        if(time > tl) break;
        const double temp = time/tl * (endTemp - startTemp) + startTemp;
        for(int i=0;i<100000;i++){
            int d = xor32()%D + 1;
            int q = xor32()%26;
            long long sub = 0;
            sub -= s[d-1][select[d]];
            auto it = days[select[d]].find(d);
            --it;
            auto pre = *it;
            ++it; ++it;
            auto next = *it;
            sub += ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[select[d]];
            sub -= (next-pre)*(next-pre-1)/2 * c[select[d]];
            q = -1;
            long long sub2 = 0;
            int q2 = xor32()%26;
            while(q2 == select[d]) q2 = xor32()%26;
            for(int j=0;j<26;j++){
                if(j == select[d]) continue;
                it = days[j].lower_bound(d);
                next = *it;
                --it;
                pre = *it;
                long long curSub = s[d-1][j];
                curSub -= ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[j];
                curSub += (next-pre)*(next-pre-1)/2 * c[j];
                if(q == -1 || sub2 < curSub){
                    q = j;
                    sub2 = curSub;
                }
            }
            sub += sub2;
            if(sub > 0 || exp(0.01*sub)/temp > rand()%10000000*1e-7){
                days[select[d]].erase(d);
                days[q].insert(d);
                select[d] = q;
                score += sub;
                if(score > bestScore){
                    bestScore = score;
                    res = select;
                }
            }
        }
    }
    for(int i=1;i<=D;i++) cout << res[i]+1 << endl;
}

Measured memory_bytes: 4240
#include <stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	int i, j;
	int hit, blow;

	while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) {
		hit = blow = 0;
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j]) {
					if (i == j) {
						hit++;
					} else {
						blow++;
					}
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}

	return (0);
}

Measured memory_bytes: 596
def sget; gets.chomp; end
def iget; sget.to_i; end
def saget; gets.chomp.split; end
def iaget; saget.map {|a| a.to_i }; end

N, A = iaget
X = iaget
$memo = N.times.map { N.times.map { {} } }
def calc(pos, count, sum)
    if pos < N && ! $memo[pos][count][sum].nil?
        return $memo[pos][count][sum]
    end
    if pos >= N
        return (sum == count * A && count > 0) ? 1 : 0
    end
    return $memo[pos][count][sum] = calc(pos + 1, count, sum) + calc(pos + 1, count + 1, sum + X[pos])
end

puts calc(0, 0, 0)

Measured memory_bytes: 23420
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000
#define MOD 1000000007
#define ll long long
using namespace std;
ll n;
ll a[100000],b[100000];
int main(){
    cin>>n;
    ll cnt;
    rep(i,n) cin>>a[i]>>b[i];
    for (int i=n-1;i>=0;i--){
        ll j=(b[i]-(a[i]+cnt)%b[i])%b[i];
        cnt+=j;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	const int V_MAX = 100000;

	int n;
	cin >> n;

	vector<int> even(V_MAX + 1), odd(V_MAX + 1);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if ((i + 1) & 1) {
			odd[x]++;
		} else {
			even[x]++;
		}
	}

	int ma = INT_MIN, sec = 0, pos = 0;
	for (int i = 1; i <= 1e5; i++) {
		if (even[i] > ma) {
			sec = ma;
			ma = even[i];
			pos = i;
		} else {
			sec = max(sec, even[i]);
		}
	}

	int ans = 0;
	for (int i = 1; i <= 1e5; i++) {
		ans = max(ans, odd[i] + (i == pos ? sec : ma));
	}

	ans = n - ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
la=[]
lb=[]
for i in range(N):
    la.append(input())
for i in range(M):
    lb.append(input())

if N==M:
    f=1
    for i in range(N):
        if f==-1:
            break
        for j in range(N):
            if la[i][j]!=lb[i][j]:
                f=-1
                break
    if f==1:
        print("Yes")
    else:
        print("No")
else:
    f=0
    for i in range(N-M):
        if f==1:
            break
        for j in range(N-M):
            if f==1:
                break
            f=0
            for k in range(M):
                if f==-1:
                    break
                for l in range(M):
                    if la[i+k][j+l]!=lb[k][l]:
                        f=-1
                        break
                if k==M-1 and l==M-1 and f!=-1:
                    f=1
                    break
    if f==1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 38384
#include<stdio.h>

int main(void){
    
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if(a>b){
        printf("a > b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }
    
    return 0;
}


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

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

  int d, n;
  cin >> d >> n;

  int base = static_cast<int>(pow(100, d));
  int res = base * n;

  if (n == 100) res += base;
  cout << res << "\n";
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,p[100001];
  cin>>N;
  for (int i(1);i<=N;i++){
    cin>>p[i];
  }
  int cnt(0);
  int flag[100001] = {0};
  for (int i(1);i<=N;i++){
    if (i == p[i]){
      flag[i] = 1;
    }
  }
  for (int i(1);i<=N;i++){
    if (flag[i] == 1){
      if (i != N && flag[i+1] == 1){
        i++;
        cnt++;
      }else{
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <string>

using namespace std;

bool catChecker(string str){

	stack<char> cnt;

	for(int i=0;i<str.size();i++){
		char c=str.at(i);
		
		if(c=='m'){
			cnt.push(c);
		}else if(!cnt.empty()){
			if(c=='e' && cnt.top()=='m'){
				cnt.pop();
				cnt.push(c);
			}else if(c=='w' && cnt.top()=='e'){
				cnt.pop();
			}else{
				return false;
			}
		}else{
			return false;
		}
		
		if(i<str.size()-1 && cnt.empty()){
			return false;
		}
	}

	if(!cnt.empty()){
		return false;
	}
	
	return true;
}

int main(void){

	string str;

	while(cin>>str)
		if(catChecker(str)) cout << "Cat" << endl;
		else cout << "Rabbit" << endl;

	return 0;
}

Measured memory_bytes: 1188
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(sc.hasNext()) {
			int n = (int)sc.nextLong();
			out.println((n*n+n+2)>>1);
		}
		out.flush();
	}
}
	
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 17064
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, k, a);
    }
    static void getAns(int n, int k, int[] a)
    {
        var ok = 1000000000;
        var ng = 0;
        while (ok - ng > 1)
        {
            var mid = ng + (ok - ng) / 2;
            if (CanCut(n, k, a, mid)) ok = mid;
            else ng = mid;
        }
        Console.WriteLine(ok);
    }
    static bool CanCut(int n, int k, int[] a, int t)
    {
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] % t == 0) count += a[i] / t - 1;
            else count += a[i] / t;
            if (count > k) return false;
        }
        return true;
    }
}


Measured memory_bytes: 44244
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

std::vector<lint> c, s, f;

lint next_train(lint cur, lint st_num)
{
    if (cur <= s[st_num])
        return s[st_num];
    if (cur % f[st_num] == 0)
        return cur;
    return (cur / f[st_num] + 1) * f[st_num];
}

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

    for (int i = 0; i < n - 1; ++i)
    {
        lint ce, se, fe;
        scanf("%lld", &ce);
        scanf("%lld", &se);
        scanf("%lld", &fe);
        c.push_back(ce);
        s.push_back(se);
        f.push_back(fe);
    }

    for (int i = 0; i < n; ++i)
    {
        lint time = 0;
        for (int j = i; j < n - 1; ++j)
        {
            time = next_train(time, j);
            time += c[j];
        }
        printf("%lld\n", time);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%2==0)
	{
		cout<<"0.500000"; 
	}
	else
	{
	    double s;
		double a=n/2+1;
		n=n+0.000000;
		s=a/n; 
		cout<<fixed<<setprecision(6)<<s;	
	}
	return 0;
} 

Measured memory_bytes: 256
fun main() {
    val n = readLine()!!.toInt()
    var ac = 0
    var wa = 0
    var tle = 0
    var re = 0
    for (i in 0 until n) {
        when (readLine()!!) {
            "AC" -> ac++
            "WA" -> wa++
            "TLE" -> tle++
            "RE" -> re++
        }
    }

    println("AC x %d".format(ac))
    println("WA x %d".format(wa))
    println("TLE x %d".format(tle))
    println("RE x %d".format(re))
}

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

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	ll n,k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	vector<int> tel(0);
	map<int,int> mp;
	int ind = 0;
	int st =1;
	for(int i=1;i<=n;i++){
		if(mp[st]){
			ind = mp[st];
			break;
		}	
		mp[st]=i;
		tel.push_back(v[st-1]);
		st=v[st-1];
	}
	//for(int i:tel)cout << i << ' ';
	//cout <<endl;
	if(k<ind){
		cout << tel[k-1];
	}
	
	else{
		if(ind>=1)ind--;
		//cout <<ind <<endl;
		k-=ind;
		k--;
		int l = tel.size()-ind;
		//cout << k%l <<'\n';
		vector<int >a(tel.begin()+ind,tel.end());
		cout << a[k%l];
	}
}


Measured memory_bytes: 13924
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }

inline ll Msq(ll x){ return (x*x) %MOD; }
inline ll Mpot(ll x, ll e){
	if(!e) return 1;
	return Msq(Mpot(x, e>>1)) * (e & 1 ? x : 1)%MOD;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN = 2e5+5;

int n;
char s[MAXN];
int main(){
	scan(s);
	n = strlen(s);
	int ans=1;
	string lst="";
	lst.pb(s[0]);
	int i=1;
	while(i<n){
		string nw = "";
		nw.pb(s[i]);
		if(nw != lst){
			lst = nw;
			ans++;
			i = i+1;
		}else{
			if(i+1<n){
				nw = nw;
				nw.pb(s[i+1]);
				lst = nw;
				ans++;
				i = i+2;
			}else{
				i = n;
			}
		}
	}
	printf("%d\n", ans);

}


Measured memory_bytes: 384
using System;
public class Program{
  public static void Main(){
    int line = int.Parse(Console.ReadLine());
    int min = 1000;
    int max = 0;
    string[] line2 = Console.ReadLine().Split(' ');
    
    for (int i = 0; i < line; i++) {
      if(int.Parse(line2[i]) < min) min = int.Parse(line2[i]);
      if(max < int.Parse(line2[i])) max = int.Parse(line2[i]);
    }
    Console.WriteLine(max - min);
  }
}

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

typedef pair<int ,int> pii;
typedef pair<int ,pii > pipii;

void solve();
void range(int o);

int R;
int room[2][510][510];
int W[2],H[2],X[2],Y[2];
int cost[2][1000000];
int dx[] = {0,1,0,-1},dy[] = {1,0,-1,0};

int main()
{
    while(scanf("%d",&R),R)
    {
        for(int i = 0; i < 2; i++)
        {
            scanf("%d%d%d%d",&W[i],&H[i],&X[i],&Y[i]);
            for(int j = 1; j < H[i] + 1; j++)
            {
                for(int k = 1; k < W[i] + 1; k++)
                {
                    scanf("%d",&room[i][k][j]);
                }
            }
        }
        solve();
    }
}

void solve()
{
    int ans = 200000000;
    for(int i = 0; i < 2; i++)
    {
        range(i);
        /*for(int j = 0; j <= H[i] * W[i]; j++)
        {
            printf("%d ",cost[i][j]);
        }
        printf("\n");*/
    }
    for(int i = 0; i <= W[0] * H[0]; i++)
    {
        if(R - i <= W[1] * H[1]&& 0 <= R - i)
        {
            ans = min(ans,cost[0][i] + cost[1][R - i]);
        }
    }
    printf("%d\n",ans);
    return;
}

void range(int o)
{
    int cou = 1;
    cost[o][0] = 0;
    priority_queue<pipii, vector<pipii>, greater<pipii> > l;
    l.push(make_pair(room[o][X[o]][Y[o]],make_pair(X[o],Y[o])));
    while(l.size())
    {
        pipii now = l.top();
        l.pop();
        if(room[o][now.second.first][now.second.second] == 0)continue;
        cost[o][cou] = now.first;
        cou++;
        for(int j = 0; j < 4; j++)
        {
            int x = now.second.first + dx[j],y = now.second.second + dy[j];
            if(x <= 0 || W[o] < x || y <= 0 || H[o] < y || room[o][x][y] == 0)continue;
            l.push(make_pair(max(room[o][x][y],now.first),make_pair(x,y)));
            //printf("{%d %d}\n",x,y);
        }
        room[o][now.second.first][now.second.second] = 0;
    }
    return;
}

Measured memory_bytes: 8248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  string s;
  cin >> s;
  rep(i,0,3){
    cout << s[i];
  }
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
	"sort"
)

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

	d := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}
	sort.Ints(d)
	fmt.Println(d[n/2] - d[n/2-1])

}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
         
using namespace std;
 
#define ll  long long
#define mod 1000000007
#define pb push_back
#define pie 3.141592653589
#define inf 1e9


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

    

    ll i,n,n2,m,t,j,l,r,pos,mpos,f=0,k,p,n1,z,q,x,y,x1,y1,x2,y2,x3,y3,x4,y4,w;

    cin>>n>>m>>k;
    if(n>=k){
        n-=k;
        cout<<n<<" "<<m;
    }
    else
    {
        k-=n;
        n=0;
        m=max(n,m-k);
        cout<<n<<" "<<m;
    }

  return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N + 1):
        if Y - 10000 * i - 5000 * j >= 0 and i + j + (Y - 10000 * i - 5000 * j) // 1000 == N:
            print(i, j, (Y - 10000 * i - 5000 * j) // 1000)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
from operator import itemgetter


def solve(N: int, H: int, A: "List[int]", B: "List[int]"):
    B.sort(reverse=True)
    maxA = max(A)

    D = 0
    res = 0

    for b in B:
        if b <= maxA:
            break

        D += b
        res += 1
        if D >= H:
            print(res)
            return

    res += (H-D)//maxA + (1 if (H-D)%maxA > 0 else 0)
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, H, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11312
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {

    ios::sync_with_stdio(false); cin.tie(0);

    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    rep (i, n) cin >> a[i];

    int hozon = -1;
    rep (i, n - 1) {
        if (a[i] + a[i + 1] >= l) {
            hozon = i + 1;
            break;
        }
    }

    if (hozon == -1) cout << "Impossible" << '\n';
    else {
        cout << "Possible" << endl;
        for (int i = 1; i < hozon; i++) cout << i << '\n';
        for (int i = n - 1; i > hozon; i--) cout << i << '\n';
        cout << hozon << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int n;
    cin >> n;
    int d[n+1],f[n+1];
    int color[n+1];
    REPP(i,1,n+1) color[i] = 0;
    REPP(i,1,n+1) d[i] = -1;
    REPP(i,1,n+1) f[i] = -1;

    vector<queue<int> > graph(n+1);
    int tmp,idx,row;
    for(int i = 1; i < n+1;i++){
        cin >> idx >> row;
        for(int l = 0; l < row;l++){
            cin >> tmp;
            //  追加順はソート済みと仮定
            graph[i].push(tmp);
        }
    }

    stack<int> doing;
    int t = 0;

    for(int i = 1; i < n+1;i++){
        int now = i;
        if(color[i] == 0){
             doing.push(now);
             color[i] = 1;
             d[i] = ++t;
        }
        while(!doing.empty()){
            if(!graph[now].empty()){
                if(color[graph[now].front()] == 0){
                    color[graph[now].front()] = 1;
                    doing.push(graph[now].front());
                    int tmp = graph[now].front();
                    graph[now].pop();
                    now = tmp;
                    
                    t++;
                    d[now] = t;
                }else{
                    graph[now].pop();
                }
            }else{
                t++;
                f[now] = t;
                doing.pop();
                if(!doing.empty()){
                    now = doing.top();
                }
            }
        }
    } 

    for(int i = 1; i < n+1;i++){
        cout << i << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

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

    t.pop_back();
    if(s==t)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;

}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = (1 << 30);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];

    vi diff(n);
    ll av=0;
    rep(i,n){
        diff[i]=a[i]-b[i];
        if(diff[i]<0){
            av+=abs(diff[i]/2);
        }else{
            av-=diff[i];
        }
    }
    shows(diff);
    if(av<0){
        no;
    }else{
        yes;
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<vector<int>> d(10, vector<int>(10, 1000000));

void warshall_floyd(int n) {
    rep(k,n) rep(i,n) {
        rep(j,n) {
            d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        }
    }
}

int main()
{
    string s; cin >> s;
    int count = 0;
    rep1(i,s.length()) {
       if (s[i] != s[i-1])
           count++;
    }
    cout << count  << endl;
    return 0;
}


Measured memory_bytes: 3748
N,M=map(int,input().split())
L=[]
for i in range(N):
    A,B=map(int,input().split())
    L.append([A,B])
L.sort()
#print(L)

D=0
cost=0
for i in range(N):
    if D+L[i][1]<M:
        D+=L[i][1]
        cost+=L[i][1]*L[i][0]
    else:
        cost+=(M-D)*L[i][0]
        break
print(cost)
            

Measured memory_bytes: 20048