akhauriyash/Code-Regression huggingface dataset:
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    readb(n, W)
    int v[n+1], w[n+1];

    fori (i, 1, n) cin >> w[i] >> v[i];

    int dp[n + 1][W + 1] = {};

    fori (i, 1, n)
    {
        ford(j, W, 0)
            if(j - w[i] >= 0) dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j - w[i]]);
            else dp[i][j] = dp[i-1][j];
    }

    print(dp[n][W])

    return 0;
}


Measured memory_bytes: 82392
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

n=int(input())
C=[];S=[];F=[]
for i in range(n-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
for start in range(n-1):
    i=start
    time=S[start]
    while i < n-1:
        while time % F[i] != 0 or time<S[i]:
            time += 1
        time += C[i]
        i+=1
    print(time)
print(0)


Measured memory_bytes: 42716
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

public static class Program
{
    static void Main()
    {
        char[] S = Console.ReadLine().ToCharArray();
        char[] T = Console.ReadLine().ToCharArray();
        int []S_frequency = new int[26];
        int[] T_frequency = new int[26];
        for(int i = 0; i < 26; i++)
        {
            S_frequency[i] = 0;
            T_frequency[i] = 0;
        }
        for(int i = 0; i < S.Length; i++)
        {
            S_frequency[S[i] - 'a']++;
            T_frequency[T[i] - 'a']++;
        }
        Array.Sort(S_frequency);
        Array.Sort(T_frequency);
        String ans = "Yes";
        for(int i = 0; i < 26; i++)
        {
            if (S_frequency[i] != T_frequency[i]) { ans = "No"; }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 15328
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <math.h>
using namespace std;
typedef unsigned long ul;

void dec2bin(ul n,  vector<bool>& vb) {
    while (n > 0) {
        vb.push_back(n % 2 == 1);
        n /= 2;
    }
}

int main() {
    ul m, n;
    cin >> m >> n;

    ul X = 1000000007;

    vector<bool> vb;

    dec2bin(n, vb);

    vector<ul> vnMod(vb.size());
    for (size_t i = 0; i < vb.size(); ++i) {
        if (i == 0) {
            vnMod[i] = m;
        }
        else {
            ul prev = vnMod[i - 1];
            vnMod[i] = (prev * prev) % X;
        }
    }

    ul res = 1;
    for (size_t i = 0; i < vb.size(); ++i) {
        if (vb[i]) {
            res = (res * vnMod[i]) % X;
        }
    }

    cout << res << endl;

    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  
  cout << (S == "AAA" || S == "BBB" ? "No": "Yes") << endl;

  return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
if n==2:
  if x==2:
    print("Yes",1,2,3,sep="\n")
    exit()
  else:
    print("No")
    exit()
if x==1 or x==n*2-1:
  print("No")
  exit()
ans=[i for i in range(1,2*n)]
for i in range(len(ans)):
  ans[i]=(ans[i]-(n-x+1))%(2*n-1)+1
print("Yes",*ans,sep="\n")

Measured memory_bytes: 15700
import sys  # sys.exit()のために必要

# 入力
N = int(input())

# 処理
for i in range(100):    # ケーキを買う個数
  for j in range(100):  # ドーナツを買う個数
    s = i*4 + j*7       # 合計金額
    if s == N:          # 条件を満たす買い方を見つけた
      print("Yes")
      sys.exit(0)       # プログラムを終了
print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue>
#include <set> 
#include <stack>
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N; cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin >> v[i];

  sort(v.begin(),v.end());
  double ans = (double)v[0];
  for(int i = 0; i < N-1; i++){
    ans = (ans + (double)v[i+1]) /2;
  }

  printf("%.10f\n", ans);

  return 0;
}


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

int n, k, mx, ans, d, a[100005], m[100005];
int main() {
	int i;
	cin >> n >> k;
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	for(i=n-1; i>=0; i--) m[i] = max(m[i+1], a[i]);
	for(i=0; i<n; i++) {
		d = m[i] - a[i];
		if(d > mx) {
			mx = d;
			ans = 1;
		} else if (d == mx) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = []
X = []
Y = []
for _ in range(n):
    x,y = LI()
    xy.append([x,y])
    X.append(x)
    Y.append(y)
X.sort(reverse = True)
Y.sort(reverse = True)
ans = inf
for i in range(n):
    uy = Y[i]
    for j in range(i+1,n):
        dy = Y[j]
        for k in range(n):
            rx = X[k]
            for l in range(k+1,n):
                lx = X[l]
                cnt = 0
                for x,y in xy:
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)


Measured memory_bytes: 50436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << 2 * N << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    ll n;
    cin >> n;
    cout << n * (n-1) / 2 << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = static_cast<int>(2e+5);
static const int MIN = static_cast<int>(1e+9);

int main() {
	int R[MAX], n;

	cin >> n;

	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = 1 - MIN;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 3872
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i< (n);i++)
#define rep1(i,n) for(int i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const static ll MOD = (1e+9)+7;

struct city{
    int city_num = -1;
    P p_y;
    string ans = "000000000000";
    city(){}
    city(int i,int p,int y){
        city_num = i+1;
        p_y.first = p;
        p_y.second = y;
        string p_s = to_string(p);
        int j = 5;//県のstring管理
        for(int i = p_s.size()-1;i>-1;i--){
            ans[j--] = p_s[i];
        }
    }
    void set_num(int x){
        string tmp = to_string(x);
        int j = 11;//県のstring管理
        for(int i = tmp.size()-1;i>-1;i--){
            ans[j--] = tmp[i];
        }
    }
    bool operator<(const city &other)const{
        return p_y.second < other.p_y.second;
    }
};

bool id_ope(const city &a,const city &b){
    return a.city_num < b.city_num;
}

int main(){
    int N,M;cin>>N>>M;
    vector<vector<city>> pres(N+1);
    //1-originで行きます.
    rep(i,M){
        int tmp_p,tmp_y;cin>>tmp_p>>tmp_y;
        city C(i,tmp_p,tmp_y);
        pres[tmp_p].push_back(C);
    }
    rep1(i,N){
        //県ごとにソート
        sort(pres[i].begin(),pres[i].end());
        //これで県におけるyearで並びかえられる.
    }
    vector<city> citys;//ここに保存しておく.最後の出力用.
    rep1(i,N){
        //県ごとに成立順を与えていく.
        int num_dev = 1;
        for(city z:pres[i]){
            z.set_num(num_dev);
            num_dev++;
            citys.push_back(z);
        }
    }
    
    //最後に、市のIDごとにソートして識別番号を出力していく.
    sort(citys.begin(),citys.end(),id_ope);
    rep(i,M){
        cout<<citys[i].ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 19120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9; 
vector <ll> v;
void rec(ll cur){
    if(cur > 3234566667)
        return; 
    v.pb(cur);
    if(cur % 10 - 1 >= 0){
        rec(cur * 10 + cur % 10 - 1);
    }
    rec(cur * 10 + cur % 10);
    if(cur % 10 + 1 < 10){
        rec(cur * 10 + cur % 10 + 1);
    }
}
void solve(){
    ll n;
    cin >> n;
    
    for(int i = 1; i <= 9; ++i) {
        rec(i);
    }
    sort(all(v));
    cout << v[n - 1];

}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 1400
import java.util.Scanner;

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

  int[][] ans = new int[300][2];
  int i = 0;
    while (true) {
      int h, w;
      h = stdInt.nextInt();
      w = stdInt.nextInt();
      if (h == 0 && w == 0) break;
      ans[i][0] = h;
      ans[i++][1] = w;
    }

    for (int j = 0; j < i; j++) {
      for (int k = 0; k < ans[j][0]; k++) {
        for (int l = 0; l < ans[j][1]; l++) {
          if (k==0 || k==ans[j][0]-1 || l == 0 || l == ans[j][1] - 1) {
            System.out.print("#");
          } else {
            System.out.print(".");
          }
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    
    int cnt_white = 0;
    int cnt_black = 0;
    for(int i = 0; i < n; i++)
    {
        if (s.at(i) == '.') cnt_white++;
    }
    
    int ans = cnt_white;
    for(int i = 0; i < n; i++)
    {
        if (s.at(i) == '.') cnt_white--;
        else cnt_black++;
                
        ans = min(ans, cnt_white + cnt_black);

    }
    cout << ans << endl;
}   

Measured memory_bytes: 640
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize
    }
    let tbl = factor_table(55555);
    let mut ans = Vec::new();
    for i in 2..tbl.len() {
        if i == tbl[i] && i % 10 == 1 {
            ans.push(i);
        }
    }

    for v in ans.iter().take(n) {
        print!("{} ", v);
    }
    

}

#[allow(dead_code)]
pub fn factor_table(max_n: usize) -> Vec<usize> {
    let mut res = vec![0; max_n + 1];
    for i in 2..max_n + 1 {
        if res[i] == 0 {
            let mut j = i;
            while j <= max_n {
                res[j] = i;
                j += i;
            }
        }
    }
    res
}

Measured memory_bytes: 2516
n = int(input())
s = [input() for _ in range(n)]

m = [name for name in s if name[0] == "M"]
a = [name for name in s if name[0] == "A"]
r = [name for name in s if name[0] == "R"]
c = [name for name in s if name[0] == "C"]
h = [name for name in s if name[0] == "H"]

march = [len(m),len(a),len(r),len(c),len(h)]
march = [i for i in march if i!= 0]

if len(march) < 3:
  print(0)
  exit()

result = 0
for i in range(len(march)):
  for j in range(len(march)):
    for k in range(len(march)):
      if i != j and j != k and k != i:
        result += march[i]*march[j]*march[k]

print(int(result/6))

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int h, w;
    cin >> h >> w;

    vector<vector<int>> as(h, vector<int>(w, 0));
    vector<vector<int>> bs(h, vector<int>(w, 0));

    rep(y, h)rep(x, w) cin >> as[y][x];
    rep(y, h)rep(x, w) cin >> bs[y][x];

    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(12801, false)));
    dp[0][0][abs(as[0][0] - bs[0][0])] = true;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            if (x == 0 && y == 0) continue;
            if (x != 0) {
                for (int i = 0; i <= 12800; i++) {
                    if (!dp[y][x - 1][i]) {
                        continue;
                    }
                    int next_1 = i + abs(as[y][x] - bs[y][x]);
                    int next_2 = abs(i - abs(as[y][x] - bs[y][x]));
                    dp[y][x][next_1] = true;
                    dp[y][x][next_2] = true;
                }
            }

            if (y != 0) {
                for (int i = 0; i <= 12800; i++) {
                    if (!dp[y - 1][x][i]) {
                        continue;
                    }
                    int next_1 = i + abs(as[y][x] - bs[y][x]);
                    int next_2 = abs(i - abs(as[y][x] - bs[y][x]));
                    dp[y][x][next_1] = true;
                    dp[y][x][next_2] = true;
                }
            }


        }
    }

    for (int i = 0; i < 12800; i++) {
        if (dp[h - 1][w - 1][i]) {
            cout << i << endl;
            return 0;
        }
    }

}

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

using namespace std;

signed main () {
  int n; cin >> n;
  vector <unsigned long long> a(n+2);
  a[0] = 2, a[1] = 1, a[2] = 3;
  //if (n == 86) cout << "939587134549734843", exit(0);
  if (n <= 2) cout << a[n], exit(0);
  for (int i = 2; i <= n+1; ++i) {
  	a[i] = a[i-1] + a[i-2];
  }
  cout << a[n];
}

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

int main()
{
  int w, h, n;
  cin >> w >> h >> n;
  vector<int> x(n), y(n), a(n);
  for (int i=0; i<n; i++)
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  
  vector<vector<int>> tile(h, vector<int>(w));
  
  for (int i=0; i<n; i++) {
    if (a.at(i)==1) {
      for (int j=0; j<h; j++) {
        for (int k=0; k<x.at(i); k++) {
          tile.at(j).at(k) = 1;
        }
      }
    }
    else if (a.at(i)==2) {
      for (int j=0; j<h; j++) {
        for (int k=x.at(i); k<w; k++) {
          tile.at(j).at(k) = 1;
        }
      }
    }
     else if (a.at(i)==3) {
      for (int j=0; j<y.at(i); j++) {
        for (int k=0; k<w; k++) {
          tile.at(j).at(k) = 1;
        }
      }
    }
    else {
      for (int j=y.at(i); j<h; j++) {
        for (int k=0; k<w; k++) {
          tile.at(j).at(k) = 1;
        }
      }
    }
  }
  
  int cnt = 0;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (tile.at(i).at(j) == 0) cnt++;
    }
  }
  cout << cnt << endl;
  
  
 
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    HashMap<String, Integer> map = new HashMap<String, Integer>();
    for(int i = 0; i < h; i++) {
      String s = sc.next();
      for(int j = 0; j < w; j++) {
        String str = String.valueOf(s.charAt(j));
        if(map.containsKey(str)) {
          map.put(str, map.get(str) + 1);
        } else {
          map.put(str, 1);
        }
      }
    }
    String ans = "Yes";
    if((h % 2 == 0) && (w % 2 == 0)) {
      ans = "Yes";
      for(String s : map.keySet()) {
        if((map.get(s) % 4) != 0) {
          ans = "No";
          break;
        }
      }
    }
    if((h % 2 == 1) && (w % 2 == 0)) {
      ans = "Yes";
      int d = 0;
      for(String s : map.keySet()) {
        if((map.get(s) % 2) != 0) {
          ans = "No";
          break;
        }
        if((map.get(s) % 4) == 2) {
          d++;
        }
      }
      if(d > (w / 2)) ans = "No";
    }
    if((h % 2 == 0) && (w % 2 == 1)) {
      ans = "Yes";
      int d = 0;
      for(String s : map.keySet()) {
        if((map.get(s) % 2) != 0) {
          ans = "No";
          break;
        }
        if((map.get(s) % 4) == 2) {
          d++;
        }
      }
      if(d > (h / 2)) ans = "No";      
    }
    if((h % 2 == 1) && (w % 2 == 1)) {
      ans = "No";
      int d = 0;
      int kisuu = 0;
      int k = 0;
      for(String s : map.keySet()) {
        if((map.get(s) % 2) != 0) {
          kisuu++;
          k = map.get(s);
        }
        if((map.get(s) % 4) == 2) {
          d++;
        }
      }
      if(((k - 1) % 4) == 2) d++;
      if((kisuu == 1) && (d <= ((h / 2) + (w / 2)))) ans = "Yes";
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int kotae=0;
    for(int i=0;i<n;i++){
      string a=s.substr(0,i);
      string b=s.substr(i,n-i);
      //cout<<a<<" "<<b<<endl;
      map<char,int>mp;
      for(int j=0;j<a.size();j++){
        if(mp.count(a[j])){}
        else mp[a[j]]=1;
      }
      int kazu=0;
      sort(b.begin(),b.end());
      for(int j=0;j<b.size();j++){
        if(j!=0){
          if(b[j]==b[j-1])continue;
        }
        if(mp.count(b[j]))kazu++;
      }
      kotae=max(kazu,kotae);
    }
  
  cout<<kotae<<endl;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;
   int m;
  
   cin >> n >> m;
   int sum = m*2+1;
  
  if(n%sum>0){
    
   cout << n/sum+1 << endl;
    
  }else{
    cout << n/sum << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string a, b, c;

int main() {
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << ln;
}

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

int main()
{
    char s[5], a[] = "AAA", b[] = "BBB";
    scanf("%s", s);
    if(!strcmp(s, a) || !strcmp(s, b))
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

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

const int maxn = 1005;
int H, W;
char grid[maxn][maxn];
const int M = 1e9+7;

void madd(int& a, int b) {
    a = (a+b) % M;
}

int dp[maxn][maxn];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
        }
    }

    dp[H-1][W-1] = 1;
    for (int i = H - 1; i >= 0; i--) {
        for (int j = W - 1; j >= 0; j--) {
            if (grid[i+1][j] != '#') madd(dp[i][j],dp[i+1][j]);
            if (grid[i][j+1] != '#') madd(dp[i][j],dp[i][j+1]);
        }
    }
    cout << dp[0][0] << '\n';

    return 0;
}



Measured memory_bytes: 5248
while True:
    try:
        s = 0
        inp = input().split("=")
        f = inp[0].split("+")
        if (len(f[0]) > 1 and f[0][0] == "X") or (len(f[1]) > 1 and f[1][0] == "X") or (len(inp[1]) > 1 and inp[1][0] == "X"):
            s = 1
        for i in range(s,10):
            left = eval(inp[0].replace("X",str(i)))
            right = int(inp[1].replace("X",str(i)))
            if left == right:
                print(i)
                break
        else:
            print("NA")
    except:
        break



Measured memory_bytes: 5612
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

void solve();

int main() {
  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

void solve() {
  ini(r, g, b);
  if ((100 * r + 10 * g + b) % 4 == 0)
    out("YES");
  else
    out("NO");
}


Measured memory_bytes: 3548
import sys
import collections
ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n = ri()
a = rl()
c = collections.Counter(a)
t = 0
for v in c.values():
    t += v*(v-1)//2

for i in a:
    print(t-c[i]+1)


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

using namespace std;
#define ll long long
#define f(i,l,u) for(ll i=l;i<u;i++)
int main() {
    ll n;
    cin>>n;
ll a[n+1];


f(i,0,n)
cin>>a[i];

ll buy=1;
ll temp=0;
ll qty;
ll bal=1000;
while(temp<n)
{
    if(buy)
    {
        while(a[temp+1]<=a[temp])
        {
            temp++;
            if(temp==n-1)
            break;
        }
        if(temp==n-1)
        break;
        else
        {
          // / cout<<"buyed at "<<a[temp]<<endl;
    
            qty=bal/a[temp];
            bal-=qty*a[temp];
                      //  cout<<"avail bal= "<<bal<<endl;
            buy=0;
            
        }
        
    }
    else
    {
        while(temp<n-1&&a[temp+1]>=a[temp])
        {
            temp++;
        }
        
        
        buy=1;
        bal+=qty*a[temp];
    //    cout<<"sold at "<<a[temp]<<endl;
    //    cout<<"avail bal= "<<bal<<endl;
        
    }
    
}
cout<<bal<<endl;


}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	int ans;
	
	while (1) {
		scanf("%d", &a);
		getchar();
		scanf("%c", &op);
		getchar();
		scanf("%d", &b);
		
		if (op == '?') break;
		
		switch(op) {
			case '+': ans = a + b; break;
			case '-': ans = a - b; break;
			case '*': ans = a * b; break;
			case '/': ans = a / b; break;
		}
		
		getchar();
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int ans = 0;
        if (str.contains("RRR")) {
            ans = 3;
        } else if (str.contains("RR")) {
            ans = 2;
        } else if (str.contains("SSS")) {
            ans = 0;
        } else {
            ans = 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35368
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<char> S(N);
	vector<int>sw(N),se(N);
	for(int i=0;i<N;i++){
		cin>>S[i];
	}
	int cntW=0,cntE=0;
/*	if(S[0]=='W'){
		cntW=1;
	}else{
		sw[0]=0;
	}
	if(S[N-1]=='E'){
		cntE=1;
		se[N-1]=1;
	}else{
		se[N-1]=0;
	}
*/
	
	for(int i=0;i<N;i++){
		if(S[i]=='W'){
			cntW++;
		}
		if(S[N-i-1]=='E'){
			cntE++;
		}
		sw[i]=cntW;
		se[N-i-1]=cntE;
	}
	
	int ans=1e6;
	for(int i=0;i<N;i++){
		int tmp1=sw[i],tmp2=se[i];
		if(S[i]=='W'){
			tmp1--;
		}else{
			tmp2--;
		}

		//cout<<tmp1<<" "<<tmp2<<endl;
		
		ans=min(ans,tmp1+tmp2);
		
		
		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    ll n, m;
    cin >> n >> m;
    if(2*n > m){
        cout << m/2 << endl;
    }else{
        cout << n + (m - 2*n)/4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
antannas = [int(input()) for _ in range(5)]
k = int(input())
count = 0
for i in range(5):
    for j in range(i+1, 5):
        if antannas[j] - antannas[i] <= k:
            count += 1
if count == 10:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct Point {
    int x,y; ll h;
};

int main(){
    int N; cin >> N;
    vector<ll> H(N);
    for (int i = 0; i < N; i++){
        cin >> H[i];
    }
    int mx = 0,tmp = 0;
    for (int i = 0; i < N-1; i++){
        if (H[i] >= H[i+1]){
            tmp++;
        } else {
            mx = max(tmp,mx);
            tmp = 0;
        }
    }
    mx = max(mx,tmp);
    cout << mx << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  ll n,a[300000],m,b[300000],x[300000];
  cin >> n;
  rep(i,n)cin >>a[i];
  rep(i,n){
           a[i]-=i+1;
          }
  rep(i,n)b[i]=a[i];
  sort(b,b+n);
  m=n/2;
  FOR(j,m-5,m+5){
    rep(i,n)x[j-m+5]+=abs(a[i]-b[j]);
  }
  sort(x,x+10);
  printf("%lld",x[0]);
}

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

#define H 1401
#define W 1401

int A[H+1][W+1];
int Hist[H+1][W+1];

struct Rectangle {
    int height;
    int pos;
};

int getLargestRectangle(int h, int w) {
    for (int i = 0; i < h+1; i++) Hist[i][0] = 0;
    for (int j = 0; j < w+1; j++) Hist[0][j] = 0;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (A[i][j] == 1) {
                Hist[i][j] = 0;
            } else {
                Hist[i][j] = Hist[i-1][j] + 1;
            }
        }
    }

    int largest = 0;
    stack<Rectangle> S;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (S.empty()) {
                S.push({Hist[i][j], j});
            } else if (S.top().height < Hist[i][j]) {
                S.push({Hist[i][j], j});
            } else if (S.top().height > Hist[i][j]) {
                int lastPos;
                while (!S.empty() && S.top().height > Hist[i][j]) {
                    Rectangle rect = S.top();
                    S.pop();
                    if (largest < rect.height * (j - rect.pos)) {
                        largest = rect.height * (j - rect.pos);
                    } 
                    lastPos = rect.pos;
                }
                S.push({Hist[i][j], lastPos});
            }
        }
        
        if (!S.empty()) {
            while (!S.empty()) {
                Rectangle rect = S.top();
                S.pop();
                if (largest < rect.height * (w - rect.pos + 1)) {
                    largest = rect.height * (w - rect.pos + 1);
                } 
            }
        }
    }

    return largest;
}

int main() {
    int h, w;
    cin >> h >> w;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < h+1; i++) A[i][0] = 0;
    for (int j = 0; j < w+1; j++) A[0][j] = 0;

    cout << getLargestRectangle(h, w) << endl;

    return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 200

i64 N, L;
i64 A[MAX_N + 1]; // 1-indexed

int main() {
  cin >> N >> L;

  i64 s_all = 0;
  REPS(i, N) {
    cin >> A[i];
    s_all += L + i - 1;
  }

  i64 min_diff = 10000000;
  i64 nearest;
  REPS(i, N) {
    i64 taste = s_all - (L + i - 1);
    if (abs(taste - s_all) < min_diff) {
      min_diff = abs(taste - s_all);
      nearest = taste;
    }
  }
  cout << nearest << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  switch(n%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout<<"hon"<<endl;
      return 0;
    case 0:
    case 1:
    case 6:
    case 8:
      cout<<"pon"<<endl;
      return 0;
    case 3:
      cout<<"bon"<<endl;
      return 0;
  }
  return 0;
}


Measured memory_bytes: 3632
l = input().split()

a = int(l[0])
b = int(l[1])
palindrome = 0
for num in range(a,b+1):

    num = str(num)
    cnt = 0

    for i in range(2):
        if num[i] == num[4-i]:
            cnt += 1
    if cnt == 2:
        palindrome += 1

print(palindrome)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define inf         1000000007
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
using namespace std;
int main()
{
	FastIO;
	double a;
	cin >> a;
	cout << 2.0 * pi * a << endl;
	return 0;
}


Measured memory_bytes: 3752
import numpy as np
N, M = map(int, input().split())
data = np.zeros((4, M))

for i in range(M):
    data[0, i] = i+1
    data[1:3, i] = list(map(int, input().split()))

city = [0 for i in range(N)]
data = data[:, np.argsort(data[2, :])]
for i in range(M):
    city[int(data[1, i]-1)] += 1
    data[3, i] = city[int(data[1, i]-1)]

data = data[:, np.argsort(data[0, :])]
for i in range(M):
    tmp = str(int(data[1, i])).zfill(6) + str(int(data[3, i])).zfill(6)
    print(tmp)


Measured memory_bytes: 27732
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <fstream>

using namespace std;

const int N = 2e5 + 5;
int n, m;
int ans;
int a[N];
int cnt[N];
int cover[N];

int main() 
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] - cnt[a[i]] >= 1)
		{
			cover[a[i] - cnt[a[i]]]++;
		}
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; i++)
	{
		if (cover[i] == 0)
		{
			ans++;
		}
		//cout << cover[i] << " ";
	}
	//cout << endl;
	for (int i = 0; i < m; i++)
	{
		int x,  y;
		cin >> x >> y;
		x--;
		cnt[a[x]]--;
		if (a[x] - cnt[a[x]] >= 1)
		{
			cover[a[x] - cnt[a[x]]]--;
			if (cover[a[x] - cnt[a[x]]] == 0)
			{
				ans++;
			}
		}
		a[x] = y;
		if (a[x] - cnt[a[x]] >= 1)
		{
			cover[y - cnt[y]]++;	
			if (cover[a[x] - cnt[a[x]]] == 1)
			{
				ans--;
			}
		}
		cnt[y]++;
		cout << ans << endl;
	}


	
}






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

int main()
{
	unsigned long long n,a,b,s1,s2;
	cin>>n>>a>>b;
	s1=n/(a+b);
	s1*=a;
	s2=n%(a+b);
	if(s2<=a)
		s1+=s2;
	else
		s1+=a;
	cout<<s1;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long s,t,k;
    cin>>s>>t>>k;
    if(k>s)
    {
        k=k-s;
        s=0;
        if(k>t)
            t=0;
        else
            t=t-k;
    }
    else
    {
        s=s-k;
    }

    cout<<s<<" "<<t<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#define STR_MAX 1025

int main () {
  int n;
  int data[ 10 ][ 6 ] = {
    { 0,   0,   0,   0,   0,   0 },
    { 5, '.', ',', '!', '?', ' ' },
    { 3, 'a', 'b', 'c',   0,   0 },
    { 3, 'd', 'e', 'f',   0,   0 },
    { 3, 'g', 'h', 'i',   0,   0 },
    { 3, 'j', 'k', 'l',   0,   0 },
    { 3, 'm', 'n', 'o',   0,   0 },
    { 4, 'p', 'q', 'r', 's',   0 },
    { 3, 't', 'u', 'v',   0,   0 },
    { 4, 'w', 'x', 'y', 'z',   0 }
  };
  scanf( "%d", &n );
  for( int i = 0; i < n; i++ ) {
    char instr[ STR_MAX ];
    char outstr[ STR_MAX ];
    int si = 0;
    int counter = 1;
    int tmp = 0;
    scanf( "%s", instr );
    for( int j = 0; instr[ j ] != '\0'; j++ ) {
      if( instr[ j ] == '0' ) {
        if( counter != 1 ){
          outstr[ si++ ] = tmp;
        }
        counter = 1;
        continue;
      }
      if( counter == data[ instr[ j ] - '0' ][ 0 ] + 1 ) {
        counter = 1;
      }
      tmp = data[ instr[ j ] - '0' ][ counter++ ];
    }
    outstr[ si++ ] = '\0';
    puts( outstr );
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> dp(10001);
ll mod=1000000007;
ll trav(ll cur)
{
	if(cur==0)
	return 1;
	else if(cur<3)
	return 0;
	else if(dp[cur]!=0)
	return dp[cur]%mod;
	else
	{
		ll x=0;
		for(ll i=3;i<=cur;i++)
		{
			x=(x%mod+(trav(cur-i))%mod)%mod;
		}
		dp[cur]=x%mod;
		return x;
	}
}
int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	ll ans=trav(n);
	cout<<ans%mod<<endl;
	return 0;
}


Measured memory_bytes: 3700
import java.util.Scanner;


 class  Main {
    static public  void  main (String[] av){
     int  b;
     int sum=0;
        Scanner sc =new Scanner(System.in);
        int n =sc.nextInt();
        int a[]= new int[n];
        int v;
        for(int  i=0;i<n;i++){
            v=sc.nextInt();
            a[i]=v;
        }
        
int n2=sc.nextInt();
for (int i=0;i<n2;i++){
    int x=sc.nextInt();
    for (int j=0;j<n;j++){
    if (a[j]==x){
        sum++;
        break;
    }
}
}
System.out.println(sum);


        }

}


Measured memory_bytes: 39896
import java.io.IOException;
import java.io.InputStream;
import java.util.AbstractMap;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		final long INF = Long.MAX_VALUE;
		long[] dp = new long[100010];
		long[] h = new long[100010];

		FastScanner fc = new FastScanner();
		int N = fc.nextInt();

		// 初期化
		for (int i = 0; i < 100010; i++) {
			dp[i] = INF;
		}
		for (int i = 0; i < N; i++) {
			h[i] = fc.nextLong();
		}

		// 初期条件を設定
		dp[0] = 0;
		dp[1] = Math.abs(h[0] - h[1]);

		for (int i = 2; i < N; i++) {
			dp[i] = chmin(dp[i], dp[i-1] + Math.abs(h[i] - h[i-1]));
			dp[i] = chmin(dp[i], dp[i-2] + Math.abs(h[i] - h[i-2]));
		}

		System.out.println(dp[N-1]);
	}

	public static  long chmin(long a, long b) {
		if (a > b) {
			return b;
		}
		return a;
	}

	public static long chmax(long a, long b) {
		if (a < b) {
			return b;
		}
		return a;
	}

	static 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;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
			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();
		}

		/**
		 *
		 * @return 次のLong
		 */
		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();
			}
		}

		/**
		 *
		 * @return 次のInt
		 */
		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		/**
		 *
		 * @return 次のDouble
		 */
		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
		/** serialVersionUID. */
		private static final long serialVersionUID = 6411527075103472113L;

		public Pair(final K key, final V value) {
			super(key, value);
		}
	}

}


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

signed main()
{
  int W, H, N;
  cin >> W >> H >> N;

  int cnt = 0;
  
  for (int i = 0; i < N; i++){
    int w[2], h[2];
    cin >> w[i % 2] >> h[i % 2];

    if (i > 0){
      if ((w[0] - w[1]) * (h[0] - h[1]) > 0){
        cnt += max(abs(w[0] - w[1]), abs(h[0] - h[1]));
      }
      else {
        cnt += abs(w[0] - w[1]) + abs(h[0] - h[1]);
      }
    }
  }

  cout << cnt << endl;

  return (0);
}

Measured memory_bytes: 3088
use proconio::*;
use std::collections::BinaryHeap;

fn main() {
    input! {
        t: usize,
    };

    for _ in 0..t {
        input! {
            n: usize,
        };

        let mut l_cml = vec![];
        let mut r_cml = vec![];
        let mut ans = 0;
        for _ in 0..n {
            input! {
                k: usize,
                l: usize,
                r: usize,
            };

            if r < l {
                ans += r;
                l_cml.push((k, l - r));
            } else {
                ans += l;
                r_cml.push((n - k, r - l));
            }
        }

        let f = |cmls: Vec<(usize, usize)>| -> usize {
            let mut heap = BinaryHeap::new();
            let mut ccml = vec![vec![]; n + 1];
            let mut res = 0;
            for cml in cmls {
                ccml[cml.0].push(cml.1);
            }
            for cml in ccml.into_iter().skip(1).rev() {
                for g in cml {
                    heap.push(g);
                }

                res += heap.pop().unwrap_or(0);
            }

            res
        };

        ans += f(l_cml);
        ans += f(r_cml);

        println!("{}", ans);
    }
}


Measured memory_bytes: 15840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] t = new int[n];
			for(int i = 0 ; i < n ; i++) {
				t[i] = sc.nextInt();
			}
			int m = sc.nextInt();
			int[] p = new int[m];
			int[] x = new int[m];
			for(int i = 0 ; i < m ; i++) {
				p[i] = sc.nextInt();
				x[i] = sc.nextInt();
			}
			for(int i = 0 ; i < m ; i++) {
				int ans = 0;
				for(int j = 0 ; j < n ; j++) {
					if(p[i] == j + 1) {
						ans += x[i];
					} else {
						ans += t[j];
					}
				}
				System.out.println(ans);
			}
		}

	}

}


Measured memory_bytes: 23124
using System;
using System.Linq;

namespace A {
    class Program {
        
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int counter = 0;
            for(int i = 1; i < N; ++i) {
                if(a[i] == a[i - 1]) {
                    a[i] = 10000 + i;
                    ++counter;
                }
            }

            Console.WriteLine(counter);
        }
    }
}


Measured memory_bytes: 13268
def solve(data, x, y)
  range = -3..3
  if data[y][x] == 1
    data[y][x] = 0
    #横に走査
    range.each do |r|
      next if x + r < 0 || x + r > 7
      if data[y][x + r] == 1
        data = solve(data, x + r, y)
      end
    end
    #縦に走査
    range.each do |r|
      next if y + r < 0 || y + r > 7
      if data[y + r][x] == 1
        data = solve(data, x, y + r)
      end
    end
  end
  data
end

($stdin.gets.to_i).times do |t|
  $stdin.gets
  data = Array.new
  8.times do |i|
    data << $stdin.gets.chomp.split("").map(&:to_i)
  end

  x =$stdin.gets.to_i - 1
  y =$stdin.gets.to_i - 1
  printf "Data %d:\n", t + 1
  data = solve(data, x, y)
  8.times do |i| puts data[i].join
  end
end

Measured memory_bytes: 6200