akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int A, B; cin >> A >> B;
  cout << max(0, A - 2*B) << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;

struct UnionFindTree{
    vector<int> par,rank;
    UnionFindTree(int n):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res*=a;
        a*=a;
        x>>=1;
    }
    return res;
}

int main(){
    int l,r,d;cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Hemant Malviya

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define lld long long int 
#define vint vector<int>
#define vlld vector<long long int>
#define vst vector<string>
#define ps push_back
#define pii pair<int,int>
#define mk make_pair
#define le length
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define sv()                  int t; scanf("%d",&t); while(t--)
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
 
int main()
{
    int n,m;
    cin>>m>>n;
    if(n>=m)cout<<"unsafe";
    else cout<<"safe";
 return 0;   
}

Measured memory_bytes: 3636
//////////package Educ_DP;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] l=s.nextLine().split(" ");
        int num=Integer.parseInt(l[0]);
        int w=Integer.parseInt(l[1]);
        long[][] dp=new long[num+1][w+1];
        long[][] list=new long[num][2];
        for (int i=0;i<num;i++){
            String[] x=s.nextLine().split(" ");
            long[] a=new long[2];
            for (int j=0;j<2;j++){
                a[j]=Long.parseLong(x[j]);
            }
            list[i]=a.clone();
        }
        for (int i=0;i<w+1;i++){
            if (list[0][0]<=i){
                dp[1][i]=list[0][1];
            }
        }
        for (int i=2;i<num+1;i++){
            for (int j=1;j<w+1;j++){
                dp[i][j]=dp[i-1][j];
                int left=(int)(j-list[i-1][0]);
                if (left>=0){
                    dp[i][j]=Math.max(dp[i][j],dp[i-1][left]+list[i-1][1]);
                }
            }
        }
        System.out.println(dp[num][w]);



    }
}


Measured memory_bytes: 140456
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int main(void) {
	int D;
    scanf("%d", &D);

    if ( D == 25 ) puts("Christmas");
    else if ( D == 24 ) puts("Christmas Eve");
    else if ( D == 23 ) puts("Christmas Eve Eve");
    else puts("Christmas Eve Eve Eve");

	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::HashSet;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    let lns = read_t_in_line::<usize>();
    let (n, k) = (lns[0], lns[1]);
    let mut v = (0..n).map(|_| read_t_in_line::<i32>()[0] ).collect::<Vec<i32>>();
    v.sort();

    let mut ans = 1000000000;
    for i in 0..n {
        if i + k > n {
            break;
        }
        else{
            ans = min(ans, (v[i + k - 1] - v[i]));
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    
    int n = s.size();
    int ans = n;
    
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            int p = i+1;
            ans = min(ans,max(p,n-p));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
S = list(map(int, list(input())))

if 0 not in S:
    print(0)

elif 1 not in S:
    print(0)

else:
    zeros = S.count(0)
    ones = S.count(1)
    if zeros > ones:
        print(ones * 2)
    else:
        print(zeros * 2)

Measured memory_bytes: 4772
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,m,las,ans;//fir
struct seg{
	int l,r;
	bool operator <(const seg b)const{
		return (l<b.l)||((l==b.l)&&(r<b.r));
	}
};
seg e[110000];
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m) scanf("%d%d",&e[i].l,&e[i].r);
	sort(e+1,e+m+1);
	las=e[1].r-1;
	ans=1;
	fo(i,2,m) if (e[i].l>las){
		ans++;
		las=e[i].r-1;
	}else las=min(las,e[i].r-1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
int N, K;
ll A[200005];

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

// a^{-1} mod を計算する
ll modinv(ll a) {
    return modpow(a, MOD - 2);
}

ll formatMOD(ll a) {
  if (a<0) a+=MOD;
  return a;
}

int main() {
  INCANT;
  cin >> N >> K;
  bool nega=true;
  rep(i, N) {
    cin >> A[i];
    if (A[i]>=0) nega=false;
  }
  sort(A, A+N,  [&](ll a, ll b) { return abs(a) > abs(b); }); // 絶対値で降順
  ll ret=1ll;
  if (nega&&K%2 || (N==K)) {
    for (int i=N-1;i>=N-K;i--) {
      ret*=A[i];
      ret%=MOD;
    }
    cout << formatMOD(ret) << endl;
    return 0;
  }

  bool fl=true;
  ll x1,x2,y1,y2;
  x1=x2=-1ll;y1=y2=1ll; //x>=0, y<0
  rep(i, K) {
    if (A[i]<0) {
      fl = !fl;
      y1 = A[i];
    } else x1 = A[i];
    ret*=A[i];
    ret%=MOD;
  }
  if (x1==0) {
    cout << 0 << endl;
    return 0;
  } 
  if (fl) {
    cout << formatMOD(ret) << endl;
    return 0;
  }
  // この段階で降順K個の積は負
  for (int i=K; i<N; i++) {
    if (A[i]>=0 && x2<0) x2 = A[i];
    else if (A[i]<0 && y2>0) y2=A[i];
  }
  ll ans1 = ret*modinv(y1)%MOD*x2%MOD;
  ll ans2 = ret*modinv(x1)%MOD*y2%MOD;
  if (y2>0 || x1<0) {
    cout << formatMOD(ans1) << endl;
  } else if (x2<0) {
    cout << formatMOD(ans2) << endl;
  } else {
    // x2/y1 < y2/x1 <=> x2*x1 > y2*y1 (両辺かけるのが負なので)
    ll ans = x1*x2 > y1*y2?ans1:ans2;
    cout << formatMOD(ans) << endl;
  }

  return 0;
}

Measured memory_bytes: 5216
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void in(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y;
int main(){
	in(x);in(y);
	if(x<y)puts("0");
	else puts("10");
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		sum += a.at(i);
	}
	ll snu = a.at(0);
	ll ara = sum - snu;
	ll ans = abs(snu - ara);
	for (int i = 1; i < n - 1; i++) {
		snu += a.at(i);
		ara -= a.at(i);
		ans = min(ans, abs(snu - ara));
	}
	cout << ans << endl;

}

Measured memory_bytes: 1792
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = input()
    b = []
    for i in a:
        b.append(i)

    aset = set(b)

    if len(aset) ==3:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3828
<?php
  $t = trim(fgets(STDIN));
  $len = strlen($t);
//   for($i=0; $i<$len; $i++){
//       if($t[$i] == "P" || $t[$i] == "?"){
//           if(isset($t[$i+1]) && $t[$i+1] == "?"){
//               $t[$i+1] = "D";
//           }
//       }
//   }
  
  for($i=0; $i<$len; $i++){
      if($t[$i] == "?") $t[$i] = "D";
  }
  
  echo $t;

Measured memory_bytes: 16476
n = int(input())
l = list(map(int, input().split()))
e, c = 0, 0
for i in range(n):
    if l[i] % 2 == 0:
        if l[i] % 3 == 0 or l[i] % 5 == 0:
            c += 1
        else:
            print("DENIED")
            exit()
        e += 1
if e == c:
    print("APPROVED")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);


	int r;
	cin >> r;

	cout << fixed << setprecision(10) << r * 1.0 * acos(-1) * 2 << endl;

	return 0;
}

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

bool check(string s1, string s2) {
    int l1 = 0, l2 = 0, diff = 0;
    while (l1 < s1.size() || l2 < s2.size()) {
        if (l1 == s1.size() || l2 == s2.size()) return false;
        if (s1[l1] != s2[l2]) return false;
        if (s1[l1] == '"') {
            l1++;
            string t1 = "";
            while (s1[l1] != '"') t1 += s1[l1++];
            l2++;
            string t2 = "";
            while (s2[l2] != '"') t2 += s2[l2++];
            l1++;
            l2++;
            if (t1 != t2) diff++;
        } else {
            l1++;
            l2++;
        }
    }
    return diff <= 1;
}

int main() {
    string s1, s2;
    while (1) {
        cin >> s1;
        if (s1 == ".") break;
        cin >> s2;
        if (s1 == s2) {
            cout << "IDENTICAL" << endl;
        } else {
            cout << (check(s1, s2) ? "CLOSE" : "DIFFERENT") << endl;
        }
    }
    return 0;
}


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

int main(void){
	long long N, K, result;
	cin >> N >> K;
	long cnt = N / K;
	result = cnt * cnt * cnt;
	if(K % 2 == 0){
		cnt = (N + K / 2) / K;
		result += cnt * cnt * cnt;
	}
	cout << result;
	return 0;
}


Measured memory_bytes: 256
///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

#include<bits/stdc++.h>
using namespace std;

#define          FaRaBi                 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define          ll                     long long int
#define          ld                     long double
#define          pii                    pair < int, int>
#define          pll                    pair < ll, ll>
#define          MOD                    1000000007
#define          ff                     first
#define          ss                     second
#define          pb                     push_back
#define          pf                     printf
#define          mp                     make_pair
#define          gcd(a, b)              __gcd(a,b)
#define          lcm(a, b)              ((a)*(b)/gcd(a,b))
#define          PI                     acos(-1.0)
#define          zero(a)                memset(a,0,sizeof a)
#define          all(v)                 v.begin(),v.end()
#define          Max(v)                 *max_element(all(v))
#define          Min(v)                 *min_element(all(v))
#define          Upper(c,x)             (upper_bound(c.begin(),c.end(),x)-c.begin())
#define          Lower(c,x)             (lower_bound(c.begin(),c.end(),x)-c.begin())
#define          Unique(X)              (X).erase(unique(all(X)),(X).end())
#define          no                     cout << "NO" << endl ;
#define          yes                    cout << "YES" << endl ;
#define          segment_tree           int Lnode = node << 1 , Rnode = Lnode + 1 , mid = ( b + e ) >> 1 ;

///--------------------**********----------------------------------

vector < ll > v, v1, v2, v3, v4 ;
vector < pair < ll, pll > > vec1, vec2 ;
vector < pll > vec, Vec ;
vector < ll > adj[ 25 ] ;
map < char, ll > Mp, Mp1, Mp2 ;
set < char > st, st1, st2 ;
queue < ll > Q ;
stack < char > Stk ;
multiset < char > S ;
vector < string > vs ;


///---------------------**********--------------------------------

ll n, m, x, y ;
string s ;

void Reset()
{

}

void Input()
{
    cin >> n >> m ;
    for( int i = 0 ; i < n ; i ++ )
    {
        cin >> s ;
        vs.pb( s ) ;
    }
}

void Calculation()
{
    sort( all( vs ) ) ;
    string ans = "" ;
    for( int i = 0 ; i < n ; i ++ )
    {
        ans += vs[ i ] ;
    }
    cout << ans << endl ;
}

void solve()
{
    Reset() ;
    Input() ;
    Calculation() ;
}

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


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

int main() {
  int h,w;cin>>h>>w;
  vector<string> v(h);
  rep(i,h){cin>>v.at(i);}
  vector<vector<int>> vec(h,vector<int>(w,0));
  rep(i,h){
    rep(j,w){
      if(v[i].at(j)=='#'){
        vec[i][j]=9;
        if(j>0){
          if(v[i].at(j-1)!='#')vec[i][j-1]++;}
        if(j<w-1){
          if(v[i].at(j+1)!='#')vec[i][j+1]++;}
        if(i>0&&j>0){
          if(v[i-1].at(j-1)!='#')vec[i-1][j-1]++;}
        if(i>0){
          if(v[i-1].at(j)!='#')vec[i-1][j]++;}
        if(i>0&&j<w-1){
          if(v[i-1].at(j+1)!='#')vec[i-1][j+1]++;}
        if(i<h-1&&j>0){
          if(v[i+1].at(j-1)!='#')vec[i+1][j-1]++;}
        if(i<h-1){
           if(v[i+1].at(j)!='#')vec[i+1][j]++;}
        if(i<h-1&&j<w-1){
          if(v[i+1].at(j+1)!='#')vec[i+1][j+1]++;}
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(vec[i][j]==9)cout<<"#";
      else{cout<<vec[i][j];}
      if(j==w-1)cout<<endl;
    }
  }
}
      



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); i++) {
    s[i] = ((s[i] - 'A') + n) % 26 + 'A';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    string s;
    int n,a,b,c,d,e,x,y,m;
    cin >> s;
    if(s == "ABC")s[1] = 'R';
    else s[1] = 'B';
    cout << s << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a, b;
  in2(n, m);
  vector<vector<ll>> c(m, vector<ll> (0));
  vector<ll> d(m);
  rep(i, m){
    in(a);
    rep(j, a){
      in(b);
      c[i].pb(b - 1);
    }
  }
  a = 0;
  bool h;
  rep(i, m)
    in(d[i]);
  rep(te, 1 << n){
    bitset<10> s(te);
    h = true;
    rep(i, m){
      b = 0;
      rep(j, c[i].size()){
        if(s.test(c[i][j]))
           b++;
      }
      if(b % 2 != d[i])
        h = false;
    }
    if(h)
      a++;
  }
  out(a);
  memi;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int a, b, c, k;

	scanf("%d%d%d%d", &a, &b, &c, &k);

	if (k < a) {
		printf("%d", k);
	}
	else if (k < a + b) {
		printf("%d", a);
	}
	else {
		printf("%d", 2*a+b-k);
	}

	return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;

  cout << a * b << endl;

  return 0;
}

/*
1101
0111101101
*/

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

typedef long long ll;

#ifndef YUKININO
#define cerr if (false) cerr
#endif
#define debug(x) cerr << "[" << #x": " << x << "]" << endl
template <class T, class U> ostream& operator<< (ostream& out, const pair<T, U> &x) { return out << x.first << " " << x.second; }
template <class T> ostream& operator<< (ostream& out, const vector<T> &vec) { for (auto i = vec.begin(); i != vec.end(); i++) { if (i != vec.begin()) out << " "; out << *i; } return out; }

void solve();
int main() {
#ifdef YUKININO
  freopen("Testing.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int T = 1;
  // cin >> T;
  while (T--) solve();
  debug((clock() * 1.0 / CLOCKS_PER_SEC));
}
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;

void solve() {
  int a, b, c;
  while (cin >> a >> b >> c) {
    int x = min(c, b / a);
    cout << x << "\n";
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j,k;
  cin>>k;
  string s;
  cin>>s;
  n=s.size();
  if(n<=k) cout<<s;
  else
  {
    for(i=0;i<k;i++) cout<<s[i];
    cout<<"...";
  }
}

Measured memory_bytes: 3628
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        mut s: [chars; n],
    }

    let mut cs = s[0].clone();
    cs.sort();
    for i in 0..n {
        s[i].sort();

        let mut j = 0;
        let mut k = 0;
        let mut ncs = vec![];
        while j < cs.len() && k < s[i].len() {
            if cs[j] == s[i][k] {
                ncs.push(cs[j]);
                j += 1;
                k += 1;
            } else if cs[j] < s[i][k] {
                j += 1;
            } else if cs[j] > s[i][k] {
                k += 1;
            }
        }
        cs = ncs;
    }
    cs.sort();
    println!("{}", cs.into_iter().collect::<String>());
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
using llint = long long int;
int n;
vector<int> vx;
vector<int> vsorted;

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    vx.push_back(x);
    vsorted.push_back(x);
  }

  sort(vsorted.begin(), vsorted.end());

  int a, b;
  a = vsorted[n / 2 - 1];
  b = vsorted[n / 2];

  for (int i = 0; i < n; i++)
  {
    if (vx[i] < b)
    {
      cout << b << endl;
    }
    else
    {
      cout << a << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3948
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();

		String aUpper = a.toUpperCase();

		if (a.equals(aUpper)){
			System.out.println("A");
		} else {
			System.out.println("a");
		}
	}

}

Measured memory_bytes: 35764
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
x = 0
y = 0
z = 0

for i in range(n):
    if p[i] <= a:
        x += 1
    elif a + 1 <= p[i] and p[i] <= b:
        y += 1
    else:
        z += 1

print(min(x,y,z))

Measured memory_bytes: 9180
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int max = 0,min = 1000000000;
		for(int i = 0;i < n;i ++) {
			int d = in.nextInt();
			max = Math.max(max, d);
			min = Math.min(min, d);
		}
		System.out.println(max - min);
	}
}


Measured memory_bytes: 23764
import numpy as np

# import sys
# sys.setrecursionlimit(200000)

N = int(input())
b = list(map(int, input().split(" ")))

res = []

while len(b) > 0:
    seq = np.arange(1, len(b) + 1)
    same = np.where(np.array(b) == seq)[0]
    if len(same) == 0:
        print(-1)
        exit()
    else:
        maximum = same[-1]
    res.append(str(b.pop(maximum)))

print("\n".join(res[::-1]))

Measured memory_bytes: 18984
k = int(input())
n = 7
c = 1
f = 1
if k % 2 == 0:
  print(-1)
else:
  while c < 1000000:
    tmp = n % k
    if tmp == 0:
      print(c)
      f = 0
      break
    else:
      n = tmp * 10 + 7
      c += 1
  if f == 1:
    print(-1)

Measured memory_bytes: 9168
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int k,x=1e6;
    cin>>k;
    int st=7,ans=0;
    map<int,int> h;
    for(int i=0;i<=x;i++)
    {
        h[st]++;
        if(st % k == 0 || st == 0)
        {
            cout<<ans+1;
            return;
        }
        st=st*10+7;
        st=st%k;
        ans++;
        if(h[st]!=0)
        {
            cout<<-1;
            return;
        }
    }
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    string s,t;
    cin >> s >> t;
    cout << t + s << endl;
}

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

int main(void) {
  long long  a, b, x;
  cin >> a >> b >> x;
  
  if (a == 0) {
    cout << b / x + 1 << endl;
  }
  else {
    cout <<  b / x - (a - 1) / x << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
l = []
for j in range(1,n+1):
    if j%2 != 0:
        l.append(j)
b = 0
for i in l:
    a = 0
    for k in range(1,i+1):
        if i%k == 0:
            a += 1
    if a == 8:
        b += 1
print(b)



Measured memory_bytes: 3060
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let (n, k) = (io.read::<usize>(), io.read::<usize>());
    let mut a = io.readn::<usize>(n);
    for _ in 0..k {
        let mut ls = vec![0usize; n];
        let mut rs = vec![0usize; n + 1];
        let mut alln = true;
        for i in 0..n {
            ls[i.saturating_sub(a[i])] += 1;
            rs[min(n - 1, i.saturating_add(a[i])) + 1] += 1;
        }
        let mut now = 0;
        let mut nxt = vec![0; n];
        for i in 0..n {
            now += ls[i];
            now -= rs[i];
            nxt[i] = now;
        }
        if ls[0] == n && rs[n] == n {
            a = nxt.clone();
            break;
        }
        a = nxt.clone();
    }
    for &c in a.iter() {
        print!("{} ", c);
    }
    println!("");
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const int INF=(int)-2e9;

vector<pair<int,int>> to[100005];

int main() {
    int N,M;
    cin>>N>>M;

    int L,R,D;
    for (int i = 0; i < M; ++i) {
        cin>>L>>R>>D; L--; R--;
        to[L].push_back(make_pair(R,D));
        to[R].push_back(make_pair(L,-D));
    }

    vector<int> dist(N,INF);
    for (int i = 0; i < N; ++i) {
        if(dist[i]>INF) continue;
        queue<int> q;
        dist[i]=0;
        q.push(i);
        while(!q.empty()){
            int node=q.front();
            q.pop();
            for(auto tsugi:to[node]){
                if(dist[tsugi.first]==INF){
                    dist[tsugi.first]=dist[node]+tsugi.second;
                    q.push(tsugi.first);
                }else{
                    if(dist[tsugi.first]!=dist[node]+tsugi.second){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 9344
#include<stdio.h>
#define MAX 500000
#define SENTI 2000000000

int L[MAX / 2 + 2],R[MAX / 2 + 2];
int count = 0;

void mergeSort(int *,int ,int ,int);
void merge(int *,int ,int ,int,int);

int main(){
  int A[MAX],n,i;

  scanf("%d",&n);
  for (i = 0 ; i < n ; i++) {
  scanf("%d",&A[i]);
  }
  mergeSort(A,n,0,n);

for(i = 0 ; i < n-1 ; i++){
  printf("%d ",A[i]);
}
printf("%d\n",A[i]);
printf("%d\n",count);

}

void merge(int A[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;

  n1 = mid - left;
  n2 = right - mid;

for(i = 0 ; i < n1 ; i++){
  L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++) {
  R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTI;
  i = 0;
  j = 0;
 for(k = left; k < right; k++) {
   count++;
   if(L[i] <= R[j]){
     A[k] = L[i++];
    }
   else{
     A[k] = R[j++];
    }
  }
}


void mergeSort(int A[],int n,int left,int right){
int mid;
if(left+1 < right){
mid = (left + right) / 2;
mergeSort(A,n,left,mid);
mergeSort(A,n,mid,right);
merge(A,n,left,mid,right);
  }
}



Measured memory_bytes: 5692
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


#include <stdio.h>

#include<stdio.h>
static char s[500000];

int main(void)
{
	int  i, x[6];
	int  y = 0, z = 0, tmp, max = 0;

	i_cins(5, x);

	for (i = 0; i < 5; i++) {
		y += x[i];
		if (!(x[i] % 10) && (x[i] >= 10)) continue;
		if (x[i] % 10)
			 tmp = 10 - x[i] % 10;
		else tmp = 10 - x[i];
		if (tmp > max) max = tmp;
	    y += tmp;
	}
	y -= max;
	i_cout(y);
	return 0;
}



Measured memory_bytes: 128
A,B=map(int,input().split())
S=input()
if S[A]!='-':
    print("No")
    exit()
for i in range(A):
    if not '0'<=S[i]<='9':
        print("No")
        exit()
for i in range(A+1,A+B):
    if not '0'<=S[i]<='9':
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)
ll mod=1e9+7;

//cf dont use unordered map. use simply map<... , ... > m;

//They are Iterator minus v.begin() krna //lower_bound(v.begin(),v.end(),x)-v.begin()  //upper_bound(v.begin(),v.end(),x)-v.begin()
// lower bound tells greater than or equal to // upper bound tells strictly greater than
//int a[1001][1001] //aise global me hi// ll lcm(ll a, ll b){ return a / __gcd(a, b) * b; }
//memset can initialize to 0 or -1 ONLY //memset(str, 't', sizeof(str)); // string //memset(a, 0, sizeof(a));  //1D array    // memset(a,0,sizeof(a[0][0])*n*n); //2D array
// set.insert(),find() //for(auto it=set.begin();....) cout<<*it;   // sort(v.begin(),v.end(),compare)

void solve()
{int n,m;cin>>n>>m;ll s=0;
    int a[m];f(i,0,m)
 {cin>>a[i];s+=a[i];}

if(s>n) cout<<"-1";
else cout<<n-s; 


}

int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
   // cin>>t;
    while(t--)
    {
     solve();
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int ara[200005];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    scanf("%d", &ara[i]);
    int cnt= 1;
    for(int i=0; i<n; i++)
    cnt+= (ara[i]==cnt);
    if(cnt==1)puts("-1");
    else printf("%d\n", n-cnt+1);
    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

char S[505050];
int N, Q;
int L[101010], R[101010];
int dp[505050][27];

/*
int uf[505050];

int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
void join(int p, int q)
{
	p = root(p);
	q = root(q);
	if (p != q) {
		uf[p] += uf[q];
		uf[q] = p;
	}
}
*/
vector<int> ch[505050];
int lf[505050], rg[505050];
int idx;

void visit(int p)
{
	if (lf[p] != -1) return;
	lf[p] = idx++;
	for (int q : ch[p]) visit(q);
	rg[p] = idx;
//	printf("%d: %d %d\n", p, lf[p], rg[p]);
}
int dbl[505050][20];

int main()
{
	scanf("%s%d", S, &Q);
	N = strlen(S);
	for (int i = 0; i < Q; ++i) {
		scanf("%d%d", L + i, R + i);
		--L[i];
	}
	for (int i = N - 1; i >= 0; --i) {
		for (int j = 0; j <= 26; ++j) {
			dp[i][j] = N + 10;
		}
		dp[i][S[i] - 'a'] = i + 1;
		for (int j = (int)(S[i] - 'a') + 1; j <= 26; ++j) {
			if (dp[i][j - 1] < N) {
				int ij = dp[i][j - 1];
				dp[i][j] = min(dp[i][j], dp[ij][j - 1]);
			}
		}
		if (dp[i][26] < N) {
			int i26 = dp[i][26];
			for (int j = 0; j < (int)(S[i] - 'a'); ++j) {
				dp[i][j] = min(dp[i][j], dp[i26][j]);
			}
		}
	}
	for (int i = 0; i < N; ++i) if (dp[i][26] <= N) {
		ch[dp[i][26]].push_back(i);
	}

	for (int i = 0; i < N; ++i) dbl[i][0] = dp[i][26];
	for (int i = 1; i < 20; ++i) {
		for (int j = 0; j < N; ++j) {
			dbl[j][i] = (dbl[j][i - 1] < N ? dbl[dbl[j][i - 1]][i - 1] : (N + 10));
		}
	}
	idx = 0;
	for (int i = 0; i <= N; ++i) lf[i] = -1;
	for (int i = N; i >= 0; --i) visit(i);

	for (int i = 0; i < Q; ++i) {
		int l = L[i], r = R[i];
		/*for (int j = 19; j >= 0; --j) {
			if (l < N && dbl[l][j] <= r) {
				l = dbl[l][j];
			}
		}*/
		//bool isok = l == r;
		bool isok = (lf[r] <= lf[l] && rg[l] <= rg[r]);
		puts(isok ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 133888
import sys
input = sys.stdin.readline

N = int(input())
Alp = [chr(i) for i in range(97, 97+26)]

ans = []
def dfs(d, maxi, T):
    if d == N-1:
        ans.append(T)
        return
    for i in range(maxi+2):
        dfs(d+1, max(maxi, i), T + Alp[i])

dfs(0, 0, "a")
print(*ans, sep='\n')

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

int main(){

    int n,k;
    cin >> n >> k;

    vector<ll> h(n);

    rep(i,n) cin >> h[i];

    sort(h.begin(),h.end());
    ll ans=1e+9;
    for(int i=0;i+k-1<h.size();i++){
        ans=min(ans,h[i+k-1]-h[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll  x, k, d;
    cin >> x >> k >> d;
    if(x < 0) x = -x;

    ll cnt = x/d;
    x -= min(k, cnt) * d;
    k -= min(k, cnt);

    if(k % 2 == 1) {
        x = (abs(x-d) < abs(x+d)) ? x-d : x+d;
    }
    
    cout << abs(x) << endl;
}


Measured memory_bytes: 3640
//50000 for aizu0056
//1000000 for aizu0185
#define M 32768
p[M+1];


main(i,j,n){
  p[1]=1;
  for(;i<=M;i++)
    if(!p[i])
      for(j=i*2;j<=M;j+=i)
        p[j]=1;
  for(;scanf("%d",&n),n;){
    for(i=2,j=0;i<=n/2;i++){
      if(!p[i]&&!p[n-i]){
        j++;
      }
    }
    printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
colors = list(input())
index = [[],[],[]]
ans = 0

for i in range(n):
    if colors[i] == 'R':
        index[0].append(i)
    elif colors[i] == 'G':
        index[1].append(i)
    else:
        index[2].append(i)

ans = len(index[0]) * len(index[1]) * len(index[2])

for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k < n and colors[i] != colors[j] and colors[j] != colors[k] and colors[k] != colors[i]:
            ans -= 1

print(ans)


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

int main() {
  int N;
  int T;
  cin >> N >> T;
  vector<int> t(N);
  for (auto&& w : t) cin >> w;
  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += min(t[i + 1] - t[i], T);
  }
  ans += T;
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int[] arr = new int[] { a, b, c };
        Arrays.sort(arr);
        for (int i = 0; i < k; i++) {
            arr[arr.length - 1] *= 2;
        }
        int result = Arrays.stream(arr).sum();

        // 出力
        System.out.println(result);
    }
}


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

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s==u){
    cout << a-1 <<" "<< b << endl;
  }else{
    cout << a <<" "<< b-1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/// 最小値を更新
template<class T> inline bool chkMin(T& a, T b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

/// 最大値を更新
template<class T> inline bool chkMax(T& a, T b){
  if(a < b){
    a = b;
    return true;
  }
  return false;
}

int main() {
  int num;
  long long weight;
  long long INF = 1LL << 40;
  
  cin >> num >> weight;
  
  vector<long long> vecW(num);
  vector<long long> vecV(num);
  
  for(int i = 0; i < num; i++){
    cin >> vecW.at(i) >> vecV.at(i);
  }
  
  vector<vector<long long>> dp(num+1,vector<long long>(100100,INF));
  dp.at(0).at(0) = 0;
  
  for(int i = 0; i < num; i++){
    for(int j = 0; j < 100100; j++){
      if(j - vecV.at(i) >= 0) chkMin(dp.at(i+1).at(j),dp.at(i).at(j - vecV.at(i)) + vecW.at(i));
      
      chkMin(dp.at(i+1).at(j), dp.at(i).at(j));
    }
  }
  
  long long Max = 0;
  for(int i = 0; i < 100100; i++){
    if(dp.at(num).at(i) <= weight){
      Max = i;
    }
  }
  
  cout << Max;
}


Measured memory_bytes: 80256