akhauriyash/Code-Regression huggingface dataset:
class HitBlow
  def check(a, b)
    hits = [a, b].transpose.select { |x, y| x == y }.flatten.uniq
    blows = a & b - hits
    [hits.size, blows.size]
  end
end

STDIN.read.split("\n").each_slice(2) do |a, b|
  result = HitBlow.new.check(a.split.map(&:to_i), b.split.map(&:to_i))
  printf "%s %s\n", result[0], result[1]
end

Measured memory_bytes: 8712
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int k = ni();
        int[] h = new int[n];
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = ni();
        }
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++ ) {
            int min = Integer.MAX_VALUE;
            for (int j = 1; j <= k; j++) {
                if (i - j < 0) {
                    break;
                }
                min = Math.min(min, dp[i - j] + Math.abs(h[i] - h[i - j]));
            }
            dp[i] = min;
        }
        out.print(dp[n - 1]);
        out.close();
    }

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

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

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}


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

typedef long long ll;
using namespace std;

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

    int ans = 0;
    for (int i = 100; 0 < i; --i) {
        for (int j = 0; j < n; ++j) {
            if (h[j] == i) {
                h[j]--;
                // 連続するi群の最後の項の場合
                if (j == n - 1 || h[j + 1] != i) {
                    ans++;
                }
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 5e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
string s;
int dp[N][N];
//dp[i][j]: maximum length of substring s when first start at i and second
//start at j
int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n >> s;
	dp[n][n-1] = 0;
	int ans = 0 ;
	for(int i=n-1; i>=0; i--){
		for(int j=i-1; j>=0; j--){
			if (s[i] == s[j]) dp[i][j] = min(1 + dp[i+1][j+1], i-j);
			else dp[i][j] = 0;
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 96384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> masu(h, vector<char> (w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> masu.at(i).at(j);
        }
    }
    vector<bool> x(w, false);
    vector<bool> y(h, false);
    for (int i = 0; i < h; i++) {
        bool tf = true;
        for (int j = 0; j < w; j++) {
            if (masu.at(i).at(j) == '#') {
                tf = false;
                goto next1;
            }
        }
        y.at(i) = true;
        next1:;
    }
    for (int i = 0; i < w; i++) {
        bool tf = true;
        for (int j = 0; j < h; j++) {
            if (masu.at(j).at(i) == '#') {
                tf = false;
                goto next2;
            }
        }
        x.at(i) = true;
        next2:;
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (y.at(i)) goto next3;
            if (!x.at(j) && !y.at(i)) {
                cout << masu.at(i).at(j);
            }
        }
        cout << endl;
        next3:;
    }
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    long long sum = 0;
    long long x = 0;
    for (int i = 0; i < n; i++) {
        sum = (sum + a.at(i) * x) % 1000000007;
        x = (x + a.at(i)) % 1000000007;
    }
    cout << sum % 1000000007 << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair <int, int>;

int main(){

  int n, K;
  cin >> n >> K;

  vector<int> p(n);
  rep(i,n){
    cin >> p.at(i);
  }
  std::sort(p.begin(), p.end() );
//  rep(i,n){
//    cout << p.at(i)<< endl;
//  }

  int total=0;
  for(int i=0; i< K; i++){
    total += p.at(i);
  }
  cout << total<< endl;

  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	int N;
	cin >> N;
	vector<ll>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	
	ll ans = 0;
	for (int i = 60; i >= 0; i--) {
		int cnt = 0;
		for (int j = 0; j < N; j++)cnt += (A[j]>>i&1);
		if (cnt % 2 == 1) { 
			ans += (1LL << i);
			for (int j = 0; j < N; j++) {
				if(A[j]>>i&1)A[j] -= (1LL << i);
			}
			continue;
		}
	}

	int r = 0;
	for (int i = 60; i >= 0; i--) {
		int ok = 0;
		for (int j = r; j < N; j++) {
			if ((A[j] >> i) & 1) {
				swap(A[r],A[j]);
				ok = 1;
				break;
			}
		}
		if (ok) {
			for (int j = 0; j < N; j++) {
				if (j == r)continue;
				if (A[j] >> i & 1)A[j] ^= A[r];
			}
			r++;
		}
	}
	ll temp = 0;
	for (int i = 0; i < N; i++)temp ^= A[i];
	temp *= 2LL;
	ans += temp;
	puts(ans);

	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long N = scan.nextInt();

        //List<String> NList = new ArrayList<String>();
        //int[] Narray = new int[N];
        long sum = 0;

        for(long i=0; i <= N ;i++){
            if(i%3 == 0 || i%5 == 0){
                continue;
            }
            sum += i;
        }
        System.out.println(sum);
    }
}

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

using namespace std;

const int MAX = 2e5+5;

int N;
int A[MAX];

bool check(int x) {
    vector< pair<int,int> > S;
    for(int i=0; i<N-1; i++) {
        if(A[i+1] > A[i]) {
            continue;
        }
        if(x <= 1) {
            return false;
        }
        int a = A[i+1];
        while(S.size() && (*(S.end()-1)).first > a) {
            S.pop_back();
        }
        if(S.size() && (*(S.end()-1)).first == a) {
            (*(S.end()-1)).second++;
        }
        else {
            S.push_back({a, 1});
        }
        while((*(S.end()-1)).second == x) {
            int d = (*(S.end()-1)).first;
            if(d == 1) {
                return false;
            }
            S.pop_back();
            if(S.size() && (*(S.end()-1)).first == d-1) {
                (*(S.end()-1)).second++;
            }
            else {
                S.push_back({d-1,1});
            }
        }
    }
    return true;
}

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

    int L = 1, R = N;
    while(L != R) {
        int mid = (L + R) >> 1;
        if(check(mid)) {
            R = mid;
        }
        else {
            L = mid+1;
        }
    }

    cout << L << "\n";

    return 0;
}


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

		
#階乗#
lim = 4*10**5   #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod

n, k = MAP()

if n-1 <= k:
	print(C(2*n-1, n))
	exit()

ans = 0
for i in range(k+1):
	ans += C(n, i) * C(n-1, i) % mod
	ans %= mod

print(ans)



Measured memory_bytes: 83692
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define long long long 
typedef pair<long,long> pii;
vector<vector<pii> > makedata(long v,long e){
    vector<vector<pii> > ans(v+1);
    long a,b,c;
    for(int i = 0;i<e;i++){
        cin >> a >> b >> c;
        ans[a].push_back(make_pair(b,c));
        ans[b].push_back(make_pair(a,c));
    }
    return ans;
}
vector<long> dijkstra(long v, long e,long a){
    const long INF = 1e15;
    vector<vector<pii> > edge=makedata(v,e);
    priority_queue<pii,vector<pii>,greater<pii> > que;
    vector<long> dist(v+1,INF);
    dist[a] = 0;
    que.push(make_pair(0,a));
    while(!que.empty()){
        pii pr = que.top();
        que.pop();
        long dis = pr.first;
        long ver = pr.second;
        if(dis>dist[ver]) continue;
        for(int i = 0;i<edge[ver].size();i++){
            if(dist[edge[ver][i].first] > dist[ver]+edge[ver][i].\
			second){
                que.push(make_pair(dist[ver]+edge[ver][i].second,\
				edge[ver][i].first));
                dist[edge[ver][i].first]=dist[ver]+edge[ver][i].second;
            }
        }
    }
    return dist;
}
int main(){
    long n;
    cin >> n;
    vector<long> distance = dijkstra(n,n-1,1);
    for(int i = 1;i<=n;i++){
        cout << distance[i]%2 << endl;
    }
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=500020;

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
  
      ll n,k;
      cin>>n>>k;
      ll a[n];
      forn(i,n) cin>>a[i];
      ll ans=0;
      ford(x,40)
      {
        ll cnt1=0,cnt2=0;
        forn(i,n)  
        {
          if((a[i]>>x)&(1LL)) cnt1++;
          else cnt2++;
        }
        //cout<<cnt1<<" "<<cnt2<<"\n";
        if(cnt1>=cnt2)
        {
            
        } 
        else{
          if(ans+(1LL<<x)<=k)
          {
           ans+=(1LL<<x);
          }
        }
      }
      ll an=0;
      forn(i,n) an+=(a[i]^ans);
      cout<<an;
}

Measured memory_bytes: 1024
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> bs(n); cin >> bs;
    vector<int> ans;
    for(int i = n; i > 0; i--){
        bool ok = false;
        for(int j = i - 1; j >= 0; j--){
            if(bs[j] == j + 1){
                ans.push_back(bs[j]);
                for(int j2 = j; j2 < n - 1; j2++){
                    bs[j2] = bs[j2 + 1];
                }
                n--;
                ok = true;
                break;
            }
        }
        bs.resize(n);
        printde(bs);
        if(!ok){
            cout << -1 << '\n';
            return 0;
        }
    }
    reverse(ans.begin(), ans.end());
    for(auto& a : ans){
        cout << a << '\n';
    }
}


Measured memory_bytes: 256
import sys
s = input()

if s[0] == 'A':
    if 'C' in s[2:-1]:
        cidx = s.find('C')
        for i in range(1, len(s)):
            if i != cidx:
                if s[i].isupper():
                    print('WA')
                    sys.exit()
        print('AC')
        sys.exit()
    else:
        print('WA')
        sys.exit()
else:
    print('WA')
    sys.exit()

print('WA')

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

using namespace std;
using ll = long long;

int n, m;
vector<vector<int>> hen;
vector<int> dp;

int dfs(int v) {

    if(dp[v] != -1)return dp[v];
    dp[v] = 0;
    for(auto i : hen[v]) {
        dp[v] = max(dp[v], dfs(i) + 1);
    }
    return dp[v];

}

int main()
{
    cin >> n >> m;
    hen.resize(n), dp.resize(n, -1);
    for(int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--, b--;
        hen[a].push_back(b);
    }

    for(int i = 0; i < n; i++) {
        dfs(i);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;

}

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

char a = 'a';
int yesorno;
string s;
int ans;

int main()
{
	cin >> s;
	for(int i = 1 ; i <= 26 ; i ++)
	{
		yesorno = 0;
		for(int j = 1 ; j <= s.length() ; j ++)
		{
			if(a + (i - 1) == s[j - 1])
			{
				yesorno = 1;
				break;
			}
		}
		if(yesorno == 0)
		{	
			ans = i;
			break;
		}
	}
	if(ans == 0)
	{
		cout << "None" << endl;
	}
	else
	{
		cout << (char)('a' + (ans - 1)) << endl;
	return 0;
	}
}	


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b==1)return a%MOD;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max((a+b)-n,(long long)0)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	int an[][]=new int[n][26];
	int bn[][]=new int[n][26];
	int min=50;
	int ans[] =new int[26];
	int a ='a';
	List<String> list = new ArrayList<String>();
    for(int i=0;i<n;i++){
    	list.add(scan.next());
    }
    for(int i=0;i<n;i++){
    	an=ch(list.get(i),i,n);
    	for(int f=0;f<26;f++){
    		bn[i][f]=an[i][f];
    	}
    }
    for(int f=0;f<26;f++){
    	min=50;
    	for(int i=0;i<n;i++){
    		if(min>bn[i][f]){
    			min=bn[i][f];
    		}
    	}
    ans[f]=min;
    }
    for(int i=0;i<26;i++){
    	a='a';
    	a=a+i;
    	for(int f=0;f<ans[i];f++){

    		System.out.print((char)a);
    	}
    }
}
	public static List<Character > cha(String s){
		List<Character > a = new ArrayList<Character >();
		for(int i=0;i<s.length();i++){
			a.add(s.charAt(i));
		}
		return a;
	}
	public static int[][] ch(String st,int b,int n){
		int [][] c=new int[n][26];
		for(int f=0;f<26;f++){
			int count=0;
			int a='a';
			a=a+f;
			for(int i=0;i<st.length();i++){
				if((char)a==st.charAt(i)){
				count++;
				}
			}
		c[b][f]=count;
		}
		return c;
	}
}

Measured memory_bytes: 23764
#!/usr/bin/env python3
# from typing import *

# def solve(X: int, Y: int, Z: int) -> Any:
def solve(x, y, z):
    x, y = y, x
    x, z = z, x
    return x, y, z

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    X, Y, Z = map(int, input().split())
    ans = solve(X, Y, Z)
    print(*ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int a,ans=1;
    char c;
    cin>>a;
    vector<char> b(a);
    for(int z=1;z<=a;z++){
        cin>>b[z];
    }
    c=b[1];
    for(int x=2;x<=a;x++){
        if(c!=b[x]){
            c=b[x];
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            ll n;
            cin>>n;
            ll sum=7,s=10;
            REP(i,0,1e6){
                if(sum%n==0)
                    return cout<<i+1,0;
                sum*=10;
                sum%=n;
                sum+=7;
                sum%=n;
            }  
            cout<<-1;
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <queue>
#include <string>
#include <vector>

int main() {
    std::string S;
    std::cin >> S;

    std::vector<int> cnt(26, 0);
    for (char c : S) ++cnt[c - 'a'];

    // (出現回数の総和、文字の集合)の昇順ヒープ
    std::priority_queue<std::pair<int, std::vector<int>>,
                        std::vector<std::pair<int, std::vector<int>>>,
                        std::greater<std::pair<int, std::vector<int>>>>
        que;

    for (int i = 0; i < 26; ++i) {
        if (cnt[i] > 0) que.emplace(cnt[i], std::vector<int>({i}));
    }

    // 文字が1種類だけの場合は例外
    if (que.size() == 1) {
        std::cout << S.length() << std::endl;
        return 0;
    }

    std::vector<int> len(26, 0);  // 各文字に対応するコードの長さ

    while (que.size() > 1) {
        int sum = 0;
        std::vector<int> nums;
        for (int i = 0; i < 2; ++i) {
            auto p = que.top();
            que.pop();
            sum += p.first;
            std::copy(p.second.begin(), p.second.end(), std::back_inserter(nums));
        }

        for (auto i : nums) ++len[i];
        que.emplace(sum, nums);
    }

    int ans = 0;
    for (char c : S) ans += len[c - 'a'];
    std::cout << ans << std::endl;
    return 0;
}



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

int main(){
    long long N;
    long long A[100005] = {};
    long long B[100005] = {};
    long long ans = 0;
    long long borrow = 0;

    cin >> N;
    for(long i=0;i<N+1;i++) cin >> A[i];
    for(long i=0;i<N;i++) cin >> B[i];
    for(long i=0;i<N;i++){
        long long Bpower = B[i] + borrow;
        if(Bpower > A[i]){
            ans += A[i];
            if(borrow > A[i]){
                borrow = B[i];
            }
            else{
                borrow = Bpower - A[i];
            }
        }
        else{
            ans += Bpower;
            borrow = 0;
        }
    }
    ans += min(A[N], borrow);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b, c, k;
  while (cin >> a) {
    cin >> b >> c >> k;
    int x = min(a, k);
    k -= a;
    if (k > 0) {
      k -= b;
    }
    if (k > 0) {
      x -= min(k, c);
    }
    cout << x << endl;
  }
}

Measured memory_bytes: 3612
num=input().split(" ")
num1=int(input())
A=int(num[0])
B=int(num[1])
C=int(num[2])
sum=0
while A>=B:
    sum+=1
    B=2*B
while B>=C:
    sum+=1
    C=2*C
if sum>num1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9188
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	long long N, M;
	cin >> N>>M;
	if(N>=2&&M>=2)cout << (N - 2)*(M - 2);
	else if (N == 1&&M>=2)cout << M - 2;
	else if(M==1&&N>=2)cout << N - 2;
	else cout <<1;
}



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

if a+k-1>=b-k+1:
    for i in range(a,b+1):
        print(i)
    quit()

ans=[]
for i in range(a,a+k):
    ans.append(i)

for i in range(b-k+1,b+1):
    ans.append(i)

for i in sorted(set(ans)):
    print(i)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> dp(N + 1);
    int cnt = 0;
    Rep(i, N) {
        if (i) {
            if (S[i - 1] == 'A' && S[i] == 'C') cnt++;
        }
        dp[i + 1] = cnt;
    }
    Rep(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l] << endl;
    }
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin>>n>>m;

    int ans = 1;
    auto d = divisor(m);

    FORR(i,0,d.size()){
        if(m%d[i]!=0) continue;

        int tmp = m/d[i];
        //DEBUG2(d[i],tmp);
        if(tmp < n) continue;

        chmax(ans, (int)d[i]);
        break;
    }

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

Measured memory_bytes: 3628
Class Main
    Public Shared Sub Main()
    Dim NK() As string = Split(Console.ReadLine())
    dim N as integer = cint(NK(0))
    dim K as integer = cint(NK(1))
    dim S(N) as string
    dim i1, i2, i3 as integer
    for i1 = 1 to N
    	S(i1) = ""
  	next i1
    for i1 = 1 to K    
        dim d as integer = Console.ReadLine
    	Dim A() As string = Split(Console.ReadLine())
    	for i2 = 0 to d - 1
  			i3 = cint(A(i2))
  			S(i3) = "1"
  		next i2
	next i1
	I2 = 0
   for i1 = 1 to N
		if S(i1) = "" then
			i2 += 1
		end if
  	next i1
      Console.WriteLine(i2)
   End Sub
End Class


Measured memory_bytes: 28788
#include <iostream>
#include <string>

using namespace std;

int main ()
{
  string str;
  string r_str;
  int N;
  int a, b;

  cin >> str;
  cin >> N;

  string order[N];
  for(int i=0; i<N; ++i){
    cin >> order[i];
    cin >> a >> b;

    /*-------------------------------------*/
    if(order[i] == "replace"){
      cin >> r_str;
      if(b-a+1 == r_str.length()){
        int k=0;
        for(int j=a; j<=b; ++j){
          str[j] = r_str[k];
          k++;
        }
      }
    }

    /*-------------------------------------*/
    else if(order[i] == "reverse"){
      while(a < b){
        swap(str[a++], str[b--]);
      }
    }

    /*-------------------------------------*/
    else if(order[i] == "print"){
      for(int j=a; j<=b; ++j){
        cout << str[j];
      }
      cout << endl;
    }

  }

  return 0;
}


Measured memory_bytes: 3236
import java.util.Scanner;
public class Main
{
    public static void main(String args[]){
        Scanner R = new Scanner(System.in);
        int rate = R.nextInt();
        if(rate >= 0 && rate < 1200){
            System.out.println("ABC");
        }
        else if (rate >= 1200 && rate < 2800){
            System.out.println("ARC");
        }
        else if (rate >= 2800){
            System.out.println("AGC");
            
        }
        R.close();
    }
    
}


Measured memory_bytes: 21844
from sys import stdin

a=int(stdin.readline())
dp=[10**9]*(a+1)
dp[0]=0
dp[1]=0
B=stdin.readline().split()
dp[2]=abs(int(B[1])-int(B[0]))

# dp[i]=min cost to reach stone i
for k in range(3,a+1):
    dp[k]=min((dp[k-1]+abs(int(B[k-1])-int(B[k-2]))),dp[k-2]+abs(int(B[k-1])-int(B[k-3])))



print(dp[a])

Measured memory_bytes: 13720
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
void p(int a,int b){
  cout<<a<<" "<<b<<endl;
}
void p(pii a){
  cout<<a.ST<<" "<<a.ND<<endl;
}

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
  int n,k;
  cin>>n>>k;
  if(n==2){
    if(k==0){
      cout<<1<<endl;
      p(1,2);
    }else{
      cout<<-1<<endl;
    }
    return 0;
  }
  if((n-1)*(n-2)/2<k){
    cout<<-1<<endl;
    return 0;
  }
  vector<pii> e;
  FOR(i,2,n+1){
    e.PB(MP(1,i));
  }
  int c=(n-1)*(n-2)/2-k;
  FOR(i,2,n+1){
    if(c==0)break;
    FOR(j,i+1,n+1){
      if(c==0)break;
      e.PB(MP(i,j));
      c--;
    }
  }
  cout<<e.size()<<endl;
  for(auto pr:e){
    p(pr);
  }

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;
ll bigp = 1000000007;

int main()
{
    ll a,b;
    cin >> a >> b;
    cout << max(0LL,a-2*b);
}


Measured memory_bytes: 256
'''
https://atcoder.jp/contests/abc084/tasks/abc084_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    def primecheck(n):
        p = [True] * (n + 1)
        p[0] = False
        p[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if p[i]:
                for j in range(i * i, n + 1, i):
                    p[j] = False
        return p
    
    p = primecheck(10**5)
    cnt = 0
    res = [0]*(10**5)
    for i in range(1, 10**5, 2):
        if p[i]==p[(i+1)//2]==1:
            cnt += 1
        res[i] = cnt


    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        if l==1:
            print(res[r])
        elif res[l]==res[l-2]:
            print(res[r]-res[l])
        else:
            print(res[r]-res[l]+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

bool cmp(ll &a, ll &b) {
    return abs(a) > abs(b);
}

ll modinv(ll a, ll m) {
    ll x = 1, y = 0, b = m;
    while (b) {
        ll s = a / b;
        // matrix{{0, 1}, {1, -s}}
        a -= s * b;
        x -= s * y;
        swap(a, b);
        swap(x, y);
    }
    x %= m;
    if (x < 0)
        x += m;
    return x;
}

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

    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    bool allm = K & 1;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] >= 0)
            allm = false;
    }

    ll ans = 1;
    if (allm) {
        sort(A.rbegin(), A.rend(), cmp);
        for (int i = 0; i < K; ++i)
            (ans *= A[i]) %= MOD;
        if (ans < 0)
            ans += MOD;
        cout << ans << endl;
        return 0;
    }

    if (N == K) {
        for (int i = 0; i < K; ++i)
            (ans *= A[i]) %= MOD;
        if (ans < 0)
            ans += MOD;
        cout << ans << endl;
        return 0;
    }

    sort(A.begin(), A.end(), cmp);

    bool pexist = false;
    ll pnxt1 = 1, mnxt1 = 0;
    ll pnxt2 = 0, mnxt2 = 0;
    for (int i = 0; i < N; ++i) {
        if (i < K) {
            (ans *= A[i]) %= MOD;
            if (A[i] > 0) {
                pnxt1 = A[i];
                pexist = true;
            }
            if (A[i] < 0)
                mnxt1 = A[i];
        } else {
            if (A[i] >= 0 && pnxt2 < A[i])
                pnxt2 = A[i];
            if (A[i] < 0 && mnxt2 > A[i])
                mnxt2 = A[i];
        }
    }

    if (ans < 0) {
        ll puse = pnxt1 * pnxt2;
        ll muse = mnxt1 * mnxt2;
        if (!pexist)
            muse = 0;
        if (puse >= muse) {
            (ans *= modinv(mnxt1 + MOD, MOD)) %= MOD;
            (ans *= pnxt2) %= MOD;
        } else {
            (ans *= modinv(pnxt1, MOD)) %= MOD;
            (ans *= mnxt2) %= MOD;
        }
    }

    if (ans < 0)
        ans += MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int rank =0;
  int ab = gcd11(a, b);
  for(int i=1;i<=ab;i++){
    if(ab%i ==0){
      rank++;
      if(rank==k){
        ab= ab/i;
        break;
      }
    }
  }
  cout << ab <<endl;
  
}

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

#define SIZE 100100
#define INF 1001001001

int n;
pair<char, int> card1[SIZE], card2[SIZE], L[SIZE / 2], R[SIZE / 2];

int partition(int p, int r) {
    int x = card1[r].second;
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (card1[j].second <= x) {
            i++;
            swap(card1[i], card1[j]);
        }
    }
    swap(card1[i + 1], card1[r]);
    return i + 1;
}

void quickSort(int p, int r) {
    if (p >= r) return;
    int q = partition(p, r);
    quickSort(p, q - 1);
    quickSort(q + 1, r);
    return;
}

void merge(int left, int middle, int right) {
    int n1 = middle - left, n2 = right - middle;
    for (int i = 0; i < n1; i++) L[i] = card2[left + i];
    for (int i = 0; i < n2; i++) R[i] = card2[middle + i];
    L[n1].second = R[n2].second = INF;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].second <= R[j].second) {
            card2[k] = L[i];
            i++;
        } else {
            card2[k] = R[j];
            j++;
        }
    }
    return;
}

void mergeSort(int left, int right) {
    if (right - left <= 1) return;
    int middle = (left + right) / 2;
    mergeSort(left, middle);
    mergeSort(middle, right);
    merge(left, middle, right);
    return;
}

int main() {
    cin >> n;
    char suit;
    int value;
    for (int i = 0; i < n; i++) {
        cin >> suit >> value;
        card1[i] = card2[i] = make_pair(suit, value);
    }

    quickSort(0, n - 1);
    mergeSort(0, n);

    bool ans = true;
    for (int i = 0; i < n; i++) {
        if (card1[i].first != card2[i].first) ans = false;
    }

    cout << (ans ? "Stable" : "Not stable") << endl;
    for (int i = 0; i < n; i++) {
        cout << card1[i].first << " " << card1[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 5452
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	if (n != t.size()) {
		cout << "No" << endl;
		return;
	}
	vector<int> v(26), chk(26);
	rep(i, 26) v[i] = i;
	rep(i,n) {
		char c = s[i];
		char d = t[i];
		if (chk[c - 'a']) {
			if (v[c - 'a'] == d - 'a') continue;
			cout << "No" << endl;
			return;
		} else {
			int l = 0;
			rep(j, 26) {
				if (v[j] == d - 'a') l = j;
			}
			if (!chk[l]) {
				swap(v[c - 'a'], v[l]);
				chk[c - 'a']++;
			} else {
				cout << "No" << endl;
				return;
			}
		}
	}
	cout << "Yes" << endl;
}

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

Measured memory_bytes: 3932
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int n;
	cin >> n;

	vector<int> ans(n);
	int v;
	for (int x = 1; x < 101; ++x)
	{
		for (int y = 1; y < 101; ++y)
		{
			for (int z = 1; z < 101; ++z)
			{
				v = x*x + y*y + z*z + x*y + y*z + z*x;
				if (v <= n)
					ans[v-1] += 1;
			}
		}
	}
	for (int i = 0; i < n; ++i)
		cout << ans[i] << endl;
}



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


void solve(long long N, std::vector<long long> P){
    ll ma = 1e9;
    int ans = 0;
    for(int i = 0;i < N;i++){
        if(ma >= P[i]){
            ans++;
        }
        ma = min(P[i], ma);
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 300
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int G[N][N];
P SIRO[N];
int n,m,l,s,T;


int dijkstra(){
  vector<vector<int> >D(1<<l,vector<int>(n,T+1));   
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  Q.push(PP(0,P(0,s)));
  D[0][s] = 0;
  
  int res = 0;
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first;
    int bit = t.second.first;
    int pos = t.second.second;
    if(D[bit][pos]<cost)continue;
    if(cost + G[pos][s]<=T)res = max(res,__builtin_popcount(bit));

    
    for(int i=0;i<l;i++){
      int npos = SIRO[i].first;
      int ncost= cost+G[pos][npos]+SIRO[i].second;
      int nbit = bit|1<<i;
      if(bit==nbit||D[nbit][npos]<=ncost)continue;
      Q.push(PP(ncost,P(nbit,npos)));
      D[nbit][npos] = ncost;
    }
  }
  return res;
}

int main(){
  while(1){
    cin>>n>>m>>l>>s>>T;
    if(!n&&!m&&!l&&!s&&!T)return 0;
    s--;
    
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) G[i][j] = i==j? 0:T+1;

    for(int i=0,a,b,c;i<m;i++)cin>>a>>b>>c,G[a-1][b-1] = G[b-1][a-1] = c;
    for(int i=0,j,e;i<l;i++)cin>>j>>e,SIRO[i] = P(j-1,e);
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  G[i][j] = min(G[i][j],G[i][k]+G[k][j]);
    
    cout<< dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 92172
#include <iostream>
#include <string>

using namespace std;

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

    string s; cin >> s;

    int ans1 = 0, ans2 = 0;
    int n = s.size();

    for(int i = 0; i < n; ++i)
    {
        if((s[i] - 48) == (i & 1)) ++ans1;
        else ++ans2;
    }

    cout << (ans1 > ans2 ? ans2 : ans1);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s1 = new Scanner(System.in);
        int n = s1.nextInt();
        int A = s1.nextInt();
        int B = s1.nextInt();
        for(int i = A; i <= B; i++) {
            if(i % n == 0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}


Measured memory_bytes: 35816
import sys
def input(): return sys.stdin.readline().rstrip()

def is_month(n):
    return 1 <= n <= 12

def main():
    s = input()
    s1 = int(s[:2])
    s2 = int(s[2:])

    if is_month(s1) and is_month(s2):
        print('AMBIGUOUS')
    elif is_month(s1):
        print('MMYY')
    elif is_month(s2):
        print('YYMM')
    else:
        print('NA')

if __name__ == '__main__':
    main()

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string res = "None";
    for (char c = 'a'; c <= 'z'; c++) {
        bool b = true;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == c) b = false;
        }
        if (b) {
            res = c;
            break;
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop,heapify
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


x=ii()
a=100
cnt=0
while a<x:
    a=a+a*0.01
    a=int(a)
    cnt+=1
    
print(cnt)


Measured memory_bytes: 72964
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  int best = 1000;
  for (int i = 0; i < s.length() - 2; i++) {
    int j = i + 1;
    int k = i + 2;
    int n = (s[i] - '0') * 100 + (s[j] - '0') * 10 + (s[k] - '0');
    best = min(best, abs(753 - n));
  }
  
  cout << best << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(ele) for ele in input().split()]
dp=[]
dp.append(0)
if h[1]>=h[0]:
    dp.append(h[1]-h[0])
else:
    dp.append(h[0]-h[1])
for i in range(2,n):
    if h[i]>=h[i-1]:
        a=dp[i-1]+h[i]-h[i-1]
    else:
        a=dp[i-1]+h[i-1]-h[i]
    if h[i]>=h[i-2]:
        b=dp[i-2]+h[i]-h[i-2]
    else:
        b=dp[i-2]+h[i-2]-h[i]
    dp.append(min(a,b))
print(dp[n-1])

Measured memory_bytes: 13772
A, B = gets.chomp.split.map(&:to_f)

a0 = (A * 100 / 8).ceil
a1 = (A + 1) * 100 / 8
b0 = (B * 100 / 10).ceil
b1 = (B + 1) * 100 / 10

m = [a0, b0].max

m = -1 unless m < a1 && m < b1

puts m


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
int n,m,nxt[maxn][30];
char s[maxn],t[maxn];
ll ans;
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	scanf("%s",t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	for (int i=1;i<=n;i++) s[i+n]=s[i];
	for (int j=1;j<=26;j++) nxt[n*2+1][j]=-1;
	for (int i=n*2;i>=1;i--) {
		for (int j=1;j<=26;j++)
			nxt[i][j]=nxt[i+1][j];
		if (i) nxt[i][s[i]-'a'+1]=i;
	}
	int pos=1,tmp=0;
	for (int i=1;i<=m;i++) {
		//printf("%d %d\n",t[i]-'a'+1,pos);
		tmp=nxt[pos][t[i]-'a'+1];
		if (tmp==-1) { printf("-1\n"); return 0; }
		ans+=tmp-pos+1;
		pos=tmp+1;
		if (pos>n) pos-=n;
		if (pos>n) pos-=n;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 23936
#include<bits/stdc++.h>
#define N 10
using namespace std;
typedef long long ll;
int n,k,a[N];
set<ll> s;

int check(){
  int perm[N];
  for(int i=0;i<n;i++)perm[i]=i;
  do{
    ll num=0;
    for(int i=0;i<k;i++){
      if(!(a[perm[i]]/10))num=num*10+a[perm[i]];
      else num=num*100+a[perm[i]];
    }
    s.insert(num);
  }while(next_permutation(perm,perm+n));
  return s.size();
}

int main(){
  while(1){
    cin>>n>>k;
    if(!n&&!k)break;
    for(int i=0;i<n;i++)
      cin>>a[i];
    cout<<check()<<endl;
    s.clear();
  }
  return 0;
}

Measured memory_bytes: 3184
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A=gets.chomp.split(' ').map{|n| n.to_i}.sort
B=gets.chomp.split(' ').map{|n| n.to_i}.sort
C=gets.chomp.split(' ').map{|n| n.to_i}.sort
numarr = Array.new(3){Array.new(N){0}}

# このくらいもかんがえられないとかむかつく @ 180208 4AM

# ソートされた配列 arr を与えられて val より大きい値を持つ要素の個数を返す二分木探索
def binary_search(arr, val)
	# 部分問題を解く関数
	# 各呼び出しでは，その区間の個数を返す．
	def inner_binary_search(arr, val, start_from, end_at)
		if(end_at < start_from)
			return 0
		end
		center = start_from + (end_at-start_from)/2
		arr_center = arr[center]
		if(val < arr_center)
			# 右すべて＋左の該当個数
			return (end_at-center+1)+inner_binary_search(arr, val, start_from, center-1)
		else
			# case val >= arr_center 
			return inner_binary_search(arr, val, center+1, end_at)
		end
	end
	inner_binary_search(arr, val, 0, arr.length-1)
end

0.upto(N-1){|i|
	numarr[2][i]=N-i
}

laymap = {0 => A, 1 => B, 2 => C}
1.downto(0){|l|	#layer
	(N-1).downto(0){|i|
		num = binary_search(laymap[l+1], laymap[l][i])
		if(num == 0)
			if(i==N-1)
				numarr[l][i] = 0
			else
				numarr[l][i] = numarr[l][i+1]
			end
		else
			if(i==N-1)
				numarr[l][i] = numarr[l+1][-num]
			else
				numarr[l][i] = numarr[l][i+1] + numarr[l+1][-num]
			end
		end
	}
}
dpp numarr
puts numarr[0][0]



Measured memory_bytes: 38204
import java.util.Scanner;

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

        String S = scanner.nextLine();
        int w = Integer.parseInt(scanner.nextLine());

        int i = 0;
        StringBuilder builder = new StringBuilder();
        while (i < S.length()) {
            builder.append(S.charAt(i));
            i += w;
        }
        System.out.println(builder);
    }
}

Measured memory_bytes: 21716