akhauriyash/Code-Regression huggingface dataset:
L, R = map(int, input().split())

reg = 2018
if R-L >= 3000:
    print(0)
else:
    for l in range(L, R):
        for r in range(l+1, R+1):
            tmp = (l * r) % 2019
            reg = min(reg, tmp)
    print(reg)

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

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if(H % h == 0 && W % w == 0) {
		cout << "No";
		return 0;
	}
	cout << "Yes\n";
	int rem = H * W - (H / h * h) * (W / w * w);
	int x = (H / h) * (W / w);
	x = (x + rem - 1) / rem;
	x++;
	for(int i = 1; i <= H; i++, cout << endl)
		for(int j = 1; j <= W; j++)
			cout << (i % h == 0 && j % w == 0? (-h) * w * x - 1 + x: x) << ' ';
}


Measured memory_bytes: 1280
a, b, k = map(int, input().split())

a_upper = min(b, a+k-1)
b_lower = max(a, b-k+1)

u = set(range(a, a_upper+1))
v = set(range(b_lower, b+1))

for i in sorted(list(u | v)):
    print(i)


Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+1;

struct BIT {
   vector<ll> bit;
   ll n;
   BIT(ll n=0):n(n),bit(n+1){}
 
   // 一点更新です
   void add(ll x, ll w) {
     for (x++; x <= n; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   ll sum(ll x) {
     ll ret = 0;
     for (x++; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    if(n==1){
        cout << a[0] << endl;
        return 0;
    }
    ll le=0,ri=INF;
    while(ri-le>1){
        ll mid=(ri+le)/2;
        vector<ll> v(n),s(n);
        rep(i,n){
            if(a[i]>=mid){
                v[i]=1;
            }
            else{
                v[i]=-1;
            }
        }
        rep(i,n){
            if(i){
                s[i]=s[i-1]+v[i];
            }
            else{
                s[i]=v[i];
            }
        }
        ll total=0;
        BIT b(n+n+10);  // これまでの数字がどんな風になってるのかをメモる為のBIT
        b.add(n+1,1LL);
        for (ll i = 0; i < n; i++) {
            total += i+1- b.sum(s[i]+n+1); // BITの総和 - 自分より左側 ＝ 自分より右側
            b.add(s[i]+n+1, 1LL); // 自分の位置に1を足す
            //cout << total << " ";
        }
        if((n+1)*n/2-total>=(n+1)*n/4) le=mid;
        else ri=mid;
        //cout << mid << " " << total << endl;
    }
    cout << le << endl;
    return 0;
} 

Measured memory_bytes: 4212
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    ans = float('inf')
    for i in range(len(s)-2):
        if i == len(s)-3:
            ans = min(ans, abs(int(s[i:]) - 753))
        else:
            ans = min(ans, abs(int(s[i:i+3]) - 753))
    print(ans)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 9060
class ABC135:
    def __init__(self):
        pass

    def solve(self, A, B):
        if((A + B) % 2 == 0):
            print((A+B)//2)
        else:
            print("IMPOSSIBLE")

if __name__ == '__main__':
    A, B = map(int, input().split())
    problem = ABC135()
    problem.solve(A, B)


Measured memory_bytes: 2940
N, M = map(int, input().split())
road_counts = {i: 0 for i in range(1, N + 1)}
for _ in range(M):
    a, b = map(int, input().split())
    road_counts[a] += 1
    road_counts[b] += 1

[print(road_counts[k]) for k in road_counts]


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int ans = 0;
		int tmp = 1;
		while(tmp<B) {
			ans++;
			tmp += A-1; 
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include <bits/stdint-intn.h>
#include <cstdint>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int64_t gcd(int64_t a, int64_t b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

int main() {
  int n, p;
  std::cin >> n >> p;
  std::vector<int> x(n);
  rep(i, n) std::cin >> x[i];

  if (n == 1) {
    std::cout << abs(p - x[0]) << std::endl;
    return 0;
  }

  int d = abs(x[0] - p);
  for (int i = 0; i < n; ++i) {
    d = gcd(d, abs(x[i] - p));
  }

  std::cout << d << std::endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
string in;
int beg=-1,en;
int main(){
    cin>>in;
    for(int i=0;i<in.length();++i){
        if(in[i]=='A'&&beg==-1){
            beg=i;
        }else if(in[i]=='Z'){
            en=i;
        }
    }
    cout<<en-beg+1<<endl;
    return 0;
}

Measured memory_bytes: 640
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int x;
	cin >> x;
	cout << 48 - x << endl;
}

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

int main(){
  string S;
  cin >> S;
  sort(S.begin(),S.end());
  
  string  T;
  cin >> T;
  sort(T.begin(),T.end());
  reverse(T.begin(),T.end());
 
  if(S<T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, std::vector<T> const &cont) {
    for (auto &i : cont) {
        out << i << ' ';
    }
    return out;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, std::pair<T1, T2> const &p) {
    out << '{' << p.first << ", " << p.second << "}";
    return out;
}
#define imie(...) __debug_print(#__VA_ARGS__, __VA_ARGS__)
#ifdef __GLIBCXX_DEBUG
template <typename Arg1>
void __debug_print(const char *name, Arg1 &&arg1) {
    cerr << "[" << name << ": " << arg1 << "]" << endl;
}
template <typename Arg1, typename... Args>
void __debug_print(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr << "[";
    cerr.write(names, comma - names) << ": " << arg1 << "],  ";
    __debug_print(comma + 2, args...);
}
#else
#pragma GCC optimize("O2")
void __debug_print(const char *, ...) {}
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<double> DP(N + 1, 0);
    double probs[N];
    DP[0] = 1;
    for (double &i : probs)
        cin >> i;
    for (int i = 1; i <= N; ++i) {
        for (int j = i; j >= 0; --j) {
            DP[j] = (j > 0 ? DP[j - 1] : 0) * probs[i - 1] + DP[j] * (1 - probs[i - 1]);
        }
        imie(DP);
    }
    double ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i > N - i)
            ans += DP[i];
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3876
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  for(int i=1; i<=N; i++){
    cin >> A[i];
  }
  int s=A[1];
  for(int i=2; i<=N; i++){
    s = A[i]-s;
  }
  vector<int> ans;
  ans.push_back(s);
  s /= 2;
  for(int i=1; i<N; i++){
    A[i] -= s;
    ans.push_back(A[i]*2);
    s = A[i];
  }
  for(int i: ans){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a + b == 15)
    cout << '+' << endl;
  else if (a * b == 15)
    cout << '*' << endl;
  else
    cout << 'x' << endl;
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

string f(string s) {
  stringstream ss;
  int n  = 0;
  char c = '*';
  for (char x : s) {
    if (c == x) {
      n++;
    } else {
      if (n) ss << n << c;
      n = 1;
      c = x;
    }
  }
  ss << n << c;
  return ss.str();
}

void solve() {
  int n;
  while (cin >> n, n) {
    string s;
    cin >> s;
    while (n--) s = f(s);
    cout << s << endl;
  }
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

// change N
#define N 100005

vector<int> g[N];
int in[N];
int parent[N];

int32_t main() {

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

    int n,m;
    cin >> n >> m;

    int u,v;
    rep(i,n+m-1) {
    	cin >> u >> v;

    	g[u].pb(v);
    	in[v]++;
    }
    queue<int> Q;
    repA(i,1,n) {
    	if(!in[i]) {
    		Q.push(i);
    		parent[i] = 0;
    	}
    }

    while(!Q.empty()) {
    	int ver = Q.front();
    	Q.pop();

    	for(auto vv :  g[ver]) {
    		parent[vv] = ver;
    		in[vv]--;
    		if(!in[vv]) Q.push(vv);
    	}

    }

    repA(i,1,n) cout << parent[i] << '\n';
}

Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0;i<N;i++) cin >> p.at(i);
    sort(p.begin(), p.end());
    int sum=0;
    for(int i=0;i<K;i++) sum += p.at(i);
    cout << sum << endl;

   return 0;
}


Measured memory_bytes: 3624
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
typedef unsigned long long ull;
ull num,num2;
int sum[30];
int main()
{
    scanf("%lld%lld",&num,&num2);
    if(num!=1&&num2!=1)
    cout<<num*num2-num*2-num2*2+4<<endl;
    else
    {
        if(num2>=2||num>=2)
            cout<<num+num2-3<<endl;
        else
            cout<<1<<endl;
    }
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  final val infity = Int.MaxValue
  var compareCount = 0
  
  def merge(left: Int, mid: Int, right: Int): Unit ={
    var al = a.slice(left, mid) ++ Array(infity)
    var ar = a.slice(mid, right) ++ Array(infity)
    var i = 0
    var j = 0
    //println("left:" + al.toList)
    //println("right:" + ar.toList)
    (left until right).foreach{ k =>
      compareCount += 1
      if(al(i) <= ar(j)){
        a(k) = al(i)
        i += 1
      } else {
        a(k) = ar(j)
        j += 1
      } 
    }
    //println("all:" + a.toList.mkString(" "))
  }
  
  val n = StdIn.readLine().trim.toInt
  val a = StdIn.readLine().trim.split(' ').map(_.toInt)

  def mergeSort(left: Int, right: Int): Unit ={
    if(left+1 < right){
      val mid = (left + right) / 2
      mergeSort(left, mid)
      mergeSort(mid, right)
      merge(left, mid, right)
    }
  }
  
  mergeSort(0, a.size)
  println(a.toList.mkString(" "))
  println(compareCount)

}




Measured memory_bytes: 466104
package main

import "fmt"

func main() {
	c := make([][]int, 3)
	for i := 0; i < 3; i++ {
		tmp := make([]int, 3)
		fmt.Scan(&tmp[0], &tmp[1], &tmp[2])
		c[i] = tmp
	}
	if checkRow(diff(c, 1, 0)) && checkCol(diff(c, 0, 1)) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func checkRow(diff [][]int) bool {
	for i := 0; i < 3; i++ {
		row := diff[i]
		if len(row) == 0 {
			continue
		}
		ans := row[0]
		for j := 1; j < len(row); j++ {
			if ans != diff[i][j] {
				return false
			}
		}
	}
	return true
}

func checkCol(diff [][]int) bool {
	for i := 0; i < 3; i++ {
		ans := diff[0][i]
		for j := 1; j < len(diff); j++ {
			if ans != diff[j][i] {
				return false
			}
		}
	}
	return true
}

func diff(c [][]int, slideI, slicdJ int) [][]int {
	diffs := make([][]int, 3)
	for i := slideI; i < len(c); i++ {
		diffs[i] = make([]int, 3)
		for j := slicdJ; j < len(c[i]); j++ {
			diffs[i][j] = c[i][j] - c[i-slideI][j-slicdJ]
		}
	}
	return diffs
}


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

#define rep(i, j, k) for(int i = (int) j; i < (int) k; ++i)
#define sz(x) ((int) (x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int >
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof (x))
#define zerox(x, y) memset((x), (y), sizeof (x))

using namespace std;

int main()
{
#ifdef PIT
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif //PIT

	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
	cin >> s;
	string t = "";
	int n = sz(s);
	for(int i = 0; i < n; i += 2) t += s[i];
	cout << t << endl;
	
#ifdef PIT
flush(cout);
cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif //PIT
	return 0;
}


Measured memory_bytes: 592
n = input()
m = len(n)
l = list(n)


for i in range(2 **(m-1)):
    op = ["-"]*(m-1) + [""]
    for j in range(m-1):
        if ((i>>j)&1):
            op[j] = "+"
    formula = ""
    for p_n, p_o in zip(l,op):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print("{}=7".format(formula))
        exit()


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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> v(26, 114514);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vector<int> now(26);
        for (auto c:s)now[c - 'a']++;
        for (int j = 0; j < 26; j++)v[j] = min(v[j], now[j]);
    }

    for (int i = 0; i < 26; i++)cout << string(v[i], 'a' + i);
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
# include <iostream>
# include <list>
# include <utility>
using namespace std;

int main() {
    int n, num_query; scanf("%d%d", &n, &num_query);
    int command, s, t, x;
    list<int> L[n]; 
    
    for (int i = 0; i < num_query; ++i) {
        scanf("%d", &command);
        
        switch(command) {
            case 0:
                scanf("%d%d", &t, &x);
                L[t].push_back(x);
                break;
            case 1:
                scanf("%d", &t);
                if (L[t].empty()) printf("\n");
                else {
                    printf("%d", L[t].front());
                    auto itr = L[t].begin(); ++itr;
                    for (; itr != L[t].end(); ++itr) printf(" %d", *itr);
                    printf("\n");
                }
                break;
            case 2:
                scanf("%d%d", &s, &t);
                L[t].splice(L[t].end(), move(L[s]));
                L[s].clear();
                break;
        }
    }
    
    return 0;
}


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

import sys


def LI():
    return list(map(int, sys.stdin.buffer.readline().split()))


def I():
    return int(sys.stdin.buffer.readline())


def LS():
    return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()


def S():
    return sys.stdin.buffer.readline().rstrip().decode('utf-8')


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


def SRL(n):
    return [list(S()) for i in range(n)]


def MSRL(n):
    return [[int(j) for j in list(S())] for i in range(n)]

# ----------------------------------------------------------------


def main():
    s = S()

    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")

    else:
        print("No")


main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,d,c=0;
    cin>>a>>b>>d;
    for(int i=a;i<=b;i++){
    	if(i%d==0){
    		c++;
		}
	}
	cout<<c<<"\n";

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
vector<int>a[300001];
struct line{int i,cnt;}b[300001];
int h,w,m,x_[300001],y_[300001],ans,cntx[300001],cnty[300001],vis[300001];
bool cmp(line i,line j){return i.cnt>j.cnt;}
int main()
{
	scanf("%d%d%d",&h,&w,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&x_[i],&y_[i]),++cntx[y_[i]],++cnty[x_[i]],a[x_[i]].push_back(y_[i]);
	for(int i=1;i<=w;i++)b[i].i=i,b[i].cnt=cntx[i];
	sort(b+1,b+w+1,cmp);
	for(int i=1;i<=h;i++)
	{
		int l1=a[i].size();
		for(int j=0;j<l1;j++)vis[a[i][j]]=i;
		for(int j=1;j<=w;j++)if(vis[b[j].i]!=i){ans=max(ans,cnty[i]+b[j].cnt);break;}
		else ans=max(ans,cnty[i]+b[j].cnt-1);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 28436
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  ll n=s.size();
  ll le=0,ri=n-1;
  ll ans=0;
  while(ri-le>0){
    if(s[le]==s[ri]){le++;ri--;}
    else if(s[le]=='x'){
      le++;
      ans++;
    }else if(s[ri]=='x'){
      ri--;
      ans++;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
  return 0;
}
  


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>;
using vvi = vector<vi>; using vvl = vector<vl>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;

vvi g;
vector<bool> r;
vi val;

void dfs(int u) {
	// dbv(val);
	r[u] = true;
	for (int v : g[u]) {
		if (r[v]) continue;
		val[v] += val[u];
		dfs(v);
	}	
}

int main() {
	int N, Q; cin >> N >> Q;
	g.assign(N + 1, {}); r.assign(N + 1, false); val.assign(N + 1, 0);
	rep(i, N - 1) {
		int a, b; cin >> a >> b;
		g[a].push_back(b); g[b].push_back(a);
	}
	rep(i, Q) {
		int p, x; cin >> p >> x;
		val[p] += x;
	}
	dfs(1);	
	rep2(i, 1, N + 1) {
		if (i - 1) cout << " ";
		cout << val[i];
	}
	cout << endl;
}


Measured memory_bytes: 23552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; string S, T;
    cin >> N >> S >> T;

    int s_it = 0, t_it = 0;
    string ans;
    for (int i = 0; i < N; i++) {
        ans += S[s_it];
        s_it++;
        ans += T[t_it];
        t_it++;
    }
    
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3560
n, k = map(int, input().split())

if n % k == 0:
    print(0)
elif n < k < 2 * n:
    print(k-n)
elif n * 2 <= k:
    print(n)
else:
    print(min(abs(n - k * (n // k)), abs(n - k * (n // k + 1))))

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    if(n==1)
    {
        if(s[0]=='?')
        {
            cout<<"D"<<endl;
            return 0;
        }
    }
    for(int i=1;i<n;i++)
    {
         if(s[i-1]=='?')
        {
            s[i-1]='D';
        }
        if(s[i-1]=='D' && s[i]=='?')
        {
            s[i]='D';
        }
        if(s[i-1]=='P' && s[i]=='?')
        {
            s[i]='D';
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3756
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	long long L[90];
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; ++i) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[N];
	return 0;
}

Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  ;; (return-from read-fixnum 0)
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (the fixnum (* result 10))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (dotimes (_ (read) (write-line "second"))
    (when (oddp (read-fixnum))
      (write-line "first")
      (return-from main))))

#-swank(main)


Measured memory_bytes: 11108
#include <bits/stdc++.h>  
   
using namespace std;  
const int N = 100005;  
typedef long long ll;  
int a[N];  
double b[N];  
int main()  
{  
     int n,maxa=-1;  
     cin>>n;  
     for(int i=1;i<=n;i++)  
        scanf("%d",&a[i]);  
    sort(a+1,a+1+n);  
    double mid=1.0*a[n]/2,minb=1000000009.0;  
    int ans;  
    for(int i=1;i<n;i++){  
       // printf("%lf\n",mid-(1.0*a[n]-1.0*a[i]));  
        if(fabs(mid-(1.0*a[n]-1.0*a[i]))<minb)  
        {  
            ans=a[i];  
            minb=fabs(mid-(1.0*a[n]-1.0*a[i]));  
        }  
    }  
    printf("%d %d\n",a[n],ans);  
}  

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 210;
const int R = 1010;
ll ds[N][N], dl[N][N];

ll dp[R][N];

ll inf = 1e16;
const int DEBUG = 0;

int main(void){
  int n, m;
  while (cin >> n >> m && n) {
    REP(i, 0, n) {
      REP(j, 0, n) {
	ds[i][j] = dl[i][j] = i == j ? 0 : inf;
      }
    }
    REP(loop_cnt, 0, m) {
      int i, j;
      ll t;
      char sl;
      cin >> i >> j >> t >> sl;
      i--, j--;
      if (sl == 'S') {
	ds[i][j] = min(ds[i][j], t);
	ds[j][i] = min(ds[j][i], t);
      } else {
	dl[i][j] = min(dl[i][j], t);
	dl[j][i] = min(dl[j][i], t);
      }
    }
    REP(k, 0, n) {
      REP(i, 0, n) {
	REP(j, 0, n) {
	  ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
	  dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
	}
      }
    }
    int r;
    cin >> r;
    VI z(r);
    REP(i, 0, r) {
      cin >> z[i];
      z[i]--;
    }
    REP(i, 0, R) {
      REP(j, 0, N) {
	dp[i][j] = inf;
      }
    }
    dp[0][z[0]] = 0;
    REP(i, 1, r) {
      REP(j, 0, n) {
	REP(k, 0, n) {
	  ll sdist = dl[z[i - 1]][j] + ds[j][k] + dl[k][z[i]];
	  dp[i][k] = min(dp[i][k], dp[i - 1][j] + sdist);
	  if (j == k) {
	    ll ldist = dl[z[i - 1]][z[i]];
	    dp[i][j] = min(dp[i][j], dp[i - 1][j] + ldist);
	  }
	  if (DEBUG) {
	    cerr << "dp[" << i << "," << k << "]=" << dp[i][k] << endl;
	  }
	}
      }
    }
    ll mi = inf;
    REP(i, 0, n) {
      mi = min(mi, dp[r - 1][i]);
    }
    cout << mi << endl;
  }
}

Measured memory_bytes: 5392
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
int main()
{
    ll a,b;
    string s,t,u;
    cin>>s;
    rep(i,s.size()) cout<<'x';
}


Measured memory_bytes: 256
def dfs(N, s, maxc):
    if len(s) == N:
        print(s)
    else:
        for i in range(ord(maxc)-ord('a') + 2):
            ord_c = ord('a')+i
            dfs(N, s+chr(ord_c), chr(max(ord_c, ord(maxc))))

N = int(input())
dfs(N, 'a', 'a')

Measured memory_bytes: 4404
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(all(a));

    cout << a[n/2] - a[n/2 -1] << endl;
}


Measured memory_bytes: 640
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if(allnums[i]) then
      table.insert(primes, i)
      local lim = math.floor(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

-- Lua 5.1 only
local function getdivisorparts(x, primes)
  local prime_num = #primes
  local tmp = {}
  local lim = math.ceil(math.sqrt(x))
  local primepos = 1
  local dv = primes[primepos]
  while(primepos <= prime_num and dv <= lim) do
    if(x % dv == 0) then
      local asdf = {}
      asdf.p = dv
      asdf.cnt = 1
      x = x / dv
      while(x % dv == 0) do
        x = x / dv
        asdf.cnt = asdf.cnt + 1
      end
      table.insert(tmp, asdf)
      lim = math.ceil(math.sqrt(x))
    end
    if(primepos == prime_num) then break end
    primepos = primepos + 1
    dv = primes[primepos]
  end
  if(x ~= 1) then
    local asdf = {}
    asdf.p, asdf.cnt = x, 1
    table.insert(tmp, asdf)
  end
  return tmp
end

local function getdivisor(divisorparts)
  local t = {}
  local pat = 1
  local len = #divisorparts
  local allpat = 1
  for i = 1, len do
    allpat = allpat * (1 + divisorparts[i].cnt)
  end
  for t_i_pat = 0, allpat - 1 do
    local div = allpat
    local i_pat = t_i_pat
    local ret = 1
    for i = 1, len do
      div = math.floor(div / (divisorparts[i].cnt + 1))
      local mul = math.floor(i_pat / div)
      i_pat = i_pat % div
      for j = 1, mul do
        ret = ret * divisorparts[i].p
      end
    end
    table.insert(t, ret)
  end
  -- table.sort(t)
  return t
end

local n, m = io.read("*n", "*n")
local ret = 1
local primes = getprimes(mce(msq(m)))
local dvparts = getdivisorparts(m, primes)
local dvs = getdivisor(dvparts)
local cnt = #dvs
for i = 1, cnt do
  local rem = mfl(m / dvs[i])
  if n <= rem then ret = mma(ret, dvs[i]) end
end
print(ret)


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

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

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9 + 7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
		
	ll N, K;
	cin >> N >> K;

	if (N % 2 == 0) {
		if (2 * K <= N) {
			ll L = N / 2;
			for (ll i = 0; i != L; ++i) {
				ll a = K + 2 * i;
				ll b = K + N + L - 1 - i;
				ll c = K + 2 * N + i;
				cout << a << " " << b << " " << c << endl;
			}
			for (ll i = 0; i != L; ++i) {
				ll a = K + 2 * i + 1;
				ll b = K + N + 2 * L - 1 - i;
				ll c = K + 2 * N + L + i;
				cout << a << " " << b << " " << c << endl;
			}
		}
		else {
			cout << "-1" << endl;
		}
	}
	else {
		if (2 * K <= N + 1) {
			ll L = (N - 1) / 2;
			for (ll i = 0; i != L + 1; ++i) {
				ll a = K + 2 * i;
				ll b = K + N + L - i;
				ll c = K + 2 * N + i;
				cout << a << " " << b << " " << c << endl;
			}
			for (ll i = 0; i != L; ++i) {
				ll a = K + 2 * i + 1;
				ll b = K + N + 2 * L - i;
				ll c = K + 2 * N + L + i + 1;
				cout << a << " " << b << " " << c << endl;
			}
		}
		else {
			cout << "-1" << endl;
		}
	}


	return 0;
}


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

int n, a, x=1, y=1;
int main() {
	cin >> n;
	while(n--) {
		cin >> a;
		x *= 3;
		if(a%2==0) y *= 2;
	}
	cout << x-y;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;


int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n) mp[i] = 0;

  rep(i,n){
    if(i == 0) continue;
    int a;
    cin >> a;
    a--;
    mp[a]++;
  }

  for(auto p:mp) cout << p.second << endl;
  
  
}


Measured memory_bytes: 13000
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        int stickCount = int.Parse(Console.ReadLine());
        string line = Console.ReadLine();
        string[] strs = line.Split(' ');
        int[] nums = new int[stickCount];
        for (int i = 0; i < stickCount; i++)
        {
            nums[i] = int.Parse(strs[i]);
        }
        Array.Sort(nums);
        Array.Reverse(nums);

        int[] biggestNumber = new int[2];
        int bigCount = 0;
        int streakCount = 0;
        for (int i = 0; i < stickCount - 1; i++)
        {
            if (nums[i] == nums[i + 1])
            {
                streakCount++;
            }
            else
            {
                streakCount = 0;
            }

            if (bigCount == 0)
            {
                if (streakCount == 1)
                {
                    biggestNumber[0] = nums[i];
                    bigCount++;
                }
            }
            else
            {
                if (streakCount == 1)
                {
                    biggestNumber[1] = nums[i];
                    break;
                }
                if (streakCount == 3)
                {
                    biggestNumber[1] = nums[i];
                    break;
                }
            }

        }

        ulong result = (ulong)biggestNumber[0] * (ulong)biggestNumber[1];
        Console.WriteLine(result.ToString());
    }
}

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

using namespace std;

#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005

int main()
{
    ll a,ans = 1e18;
    cin >> a;
    ll len = sqrt(a);
    for(ll i = 1; i <= len ; i++)
    {
		if(a%i == 0)
		{
			ll b = a/i;
			ans = min(ans,abs(i-1)+abs(b-1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector<ld>p(n + 1);
	for (int i = 1; i <= n; i++)cin >> p[i];
	vector<vector<ld>> dp(n + 1, vector<ld>(n + 1, 0));
	dp[1][0] = 1 - p[1]; dp[1][1] = p[1];
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0) {
				dp[i][j] = dp[i - 1][0] * (1 - p[i]);
			}
			else {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
			}
		}
	}
	ld ans = 0;
	for (int j = ceil(n / 2.0); j <= n; j++)ans += dp[n][j];
	cout <<fixed<<setprecision(10)<< ans;
	//system("PAUSE");
}


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

using namespace std;

int d[100020];
int k;

int resi(int h[], int i, int n)
{   
    if(i == n-1)
        return 0;
    
    
    int min1 = INT_MAX;

    for(int j = 1; j <= k; j++)
    {
        if(i+j > n-1)
        {
            continue;
        }
        if(d[i+j] == -1)
        {
            d[i+j] = resi(h, i+j, n);
        }
        min1 = min(min1, d[i+j] + abs(h[i]-h[i+j]));
        //cout << "i:   " << i<< " j:   " << j << " POM1 :" << d[i+j] + abs(h[i]-h[i+j]) << endl;
    }

    return min1;

}

int main()
{
    int n;

    cin >> n >> k;

    int h[100020];
    
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
        d[i] = -1;
    }


    cout << resi(h,0,n) << endl;


    // for(int i = 0; i < n; i ++)
    //     cout << "d"<< i<< " "  << d[i] << endl;

    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <math.h>
using namespace std;


int f(long long A){
    int res=0;
    while(A>0){
        A/=10;
        res++;
    }
    return res;
}

int F(long long A,long long B){
    return max(f(A),f(B));
}

long long a[100005],b[100005];
int main(void){
    // Your code here!
    long long n;
    cin>>n;
    
    int k=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            a[k]=i;
            b[k]=n/i;
            //cout<<a[k]<<" "<<b[k]<<endl;
            k++;
        }
    }
    int minute=2000000;
    for(int i=0;i<k;i++){
        minute=min(minute,F(a[i],b[i]));
    }
    cout<<minute<<endl;
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  int N; cin >> N;
  int ans = 1;
  while(true){
    if(ans * ans > N){
      ans--;
      ans = ans * ans;
      break;
    }
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Aoj.DPL.Chapter1A
{
    class Program
    {
        public static void Solve()
        {
            int[] n_m = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = n_m[0];
            int m = n_m[1];

            int[] coins = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            // key: 0 yen ~ n yen
            // value: count of coins;
            int[] cost = Enumerable.Repeat(Int32.MaxValue, n+1).ToArray();
            cost[0] = 0;

            for (int i = 0; i < m; i++)
            {
                for (int j = coins[i]; j <= n ; j++)
                {
                    // ????????????????????????????????£?????´?????????
                    // ???????????????????????£?????´?????§DP?????????????????´??°?????????
                    cost[j] = Math.Min(cost[j], cost[j - coins[i]] + 1);
                }
            }

            Console.WriteLine(cost[n]);
        }

        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("DiscreteOptimizationProblems/Input/01_Combinational_A_02.txt"));
            // var sw = new Stopwatch();
            // sw.Start();

            Solve();

            // Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
        }
    }
}

Measured memory_bytes: 10220
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int digit_sum(int n){
  if(n==0){
    return 0;
  }else{
    int res = 0;
    res = n%10;
    res += digit_sum(n/10);
    return res;
  }
}

int main(){
  
  int n;
  cin>>n;
  int ans = 1;
  REP(i,3){
    ans *= n;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    int N, Q;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());

    cin >> Q;
    int t;
    int left, right, mid;
    bool flag=false;
    rep(i, Q){
        cin >> t;
        left=0; right=N-1; mid=(left + right)/2;
        flag=false;
        while(left <= right){
            if(a[mid]==t){
                flag=true;
                break;
            }else if(a[mid]<t){
                left = mid + 1;
                mid = (left+right)/2;
            }else if(a[mid]>t){
                right = mid - 1;
                mid = (left+right)/2;
            }
        }

        if(flag) printf("1\n");
        else printf("0\n");
    }
    return 0;
}


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

int main(){
	stack<int> train;
	int n;
	while(cin>>n){
		if(n==0){
			cout<<train.top()<<endl;
			train.pop();
		}else{
			train.push(n);
		}
		
	}
    return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>

int main(void){

int m,f,b;
scanf("%d %d %d",&m,&f,&b);
if(m+f<b){
printf("NA\n");
}
else if(m>=b){
printf("0\n");
}
else if(m<b){
printf("%d\n",b-m);
}
return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[100005],b[100005],s=0,ans=0;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n+1;i++)
    cin>>a[i];
for(ll i=0;i<n;i++)
    cin>>b[i];
ll s1=0;
for(ll i=0;i<n;i++)
{
    ans=ans+min(a[i],b[s1]);
   if(b[s1]-a[i]>0){
    ans=ans+min(a[i+1],b[s1]-a[i]);
    a[i+1]=max(0LL,a[i+1]-b[s1]+a[i]);
   }
   s1++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<string> blue(n);
  for ( int i =0; i < n; i++ ){
    cin >> blue[i];
  }
  int m;
  cin >> m;
  vector<string> red(m);
  for ( int i =0; i < m; i++){
    cin >> red[i];
  }

  int ans = 0;
  for (string t:blue){
    int cnt = 0;

    for ( string s:blue ){
      if ( t == s ) cnt++;
    }
    for (string s:red){
      if ( t== s ) cnt--;
    }

    ans = max(cnt, ans); 
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
string s;

void input() {
    cin >> s;
}

void solve() {
    cout << s.substr(0,3) << endl;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3628