akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int a[5];

void init()
{
}

void solve()
{
    int ans = INF;
    sort(a, a+5);
    do{
        int t = 0;
        REP(i, 5){
            if(t % 10 != 0) t += 10 - (t % 10);
            t += a[i];
        }
        ans = min(ans, t);
    }while(next_permutation(a, a+5));
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 5) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>

using namespace std;


int N, q;
vector<int> seg;
int segSize = 2;
int n;

void add(int x, int y){

	x += n - 1;
	seg[x] += y;

	while(x > 0){
		x = (x-1)/2;
		seg[x] = seg[2*x+1] + seg[2*x+2];
	}
	
}

int sum(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return 0;
	if(a <= l && r <= b){
		return seg[k];
	}
	else{
		return sum(a, b, 2*k+1, l, (l+r)/2 ) + sum(a, b, 2*k+2, (l+r)/2, r);
	}
}

int main(){

	cin >> N >> q;

	

	while(segSize < N){
		segSize *= 2;
	}

	segSize *= 2;
	segSize--;

	n = (segSize+1)/2;

	for(int i=0; i<segSize; i++){
		seg.push_back(0);
	}

	for(int i=0; i<q; i++){
		int com, x, y;
		cin >> com >> x >> y;

		if(com == 0){
			add(x-1, y);
		}

		if(com == 1){
			cout << sum(x-1, y, 0, 0, n) << endl;
		}
	}


	return 0;
}



Measured memory_bytes: 3880
n = int(input())
x = []
for i in range(n):
    l = list(map(int, input().split()))
    x.append(l)
count = 0
dp = [[0 for j in range(3)] for i in range(n)]
dp[0][0], dp[0][1], dp[0][2] = x[0][0], x[0][1], x[0][2]

for i in range(1, n):
    for j in range(3):
        dp[i][j] = x[i][j] + max(dp[i-1][x] for x in range(3) if x != j)


print(max(dp[n-1]))


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

using namespace std;

vector <int> dp;

int dfs(int A){
    if(A == 0) return 1;
    if(A < 0) return 0;
    if(dp[A] >=0) return dp[A];


    int ans = 0;
    for(int i=1;i<=2;i++){
        ans +=dfs(A-i);
        ans %= 1000000007;
    }

    return dp[A]=ans;
}

int main(){
    int N,M;
    int tmp1=-10;
    int tmp2=-10;
    int flag=0;
    cin >> N >>M;
    dp=vector<int> (N+1,-1);

    for(int i=0;i<M;i++){
        cin >> tmp1;
        if(tmp1-tmp2==1){
            flag=1;
            break;
        }
        dp[tmp1] = 0;
        tmp2 = tmp1;
    }

    if(flag==1){
        cout<<0<<endl;
    }else{
        cout << dfs(N) << endl;
    }

}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    
    long long int sum=0;
    for(int i=0;i<str.size();i++)
    {
        sum=sum+(str[i]-'0');
    }
    if(sum%9==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
    
    return 0;
}

Measured memory_bytes: 3724
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

int n,k;
cin>>n>>k;
if(k>(((n-2)*(n-1))/2))
cout<<-1;
else
{
int a[n][n];
mems(a,0);

for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n;j++)
	{
		
		a[i][j]=1;
	}
	
	
}

for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n-1;j++)
	{
		if(k>0)
		{
		a[i][j]=0;
		k--;
	}
		if(k==0)
		break;
	}
	if(k==0)
	break;
}

int m=0;
for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n;j++)
	{if(a[i][j]==1)
	m++;
}
}

cout<<m<<"\n";

for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n;j++)
	{
		if(a[i][j]==1)
		cout<<i+1<<" "<<j+1<<"\n";
	}
}
}

}return 0;}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<map>

using namespace std;

int main(){

	string S;

	cin >> S;

    if(S.find('a') == string::npos || S.find('b') == string::npos || S.find('c') == string::npos){
    	cout << "No";
    }else{
        cout << "Yes";
    }


    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const ll mod2=1e9+9 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   int m=1<<n;
   unordered_map<string,ll> mp;
   ll ans=0;
   rep(i,m){
       string ret="";
       string res="";
       rep(j,n){
           if(i&(1<<j)){ret+=s[j];}
           else res+=s[j];
       }
       reverse(res.begin(),res.end());
       ret=ret+'+'+res;
       mp[ret]++;
   }
   rep(i,m){
       string ret="";
       string res="";
       rep(j,n){
           if(i&(1<<j))ret+=s[n+j];
           else res+=s[n+j];
       }
       reverse(ret.begin(),ret.end());
       ret=ret+'+'+res;
       ans+=mp[ret];
   }
   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 71540
# Problem https://atcoder.jp/contests/abc072/tasks/abc072_b
# Python 1st Try
import sys


def solver(inputStr):
    answer = ''
    answerList = []
    for j in range(0, len(inputStr), 2):
        answerList.append(inputStr[j])
    answer = ''.join(answerList)
    return answer


if __name__ == "__main__":
    s = sys.stdin.readline().split()
    print(solver(s[0]))


Measured memory_bytes: 3572
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}]

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll sum = 0 ;
	for(int i=0;i<n;i++) sum += a.at(i) ;
	if(sum<=k){
		cout << 1 << endl ;
		return 0 ;
	}
	ll l=1,r=1e10,m ;
	while(l+1<r){
		m = (l+r)/2 ;
		ll cnt = 0 ;
		for(int i=0;i<n;i++){
			cnt += (a.at(i)-1)/m ;
		}
		if(cnt>k) l = m ;
		else r = m ;
	}
	cout << r << endl ;
}


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

using ll=long long;
int main(){
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll a,b;
        cin>>a>>b;
        ll x=a*b-1;
        ll lb=0;
        ll ub=1e9;
        if(a*b<3){
            cout<<0<<endl;
            continue;
        }
        while(ub-lb>1){
            ll mid=(lb+ub)/2;
            if(x>=mid*(mid+1)){
                lb=mid;
            }
            else{
                ub=mid;
            }
        }

        ll k=lb;
        ll res=k*2;
        res-=(int)(a<=k)+(int)(b<=k);
        if(x/k!=k+1 && a!=k+1 && b!=k+1 && (k+1)*(k+1)<=x){
            res++;
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  char c11, c12, c13, c21, c22, c23;
  scanf("%c %c %c %c %c %c", &c11, &c12, &c13, &c21, &c22, &c23);
  if (c11 == c23 && c12 == c22 && c13 == c21)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> v(m);
    for(auto& i : v){
        cin >> i.first >> i.second;
    }
    vector<int> judge(n, 0);
    for(auto i : v){
        if(i.first == 1){
            judge[i.second-1]++;
        }else if(i.second == n){
            judge[i.first-1]++;
        }
    }
    string ans = "IMPOSSIBLE";
    for(auto i : judge){
        if(i > 1){
            ans = "POSSIBLE";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
n = int(input())
an = list(map(int, input().split()))

sub_an = []
count = 0

for i in an:
    sub_an.append(abs(i))

for i in an:
    if i < 0:
        count += 1

sub_an.sort()

if count % 2 == 0:
    ans = sum(sub_an)
else:
    ans = sum(sub_an) - sub_an[0]*2

print(ans)


Measured memory_bytes: 14284
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1100000
using namespace std;

int dp[20][110000];

int main() {
	int N;
	cin >> N;
	vector<int> money;
	money.push_back(1);
	for(int tmp = 6; tmp <= N; tmp *= 6) money.push_back(tmp);
	for(int tmp = 9; tmp <= N; tmp *= 9) money.push_back(tmp);
	sort(money.begin(), money.end());

	int K = money.size();
	for(int i = 0; i <= K; i++) {
		for(int j = 0; j <= N; j++) {
			dp[i][j] = INF;
		}
	}
	for(int i = 0; i <= K; i++) dp[i][0] = 0;
	for(int i = 0; i < K; i++) {
		for(int j = 0; j <= N; j++) {
			//cout << i << ' ' << j << ' ' << money[i] << endl;
			dp[i][j+money[i]] = min(dp[i][j] + 1, dp[i][j + money[i]]);
			dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
			dp[i+1][j+money[i]] = min(dp[i][j] + 1, dp[i+1][j+money[i]]);
		}
	}
	cout << dp[K][N] << endl;

	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long A, long long B, long long C){
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
		cout << 0 << endl;
	}else{
		ll l[3] = {A,B,C};
		sort(l,l+3);
		cout << l[0]*l[1] << endl;
	}


}



int main(){	
	ios::sync_with_stdio(false);
	long long A;
	long long C;
	long long B;
	cin >> A;
	cin >> B;
	cin >> C;
	solve(A, B, C);
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    println(solve1(s))
}

fun solve1(s: String): Int {
    var ans = 0
    for (i in 0 until 1000) {
        val pin = i.toString().padStart(3, '0')
        var j = 0
        for (c in s) {
            if (j < 3 && c == pin[j]) {
                j++
            }
        }
        if (j == 3) {
            ans++
        }
    }
    return ans
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int H, A;
    cin >> H >> A;
    int ans = 0;
    while (H > 0) {
        H -= A;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

int main(){
  string s;
  cin >> s;
  char c = s.at(0);
  bool flag = false;
  for(int i=0; i<3; i++){
    if(c != s.at(i)){
      flag = true;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No"<< endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a;cin>>a;
    int b=a/100,c=a%100;
    if(b>=1&&b<=12) 
    {
    	if(c>=1&&c<=12) cout<<"AMBIGUOUS";
    	else cout<<"MMYY";
	}
	else {
		if(c>=1&&c<=12) cout<<"YYMM";
    	else cout<<"NA";
	}
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int di[] = {-1, 0, +1, 0};
const int dj[] = {0, +1, 0, -1};

const int MAXH = 500;
const int MAXW = 500;
bool visited[MAXH][MAXW];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    int a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    vector<vector<int> > res;
    for(int i=0;i<h;i++){
        // increment
        if(i %2 == 0){
            for(int j=0;j<w-1;j++){
                if(a[i][j] %2 == 1){
                    vector<int> resi = {i, j, i, j+1};
                    res.push_back(resi);
                    a[i][j] -= 1;
                    a[i][j+1] += 1;
                }
            }
            if(a[i][w-1] %2 == 1 && i+1 < h){
                vector<int> resi = {i, w-1, i+1, w-1};
                res.push_back(resi);
                a[i][w-1] -= 1;
                a[i+1][w-1] += 1;
            }
        // decrement
        }else{
            for(int j=w-1;j>0;j--){
                if(a[i][j] %2 == 1){
                    vector<int> resi = {i, j, i, j-1};
                    res.push_back(resi);
                    a[i][j] -= 1;
                    a[i][j-1] += 1;
                }
            }
            if(a[i][0] %2 == 1 && i+1 < h){
                vector<int> resi = {i, 0, i+1, 0};
                res.push_back(resi);
                a[i][0] -= 1;
                a[i+1][0] += 1;
            }
        }
    }
    cout << res.size() << endl;
    for(vector<int> r: res){
        cout << r[0] + 1 << " " << r[1] + 1 << " " << r[2] + 1 << " " << r[3] + 1 << endl;
    }
}

Measured memory_bytes: 9904
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
const long double pi = 3.14159265358979323846264338327950288;
int n;
ll x, a[100000];
int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll sum = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] + a[i] > x) {
			sum += min(a[i - 1] + a[i] - x, a[i]);
			a[i] -= min(a[i - 1] + a[i] - x, a[i]);
		}
		if (a[i - 1] + a[i] > x) {
			sum += (a[i - 1] + a[i] - x);
			a[i - 1] -= (a[i - 1] + a[i] - x);
		}
	}
	cout << sum << endl;
	cin >> sum;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
int h,w;
int fie[1501][1501];
int fade[1501][1501];
int cnt[1501][1501];
int t[1501][1501];

int bfs(){
	queue<P> que;
	int res=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int none=0;
			for(int k=-1;k<=1;k++){
				for(int l=-1;l<=1;l++){
					int y=i+k,x=j+l;
					if(x>=0 && x<w && y>=0 && y<h){
						if(fie[y][x]==0)none++;
					}
				}
			}
			cnt[i][j]=none;
			if(none>=fie[i][j] && fie[i][j]>=1){
				t[i][j]=1;
				fade[i][j]=1;
				que.push(P(i,j));
			}
		}
	}
	while(que.size()){
		P q=que.front();
		que.pop();
		int y=q.first,x=q.second;
		fie[y][x]=0;
		for(int i=-1;i<=1;i++){
			for(int j=-1;j<=1;j++){
				int nx=x+j,ny=y+i;
				if(nx>=0 && nx<w && ny>=0 && ny<h){
					cnt[ny][nx]++;
					if(cnt[ny][nx]>=fie[ny][nx] && fie[ny][nx]>=1 && fade[ny][nx]==0){
						fade[ny][nx]=1;
						t[ny][nx]=t[y][x]+1;
						que.push(P(ny,nx));
					}
				}
			}
		}

	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			res=max(res,t[i][j]);
		}
	}
	return res;
}

int main(void){
	scanf("%d %d",&h,&w);
	for(int i=0;i<h;i++){
		string str;
		cin >> str;
		for(int j=0;j<w;j++){
			if(str[j]>='0' && str[j]<='9')fie[i][j]=str[j]-'0';
		}
	}
	printf("%d\n",bfs());
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x-r<0||w<x+r||y-r<0||h<y+r) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

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

    vl v(n);

    forn(i,0,n) cin>>v[i];


    vector<ll> dp(n+10);
    dp[0] = 0;
    dp[1] = abs(v[1]-v[0]);


    forn(i,2,n)
    {
        ll mini = inf;
        for(int j = i-1; j >= max(0,i-k); j--)
        {
/*            if(i == 4)
            {
                cout<<j<<" "<<dp[j]+abs(v[i]-v[j])<<endl;
            }*/
            mini = min(dp[j]+abs(v[i]-v[j]),mini);
        }
        dp[i] = mini;
    }

/*    forn(i,0,n)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/

    cout<<dp[n-1];

    return 0;
}

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

const int N = 100100;
const int INF = (1 << 30);

int h[N];
int dp[N];
int n, k;


int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) scanf("%d", &h[i]);
    fill(dp, dp + N, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i + j < n) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            }
            else break;
        }
    }
    printf("%d\n", dp[n - 1]);
}



Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

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

	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i+2<n;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
	}
	cout<<ans;
}  
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

void add_edge(V<V<edge>>& G, int u, int v, int cost) {
   if (u == v) return;
   G[u].PB((edge){ u, v, cost });
}

template<typename T>
void dijkstra(const vector< vector<edge> >& G, vector<T>& d, int s)
{
   priority_queue<P<T,int>, vector<P<T,int>>, greater<P<T,int>> > que;
   fill(d.begin(), d.end(), INF);
   d[s] = 0;
   que.push(make_pair(0, s));
   while(!que.empty()) {
      T temp_cost = que.top().first;
      int from = que.top().second;
      que.pop();
      if (d[from] < temp_cost) continue;
      for (int i = 0; i < G[from].size(); i++) {
         edge e = G[from][i];
         if (d[e.to] > d[from] + e.cost) {
            d[e.to] = d[from] + e.cost;
            que.push(make_pair(d[e.to], e.to));
         }
      }
   }
}

signed main()
{
   int K; cin >> K;
   V<V<edge>> G(K);
   FOR(i, 0, K) {
      add_edge(G, i, (i+1)%K, 1);
   }
   FOR(i, 0, K) {
      add_edge(G, i, (i*10)%K, 0);
   }

   V<int> d(K);
   dijkstra(G, d, 1);
   int ans = d[0] + 1;
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 10780
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		
		Scanner s = new Scanner(System.in);
		long x=s.nextLong();
		long y=s.nextLong();
		
		Long z=(long)Math.pow(10, 18);
		
		while(x<z){
			long t= x/y;
			if(t*y==x){
				x+=x;
			}
			else{
				System.out.println(x);
				System.exit(0);
			}
		}
		System.out.println(-1);
		
	}
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

// 大きい順にpop
class CompareDist
{
public:
    bool operator()(P n1, P n2) {
        return n1.second<=n2.second;
    }
};

int main() {
    lli n;
    cin1(n);
    lli a[n];
    lli b[n];
    ncin1(n, a);
    ncin1(n, b);


    priority_queue< P, vector<P>, CompareDist > que;

    REP(i, 0, n) {
        que.push(P(i, b[i]-a[i]));
    }

    lli ans = 0;
    while (true) {
        P p = que.top();
        lli cur = p.first;
        lli prev = (cur + n - 1) % n;
        lli next = (cur + n + 1) % n;

        lli x = b[cur];
        lli y = b[prev] + b[next];
        lli count = (x - a[cur]) / y;
        if (count == 0)
            break;
        x -= y * count;

        b[cur] = x;
        que.pop();
        if (x != a[cur]) {
            que.push(P(cur, b[cur]-a[cur]));
        }

        ans+=count;
        //cout1(ans);
    }

    REP(i, 0, n) {
        if (a[i] != b[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9584
import java.util.*;

public class Main{ 
  
  public static void main(String[] args) throws Exception{
    
    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int M = sc.nextInt();
     
    
    if(A>=1 && A<=100000 && B>=1 && B<=100000 && M>=1 && M<=100000){
    int[] aList = new int[A];
    int[] bList = new int[B];
    
    
    for(int i = 0; i < A; ++i){
      int next = sc.nextInt();
      if(next != 0){
       aList[i] = next;
      }
    }
    int MinA = aList[0];
    for(int i = 1; i < A; ++i){
      if(MinA >= aList[i]){
        MinA = aList[i];
      }
    }
    
    for(int i = 0; i < B; ++i){
      int next = sc.nextInt();
      if(next != 0){
      bList[i] = next;
      }
    }
    int MinB = bList[0];
    for(int i = 1; i < B; ++i){
      if(MinB >= bList[i]){
        MinB = bList[i];
      }
    }
    
    int AB = MinA + MinB;
    
    int a = 0;
    int b = 0;
    int c = 0;
    int answer = 0;
    for(int i = 0; i < M; ++i){
          a = sc.nextInt();
          if(a > A){
            throw new Exception("ダメです");
          }
      
          b = sc.nextInt();
          if(b > B){
            throw new Exception("ダメです");
          }
          int ans = aList[a-1] + bList[b-1];
          c = sc.nextInt();
          if(c > ans){
            throw new Exception("ダメです");
          }
         answer = ans - c;
         if(AB > answer){
            AB = answer;   
        } 
   }
    
    System.out.println(AB);
    }else{
       System.out.println("ダメです");
    }
  }
} 


Measured memory_bytes: 60508
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

int c[100010];

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

  int n, m, k;
  cin >> n >> m >> k;
  int a[n], b[m];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  for (int i = 0; i < m; i++)
    cin >> b[i];

  int s = 0;
  int B[m];
  
  for (int i = 0; i < m; i++)
    s += b[i], B[i] = s;

  int A = 0;
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (A > k)
      break;
    int l = 0, r = m - 1;
    while (r > l){
      int mid = (r + l) / 2;
      int mid_v = B[mid];
      int pre_r = r, pre_l = l;
      if (mid_v > k - A)
	r = mid;
      else
	l = mid;
      if (l == pre_l and r == pre_r)
	break;
    }
    if (B[r] <= k - A)
      ans = max(ans, r + 1 + i);
    else if (B[l] <= k - A)
      ans = max(ans, l + 1 + i);
    else
      ans = max(ans, i);
    A += a[i];
  }
  int l = 0, r = m - 1;
    while (r > l){
      int mid = (r + l) / 2;
      int mid_v = B[mid];
      int pre_r = r, pre_l = l;
      if (mid_v > k - A)
	r = mid;
      else
	l = mid;
      if (l == pre_l and r == pre_r)
	break;
    }
    if (A <= k){
    if (B[r] <= k - A)
      ans = max(ans, r + 1 + n);
    else if (B[l] <= k - A)
      ans = max(ans, l + 1 + n);
    else
      ans = max(ans, n);
    }
  cout << ans << endl;

  
}


Measured memory_bytes: 8300
#include <stdio.h>

int main() {
  int a, b, k;
  scanf("%d %d %d", &a, &b, &k);
  for(int i = a; i <= a + k - 1; i++) {
    if(i > b - k)
      break;
    printf("%d\n", i);
  }
  for(int i = b - k + 1; i <= b; i++) {
    if(i < a)
      continue;
    printf("%d\n", i);
  }
}

Measured memory_bytes: 128
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


X, Y = map(int, input().split())
mod = 10**9 + 7

if (X + Y)%3 != 0:
  result = 0
else:
  n1 = (2*Y - X)//3
  n2 = (2*X - Y)//3
  if n1 < 0 or n2 < 0:
    result = 0
  else:
    result = comb(n1+n2, n1, mod)

print(result)
    

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int n,a,w=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(a==i){
            w++;
            i++;
            cin>>a;
        }
    }
    cout<<w<<endl;
}


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

if a<b :
    if b<c :
        print(a,b,c)
    elif c<a :
            print(c,a,b)
    else:
            print(a,c,b)
else:
    if a<c :
        print(b,a,c)
    elif c<b :
        print(c,b,a)
    else:
        print(b,c,a)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9+3;
const ll INF = 1e18+3;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N, X;
    cin >> N >> X;
    ll x[N], ans = INF;
    rep(i, N) cin >> x[i];
    ll sum[N+1];
    sum[0] = 0;
    rep(i, N) sum[i+1] = sum[i]+x[i];
    //i回ゴミ箱に戻ってくる場合
    rep2(i, 1, N){
        ll tmp = (N+i)*X+5*sum[N];
        for(ll j = N-2*i; j >= 0; j -= i){
            tmp += 2*sum[j];
            if(tmp > ans) break;
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

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


int N, A, B, C;
int dfs(int cur, int a, int b, int c, vector<int> l) {
  if(cur == N) {
    return min({a, b, c}) > 0 ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : 1e+9;
  }

  int res0 = dfs(cur + 1, a, b, c, l);
  int res1 = dfs(cur + 1, a + l[cur], b, c, l) + 10;
  int res2 = dfs(cur + 1, a, b + l[cur], c, l) + 10;
  int res3 = dfs(cur + 1, a, b, c + l[cur], l) + 10;

  return min({res0, res1, res2, res3});
}


int main() {
  cin >> N >> A >> B >> C;

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

  cout << dfs(0, 0, 0, 0, l) << endl;
}


Measured memory_bytes: 256
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush
# import threading
# setrecursionlimit(10**6)
# threading.stack_size(2**26)

def iin(): return int(input())
def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input

def main():
    dc=[2,0,0,0,0]
    no = 0
    for _ in range(3):
        a, b= lin()
        if a==b:
            no = 1
        dc[a]+=1
        dc[b]+=1
    print('YES' if max(dc)==2 and not no else 'NO')
    





        
main()
#threading.Thread(target=main).start()

Measured memory_bytes: 38256
#include <stdio.h>

int main(int argc, char *args[])
{
	unsigned int n,m,l;
	int x,y;
	unsigned int i,j,k;

	scanf("%d %d %d", &n, &m, &l);

	int A[n][m];
	int B[m][l];
	long long C[n][l];


	for( x=0; x<n; x++ ) {
		for( y=0; y<l; y++ ) {
			C[x][y] = 0;
		}
	}


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

	for( i=0; i<m; i++ ) {
		for( j=0; j<l; j++ ) {
			scanf("%d", &B[i][j]);
		}
	}

	for( i=0; i<n; i++ ) {
		for( j=0; j<l; j++ ) {
			for( k=0; k<m; k++ ) {
				C[i][j] += A[i][k] * B[k][j];
			}
			printf("%lld", C[i][j]);
			if( j<l-1 ) {
				printf(" ");
			}
		}
		printf("\n");
	}


	return 0;

}

Measured memory_bytes: 756
package main

import (
	"fmt"
)

const INF = 1 << 30

func main(){
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]int, n)
	dp := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	for i := 1; i < len(dp); i++ {
		dp[i] = INF
	}
	dp[0] = 0

	for i := 0; i < n-1; i++ {
		for j := i + 1; j <= i + k; j++ {
			if j > n - 1 {
				continue
			}
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
		}
	}
	fmt.Println(dp[n-1])
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e6+10, mod=1e9+7;

bool exists(string a,string b){
	vector<bool> x(26);
	for(auto c:a) x[c-'a']=1;
	for(auto c:b){
		if( x[c-'a']==0 ) return 0;
	}
	return 1;
}

int main(){
//	ios_base::sync_with_stdio(0);	cin.tie(0);
	string s,t;  int i,j;
	cin>>s>>t;
	
	if(!exists(s,t)){
		cout<<"-1";
		return 0;
	}
	int n=s.length();
	
	int nxt[ n +1 ][ 26 ];
	for(i=0;i<=n;i++)for(j=0;j<26;j++)nxt[i][j]=n+1;
	
	for(i=n-1;i>=0;i--){
		for(j=0;j<26;j++){
			nxt[i][j]=nxt[i+1][j];
		}
		nxt[i][s[i]-'a']=i;
	}

	
	int ct=0,last=0;
	for(i=0,j=0;j< (int)t.length() ; ){
		if( s[i]==t[j] ){
			last=i;
			i++; j++;
		}else{  
			i=nxt[i][ t[j]-'a' ];
			if(i== n+1 ){
				i=0;
				ct++;
			}else continue;
		}
	}
	cout<<1LL*ct*n+ last+1;
}
// check for any potential overflow before submitting



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

int main() {
    int a, b;
    cin >> a >> b;
    while(a!=0 && b!=0) {
        for(int i=0; i<a; i++) {
            for (int j=0; j<b; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
        cin >> a >> b;

    }
    return 0;
}


Measured memory_bytes: 3100
#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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;

    if((a == b) && (b == c))
    {
        cout<<"No"<<endl;
        return 0;
    }
    else if ((a == b))
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else if (b == c)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else if (a == c)
    {
        cout <<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {

    public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        String S = Input.next();
        String Ans = "";
        Ans = S.substring(1, S.length() - 1);
        S = S.charAt(0) + "" + Ans.length() + "" + S.charAt(S.length() - 1);
        System.out.println(S);
    }
}


Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, T = mi()
    t = list(mi())
    l = [max(t[i+1]-t[i]-T, 0) for i in range(N-1)]
    print(t[-1]+T-sum(l))


if __name__ == '__main__':
    main()


Measured memory_bytes: 105972
#include <cstdio>
#include <map>
using namespace std;

int main()
{
  for(;;){
    int n;
    scanf("%d",&n);
    if(n == 0) break;
    map<int,int> m;
    for(int i=0; i<n; i++){
      int p,d1,d2;
      scanf("%d %d %d",&p,&d1,&d2);
      m.insert(map<int,int>::value_type(d1+d2,p));
    }
    /*
    for(map<int,int>::iterator it = m.begin(); it != m.end(); it++){
      printf("%d %d\n",(*it).first, (*it).second);
    }
    */
    map<int,int>::iterator it = m.end();
    it--;
    printf("%d %d\n",(*it).second,(*it).first);
  }
  return 0;
}

Measured memory_bytes: 1500
import sys
import heapq
def v():
    N,T=tuple(map(int,sys.stdin.readline().split()))
    A=list(map(int,sys.stdin.readline().split()))
    ma=0
    d=[]
    heapq.heapify(d)
    for a in reversed(A):
        if a<ma:heapq.heappush(d,a-ma)
        else:ma=a
    res,x=1,heapq.heappop(d)
    while len(d)>0:
        y=heapq.heappop(d)
        if x==y:res+=1
    print(res)
if __name__=='__main__':v()

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

int main(){
    string N;
    cin >> N;
    int n = N.size()-1;
    if(N.at(n)=='3'){
        cout << "bon" << endl;
    }else if(N.at(n)=='0'||N.at(n)=='1'||N.at(n)=='6'||N.at(n)=='8'){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
using vi = vector<ll>; // intの1次元の型に vi という別名をつける

ll n;
string s;

int putq(int starti,int flag,int sc){
    cout<<"? ";
    for(int i=0;i<n-flag;i++){
      cout<<((starti+i)%(2*n)+1)<<" ";
    }

    if (flag!=0) cout<<(sc+1)<<" ";
    cout<<endl;
    cin>>s;
    if (s=="Blue"){
      return 1;
    }
    return 2;
}


int main(){
  cin >> n;
  vi a(n*2);

  //2分岐探索
  int end=n;
  int srt=0;
  int mid;
  int srtcol=putq(0,0,0);
  int endcol=3-srtcol;
  int midcol=0;
  //2分岐？でSUM i～n-1までのリダクション
  for(int j=0;;j++){
    mid=(srt+end)/2;
    midcol=putq(mid,0,0);
    if (srtcol==midcol){
      srt=mid;
    }else{
      end=mid;
    }
    if ((end-srt)==1)break;
  }

  a[(end+n-1)%(2*n)]=endcol;
  a[srt]=3-endcol;

  int idx=end;
  int dindx=idx;
  idx+=n;
  idx%=2*n;
  for(int i=0;i<n-1;i++){
    a[idx]=putq(dindx,1,idx);
    idx++;
    idx%=2*n;
  }

  idx=dindx;
  dindx+=n;
  dindx%=2*n;
  for(int i=0;i<n-1;i++){
    a[idx]=putq(dindx,1,idx);
    idx++;
    idx%=2*n;
  }

  //答え
  cout<<"! ";
  REP(i,n*2){
    if (a[i]==1)cout<<"B";
    if (a[i]==2)cout<<"R";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include <iomanip>
#include <cmath>

int main()
{
    double x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;

    double dist= sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    std::cout << std::fixed << dist << std::endl;

    return 0;
}

Measured memory_bytes: 1284
require 'pp'

n = gets.chomp!.to_i
s = gets.chomp!

if s.length % 2 != 0
    puts "No"
else
    if s[0, s.length / 2] == s[s.length / 2, s.length / 2]
        puts "Yes"
    else
        puts "No"
    end
end


Measured memory_bytes: 2044
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			BigDecimal num = new BigDecimal(a).divide(new BigDecimal(b), 6, RoundingMode.HALF_EVEN);

			System.out.println(a / b + " " + a % b + " " + num);
		}
	}
}


Measured memory_bytes: 26484
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a, b;
    cin >> a >> b;
    string s = "", t = "";
    for(int i=0; i<stoi(b); i++){
        s += a;
    }
    for(int i=0; i<stoi(a); i++){
        t += b;
    }
    cout << min(s,t) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int x,n;cin>>x>>n ;
    // bool pres[105] ;
    vector<bool> pres(105) ;
    // for(int i=0;i<105;i++) pres[i] = false ;
    for(int i=0;i<n;i++) 
    {
        int xx;cin>>xx ;
        pres[xx] = true ;
    }
    int left = x, right = x ;
    while(left && pres[left]) left-- ;
    while(right<101 && pres[right]) right++ ;
    // cout<<min(x-left,right-x)<<"\n" ;
    if(x-left==right-x) cout<<left<<"\n";
    else if(x-left<right-x) cout<<left<<"\n" ;
    else cout<<right<<"\n" ; 
    
    
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int n,k,q,a[2005],ans=0x7fffffff,t[2005],b[2005],c[2005];
inline int min(int x,int y){
	return x<y?x:y;
}
void solve(int mn){
    int l=1,r=1,tot=0;
    while(l<=n){
        int cnt=0;
        while(l<=n&&a[l]<mn) l++;
        r=l;
        while(r<=n&&a[r]>=mn) r++;
        for(int i=l;i<=n&&i<r;i++)
            c[++cnt]=a[i];
        if(cnt>=k){
            sort(c+1,c+cnt+1);
            for(int i=1;i<=cnt-k+1;i++)
                b[++tot]=c[i];
        }
        l=r;
    }
    sort(b+1,b+tot+1);
    if(tot>=q) ans=min(ans,b[q]-b[1]);
}
int main(){
    scanf("%d%d%d",&n,&k,&q);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        t[i]=a[i];
    }
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++) solve(t[i]);
    printf("%d\n",ans);
    return 0;
}

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

int main()
{
    int n, m; cin >> n >> m;
    vector<int>  ac(n,0),wa(n,0);
    vector<int> p(m);
    vector<string> s(m);
    int AC = 0;
    int WA = 0;
    for(int i=0;i<m;i++){
        cin >> p[i] >> s[i];
    }
    for(int i=0;i<m;i++){
        if(s[i] == "WA" && ac[p[i]-1] == 0){
            wa[p[i]-1]++;
        }
        else if(s[i] == "AC" && ac[p[i]-1] == 0){
            ac[p[i]-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        if(ac[i] == 1) {
            AC++;
            WA += wa[i];
        }
    }
    cout << AC << " " << WA << endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX


int memo[200000],ans;
string s;
map<int,int> m;


signed main() {
    cin >> s;
    for(int i=s.size()-1;i>=0;--i) {
        memo[i] = s.size()-i-1-m[s[i]];
        m[s[i]]++;
    }
    rep(i,s.size()) ans += memo[i];
    ans++;
    cout << ans << endl;
}




Measured memory_bytes: 2180
n=int(input())
f=list(map(int,input().split()))
c=0
for i in range(n-1):
    if f[i]==i+1:
        c+=1
        f[i],f[i+1]=f[i+1],f[i]
if f[n-1]==n:
    c+=1

print(c)

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

int main()
{
	int k, s;
	cin >> k >> s;
	long long int ans = 0;
	for (int i = 0; i <= k; i++){
		for (int j = 0; j <= k; j++){
			if (s-i-j >= 0 and s-i-j <= k) ans++; 
		}
	}

	cout << ans << endl;
}


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

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

      if( a[a.length()-1] == b[0] && b[b.length()-1] == c[0] )
            cout<<"YES"<<endl;
      else
            cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>

using namespace std;

#define LL long long

int N,n[10002],n_max=0,ans=0;
vector<int> pr;

int main() {
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>n[i];
		n_max=max(n_max,n[i]);
	}

	for(int i=2;i*i<=n_max;i++){//O(n_max^(3/4))?
		bool ispr=true;
		for(int j=0;(j<pr.size() && pr[j]*pr[j]<=i); j++){
			if(i%pr[j]==0){
				ispr=false;
				break;
			}
		}
		if(ispr)pr.push_back(i);
	}

	for(int i=0;i<N;i++){
		bool ispr=true;
		for(int j=0;(j<pr.size() && pr[j]*pr[j]<=n[i]); j++){
			if(n[i]%pr[j]==0){
				ispr=false;
				break;
			}
		}
		if(ispr)ans++;
	}
	cout<<ans<<endl;

	return 0;
}




Measured memory_bytes: 3212