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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 23;
const ll INFL = 2e18 + 23;

int32_t main()
{
    int h1, m1;
    int h2, m2;
    cin >> h1 >> m1 >> h2 >> m2;
    int k;
    cin >> k;
    int t1 = h1*60 + m1;
    int t2 = h2*60 + m2;

    int ans = (t2-k) - t1;
    cout << ans;

    return 0;
}		

Measured memory_bytes: 3620
def find_max_rectangle(pair):
  """
  Args:
    pair (list): reversely sorted 
  Returns:
    area (int)
  """
  if len(pair) >= 2:
    M = pair[0]
    second_max = pair[1]
    return M * second_max
  else:
    return 0



n = int(input())
L = list(map(int, input().split()))
L.sort()
pair = []
prev = None
while L:
  popped = L.pop()
  if prev == popped:
    pair.append(prev)
    prev = None
  else:
    prev = popped

print(find_max_rectangle(pair)) 


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  priority_queue<ll,vector<ll>,greater<ll>>p;
  priority_queue<ll,vector<ll>,greater<ll>>q;
  vector<ll>r(c);
  rep(i,a){
    ll A;
    cin >> A;
    p.push(A);
  }
  while(p.size()>x){
    p.pop();
  }
  rep(i,b){
    ll B;
    cin >> B;
    q.push(B);
  }
  while(q.size()>y){
    q.pop();
  }
  rep(i,c){
    cin>>r[i];
    if(p.top()<q.top()){
      ll t=p.top();
      p.pop();
      p.push(max(r[i],t));
    }
    else{
      ll t=q.top();
      q.pop();
      q.push(max(r[i],t));
    }
  }
  ll ans=0;
  while(!p.empty()){
    ans+=p.top();
    p.pop();
  }
  while(!q.empty()){
    ans+=q.top();
    q.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 3316
# include <stdio.h>
# include <string.h>
int main ()
{
	char s[250][250],p[250];
	int flag=0,n,i,j,a;
    scanf ("%d",&n);
	gets(p);
	for ( i=1;i<=n;++i)
	   if (gets(s[i])==0)
	     break;
    for (i=1;i<n;++i)
       {
       	a=strlen(s[i])-1;
       	if (s[i+1][0]!=s[i][a]) break;
       	else
       	  {
       	  	for ( j=i+1;j<=n;++j)
       	        if (strcmp(s[i],s[j])==0)
				   flag=1;
		  }	
	   }
	if (flag==1||i!=n)
	   printf ("No\n");
	else
	  printf ("Yes\n");
	return 0;
} 

Measured memory_bytes: 256
#初期値の準備
data_count = 0
input_data = list()

#インプットdataから初期値の挿入
while data_count >= 0:
    input_data.append(list(map(int, input().split())))
    if input_data[data_count][0] == 0 and input_data[data_count][1] == 0:
        break
    data_count += 1

#結果判定
result = [0] * data_count
for h in range(data_count):
    max_number = input_data[h][0]
    judg_number = input_data[h][1]
    for i in range(max_number):
        for j in range(i+1, max_number):
            for k in range(j+1, max_number):
                if i+1+j+1+k+1 == judg_number:
                    result[h] += 1
                    break
                elif i+1+j+1+k+1 > judg_number:
                    break
                else:
                    continue

#結果表示
[print(i) for i in result]



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

int main(){
  int a,b;cin >> a >> b;
  if(a%3 == 0||b%3 == 0||(a+b)%3 == 0)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

fn type_of<T>(_: T) -> String{
    let a = std::any::type_name::<T>();
    return a.to_string();
}

#[fastout]
fn main() {
    input! {
        a:i32,
    }
    println!("{}",a/3);
}

Measured memory_bytes: 2200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll L, R;
    cin >> L >> R;
    auto solve = [](ll L, ll R) {
        if (L / 2019 != R / 2019) { return 0LL; }
        L = L % 2019;
        R = R % 2019;
        ll m = INF;
        for (ll l = L; l <= R - 1; l++) {
            for (ll r = l + 1; r <= R; r++) { chmin(m, (l * r) % 2019); }
        }
        return m;
    };

    cout << solve(L, R) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n,m;
signed main()
{
	scanf("%d%d",&n,&m);
	((n>m)?(printf("%d",(n-m))):(putchar(48)));
	return putchar(10),0;
}

Measured memory_bytes: 256
from collections import deque

h,w = map(int, input().split())
PATH = "."
WALL = "#"
z=0
# 迷路の配列を作成する。
maze=list()
for a in range(h):
 mazew=list()
 mazeh = input()
 for b in range(w):
  mazew.append(mazeh[b])
 maze.append(mazew)
for c in range(h):
 for d in range(w):
   # 地図上の未訪問地点を-1とする。
   # また、移動するごとに+1することで、スタート地点からの移動距離を保持する
  if maze[c][d]==WALL:
   continue
  else:
   distance_visited = list()
   for l in range(h):
    distance_visited.append([-1] * w)
   # スタート地点を登録する。
   queue = deque([[c, d]])
   distance_visited[c][d] = 0
   while True:
    x,y = queue.popleft()
      # 現在地点の上下左右のマスを確認する。
    for i,j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
     new_x, new_y = x + i, y + j
       # それぞれのマスが移動できる場合、かつまだ移動したことが無い場合
     if new_x>=0 and new_x<=h-1 and new_y>=0 and new_y<=w-1:
      if maze[new_x][new_y] != WALL and distance_visited[new_x][new_y] == -1:
               # そのマスのスタートからの移動距離を設定し、またキューに登録する。
       distance_visited[new_x][new_y] = distance_visited[x][y] + 1
       queue.append([new_x, new_y])
       if distance_visited[new_x][new_y]>z:
        z=distance_visited[new_x][new_y]
    if queue==deque([]):
     break
print(z)

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int ans = 0;
    for(int i = 0; i < N-1; i++){
        if(S[i] == S[i+1]){
            ans++;
        }
    }

    ans = min(ans+2*K, N-1);

    cout << ans << endl;


    return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    int N;
    cin >> N;

    vector<int> T(N);
    for (int &x : T)
        cin >> x;
    int sum = accumulate(T.begin(), T.end(), 0);

    int M;
    cin >> M;

    while (M--)
    {
        int P, X;
        cin >> P >> X;
        cout << sum - T[P - 1] + X << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
//
//  Created by Vijay Bhati on 21/02/20.
//  Copyright © 2019 Vijay Bhati. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <map>
#include <sstream>
#include <set>
#include <iomanip>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cassert>
#include <memory>
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define rf freopen("in.txt", "r", stdin);
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define P pair<ll, ll>
#define ff first
#define ss second
#define F first
#define S second
#define MOD 1000000007
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)

using namespace std;

ll max(ll a, ll b) {
    return a > b ? a : b;
}

ll min(ll a, ll b) {
    return a > b ? b : a;
}

ll __gcd(ll a, ll b) {
    if (a == 0) {
        return b;
    }
    return __gcd(b%a, a);
}

ll find_power(ll a, ll b) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1) {
            ans = (ans * a) % 1000000007;
        }
        b = b >> 1;
        a = (a * a) % 1000000007;
    }
    return ans;
}

const int MX = 1007;
string s[MX];
ll dp[MX][MX];

int main() {
#ifdef __APPLE__
    const clock_t begin_time = clock();
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    
    ll n, m;
    cin >> n >> m;

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

    for (int i = n-1; i >= 0; i--) {
        for (int j = m-1; j>= 0; j--) {
            if (s[i][j] == '#') {
                continue;
            }

            if (i == n-1 && j == m-1) {
                dp[i][j] = 1;
            } else {
                dp[i][j] = (dp[i+1][j] + dp[i][j+1]) % 1000000007;
            }
        }
    }


    cout << dp[0][0] << endl;

    
#ifdef __APPLE__
    cout << endl;
    cout << "Time : ";
    cout << float( clock () - begin_time ) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


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

string pos = "keyence";

int main(){
	string s;
	cin >> s;
	int n = s.length();
	if (n < 7){
		cout << "NO" << endl;
		return 0;
	}
	int i = 0, j = pos.size() - 1;
	while (i < pos.size() && pos[i] == s[i]) i++;
	i--;
	while (j >= 0 && pos[j] == s[n - pos.size() + j]) j--;
	j++;
	if (i + 1 + pos.size() - j >= pos.size()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

template <ll mod>
struct modular {
    ll value;
    modular(ll x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }

    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        ll a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            ll t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular& operator^=(modular other) {
        ll r = 1, x = value, n = other.value;
        while (n > 0) {
            if (n & 1) r = r * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        value = r;
        return *this;
    }
    modular operator+(modular rhs) {
        return modular(*this) += rhs;
    }
    modular operator-(modular rhs) {
        return modular(*this) -= rhs;
    }
    modular operator*(modular rhs) {
        return modular(*this) *= rhs;
    }
    modular operator/(modular rhs) {
        return modular(*this) /= rhs;
    }
    modular operator^(modular rhs) {
        return modular(*this) ^= rhs;
    }
    bool operator==(modular rhs) {
        return value == rhs.value;
    };
    bool operator!=(modular rhs) {
        return value != rhs.value;
    };
    bool operator<(modular rhs) {
        return value < rhs.value;
    }
};
template <ll mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <ll mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <ll mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
}
const ll mod = 1e9 + 7;
using mint = modular<mod>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    mint res = 2;
    res ^= n;
    mint aa = 1, bb = 1;
    rep(i, 1, a + 1) {
        aa *= n - i + 1;
        aa /= i;
    }
    rep(i, 1, b + 1) {
        bb *= n - i + 1;
        bb /= i;
    }
    res -= aa + bb + 1;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    s = 0
    m = INF
    su = 0
    for i in range(n):
        if v[i] < 0:
            s += 1
        if abs(v[i]) < m:
            m = abs(v[i])
        su += abs(v[i])
    if s % 2 == 0:
        print(su)
    else:
        print(su - 2 * m)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64752
#include<bits/stdc++.h>
#define int long long int
using namespace std;
const int MOD = (int)1e9 + 7;

int dp[5010][5010], stock[5010][5010];
int n;
string s;
signed main()
{
  cin >> n >> s;

  dp[0][0] = 1;
  for(int i = 1; i <= n; i++){
    dp[i][0] += dp[i - 1][0];
    for(int j = 0; j <= n; j++){
      dp[i][j] += dp[i - 1][j + 1] * 2;
      if(j > 0)
	dp[i][j] += dp[i - 1][j - 1];
      dp[i][j] %= MOD;
    }
  }

  cout << dp[n][s.size()] << endl;
  return 0;
}


Measured memory_bytes: 195968
N = int(input())
A = list(map(int, input().split()))


def check(k):
    if k == 1:
        for i in range(1, N):
            if A[i - 1] >= A[i]:
                return False
        return True
    stack = []
    for i in range(1, N):
        if A[i - 1] >= A[i]:
            q = A[i]
            while True:
                if stack:
                    if stack[-1][0] > q:
                        stack.pop()
                    else:
                        break
                else:
                    break

            p = q
            while p >= 1:
                if not stack:
                    stack.append([p, 1])
                    break
                if stack[-1][0] == p:
                    if stack[-1][1] == k - 1:
                        if p != 1:
                            stack.pop()
                            p -= 1
                        else:
                            return False
                    else:
                        stack[-1][1] += 1
                        break
                else:
                    stack.append([p, 1])
                    break
    return True


l, r = 0, N
while r - l > 1:
    mid = (l + r) // 2
    if check(mid):
        r = mid
    else:
        l = mid

print(r)

Measured memory_bytes: 88148
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void drop(string s) {
    cout << s << endl;
    exit(0);
}

int main() {
    int N; cin >> N;
    if(N == 2) drop("-1");
    if(N == 3) {
        printf("aa.\n");
        printf("..b\n");
        printf("..b\n");
        return 0;
    }

    vector< vector<string> > pat = {
        {
            "aaef",
            "bbef",
            "ghcc",
            "ghdd"
        },
        {
            "aabcc",
            ".hb.j",
            "gh..j",
            "g.iif",
            "ddeef"
        },
        {
            "aaij..",
            "bbij..",
            "..ccef",
            "..ddef",
            "gh..kk",
            "gh..ll"
        },
        {
            "aabbcc.",
            "dd.dd.a",
            "..d..da",
            "..d..db",
            "dd.dd.b",
            "..d..dc",
            "..d..dc"
        }
    };

    int d = N / 4, m = N % 4;
    m += 4, d--;
    
    vector<string> ans(N, string(N, '.'));
    int x = 0, y = 0;
    for(int i=0; i<d; i++) {
        for(int a=0; a<4; a++) {
            for(int b=0; b<4; b++) {
                int nx = x + a, ny = y + b;
                ans[nx][ny] = pat[0][a][b];
            }
        }
        x += 4, y += 4;
    }
    for(int a=0; a<m; a++) {
        for(int b=0; b<m; b++) {
            int nx = x + a, ny = y + b;
            ans[nx][ny] = pat[m-4][a][b];
        }
    }
    for(int i=0; i<N; i++) cout << ans[i] << endl;
    return 0;
}


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

string abc = "acdfhjlnpqrstuvwxyz";

main()
{
    int n; cin >> n;
    int a[n];
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    for(int i = 0; i < n; i++)
    {
        if(i % 2 == 0)
        ans += a[i];
        else
        ans -= a[i];
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
//#include <tuple>
#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
using namespace std;


int t, x;


int main(){
	cin >> t >> x;
	double ans;
	ans = (double)t / x;

	cout << ans << "\n";

	return 0;
}

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

const int mod = (int)1e9 + 7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n), ps(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ps[i + 1] = (ps[i] + a[i]) % mod;
    if (ps[i + 1] < 0) {
      ps[i + 1] += mod;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = (ps[n] - ps[i + 1]) % mod;
    if (sum < 0) {
      sum += mod;
    }
    sum = ((long long)a[i] * sum) % mod;
    if (sum < 0) {
      sum += mod;
    }
    ans = (ans + sum) % mod;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4744
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<set>
//#include <Eigen/Dense>
//#include <Eigen/Geometry>
//using namespace Eigen;

using namespace std;

int main() 
{
	
	long long n;
	cin >> n;
	long long m = 100;
	long long iter = 0;
	while (1)
	{
		m *= 1.01;
		iter++;
		if (m >= n)
		{
			cout << iter << endl;
			return 0;
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
int main()
{
    ll n,k;
    cin>>n>>k;
    ll t=n%k;
    ll t1=k-t;
    cout<<min(t,t1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int as[100005];

int main(){
  int N,X;
  scanf("%d %d",&N,&X);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  std::sort(as,as+N);
  int cnt=0;
  for(int i=0;i<N;i++){
    if(as[i]<=X){
      X-=as[i];
      cnt++;
    }
  }
  printf("%d\n",cnt-((cnt==N)&&(X>0)));
  return 0;
}


Measured memory_bytes: 128
var
a,s,d:integer;
begin
read(a,s,d);
begin
if (a=7) and (s=5) and (d=5) then write('YES')
else if (a=5) and (s=7) and (d=5) then write('YES')
else if (a=5) and (s=5) and (d=7) then write('YES')
else write('NO');
end;
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
  int N,L;
  ostringstream os;
  cin >> N >> L;
  vector<string>S(N);
  for(int i=0;i<N;++i){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  copy(S.begin(),S.end(),ostream_iterator<string>(os));
  cout << os.str() << endl;
}


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

int main(){
  int a,b;cin>>a>>b;
  for(int i=1;i<=1000;i++){
    if(i*8/100==a&&i*10/100==b){
      cout <<i<<endl;
      return 0;
    }
  }
  cout <<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

vector<ll> a,b;
int main() {
	ll h,w;
	cin>>h>>w;
	for(ll i=0;i<h;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	for(ll i=0;i<w;i++){
		ll y;
		cin>>y;
		b.push_back(y);
	}
	a.push_back(inf);
	b.push_back(inf);
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	ll ans=0;
	while(a.size()!=1||b.size()!=1){
		if(a[a.size()-1]<=b[b.size()-1]){
			ans+=a[a.size()-1]*(w+1);
			h--;
			a.pop_back();
		}
		else{
			ans+=b[b.size()-1]*(h+1);
			w--;
			b.pop_back();
		}
		//cout << ans<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

signed main() {
    int D;
    cin>>D;
    if(D==25)cout<<"Christmas"<<endl;
    if(D==24)cout<<"Christmas Eve"<<endl;
    if(D==23)cout<<"Christmas Eve Eve"<<endl;
    if(D==22)cout<<"Christmas Eve Eve Eve"<<endl;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll N;
string S;

ll dfs(vector<char> pin){
    if(pin.size() == 3){
        ll head = 0;
        bool f = true;
        rep(i, 0, 3){
            char p = pin[i];
            while(true){
                if(head > N-1){
                    f = false;
                    break;
                }
                if(S[head] == p){
                    head++;
                    break;
                }
                head++;
            }
        }
        if(f){
            return 1;
        }else{
            return 0;
        }
    }
    ll ret = 0;
    for(char c = '0'; c <= '9'; c++){
        pin.push_back(c);
        ret += dfs(pin);
        pin.pop_back();
    }
    return ret;
}

int main(){
    cin >> N >> S;
    cout << dfs((vector<char>){}) << endl;   
    return 0;
}

Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int a[N]={0};
int main()
{
    IOS();
  
    vector<string> v={"Sunny","Cloudy","Rainy"};
    string s;
    cin>>s;
    if(s[0]=='S')
      cout<<v[1];
    else if(s[0]=='C')
      cout<<v[2];
    else if(s[0]=='R')
      cout<<v[0];
   return 0;




  
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
    long long n, ans = 0, sum = 0;
    cin >> n;
    if(n == 1) {
        cin >> ans;
        cout << ans << endl;
        return 0;
    }
    vector<long long> a(n);
    if(n % 2 == 0) {
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
            if(i % 2 == 1) sum += a[i];
        }
        ans = sum;
        for(int i = 0; i < n; i += 2) {
            sum = sum + a[i] - a[i+1];
            if(ans < sum) ans = sum; 
        }
        cout << ans << endl;
        return 0;
    }
    vector<vector<long long>> dp(n, vector<long long>(3, 0));
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = a[1];
    dp[0][2] = a[2];
    for(int i = 2; i < n-1; i += 2) {
        dp[i][0] = dp[i-2][0] + a[i];
        dp[i][1] = max({dp[i-2][0], dp[i-2][1]}) + a[i+1];
        dp[i][2] = max({dp[i-2][0], dp[i-2][1], dp[i-2][2]}) + a[i+2];
    }
    cout << max({dp[n-3][0], dp[n-3][1], dp[n-3][2]}) << endl;

    return 0;
}

Measured memory_bytes: 15668
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

#define int long long

//0-origin
template <typename T>
struct FenwickTree {
	vector<T> data;
	FenwickTree(int n) : data(n, 0) {}
        //v[i] += x
	void add(int i, T x) { for (int p = i; p < (int)data.size(); p |= p + 1) data[p] += x; }
        //[0, i)
	T sum(int i) {
		T s = 0;
                for (int p = i - 1; p >= 0; p = (p & (p + 1)) - 1) s += data[p];
		return s;
	}
        //[l, r)
	T sum(int l, int r) { return sum(r) - sum(l); }
};

signed main() { 
        int n, k;
        cin >> n >> k;
        FenwickTree<int> ft(202020);
        vector<int> a(n);
        rep(i, n) {
                cin >> a[i];
                a[i] -= k;
        }
        rep(i, n - 1) a[i + 1] += a[i];
        int ans = 0;
        rep(i, n) if (a[i] < 0) ans ++;
        vector<int> b(n);
        rep(i, n) b[i] = a[i];
        sort(all(b));
        map<int, int> zip;
        rep(i, n) {
                zip[b[i]] = i + 1;
        }
        rep(i, n) {
                ans += i - ft.sum(zip[a[i]] + 1);
                ft.add(zip[a[i]], 1);
        }
        cout << n * (n + 1) / 2 - ans << endl;
        return 0;
}               



Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

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

  cout << min(n%k, k-(n%k)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define fast_io ios_base::sync_with_stdio(false)
#define pb push_back
#define fir first
#define sec second
#define tr(it,x) for(it = x.begin();it != x.end();it++)
#define mp make_pair
#define sz(x) (ll)x.size()
#define rep(i,n) for(ll i=0;i<n;i++)
#define double long double
#define accuracy ll precision = numeric_limits<double>::digits10
#define pll pair<ll,ll>
#define N 200005

ll n,a[N],h[N],ind[N],ans,s[4*N],ori[N];

void modify(ll p,ll x,ll id = 1,ll l = 0,ll r = n){
	if(r - l < 2){	
		ori[p] = x;
		s[id] = x;
		return ;
	}
	ll mid = (l + r)/2;
	if(p < mid) modify(p, x, id * 2, l, mid);
	else modify(p, x, id * 2 + 1, mid, r);
	s[id] = max(s[2*id],s[2*id + 1]);
}

ll sum(ll x,ll y,ll id = 1,ll l = 0,ll r = n){
	if(x >= r or l >= y) return 0;
	if(x <= l && r <= y) return s[id];
	ll mid = (l+r)/2;
	return max(sum(x, y, id * 2, l, mid) , sum(x, y, id * 2 + 1, mid, r) );
}

int main() {
	// freopen("input.txt", "r", stdin); 
	// freopen("output.txt", "w", stdout);
	fast_io;	 
	accuracy;
	cin >> n;
	fr(i,1,n) {
		cin >> h[i];
		ind[h[i]] = i;
	}
	fr(i,1,n) cin >> a[i];
	fr(i,1,n) {
		ll temp = a[ind[i]] + sum(0,ind[i] - 1);
		ans = max(ans,temp);
		modify(ind[i] - 1,temp);		
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
let n=Int(readLine()!)!

let a=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var sa 	= Array(count: n, repeatedValue: 0 )

var i = 0
for i in 0..<n {
	sa[a[i]-1] = i+1
}

for i in 0..<n {
	print( sa[i], terminator: " " )
}

Measured memory_bytes: 6720
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int ans = 0;
    REP(i, s.size()) ans += (s[i] == '+' ? 1 : -1);
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        string S = Console.ReadLine();

        if (S=="A"||S=="B"|| S == "C" || S == "D" || S == "E" || S == "F" || S == "G" || S == "H" || S == "I" || S == "J" || S == "K" || S == "L" || S == "M" || S == "N" || S == "O" || S == "P" || S == "Q" || S == "R" || S == "S" || S == "T" || S == "U" || S == "V" || S == "W" || S == "X" || S == "Y" || S == "Z")
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("a");
        }
    }

}

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

int main() {
    int N; cin >> N;
    string tmp;
    int ans = 0;

    bool flag = false; // 直前がAだったらフラグを立てる

    int last_A=0;
    int first_B=0;
    int last_A_first_B=0;

    for(int i=0; i<N; i++) {
        cin >> tmp;
        for (int j = 0; j < tmp.length(); j++) {
            if (tmp.at(j) == 'A') {
                flag = true;
            } else if (flag && tmp.at(j) == 'B') {
                ans++;
                flag = false;
            } else {
                flag = false;
            }
        }
        flag = false;
        if (tmp.at(0) == 'B' && tmp.at(tmp.length() - 1) == 'A') {
            last_A_first_B++;
        } else if (tmp.at(0) == 'B') {
            first_B++;
        } else if (tmp.at(tmp.length() - 1) == 'A') {
            last_A++;
        }
    }



    if(first_B==0 && last_A==0) {
        ans += max(last_A_first_B - 1, 0);
    } else {
        ans += min(first_B, last_A) + last_A_first_B;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
numbers=[]
for _ in range(N):
  c=input().split()
  C=[int(a) for a in c]
  numbers.append(C)

skills=[]
for i in range(2 ** N):
  skill=[0 for _ in range(M+1)]
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        skill[k]+=numbers[j][k]
  skills.append(skill)

del(skills[0])

answers=[]
for ability in skills:
  new_ability=ability[1:]
  necessary=[a for a in new_ability if a >= X]
  if len(necessary)==M:
    answers.append(ability[0])
if len(answers)==0:
  print(-1)
else:
  print(min(answers))
  

Measured memory_bytes: 11280
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
long long order_p=0;
long long order_q=0;
vector<long long>p(n);
vector<long long>q(n);
vector<long long>sample(n);
for (int i=0;i<n;i++){
    cin >> p[i];
    }
for (int i=0;i<n;i++){
    cin >> q[i];
    }
for(int i=0;i<n;i++){
    sample[i]=i+1;
}
do{
    order_p++;
    if(sample==p)break;
}while(next_permutation(sample.begin(),sample.end()));
for(int i=0;i<n;i++){
    sample[i]=i+1;
}
do{
    order_q++;
    if(sample==q)break;
}while(next_permutation(sample.begin(),sample.end()));
cout << abs(order_p - order_q) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
using namespace std;

int main(){
  int n;  cin >> n;
  int h[n]; int ans=0;
  for(int i=0;i<n;i++) cin >> h[i];
  
  for(int p=0;p<n;p++){
    bool pop = true;
    for(int i=0;i<p;i++){
      if(h[p] < h[i]){
        pop = false;
        break;
      }
    }
    if(pop){
      ans++;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	s := nextLine()
	fmt.Println(s[:4] + " " + s[4:])
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<pair<char,int>> v(1,make_pair(s[0],0));
    for(auto c : s){
        if(v.back().first == c){
            v.back().second++;
        }else{
            v.emplace_back(c,1);
        }
    }
    cout << v.size() << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<int> mp(n, 0);
    rep(i, k) {
        int d; cin >> d;
        rep(j, d) {
            int a; cin >> a;
            a--;
            mp[a]++;
        }
    }
    int ans = 0;
    for (auto kv : mp) {
        if (kv == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
using System;
using System.Collections.Generic;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split(' ');
            int H = int.Parse(buffer[0]);
            int W = int.Parse(buffer[1]);
            int K = int.Parse(buffer[2]);

            string[,] field = new string[H, W];
            for (int i = 0; i < H; i++)
            {
                var buf = Console.ReadLine();
                for (int j = 0; j < W; j++)
                    field[i, j] = buf[j].ToString();
            }

            int sum = 0;
            for (int bit_i = 0; bit_i < 1 << H; bit_i++)
            {
                var hl = new List<int>();

                for (int i = 0; i < H; i++)
                    if ((bit_i & (1 << i)) != 0)
                        hl.Add(i);

                for (int bit_j = 0; bit_j < 1 << W; bit_j++)
                {
                    var wl = new List<int>();

                    for (int i = 0; i < W; i++)
                        if ((bit_j & (1 << i)) != 0)
                            wl.Add(i);

                    var tmp = (string[,])field.Clone();

                    foreach (var v in hl)
                        for (int i = 0; i < W; i++)
                            tmp[v, i] = "r";

                    foreach (var v in wl)
                        for (int i = 0; i < H; i++)
                            tmp[i, v] = "r";

                    if (Count(tmp) == K) sum++;
                }

            }

            Console.WriteLine(sum);
        }

        static int Count(string[,] field)
        {
            int cnt = 0;
            for (int i = 0; i < field.GetLength(0); i++)
                for (int j = 0; j < field.GetLength(1); j++)
                    if (field[i, j] == "#") cnt++;

            return cnt;
        }
    }
}


Measured memory_bytes: 29476
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container;

void main() {
  int n, k;
  readf("%d %d\n", &n, &k);
  int i=1;
  while(n/k > 0) {
    n /= k;
    i++;
  }
  writeln(i);
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

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

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

using namespace std;
typedef long long ll;

ll T[100007];

bool is_load(ll p,int n, int k){
   int i;
   ll k_p = p;
   REP(i,n){
    if( (k_p - T[i])<0 ){
      if(k<=1) { 
        return false;
      }
      else{
        k--;
        i--;
        k_p = p;
      }
    }
    else{
      k_p -= T[i];
    }
    if(p<10){
      //cout<<"p "<<p<<" "<<k_p << " " << k << " " << i << endl;
    }
    
   }
   return true;
}

int main(void){
  int i,n,k;
  ll l,m,r;
  cin >> n>> k;
  REP(i,n) cin>> T[i];
  l = 0;
  r = 100000*10000;
  while(r-l>1){
    m = (l+r) >> 1;
    if(is_load(m,n,k)){
      r = m;
    }
    else{
      l =m;
    }
  }
  cout << r << endl;
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define ponto pair<int,int>

int m,n,a;

int32_t main()
{
	cin >> n >> m;
	int s = 0;
	for(int i=0; i<m; i++)
	{
		cin >> a;
		s += a;
	}
	if((n-s) < 0) cout << -1 << '\n';
	else cout << n-s << '\n';
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        final List<Route> routes = new ArrayList<>();

        for(int i = 0; i < 3 ; i++) {
            final int a = sc.nextInt();
            final int b = sc.nextInt();
            routes.add(new Route(a, b));
        }
        Collections.sort(routes);
    
        boolean[] record = {false, false, false, false};

        int endpoint = routes.get(0).getA();

        while(0 < routes.size()) {
            for(int i = 0; i < routes.size() ; i++) {
                final Route route = routes.get(i);
                if (route.getA() == endpoint) {
                    record[route.getA() - 1] = true;
                    record[route.getB() - 1] = true;
                    endpoint = route.getB();
                    routes.remove(i);
                    break;
                } else if (route.getB() == endpoint) {
                    record[route.getA() - 1] = true;
                    record[route.getB() - 1] = true;
                    endpoint = route.getA();
                    routes.remove(i);
                    break;
                }
                if (routes.size() -1 == i ) {
                    System.out.println("NO");
                    return;
                }
            }
        }
    
        for(boolean b : record) {
            if(!b) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
        
    }
    
    static class Route implements Comparable<Route> {
        private int a;
        private int b;
        
        public Route(final int a, final int b) {
            this.a = a < b ? a : b;
            this.b = (a + b) - this.a;
        }
        
        int getA() {
            return this.a;
        }
    
        int getB() {
            return this.b;
        }

        @Override
        public int compareTo(Route otherRoute) {
            return (this.getA() - otherRoute.getA());
        }
    }
}


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

using namespace std;
const int maxn = 5005;
typedef long long ll;
int dp[2][maxn],sum[maxn];
int main() {
	int n,mod,rt = 0;
	cin>>n>>mod;
	dp[rt][0] = 1;
	for(int i = 1;i < n;++i) {
		rt ^= 1;
		int s = i;
		if(n%2 == 1&& s > n/2 + 1) s = (n-i+1);
		if(n%2 == 0 && s > n/2) s = (n-i+1);
		memset(dp[rt],0,(n+1)<<2);
		for(int j = 0;j < n; ++j) {
			ll temp = 0;
			int k = 0;
			for(k = 0;k < n&&j-(k+32)*s>=0; k += 16) {
				temp += dp[rt^1][j-k*s];
				temp += dp[rt^1][j-(k+1)*s];
				temp += dp[rt^1][j-(k+2)*s];
				temp += dp[rt^1][j-(k+3)*s];
				temp += dp[rt^1][j-(k+4)*s];
				temp += dp[rt^1][j-(k+5)*s];
				temp += dp[rt^1][j-(k+6)*s];
				temp += dp[rt^1][j-(k+7)*s];
				temp += dp[rt^1][j-(k+8)*s];
				temp += dp[rt^1][j-(k+9)*s];
				temp += dp[rt^1][j-(k+10)*s];
				temp += dp[rt^1][j-(k+11)*s];
				temp += dp[rt^1][j-(k+12)*s];
				temp += dp[rt^1][j-(k+13)*s];
				temp += dp[rt^1][j-(k+14)*s];
				temp += dp[rt^1][j-(k+15)*s];
				k += 16;
				temp += dp[rt^1][j-k*s];
				temp += dp[rt^1][j-(k+1)*s];
				temp += dp[rt^1][j-(k+2)*s];
				temp += dp[rt^1][j-(k+3)*s];
				temp += dp[rt^1][j-(k+4)*s];
				temp += dp[rt^1][j-(k+5)*s];
				temp += dp[rt^1][j-(k+6)*s];
				temp += dp[rt^1][j-(k+7)*s];
				temp += dp[rt^1][j-(k+8)*s];
				temp += dp[rt^1][j-(k+9)*s];
				temp += dp[rt^1][j-(k+10)*s];
				temp += dp[rt^1][j-(k+11)*s];
				temp += dp[rt^1][j-(k+12)*s];
				temp += dp[rt^1][j-(k+13)*s];
				temp += dp[rt^1][j-(k+14)*s];
				temp += dp[rt^1][j-(k+15)*s];
			}
			for(;k < n &&j - k*s >= 0; ++k) temp += dp[rt^1][j-k*s];
			dp[rt][j] = temp%mod;
		}
	}
	ll ans = 0;
	for(int i = 0;i < n; ++i) {
		int j = n-i-1;
		ans += 1ll*(j+1)* dp[rt][i];
		ans %= mod;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string a;
    cin >> a;

    if (a[2] == a[3] && a[4] == a[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    s = input()
    t = input()

    if s == t[:-1]:
        print('Yes')
    else:
        print('No')

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """chokudai
chokudaiz"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """snuke
snekee"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """a
aa"""
        output = """Yes"""
        self.assertIO(input, output)


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


Measured memory_bytes: 16288
N,M = gets.split.map(&:to_i)
a = []
b = []
c = []
for i in 0..M-1 do 
    a[i],b[i],c[i] = gets.split.map(&:to_i)
end
dist = Array.new(N).map{Array.new(N)}
#distの初期化
for i in 0..N-1 do
    for j in 0..N-1 do
        if i == j then
            dist[i][j] = 0
        else
            dist[i][j] = 10000
        end
    end
end

for i in 0..M-1 do
    dist[a[i]-1][b[i]-1] = c[i]
    dist[b[i]-1][a[i]-1] = c[i]
end
#ワーシャルフロイド法
for k in 0..N-1 do
    for i in 0..N-1 do
        for j in 0..N-1 do
            dist[i][j] = [dist[i][j],dist[i][k] + dist[k][j]].min
        end
    end
end
#使用されていない辺の計算
sum = 0
for i in 0..M-1 do
    if dist[a[i]-1][b[i]-1] < c[i] then
        sum = sum + 1
    end
end
puts sum


Measured memory_bytes: 2044
b,s,o,i;main(a){for(scanf("%d",&i);i<100&&~scanf("%s",&a);b=a%3?a&1?o?b:(s=!printf("%d\n",b>3?s+b-3:s)):b+1:!(s+=++b))  o=a&1?-~o%3:o;return 0;}

Measured memory_bytes: 0