akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<Pll>xl(n);
    for(ll i=0;i<n;i++)
        cin>>xl[i].fi>>xl[i].se;
    ll ans=n,last=0;
    sort(all(xl));
    
    for(int i=1;i<n;i++){
        if(xl[i].fi-xl[i].se<xl[last].fi+xl[last].se){
            ans--;
            if(xl[i].fi+xl[i].se<xl[last].fi+xl[last].se)last=i;
        }
        else
            last=i;
    }
    
    
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









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

#define lld long long

lld N;
string S;

int main(){
    cin >> N;
    cin >> S;
    lld sum = 0;
    lld Rcnt[4001];
    lld Gcnt[4001];
    lld Bcnt[4001];
    Rcnt[0] = Gcnt[0] = Bcnt[0] = 0;
    if(S[0] == 'R'){
        Rcnt[0]++;
    } else if(S[0] == 'G'){
        Gcnt[0]++;
    } else {
        Bcnt[0]++;
    }
    for(int i=1;i<N;i++){
        if(S[i] == 'R'){
            Rcnt[i] = Rcnt[i-1] + 1;
            Gcnt[i] = Gcnt[i-1];
            Bcnt[i] = Bcnt[i-1];
        } else if(S[i] == 'G'){
            Rcnt[i] = Rcnt[i-1];
            Gcnt[i] = Gcnt[i-1] + 1;
            Bcnt[i] = Bcnt[i-1];
        } else {
            Rcnt[i] = Rcnt[i-1];
            Gcnt[i] = Gcnt[i-1];
            Bcnt[i] = Bcnt[i-1] + 1;
        }
    }
    for(int i=N-1;i>=0;i--){
        for(int j=i-1;j>=0;j--){
            if(j-1 >= 0 && S[i] != S[j]){
                if(S[i] != 'R' && S[j] != 'R'){
                    sum += Rcnt[j-1];
                    if(j-(i-j) >= 0 && S[j-(i-j)] == 'R'){
                        sum--;
                    }
                } else if(S[i] != 'G' && S[j] != 'G'){
                    sum += Gcnt[j-1];
                    if(j-(i-j) >= 0 && S[j-(i-j)] == 'G'){
                        sum--;
                    }
                } else {
                    sum += Bcnt[j-1];
                    if(j-(i-j) >= 0 && S[j-(i-j)] == 'B'){
                        sum--;
                    }
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3672
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i=0;i<N;i++) a[i] = sc.nextInt();
        long[] sum = new long[N+1];
        for(int i=1;i<=N;i++) sum[i]=sum[i-1]+a[i-1];
        long ans = Long.MAX_VALUE;
        for(int i=1;i<N;i++){
            long cur = sum[i]-(sum[N]-sum[i]);
            ans = Math.min(ans,Math.abs(cur));
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 65004
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i,s.size()){
		for(int j = i; j < s.size(); ++j){
			string t = "";
			for(int k = 0; k < i; ++k) t += s[k];
			for(int k = j; k < s.size(); ++k) t += s[k];
			if(t == "keyence"){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, ans = 0, k;
    cin>>n;
    vl v;
    f(i,n)cin>>k,v.pb(k);
    sort(all(v));
    for(int i = v.size() - 1; i >= 0; i--){
        int x = 0, y = i - 1;
        while(x < y){
            int p = (v[x] + v[y]);
            if(p > v[i])ans += (y - x),y--;
            else x++;
        }
    }
    cout<<ans;
}


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


Measured memory_bytes: 256
#include<stdio.h>
/*0≤a<b≤100
0≤c<d≤100
All input values are integers.*/
int main()
{
    int a,b,c,d,k,min,max;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(d<=a||c>=b)
         k=0;
    else{
        min=b;
        max=a;
        if(min>d)
            min=d;
        if(max<c)
            max=c;
    k=min-max;
    }

        printf("%d",k);
}


Measured memory_bytes: 128
from functools import lru_cache
N = int(input())


@lru_cache(maxsize=1000)
def get_v(i, j, c, r):

    if i < c // 2 <= j:
        return r
    elif j < c // 2:
        return get_v(i, j, c // 2, r + 1)
    else:
        return get_v(i - c // 2, j - c // 2, c - c // 2, r + 1)


for k in range(N - 1):
    print(*[get_v(k, m, N, 1) for m in range(k + 1, N)])



Measured memory_bytes: 5088
#include<iostream>
using namespace std;
int main()
{
    int n, k, p = 1;
    cin >> n >> k;
        while(n >= 1)
        {
            if(p * 2  < p + k)
                p = p * 2;
            else
                p = p + k;
                n--;
        }
    cout << p;
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(void){
    int N, K; cin >> N >> K;
    int P[N]; rep(i, N) cin >> P[i];
    int kukan_max[N-K+1]; //kukan_max[i] = max(P[i], P[i+1], ..., P[i+K-1])
    priority_queue<pair<int, int>> pq;
    rep(i, K){
        pair<int, int> temp = make_pair(P[i], i);
        pq.push(temp);
    }
    for(int i = 0; i <= N-K; i++){
        int val = pq.top().first;
        int pos = pq.top().second;
        if(pos < i){
            i--;
            pq.pop();
        }
        else{
            kukan_max[i] = pos;
            pq.push(make_pair(P[i+K], i+K));
        }
    }

    int kukan_min[N-K+1];
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq_min;
    rep(i, K){
        pair<int, int> temp = make_pair(P[i], i);
        pq_min.push(temp);
    }
    for(int i = 0; i <= N-K; i++){
        int val = pq_min.top().first;
        int pos = pq_min.top().second;
        if(pos < i){
            i--;
            pq_min.pop();
        }
        else{
            kukan_min[i] = pos;
            pq_min.push(make_pair(P[i+K], i+K));
        }
    }

    UnionFind uf(N-K+1);

    vector<int> row_ls;
    int row = 1;
    for(int i = 1; i < N; i++){
        if(P[i-1] > P[i]){
            row = 1;
        }
        else{
            row++;
            if(row >= K){
                row_ls.push_back(i - (K-1));
            }
        }
    }

    int sz = row_ls.size();

    rep(i, sz-1){
        uf.merge(row_ls[i], row_ls[i+1]);
    }

    for(int i = 0; i < N-K; i++){
        if(P[i] == P[kukan_min[i]] && P[i+K] == P[kukan_max[i+1]]) uf.merge(i, i+1);
    }

    set<int> ans;
    rep(i, N-K+1) ans.insert(uf.root(i));
    cout << ans.size() << endl;

    //rep(i, N-K+1) cout << kukan_max[i] << " "; cout << endl;
    return 0;
}

Measured memory_bytes: 15728
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int FIND(string s){
  string tmp[]={"yotta","zetta","exa","peta","tera","giga","mega","kilo","hecto","deca","","deci","centi","milli","micro","nano","pico","femto","ato","zepto","yocto"};
  int cnt[]={24,21,18,15,12,9,6,3,2,1,0,-1,-2,-3,-6,-9,-12,-15,-18,-21,-24};
  for(int i=0;i<21;i++) if(s == tmp[i]) return cnt[i];
}
int main(){
  int n;

  cin >> n;
  getchar();
  while(n--){
    string str,no,op1="",op2;
    getline(cin,str);
    no = str.substr(0,str.find(' '));
    if(str.find(' ')!=str.rfind(' '))
      op1 = str.substr(str.find(' ')+1,str.rfind(' ') - str.find(' ')-1);
    op2 = str.substr(str.rfind(' ')+1);
    int ans = FIND(op1);
    if(no.find('.') == string::npos) no += '.';
    if(no[1] == '.'){
      while(no[0] == '0'){
        no.erase(0,1);
        swap(no[0],no[1]);
        ans--;
      }
      if(no[no.size()-1] == '.') no.erase(no.size() - 1);
    } else {
      while(no[1] != '.'){
        swap(no[no.find('.')],no[no.find('.')-1]);
        ans++;
      }
    }
    cout << no << " * 10^" << ans << " " << op2 << endl;
  }
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
int main()
{   int n;
    cin>>n;
    int arr[n+1][3];
    int i,j,maxi;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(i=2;i<=n;i++)
    {
        for(j=0;j<3;j++)
        {
            if(j==0)
            arr[i][j]+=max(arr[i-1][1],arr[i-1][2]);
            if(j==1)
            arr[i][j]+=max(arr[i-1][0],arr[i-1][2]);
            if(j==2)
            arr[i][j]+=max(arr[i-1][1],arr[i-1][0]);
        }
    }
    maxi=max(arr[n][0],max(arr[n][1],arr[n][2]));
    cout<<maxi;
    return 0;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,d;
    cin >> n >> d;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        double z=x*x+y*y;
        if(z<=d*d) ans++;
    }
    
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 3616
/******************************************************/
/******************************************************/
/**                                                  **/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         REAZ AHAMMED CHOWDHURY - reaziii         **/
/**  Department of Computer Science and Engineering  **/
/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/
/**                                                  **/
/******************************************************/
/******************************************************/



#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define ff           first
#define ss           second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num, int pos);
ll setbitt(ll num, ll pos);
ll resetbitt(ll num, int pos);
void read(int *aa, int sz) {fri(sz) scanf("%d", (aa + i));}
void read(ll *aa, int sz) {fri(sz) scanf("%lld", (aa + i));}
void read(ll *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%lld", (aa + i));}
void read(int *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%d", (aa + i));}
const ll mod =       1e9 + 7;
const ll N =     1e6 + 10;

//.................___Start from here___.................//
//.................._____________________................//

int n;
int dp[N][5];
int a[N], b[N], c[N];
int A = 1, B = 2, C = 3;
int solve() {
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}


	for (int i = n; i >= 1; i--) {
		dp[i][A] = max(dp[i + 1][B], dp[i + 1][C]) + a[i];
		dp[i][B] = max(dp[i + 1][A], dp[i + 1][C]) + b[i];
		dp[i][C] = max(dp[i + 1][A], dp[i + 1][B]) + c[i];
	}

	cout << max(dp[1][A], max(dp[1][B], dp[1][C])) << endl;



	return 0;
}
int main() {
// #ifndef ONLINE_JUDGE
// 	input;
// 	output;
// #endif
// #ifdef ONLINE_JUDGE
// 	ios_base::sync_with_stdio(false);
// 	cin.tie(0);
// #endif
	int cs = 1;
	int cn = 1;
	//cin>>cs;
	while (cs--) {
		solve();

	}
}


bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}
ll setbitt(ll num, ll pos) {return (1 << pos) | num;}
ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
mytype root = power < lli > (a, b / 2, m);mytype ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}
const lli MOD = 1e9 + 7;
int main()
{
   int h, w;
   cin >> h >> w;
   vector<string> v(h);
   for(int i =0 ; i < h ; i++) cin >> v[i];
   vector< vector<lli> > dp(w , vector<lli>(h , 0));
   dp[0][0] = 1;
   for(int i = 0 ; i < h ; i++){
    for(int j = 0 ; j < w ; j++){
        if(v[i][j] == '#') continue;
        if(i > 0) dp[j][i] = (dp[j][i]+ dp[j][i-1])%MOD;
        if(j > 0) dp[j][i] = (dp[j][i] + dp[j-1][i])%MOD;
    }
   }
   cout << dp[w-1][h-1] << endl;
   return 0;
}


Measured memory_bytes: 9216
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	int ans = 1;
	multiset<int>s;
	cin >> M;
	s.insert(-M);
	for (int i = 1; i < N; i++) {
		cin >> M;
		auto it = s.upper_bound(-M);
		if (it == s.end()) {
			ans++;
			s.insert(-M);
		}
		else {
			s.erase(it);
			s.insert(-M);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while (A > 0 || C > 0) {
        // 高橋君の攻撃
        C -= B;
        if (C <= 0) {
            break;
        }

        // 青木君の攻撃
        A -= D;
        if (A <= 0) {
            break;
        }
    }

    if (A <= 0) {  // 高橋君の負け
        cout << "No" << endl;
    } else {  //高橋君の勝ち
        cout << "Yes" << endl;
    }

    return 0;
}

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

int main(){
  int x, y, z, k; cin >> x >> y >> z >>k;
  vector<ll> a(x);
  vector<ll> b(y);
  vector<ll> c(z);
  for(int i=0; i<x; i++){
    cin >> a[i];
  }for(int i=0; i<y; i++){
    cin >> b[i];
  }for(int i=0; i<z; i++){
    cin >> c[i];
  }

  vector<ll> ab(x*y);
  for(int i=0; i<x; i++){
    for(int j=0; j<y; j++){
      ab[i*y+j]=a[i]+b[j];
    }
  }sort(ab.begin(),ab.end());
  reverse(ab.begin(),ab.end());


  vector<ll> abc(min(k,x*y)*z);
  for(int i=0; i<min(k,x*y); i++){
    for(int j=0; j<z; j++){
      abc[i*z+j]=ab[i]+c[j];
    }
  }

  sort(abc.begin(),abc.end());
  reverse(abc.begin(),abc.end());
  for(int i=0; i<k; i++){
    cout << abc[i] << endl;
  }
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s, t;
	cin >> n >> s >> t;
	for(int i = n; i >= 0; i--) {
		bool ok = true;
		for(int j = 0; j < i; j++) {
			if(s[n-i+j] != t[j]) ok = false;
		}
		if(ok) {
			int ans = n + n - i;
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
string in;
void solve(int T){
	int len,ans=0;
	scanf("%d",&len);
	int l=0,r=len-1;
	cin>>in;
	while(l<r){
		while(in[l]!='W'&&l<len){
			l++;
		}
		while(in[r]!='R'&&r>0){
			r--;
		}
		if(l<r){
			swap(in[l],in[r]);
			ans++;
		}
	}
	printf("%d",ans);
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}



Measured memory_bytes: 3944
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
for(i=0; i<=VMAX; i++) C[i] = 0;

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

for(i=1; i<= VMAX; i++) C[i] = C[i] + C[i-1];

for(j=1; j<=n; j++){
  B[C[A[j]]] = A[j];
  C[A[j]]--;
}

for(i=1; i<=n; i++){
  if(i>1) printf(" ");
  printf("%d", B[i]);
}
printf("\n");

return 0;
}



Measured memory_bytes: 9636
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        int A = entrada.nextInt();
        int B = entrada.nextInt();
        int C = A+(A-1);
        int D= A+B;
        int E= B+(B-1);
        int F=Math.max((Math.max(C, E)), D);
        System.out.println(F);
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
int main() {
    int N;
    cin>>N;
    int ans=0;
    int tmp=0;
    int prev=0;
    for (int i = 0; i < N; i++){
        int h;
        cin>>h;
        if(prev>=h){
            tmp++;
            ans=max(ans,tmp);
        }else tmp=0;
        prev=h;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N), y(M);
	for (int i = 0; i < N; i++) cin >> x[i];
	for (int i = 0; i < M; i++) cin >> y[i];
	string ans = "War";
	for (int Z = X + 1; Z <= Y; Z++) {
		bool ok = true;
		for (int i = 0; i < N; i++) {
			if (x[i] >= Z) ok = false;
		}
		for (int j = 0; j < M; j++) {
			if (y[j] < Z) ok = false;
		}
		if (ok) ans = "No War";
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int64_t A, B, M;
    cin >> A >> B >> M;
    vector<int64_t> a(A), b(B), x(M), y(M), c(M);
    for (int64_t i = 0; i < A; i++) {
        cin >> a[i];
    }
    for (int64_t i = 0; i < B; i++) {
        cin >> b[i];
    }

    for (int64_t i = 0; i < M; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--; y[i]--;
    }

    int64_t ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    for (int64_t i = 0; i < M; i++) {
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>

using namespace std;
int dp[100001][3];
int a, b, c, N;

int solve() {
    cin >> N;
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(int i = 1; i < N; i++) {
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    return max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
}
int main() {
    cout << solve() << endl;   
}

Measured memory_bytes: 1408
#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() {
  string s;
  cin >> s;

  // 初期状態のWの位置の総和
  // ついでにWの数量をカウント
  int wc = 0;
  ll v1 = 0;
  rep(i, s.size()) {
    if (s[i] == 'W') {
      v1 += i;
      wc++;
    }
  }
  // 終了状態のWの位置の総和
  // 前半wc個がW
  ll v2 = 0;
  rep(i, wc) {
    v2 += i;
  }
  cout << v1 - v2 << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))

min_val = 10000

for i in range(len(H)):
    tmp = T - H[i] * 0.006
    sub = abs(tmp - A)
    if min_val > sub:
        ans = i
        min_val = sub


print(ans+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  A.push_back(0);

  int cnt = 0;
  ll ans = 1000;
  REP(i,N){
    if(A[i]<=A[i+1]){
      cnt++;
    }else{
      ans=ans/A[i-cnt]*A[i]+ans%A[i-cnt];
      cnt=0;
    }
  }

  cout << ans << endl;
}

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

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

map<string, int> memo;
for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    memo[s] += 1;
}

int maxy = 0;
for (auto x : memo) {
int y = x.second; 
if(y > maxy) maxy = y;
}



for (auto x : memo) {
if(maxy == x.second){
    cout << x.first << endl;
}
}

}

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

int main() {
    int a, b;
    char op;

    while(1){
        cin >> a >> op >> b;
        if(op == '?')break;

        if(op == '+')cout << a + b << endl;
        else if(op == '-')cout << a - b << endl;
        else if(op == '*')cout << a * b << endl;
        else if(op == '/')cout << a / b << endl; 
    }

    return 0;
}


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

m = int(input())

sum_n = 0
len_n = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_n += d*c
    len_n += c

ans = len_n-1 + (sum_n-1)//9
print(ans)

Measured memory_bytes: 40428
#include <iostream>
using namespace std;
 
int main() {
	int i,j,flag=0;
	// your code goes here
	char a[2][3];
	for(i=0;i<2;i++)
	{
		for(j=0;j<3;j++)
		cin>>a[i][j];
	}
	char b[2][3];
      b[0][0]=a[1][2];
      b[0][1]=a[1][1];
      b[0][2]=a[1][0];
      b[1][0]=a[0][2];
      b[1][1]=a[0][1];
      b[1][2]=a[0][0];
      for(i=0;i<2;i++)
      {
      	for(j=0;j<3;j++)
      	{
      		if(a[i][j]!=b[i][j])
      		flag=1;
      	}
      }
      if(flag==1)
      cout<<"NO";
      else
      cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

struct node{
	int l, r;
};

void dfs(vector<node> &tree, int now, int mode){
	if(now == -1) return;
	if(mode == 0) cout << " " << now;
	dfs(tree, tree.at(now).l, mode);
	if(mode == 1) cout << " " << now;
	dfs(tree, tree.at(now).r, mode);
	if(mode == 2) cout << " " << now;
}

int main(){
	int n;
	cin >> n;
	vector<node> tree(n);
	rep(i, n){
		int id, a, b;
		cin >> id >> a >> b;
		tree.at(id).l = a;
		tree.at(id).r = b;
	}

	vector<bool> ch(n, false);
	rep(i, n){
		auto now = tree.at(i);
		if(now.l != -1) ch.at(now.l) = true;
		if(now.r != -1) ch.at(now.r) = true;
	}
	int stn = -1;
	rep(i, n){
		if(ch.at(i) == false){
			stn = i;
			break;
		}
	}

	cout << "Preorder" << endl;
	dfs(tree, stn, 0);
	cout << endl << "Inorder" << endl;
	dfs(tree, stn, 1);
	cout << endl << "Postorder" << endl;
	dfs(tree, stn, 2);
	cout << endl;
	return 0;
}


Measured memory_bytes: 3108
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func minFirstDigit(ints []int) int {
	res := 0
	t := 10
	for _, n := range ints {
		x := n % 10
		if x == 0 {
			continue
		}
		if x < t {
			t = x
			res = n
		}
	}
	if res == 0 {
		return ints[0]
	}
	return res
}

func roundUp(i int) int {
	fd := i % 10
	if fd == 0 {
		return i
	}
	return i + (10 - fd)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	var ints []int
	for i := 0; i < 5; i++ {
		line := readLine(sc)
		n, _ := strconv.Atoi(line)
		ints = append(ints, n)
	}

	flg := false
	min := minFirstDigit(ints)
	res := 0
	for _, n := range ints {
		if n == min && !flg {
			flg = true
			continue
		}
		res += roundUp(n)
	}
	res += min

	fmt.Println(res)
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
typedef long long ll;
#define MAX 100100
using namespace std;

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a + b + c > 21) printf("bust");
	else printf("win");
	return 0;
}

Measured memory_bytes: 128
//
// Created by pavao on 9/22/2019.
//

// C++ program to find the longest repeated
// non-overlapping substring
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int sol = 0;
    vector<vector<int> > dp(n + 1, vector<int>(n + 1, 0));
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j] && dp[i][j] < (j - i)) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
                sol = max(sol, dp[i + 1][j + 1]);
            }
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 98176
N = int(input())
S = input()
east = [0]*N
west = [0]*N
for i in range(N):
    s = S[i]
    if i == 0:
        if s == "E":
            east[i] = 1
        else:
            west[i] = 1
    else:

        if s == "E":
            east[i] = east[i-1]+1
            west[i] = west[i-1]
        else:
            east[i] = east[i-1]
            west[i] = west[i-1]+1
Min = 10000000000
for i in range(N):
    if i == 0:
        num = east[N-1]-east[0]
    elif i == N-1:
        num = west[N-2]
    else:
        num = east[N-1]-east[i]+west[i-1]
    Min = min(Min,num)
print(Min)

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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define endl '\n'
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define ff first
#define ss second
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;



int solve() {
	int x, n;
	cin >> x >> n;
	unordered_set<int> h;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		h.insert(a);
	}

	int near = inf;
	int val;
	for (int i = 0; i <= 101; i++) {
		if (h.count(i)) continue;
		if (abs(i - x) < near) {
			val = i;
			near = abs(i - x);
		}
	}

	return val;
}

int32_t main() {
	fast
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 3656
/*
Author- Aasav Badera
Time- Tue Mar 24 21:33:15 2020
*/
#include<bits/stdc++.h> 
#define ll                 long long                            
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define rep(i, a, b)         for(ll  i=a;i<b;i++)
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define mp                 make_pair
#define yes                cout << "YES" << endl;
#define no                 cout << "NO" << endl;
#define inf                1e18L+1
#define endl               '\n' 
using namespace std;
#define N  300005
ll powe(ll x, ll y) 
{ 
    ll res = 1;
  
    x = x;

    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x); 
  
        y = y>>1; 
        x = (x*x) ; 
    } 
    return res; 
} 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ll tests = 1;
    // cin >> tests;
    while(tests--)
    {
    	ll h, w, k;
    	cin >> h >> w >> k;
    	string s[h];
    	rep(i,0 , h)cin >> s[i];
    	ll dp[h+1][w+1];
    	rep(i, 0, h+1)dp[i][0] = 0;
    	rep(i ,0, w+1)dp[0][i] = 0;
    	rep(i, 1, h+1)
    	{
    		rep(j,1,w+1)
    		{
    				dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + s[i-1][j-1] - '0';
    		}
    	}
    	// rep(i, 0, h)
    	// {
    	// 	rep(j, 0 ,w)
    	// 	{
    	// 		cout << dp[i][j] << " ";
    	// 	}
    	// 	cout << endl;
    	// }
    	ll ans = inf;
    	rep(i, 0, powe(2, h-1))
    	{
    		ll ans1 = 0;
    		vi v;
    		ll j = 1, z = 1;
    		v.pb(0);
    		while(j <= 2*i)
    		{
    			if(j & i)v.pb(z);
    			j *= 2;z++;
    		}
    		v.pb(h);
    		ll prevmove = 0;
    		rep(width, 1, w+1)
    		{
    			rep(division, 1, sz(v))
    			{
    				if(dp[v[division]][width] - dp[v[division-1]][width] - dp[v[division]][width-1] + dp[v[division-1]][width-1] > k)
    				{
    					ans1 = inf;
    					break;
    				}
    				if(dp[v[division]][width] - dp[v[division-1]][width] - dp[v[division]][prevmove] + dp[v[division-1]][prevmove] > k)
    				{
    					ans1++;
    					prevmove = width-1;
    					break;
    				}
    			}
    		}
    		ans1 += sz(v) -2;
    		ans = min(ans1, ans);
    	}
    	cout << ans << endl;
    }
    return 0;
}

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

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

int main() {
  vector<string> s(110);
  vector<string> t(110);
  int N,M;
  cin >> N;
  rep(i,N) cin >> s.at(i);
  cin >> M;
  rep(i,M) cin >> t.at(i);
  int ans =0;
  for(int i = 0; i < N; i++){
    int score = 0;
    for(int j =0; j < N; j++) if(s[j] == s[i]) score++;
    for(int j =0; j < M; j++) if(t[j] == s[i]) score--;
    ans = max(ans,score);
    }
    cout << ans << endl;
  }

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

odd_cnt = 0
four_times_cnt = 0
two_times_cnt = 0
for a in A:
    if a % 2 == 1:
        odd_cnt += 1
    elif a % 4 == 0:
        four_times_cnt += 1
    elif a % 2 == 0:
        two_times_cnt += 1

if two_times_cnt >= 1:
    if odd_cnt <= four_times_cnt:
        print('Yes')
    else:
        print('No')
else:
    if odd_cnt <= four_times_cnt + 1:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 14252
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define MAX 1000001

int n, q; 
int arr[500009];

struct Query { 
    int l, r, idx; 
}; 

bool cmp(Query x, Query y) { 
    return x.r < y.r; 
} 

void update(int idx, int val, int bit[], int n) { 
    for (; idx <= n; idx += idx & -idx) 
        bit[idx] += val; 
} 

int query(int idx, int bit[], int n) { 
    int sum = 0; 
    for (; idx > 0; idx -= idx &- idx) 
        sum += bit[idx]; 
    return sum; 
} 


void solve(int arr[], int n, Query queries[], int q) {

    int bit[n + 1];
    memset(bit, 0, sizeof bit);

    int last[MAX];
    memset(last, -1, sizeof last);


    int ans[q];
    int cntr = 0;

    for(int i = 0; i < n; i++) {

        if (last[arr[i]] != -1) 
            update (last[arr[i]] + 1, -1, bit, n); 
  
        last[arr[i]] = i; 
        update(i + 1, 1, bit, n); 

        while (cntr < q && queries[cntr].r == i) { 
            ans[queries[cntr].idx] =  query(queries[cntr].r + 1, bit, n) - query(queries[cntr].l, bit, n); 
            cntr++; 
        } 

    }

    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
}

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> q;
    
    for(int i = 0; i < n; i++)
        cin >> arr[i];

    Query queries[q];

    for(int i = 0; i < q; i++) {
        int l , r;
        cin >> l >> r;
        l--;
        r--;
        queries[i].l = l;
        queries[i].r = r;
        queries[i].idx = i;

    }

    sort(queries, queries + q, cmp);

    solve(arr, n, queries, q);
    

    return 0;
}

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

int main(){
    string in;
    int n;
    while(cin >> n >> in){
        if(n == 0) break;
        string nstr = "";
        int count = 1;
        for(int j = 0;j<n;j++){
            nstr = "";
            count = 1;
        for(int i = 1;i<in.length();i++){
            if(in[i-1] != in[i]){
                nstr += to_string(count) + in[i-1];
                count = 1;
            }
            else{
                count++;
            }
            // cout << nstr << endl;
        }
        nstr += to_string(count) + in[in.length()-1];
        in = nstr;
        }
        cout << in << endl;
    }
}

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


int main() {

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

	int N, K;


	cin >> N >> K;

	vector<int> p(N + 1);

	for (int i = 1; i <= N; i++) {
		cin >> p[i];
	}
	
	double maxProb = 0;

	vector<double> probs = { 0, 0 };

	for (int i = 1; i <= N; i++) {
		probs.push_back(probs.back() + (double)((p[i] * (p[i] + 1)) / (double)2.0)* (1 / ((double)p[i])));
	}

	for (int i = 1; i <= probs.size() - K - 1; i++) {
		maxProb = max(probs[i + K] - probs[i], maxProb);
	}

	cout << fixed << std::setprecision(6) << maxProb << endl;

	/*
	
	
	for (int i = 1; i <= N - K + 1; i++) {

		double eachProb = 0;

		for (int j = i; j < i + K; j++) {
			eachProb += (double)((p[j] * (p[j] + 1)) / (double)2.0) * (1 / ((double)p[j]));
		}

		maxProb = max(eachProb, maxProb);
	}

	cout << fixed << std::setprecision(6) << maxProb << endl; */
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int x;
  cin >> x;

  int i = 0, s = 0;
  while(true) {
    s += i;
    //cout << s << endl;
    if(s >= x) {
      cout << i << endl;
      return 0;
    }
    i++;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
    #define LF '\n'
    #define ALL(x) x.begin(), x.end()
    #define iostreamBooster() do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
    using namespace std;
    typedef int64_t i64;
    typedef pair<int,int> pii;
    template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
    template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
    constexpr int INF = 0x3f3f3f3f;
    constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;
     
     
    signed main()
    {
    int N;
    int a[105];
    int ans = 0;
     
    cin >> N;
    for (int i = 0; i < N; ++i) {
    cin >> a[i];
    ans += a[i];
    }
     
    sort(a, a+N);
    ans -= a[N-1];
    ans += a[N-1] / 2;
     
    cout << ans << endl;
     
     
    return 0;
    }
     

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



int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3556
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = input()
    N = len(S)

    lis = [0]*2019
    lis[0] = 1

    ct = 0
    for i, x in enumerate(reversed(S)):
        ct += int(x) * pow(10, i, 2019)
        ct %= 2019
        lis[ct] += 1

    ans = 0

    for x in lis:
        if x != 0:
            ans += x*(x-1)//2

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  string T;
  int m, h;
  while(cin >> T && T != "-"){
    cin>>m;
    for(int i=0; i<m; i++){
      cin>>h;
      string T_1 = T.substr(0, h);
      T.erase(0, h);
      T = T + T_1;
    }
    cout<<T<<endl;
  }
  return 0;
}



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

#define pb push_back
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define beg begin()
#define en end()
#define sz size()
#define mem(a,b) memset(a,b,sizeof a)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

bool ans[11110];

void gen(){
	mem(ans,false);
	for(int i=1;i<=25;++i){
		ans[4*i]=true;
	}
	for(int i=1;i<=14;++i){
		ans[i*7]=true;
	}
	
	for(int i=4;i<=92;i+=4){
		//ans[i*7]=true;
		for(int j=7; j<100;j+=7){
			if(i+j>100)break;
			ans[i+j]=true;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	gen();
	int n;cin>>n;
	if(ans[n]==true){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	cout<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());

		String S = st.nextToken();

		int abs= 1000;
//		int A = -1;
		int p=3;
		for(int i=0;i<S.length()-(p-1);i++) {
			int x = parseInt(S.substring(i, i+p));
//				System.out.println(x);
			if(abs > Math.abs(753-x)) {
				abs = Math.abs(753-x);
			}

		}
		System.out.println(abs);


	}
}


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

N, M = (int(i) for i in input().split())

hasis = []
for i in range(M):
    a, b = (int(i) for i in input().split())
    hasis.append((b , a))
hasis.sort()

cc = 0
now = 0
temp = 0
for hasi in hasis:
    now = hasi[0]
    if hasi[1] <= temp < hasi[0]:
        pass
    else:
        temp = now -1
        cc += 1

print(cc)



Measured memory_bytes: 49384
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll N,A,B;
  cin >> N >>A >> B;
  if((B-A)%2==0){
    cout << "Alice" << endl;
  }else{
    cout << "Borys" << endl;
  }
  
       
    
  

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int[] D = new int[K];
		boolean next = false;
		for(int i = 0; i < K; i++) {
			D[i] = scan.nextInt();
		}
		while(true) {
			for(int i = 0; i < Integer.toString(N).length(); i++) {
				for(int j = 0; j < D.length; j++) {
					if(Integer.toString(N).substring(i, i + 1).equals(Integer.toString(D[j]))) {
						next = true;
						break;
					}
				}
				if(next) {
					break;
				}
			}
			if(next) {
				next = false;
				N++;
			} else {
				break;
			}
		}
		
		System.out.println(N);
		
		scan.close();
	}

}


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

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

    int size = S.size();

    if(size <= K){
        cout << S << endl;
    }else{
        cout << S.erase(K) << "..." << endl;
    }
}

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

void next_lunlun(string &n){
	bool inc=true;
	for (int i=1;i<n.size();i++) inc=inc && n[i]>n[i-1];
	if (inc){
		if (n[0]!='9'){
			n[0]++;
			for (int i=1;i<n.size();i++) n[i]=max((char) (n[i-1]-1),'0');
			return;
		}
	}
	else{
		for (int i=n.size()-1;i>0;i--)
			if (n[i]<=n[i-1] && n[i]!='9'){
				n[i]++;
				for (int j=i+1;j<n.size();j++) n[j]=max((char) (n[j-1]-1),'0');
				return;
			}
		if (n[0]!='9'){
			n[0]++;
			for (int i=1;i<n.size();i++) n[i]=max((char) (n[i-1]-1),'0');
			return;
		}
	}
	n="1"+n;
	for (int i=1;i<n.size();i++) n[i]='0';
}

int main(){
	int k;
	cin>>k;
	string lunlun="0";
	for (int i=0;i<k;i++) next_lunlun(lunlun);
	cout<<lunlun<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int a = stdin.nextInt();
	    final int b = stdin.nextInt();

	    if ( a == 0 && b == 0 ) {
		break;
	    }

	    int count = 0;
	    int mx = max( a, b );
	    int mn = min( a, b );

	    while ( mn > 0 ){
		final int mod = mx % mn;
		mx = mn;
		mn = mod;
		count++;
	    }

	    System.out.printf( "%d %d\n", mx, count );
	}	
    }    
}

Measured memory_bytes: 31744
#include<stdio.h>
int main(){

int m,f,r;
while(1){
	scanf("%d%d%d", &m,&f,&r);

	if(m==-1 && f==-1 && r==-1)
		break;
	
	if(m+f<30 || m==-1 || f==-1){
		printf("F\n");

	}else if(m+f>=80){
		printf("A\n");

	}else if(m+f>=65 && m+f<80){
		printf("B\n");

	}else if(m+f>=50 && m+f<65){
		printf("C\n");

	}else if(m+f>=30 && m+f<50){
		if(r>=50)
			printf("C\n");
		else
			printf("D\n");

	}

}

return 0;

}		

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

int N;
int A[50];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];
  
    int res = 0;
    int counter = 0; 
  
  	while(res <= N - 1) {
      if (A[res] != res + 1) {
        counter += 1;
      } 
      res += 1;
    }
  
    if (counter <= 2) {
      cout << "YES";
    } else {
      cout << "NO";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}

ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}

int main(void) {
	int x1,x2;
	cin >> x1 >> x2;
	cout << abs(x1-x2) << endl;
	return 0;
}


Measured memory_bytes: 3088