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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) int(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (ceil(a * 1.0 / d) >= ceil(c * 1.0 / b))
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3644
def check(s):
    h = 0
    for p in s:
        b = h + p[0]
        if b < 0:
            return False
        h += p[1]
    return True


N = int(input())
S = []
left = []
right = []
total = 0
for i in range(N):
    last = 0
    bottom = 0
    s = input().strip()
    for c in s:
        if c == "(":
            last += 1
        else:
            last -= 1
        bottom = min(bottom, last)
    if last > 0:
        left.append((bottom, last))
    else:
        right.append((bottom-last, -last))
    total += last

left.sort(key=lambda x: -x[0])
right.sort(key=lambda x: -x[0])

if check(left) and check(right) and total == 0:
    print('Yes')
else:
    print('No')


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<VI> a(n, VI(n-1));
	rep(i, n) rep(j, n-1){ cin >>a[i][j]; a[i][j]--;}
	rep(i, n) reverse(all(a[i]));
	int ans = 0;
	VI seq(n); iota(all(seq), 0);
	for(int g=0, nxt =1; nxt; g++){
		nxt = 0;
		VI usd(n);
		VI nsq;
		swap(seq, nsq);
		rep(pi, sz(nsq)){
			int i = nsq[pi];
			if(usd[i] !=0 || sz(a[i]) < 1) continue;
			int tcr = a[i].back();
			if(a[tcr].back() == i && usd[tcr]==0){
				usd[i] = usd[tcr] = 1;
				a[tcr].pop_back();
				a[i].pop_back();
				nxt = 1;
				ans = max(ans, g+1);
				seq.push_back(i); seq.push_back(tcr);
			}
		}
		sort(all(seq));
		seq.erase(unique(all(seq)), seq.end());
	}
	rep(i, n) if(sz(a[i])>0) ans =-1;
	cout <<ans <<"\n";
	return 0;
	
}


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

typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int d=a[n-1]-a[0];
    if (d>=2) {
        cout << "No";
    } else if (d==1) {
        int chi;
        for (int i=1; i<n; ++i) {
            if (a[i]!=a[0]) {
                chi=i;
                break;
            }
        }
        if (2*(a[0]-chi+1)<=n-chi&&a[0]>chi-1) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    } else {
        if (2*a[0]<=n||a[0]==n-1) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> L(2*N, 0);
	rep (i, 2*N) cin >> L[i];
	sort(ALL(L), greater<int>());

	int res = 0;
	for (int i = 1; i < 2*N; i += 2){
		res += L[i];
	} // end for
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N;
	int A[20],B[50],C[50];
	int i;
	int sum;

	scanf("%d",&N);
	for(i=0; i<N; i++) scanf("%d",&A[i]);  //input A[i]
	for(i=0; i<N; i++) scanf("%d",&B[i]);  //input B[i]
	for(i=0; i<N-1; i++) scanf("%d",&C[i]);//input C[i]

	sum=0;
	for(i=0; i<N; i++){
		int d;
		d = A[i]-1;
		sum+=B[d]; 
		if(d+1==A[i+1]-1) sum+=C[d];
	}

	printf("%d\n",sum );
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int change1 = 0;
	int change2 = 0;

	for (int i = 0; i < s.size(); i++) {
		if ((i % 2 == 0 && s[i] == '0') ||
		    (i % 2 == 1 && s[i] == '1')
		) {
			change1++;
		}

		if ((i % 2 == 0 && s[i] == '1') ||
		    (i % 2 == 1 && s[i] == '0')
		) {
			change2++;
		}
	}

	int ans = min(change1, change2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
S = str(input())

ans = []
for i in range(len(S)):
  if S[i] == "B":
    if ans == []:
      continue
    else:
      ans = ans[:-1]
  else:
    ans.append(S[i])
  #print(ans)
#print(ans)  

for i in range(len(ans)):
  print(ans[i], end = "")

Measured memory_bytes: 8940
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int N;
   string S;
   cin >> N >> S;
   vector<ll> men(N,0);
   ll sum = 0;
   for(int i=0;i<N;i++){
      if(i-1 >= 0 && S[i-1] == 'W')sum++;
      men[i] += sum;
   }
   sum = 0;
   for(int i=N-1;i>=0;i--){
      if(i+1<N && S[i+1] == 'E')sum++;
      men[i] += sum;
   }
   cout << *min_element(men.begin(),men.end()) << endl;
   return 0;
}


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

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

    if(s[0] == '1')ans++;
    if(s[1] == '1')ans++;
    if(s[2] == '1')ans++;
    
    cout << ans << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int l = ri(), q = ri();
	int upper[n];
	for (int i = 0; i < n; i++) upper[i] = std::upper_bound(a, a + n, a[i] + l) - a - 1;
	std::vector<int> go[n];
	for (int i = n - 1; i >= 0; i--) {
		if (upper[i] == i) continue;
		int cur = upper[i];
		go[i].push_back(cur);
		for (int j = 0; ; j++) {
			if (j >= (int) go[cur].size() || cur == go[cur][j]) break;
			go[i].push_back(cur = go[cur][j]);
		}
	}
	for (int i = 0; i < q; i++) {
		int x = ri() - 1, y = ri() - 1;
		if (x > y) std::swap(x, y);
		int cost = 0;
		for (int i = 20; i >= 0; i--)
			if (i < (int) go[x].size() && go[x][i] < y) cost += 1 << i, x = go[x][i];
		std::cout << cost + 1 << std::endl;
	}
	return 0;
}


Measured memory_bytes: 13952
#include <iostream>
using namespace std;
const int VMAX=10000;
void countingSort(int A[],int n,int vmax,int B[]){
   int *C=new int[vmax];
   for(int i=0;i<vmax;i++)C[i]=0;
   for(int i=0;i<n;i++)	C[A[i]]++;
   for(int i=1;i<vmax;i++)C[i]+=C[i-1];
   
   for(int i=n-1;i>-1;--i){
   		B[C[A[i]]--]=A[i];
   } 
   
   delete C;

}
int main(){
	int n;
	cin>>n;
	int *A=new int[n];
	int *B=new int[n+1];
    int vmax=0;
	for(int i=0;i<n;i++){
		cin>>A[i];
		if(vmax<A[i])vmax=A[i];
	}
    
    countingSort(A,n,vmax+1,B);
    

    for(int i=1;i<n+1;i++){
       if(i>1)cout<<" ";
       	cout<<B[i];
    }
    cout<<endl;
    delete A;
    delete B;
    return 0;
}


Measured memory_bytes: 18372
N = int(input())
S = []
T = ["AC", "WA", "TLE", "RE"]
for i in range(N):
    S.append(input())
# print(S)

C = []
for j in T:
    C.append(S.count(j))
# print(C)

for k in range(len(T)):
    print(T[k] + " x " + str(C[k]))

Measured memory_bytes: 82680
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 5000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int x[51], y[51];
    rep(i, N) cin >> x[i] >> y[i];
    int ans = INF2;
    rep(i, N) {
        rep(j, N) {
            //if(i == j) continue;
            rep(k, N) {
                //if(i == k || j == k) continue;
                rep(s, N) {
                    //if(i == s || j == s || k == s) continue;
                    int L = min({x[i], x[j], x[k], x[s]});
                    int R = max({x[i], x[j], x[k], x[s]});
                    int U = min({y[i], y[j], y[k], y[s]});
                    int D = max({y[i], y[j], y[k], y[s]});
                    int cnt = 0;
                    rep(t, N) {
                        if(L <= x[t] && x[t] <= R && U <= y[t] && y[t] <= D) cnt++;
                    }
                    if(cnt >= K) ans = min(ans, (R - L) * (D - U));
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    INF = 10 ** 9
    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, 3):
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i - j] + abs(A[i] - A[i - j]))
    print(dp[N - 1])

solve()


Measured memory_bytes: 83984
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int digits(ll num){
    int c = 0;
    while(num > 0){
        num /= 10;
        c++;
    }

    return c;
}

int main()
{
    ll N,A,B;
    cin >> N;
    int ans = digits(N);

    for(ll i = 1LL;i * i <= N;i++){
        if(N % i != 0){
            continue;
        }

        A = i;
        B = N / A;

        ans = min(ans, max(digits(A), digits(B)));
    }

    cout << ans << endl;
}



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

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
    while( x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while( y != NIL && x == y->right){ //左の子になった途端にループを抜ける
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y; //削除する対象
    Node *x; //yの子

    //削除する節点を求める
    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);


    //yの子xを決める
    if(y->left != NIL){
        x = y->left;
    }else{
        x = y->right;
    }

    if(x != NIL){
        x->parent = y->parent;
    }

    if(y->parent == NIL){
        root = x;
    }else{
        if(y == y->parent->left){
            y->parent->left = x;
        }else{
            y->parent->right = x;
        }
    }

    if(y != z){
        z->key = y->key;
    }

    free(y);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }

    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        cin >> com;
        if(com[0] == 'f'){
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }else if(com == "delete"){
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}


Measured memory_bytes: 22040
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define pb push_back
#define ld long double
typedef pair<ll,ll> P;
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
int main()
{
    ll n,i,k,j;
    cin>>n>>k;
    ll A[n];
    ll DP[n];
    DP[0]=0;
    for(i=0;i<n;i++)
    cin>>A[i];
    DP[1]=abs(A[1]-A[0]);
    for(i=2;i<=n;i++)
    {
        DP[i]=INT_MAX;
        for(j=0;j<k && i-1-j>=0;j++)
        DP[i]=min(DP[i-1-j]+abs(A[i]-A[i-1-j]),DP[i]);
    }
    cout<<DP[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,a,n) for(int i=a;i<n;i++)
#define ull unsigned long long
#define ll long long
int main(){
  int n,c=0;
  cin>>n;
  ll a[n*3];
  r(i,n*3)cin>>a[i];
  sort(a,a+n*3);
  ull ans=0;
  for(int i=n*3-1-1;i>=0;i-=2){
    if(c==n)break;
    ans+=a[i];c++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n,k;
  cin >> n >> k;
  int ans=0;
  rep(i,n){
    int x; cin>>x;
    ans += min(abs(x-0),abs(k-x));
  }
  cout << ans*2 << endl;
  return 0;
}

Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

  x = inp
  p x.index(0)+1

Measured memory_bytes: 14276
fun main(args: Array<String>) {
    sandbox4()
}

fun sandbox4() {
    val (a, b) = readLine()!!.split(' ').map { it.toInt() }

    if ((a + b) % 2 != 0) return println("IMPOSSIBLE")

    val answer = (a + b) / 2

    println(answer)
}


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

int main(){

    int a,b;
    cin>>a>>b;
    if(a>b){
        while(a--){
            cout<<b;
        }
        cout<<'\n';

    }
    else{
        while(b--){
            cout<<a;
        }
        cout<<'\n';
    }


}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i = 0; i < s.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (s.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }


    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int     main() {
        int N;
        cin >>N;
        string S;
        cin >>S;
        int SS=0;
        for (int i=0; i<S.size()-1; i++) {
                int SSS=0;
                for (int j=0; j<=i; j++) {
                        int k=0;
                        while (S.at(j) != S.at(k)) k++;
                        if (k == j) {
                                k=S.size()-1;
                                while (S.at(j) != S.at(k)) k--;
                                if (k>i) SSS++;
                        }
                }
                SS=max(SS, SSS);
        }
        cout <<SS <<endl;
        return 0;
};

Measured memory_bytes: 256
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int a, b;
        cin >> a >> b;

        for(double i = 0; i <= 100000000; i++) {
           // cout << i << " : " << (int)(i * 0.08) << ' ' << (int)(i * 0.01) << '\n';
            if((int)(i * 0.08) == a && (int)(i * 0.1) == b)
                return cout << i, 0;
        }

        cout << "-1\n";

    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "Impossible" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------


//--MAIN-----------------------------------
void Main() {
    ll N,L; cin>>N>>L;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll nihon=0,nihoni;
    rep(i,N-1){
        if(maxi(nihon,A[i]+A[i+1])) nihoni=i;
    }
    if(nihon<L) dame;
    cout<< "Possible"<<"\n";
    rep(i,nihoni){
        cout<< i+1 <<"\n";
    }
    repr(i,N-1,nihoni+1){
        cout<< i <<"\n";
    }
    
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main() {
  int q,m=100005;
  cin>>q;
  vector<int> a(100005,0),s(100005,0);
  
  bitset<100005> is_prime;
  for(int i=2;i<m;i++) is_prime.set(i);
  for(int i=2;i<m;i++){
    if(is_prime[i]){
      a[i]=1;
      for(int j=i*2;j<m;j+=i){
        is_prime.reset(j);
      }
    }
  }
  
  for(int i=m-1;i>=3;i--){
    if(a[(i+1)/2]==0) a[i]=0;
  }
  a[2]=0;
  for(int i=1;i<m;i++){
    s[i]=s[i-1]+a[i];
  }
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<s[r]-s[l-1]<<endl;
  }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    bool ok=true;
    if(c-a-b<=0) ok=false;
    if((c-a-b)*(c-a-b)<=4*a*b) ok=false;
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

    int A = 0 , B = 0 , number = 0 ;
    int answer = 0;
    int D[5];


    scanf("%d %d",&A,&B);

    for (int i = A; i <= B ; ++i ){
        number = i;
        for (int j = 4; j >= 0;--j){
            D[j] = number % 10;
            number /= 10;
            }
        if (D[0] == D[4] && D[1]== D[3] )
            ++answer;
    }

    printf("%d\n",answer );

return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    ll n;
    cin >> n;
    string tmp;
    vector<ll> a(26,0);
    vector<bool> b(26,false);

    for(ll i = 0;i < n;i++){
        cin >> tmp;
        if(tmp[0] == 'M' || tmp[0] == 'A' || tmp[0] == 'R'|| tmp[0] == 'C' || tmp[0] == 'H'){
            a[tmp[0]-'A']++;
        }
        b[tmp[0]-'A'] = true;
    }
    ll count = 0;
    REP(26){
        if(b[i] == true){
            count++;
        }
    }

    /*REP(26){
        cout << a[i] << endl;
    }*/

    if(count < 3){
        cout << "0" << endl;
        return 0;
    }
    ll ans = 0;
    for(int i = 0;i < 26;i++){

        for(int j = i+1;j < 26;j++){

            for(int k = j+1;k < 26;k++){

            ans = ans + a[i]*a[j]*a[k];
            //cout << ans << endl;

            }
        }
        //cout << ans << endl;
    }

    cout << ans << endl;










    return 0;
}

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

char outc(int button, int cnt) {
  static char s[10] = {' ',' ','a','d','g','j','m','p','t','w'};
  static int a[10] = {0,0,3,3,3,3,3,4,3,4};
  if(button == 1) {
    switch(cnt%5) {
    case 1:return '.';
    case 2:return ',';
    case 3:return '!';
    case 4:return '?';
    case 0:return ' ';
    }
  } else {
    return s[button] +  (cnt-1)%a[button];
  }
}

main() {
  int N;
  int button;
  int cnt;
  cin >> N;
  getchar();
  for(int t = 0; t < N; t++) {
    button = 0;
    while(1) {
      char c = getchar();
      if(button == 0 && c != '0') {
	button = int(c-'0');
	cnt = 1;
      } else if(button != 0 && c == '0') {
	cout << outc(button, cnt);
	button = 0;
      } else {
	cnt++;
      }
      if(c == '\n') break;
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

using namespace std;
int main(void) {
	char str[3] = "\0";
	scanf("%s", str);
	printf("%s\n", str[0] == str[2] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a,b;
    while(~scanf("%c %c",&a,&b))
    {
        if(a=='H'&&b=='H')
            printf("H");
        else if(a=='H'&&b=='D')
            printf("D");
        else if(a=='D'&&b=='H')
            printf("D");
        else if(a=='D'&&b=='D')
            printf("H");
    }
    return 0;
}

Measured memory_bytes: 128
//
//  main.swift
//  AtCorder
//
//  Created by KATSUHITO YASUMOTO on 2020/05/14.
//  Copyright © 2020 KATSUHITO YASUMOTO. All rights reserved.
//

import Foundation

let input_line = readLine()!.components(separatedBy: " ")

let N = Int(input_line[0])!
let M = Int(input_line[1])!
let Q = Int(input_line[2])!

var ans = 0

var inputSequences = [[Int]]()
for _ in 0..<Q {
    let input_line = readLine()!.components(separatedBy: " ")
    inputSequences.append(input_line.map({return Int($0)!}))
}

func dfs (_ arg: [Int]) {
    if arg.count == N+1 {
        var point = 0
        inputSequences.forEach({
            if arg[$0[1]] - arg[$0[0]] == $0[2] {
                point += $0[3]
            }
        })
        ans = max(point, ans)
        return
    }
    
    
    var increase = 0
    var last = arg.last!
    while last <= M {
        var sequence = arg
        sequence.append(sequence.last! + increase)
        dfs(sequence)
        increase += 1
        last += 1
    }
}
dfs([1])
print(ans)


Measured memory_bytes: 14176
<?php
fscanf(STDIN, '%d %d', $m, $d);
$ans = 0;
for ($i = 1; $i <= $m; $i++) {
    for ($j = 1; $j <= $d; $j++) {
        $d1 = $j % 10;
        $d10 = floor($j / 10);
        if ($d1 >= 2 && $d10 >= 2 && (int)($d1 * $d10) === $i) $ans++;
    }
}
echo $ans . PHP_EOL;

Measured memory_bytes: 4728
import java.util.*;

public class Main {

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

        int x = scanner.nextInt();
        int y = scanner.nextInt();


        int TURU = 2;
        int KAME = 4;
        for (int t = 0; t <= x; t++) {
            int k = x - t;
            int r = t * TURU + k * KAME;
            if (r == y) {
                System.out.println("Yes");
                System.exit(0);
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35780
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    t_x_y_arr = [[0,0,0]]
    for i in range(N):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        t_x_y_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'Yes'
    for i in range(N):
        dt = t_x_y_arr[i+1][0]-t_x_y_arr[i][0]
        dist = abs(t_x_y_arr[i+1][1]-t_x_y_arr[i][1]) + abs(t_x_y_arr[i+1][2]-t_x_y_arr[i][2])
        if dt<dist or dist%2!=dt%2:
            TF = 'No'
            break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 80220
from collections import deque

N, M = map(int, input().split())

R = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    R[a-1].append(b-1)
    R[b-1].append(a-1)

def bfs(u):
    
    q = deque()
    q.append(u)
    while q:
        r = q.popleft()
        for v in R[r]:
            if S[v] == -1:
                S[v] = r
                q.append(v)

S = [-1] * N
S[0] = 0

bfs(0)

print("Yes")
for i in range(1,N):
    print(S[i]+1)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin>>s;
  if(s=="ABC")
    cout<<"ARC"<<endl;
  else
    cout<<"ABC"<<endl;


}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

ll table[SIZE];

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

int main(){


	ll N;
	scanf("%lld",&N);

	for(ll i = 0; i < N; i++){

		table[i] = 0;
	}

	int tmp;
	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		table[tmp]++;
	}

	if(N%2 == 1 && table[0] != 1){

		printf("0\n");
		return 0;
	}
	for(ll i = 1; i <= N; i++){

		int loc = abs(N-2*i+1);
		if(loc == 0)continue;

		if(table[loc] != 2){

			printf("0\n");
			return 0;
		}
	}

	printf("%lld\n",mod_pow(2,N/2,MOD));

	return 0;
}


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

def scoring(sc):
    last = [0] * 26
    res = 0
    penalty = 0
    for i in range(D):
        t = out[i]
        res += S[i][t]
        penalty += sc - (i + 1 - last[t]) * C[t]
        res -= penalty
        last[t] = i + 1
    return res

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
out = [int(input()) - 1 for _ in range(D)]
sc = sum(C)
M = int(input())
for _ in range(M):
    d, q = map(int, input().split())
    out[d-1] = q - 1
    print(scoring(sc))



Measured memory_bytes: 75260
n, q = map(int, input().split())
que, result = [], []
t = 0

for i in range(n):
    que_name, que_time = input().split()
    que.append([que_name, int(que_time)])

while len(que) != 0:
    a = que[0][1] - q
    if a > 0:
        t = t + q
        que.append([que[0][0], a])
        del(que[0])
    elif a == 0:
        t = t + q
        result.append([que[0][0], t])
        del(que[0])
    else:
        t = t + que[0][1]
        result.append([que[0][0], t])
        del(que[0])

for r in result:
    print("{} {}".format(r[0], r[1]))



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

const int MOD = 1e9 + 7;
const int MXN = 5e5 + 1;
int fact[MXN];
int add(ll x, ll y) {return (x+y) % MOD;}
int sub(ll x, ll y) {return add(x, MOD-y);}
int mul(ll x, ll y) {return (x*y) % MOD;}
int bp(ll x, ll y) {
	int ans = 1;
	while (y) {
		if (y&1) ans = mul(ans, x);
		x = mul(x, x);
		y>>=1;
	}
	return ans;
}
int inv(int x) {return bp(x, MOD-2);}
int chs(int n, int k) {
	return mul(fact[n], inv(mul(fact[k], fact[n-k])));
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int n, m;
	cin >> n >> m;
	fact[0] = 1;
	for (int i=1; i<=m; i++) fact[i] = mul(fact[i-1], i);
	int ans = 0;
	int div = inv(fact[m-n]);
	for (int i=0; i<=n; i++) {
		int cur = mul(chs(n, i), mul(fact[m-i], div));
		if (i&1) ans = sub(ans, cur);
		else ans = add(ans, cur);
	}
	cout << mul(mul(fact[m], div), ans) << '\n';
}

Measured memory_bytes: 5560
#include<bits/stdc++.h>
#define maxn 10010
using namespace std;
vector<int> node[maxn];
int u[maxn], v[maxn], m;
void get_edge(int x, int y)
{
	int t1 = node[x].size(), t2 = node[y].size();
	for (int i = 0; i <= t1 - 1; i++)
		for (int j = 0; j <= t2 - 1; j++)
		{
			u[m + 1] = node[x][i];
			v[m + 1] = node[y][j];
			m++;
		}
}
int main()
{
	int n, cnt = 0;
	scanf("%d", &n);
	if (n % 2)
	{
		cnt = 1;
		node[1].push_back(n);
		n--;
	}
	for (int i = 1; i <= n / 2; i++)
	{
		cnt++;
		node[cnt].push_back(i);
		node[cnt].push_back(n - i + 1);
	}
	for (int i = 1; i <= cnt - 1; i++)
		get_edge(i, i + 1);
	if (cnt != 2) get_edge(cnt, 1);
	printf("%d\n", m);
	for (int i = 1; i <= m; i++)
		printf("%d %d\n", u[i], v[i]);
	return 0;
}

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

int main(){
  int n, k, i, tmp, ans = 0;
  cin >> n >> k;
  int a[n] = {};

  for(i = 0; i < n; i++){
    cin >> tmp;
    a[tmp-1]++;
  }

  sort(a, a+n);

  for(i = 0; i < n-k; i++){
    ans += a[i];
  }

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


Measured memory_bytes: 1024
a = [[int(i) for i in input().split()] for j in range(3)]
ans = [[0 for i in range(3)] for j in range(3)]

n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b==a[i][j]:
                ans[i][j] += 1
text ="No"

for i in range(3):
    if sum(ans[i])==3:
        text ="Yes"
    if sum([j[i] for j in ans])==3:
        text ="Yes"
    if sum([ans[j][j] for j in range(3)])==3:
        text ="Yes"
    if sum([ans[j][2-j] for j in range(3)])==3:
        text ="Yes"

print(text)

#print(sum([j[i] for j in ans]))


Measured memory_bytes: 3064
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n,m,r;

struct edge {
    lli from,to;
    lli cost;
};
vector<edge> e;
vll ans;
bool updt;
lli k = 0;

const lli INF = 10000001;

int main(){
    cin >> n >> m >> r;
    e = vector<edge> (m);
    for(lli i = 0;i < m;i++) cin >> e[i].from >> e[i].to >> e[i].cost;
    ans = vll(n,INF);
    ans[r] = 0;
    for(;;){
        updt = false;
        for(lli i = 0;i < m;i++){
            if(ans[e[i].from] != INF && ans[e[i].to] > ans[e[i].from] + e[i].cost){
                updt = true;
                ans[e[i].to] = ans[e[i].from] + e[i].cost;
            }
        }
        k++;
        if(k > n){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
        if(!updt) break;
    }
    for(lli i = 0;i < n;i++) if(ans[i] == INF) cout << "INF" << endl;
    else cout << ans[i] << endl;
    return 0;

}

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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

const int maxn = 55;

vector< vector<int> > aa(maxn);

int vis[maxn];

int tot;

void dfs(int u) {
	vis[u] = 1;
	tot++;
	
	for(auto v : aa[u]) {
		if(!vis[v]) {
			dfs(v);
		}
	}
}

void solve()
{
	int n , m;
	
	cin >> n >> m;
	
	int a[m] , b[m];
	
	for(int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
	}
	
	int ans = 0;
	
	for(int i = 0; i < m; ++i) {
		for(int j = 0; j <= n; ++j) {
			aa[j].clear();
		}
		
		for(int j = 0; j < m; ++j) {
			if(i == j) {
				continue;
			}
			aa[a[j]].pb(b[j]);
			aa[b[j]].pb(a[j]);
		}
		
		tot = 0;
		
		fill(vis , 0);
		
		dfs(1);
		
		if(tot != n) {
			ans++;
		} 
	}
	
	cout << ans;
}

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


Measured memory_bytes: 3696
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string trans(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

int main() //input->compute->output
{
        string N, T;
        cin >> N >> T;
        if (N.size() > T.size())
        {
                cout << "GREATER" << endl;
        }
        else if (N.size() < T.size())
        {
                cout << "LESS" << endl;
        }
        else
        {
                for (int i = 0; i < N.size(); i++)
                {
                        if (N[i] > T[i])
                        {
                                cout << "GREATER" << endl;
                                return 0;
                        }
                        else if (N[i] < T[i])
                        {
                                cout << "LESS" << endl;
                                return 0;
                        }
                        else
                        {
                                continue;
                        }
                }

                cout << "EQUAL" << endl;
        }

        return 0;
}


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

using namespace std;
const int N = 200010;
const int MOD = 1e9+7;
int _w;

int n, c[N], f[N], last[N];

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", c+i );
	f[1] = 1, last[c[1]] = 1;
	for( int i = 2; i <= n; ++i ) {
		if( last[c[i]] ) {
			f[i] = (f[i] + f[last[c[i]]]) % MOD;
		}
		if( last[c[i]] != i-1 ) {
			f[i] = (f[i] + f[i-1]) % MOD;
		}
		// printf( "f[%d] = %d\n", i, f[i] );
		last[c[i]] = i;
	}
	cout << f[n] << endl;
	return 0;
}


Measured memory_bytes: 6080
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int firstA,lastZ;
  string str;
  cin >> str;

  for(int i = 0; i < str.size(); i++){
    if(str[i] == 'A'){
      firstA = i;
      break;
    }
  }

  for(int j = str.size() - 1; j >= 0; j--){
    if(str[j] == 'Z'){
      lastZ = j;
      break;
    }
  }

  cout << lastZ - firstA + 1 << endl;
}


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

int main(){ 
    string s;
    cin>>s;
    if(s[0]!=s[1]&&s[0]!=s[2]&&s[2]!=s[1]){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
string s, t;
int check(int tpos,int spos) {
	int ans = 0;
	int tl = tpos + 1;
	int sl = spos + 1;
	while (tpos >= 0) {
		if (s[spos] != t[tpos])ans++;
		tpos--;
		spos--;
	}
	while (tl <int(t.size())) {
		if (t[tl] != s[sl])ans++;
		tl++; sl++;
	}
	return ans;
}
int main() {
	cin >> s >> t; vector<int>res;
	set<char>st; map<char, int>mp; int f = 0;
	for (int i = 0; i < int(t.size()); ++i) {
		mp[t[i]] = i;
	}
	for (char c : t)st.insert(c);
	for (int i = 0; i < int (s.size()); ++i) {
		if (st.find(s[i]) != st.end()) {
			if (i >= mp[s[i]] && (s.size() - 1) - i >= ((t.size() - 1) - mp[s[i]])) {
				int temp = check(mp[s[i]], i); f = 1;
				res.push_back(temp);
			}
			//else cout << i << "\n";
		}
	}
	sort(res.begin(), res.end());
	if (f)
		cout << res[0];
	else cout << t.size();
	return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b<c+d) printf("Right");
    if(a+b==c+d) printf("Balanced");
    if(a+b>c+d) printf("Left");
    return 0;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;


int main(){
	int n;
	cin >> n;
	vector<ll> a(n+1, 0);
	for(int i = 1; i<= n; i++){
		int x = i;
		while(x <= n){
			a[x]++;
			x += i;
		}
	}
	ll sum = 0;
	for(int i = 1; i<= n; i++){
		sum += a[i]*i;
	}
	cout << sum << endl;
}


Measured memory_bytes: 81400
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
bool cmp(const P &a, const P &b){
    if(a.second < b.second) return true;
    else if(a.second > b.second) return false;
    else {
        if(a.first < b.first) return true;
        else return false;
    }
}

int main() {
    int n; cin >> n;
    vector<P> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end(), cmp);
    ///rep(i, n) printf("%d %d\n",p[i].first, p[i].second);
    int time = 0;
    bool flag = true;
    rep(i, n) {
        time += p[i].first;
        if(time > p[i].second) flag = false;
    }
    if(flag) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
 
int main() {
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
 
    if (e - a > k)
    {
	    cout << ":(" << endl;
    }
    else
    {    
    	cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main (){
    int n,z=0,l=0;
    cin>>n;
    for(int i=0,x=0;i<n;i++){
        cin>>x;
        if(x%2==0){l++;
            if(x%3==0 || x%5==0){z++;}
            else{cout<<"DENIED"<<endl;return 0;}
        }

    }
    if(z==l){cout<<"APPROVED"<<endl;}
    else{cout<<"DENIED"<<endl;return 0;}

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long t = x / 500;
    x -= (500 * t);
    long s = x / 5;
    System.out.println((1000 * t) + (5 * s));
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using edge = tuple<ll, ll, ll>; // (from, to, cost)
const ll N = 1e3+9;
const ll INF = 1LL<<60;

ll dist[N];
ll n, m;
vector<edge> e;

int main() {
    fill_n(dist, N, INF);
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        e.push_back(edge(a, b, -c));
    }

    dist[1] = 0;
    bool inf = false;
    for(int step = 1; step <= n; step++) {
        for(auto x : e) {
            ll from, to, cost;
            tie(from, to, cost) = x;
            if(dist[from] == INF)  continue;
            if(dist[from] + cost >= dist[to])  continue;
            dist[to] = dist[from] + cost;
            if(step == n && to == n)  inf = true;
        }
    }

    if(inf)  cout << "inf" << endl;
    else     cout << -dist[n] << endl;
}

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

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void dfs(vector<vector<int>> &arr, vector<int> &vis, int curr,int col) {
	queue<int> q;
	q.push(curr);
	while(!q.empty()) {
		int now = q.front();
		q.pop();
		if(vis[now]!=0)continue;
		vis[now]=col;
		for(auto i:arr[now]) {
			if(vis[i]==0)q.push(i);
			//cerr<<i<<" ";
		}
		//cerr<<endl;
	}
}

void solve(int test_case) {
	int n,m;
	cin>>n>>m;
	if(m==0){
		cout<<1;
		return;
	}
	vector<vector<int>> arr(n,vector<int>());
	while(m--) {
		int f,t;
		cin>>f>>t;
		f--,t--;
		arr[f].PUB(t);
		arr[t].PUB(f);
	}
	vector<int> vis(n,0);
	int col = 1;
	for(int i=0;i<n;i++)if(vis[i]==0)dfs(arr,vis,i,col++);
	vector<int> cols(col,0);
	int ans = 0;
	for(int i:vis) {
		if(i!=0)cols[i]++, ans = max(ans,cols[i]);
	}
	//for(int i:cols)cerr<<i<<" ";
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 15640
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);

    string s;
    cin >> s;

    ll cnt = 0, ans = 0;
    for (ll i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            cnt++;
            ans += i + 1 - cnt;
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3752
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    a:i64,b:i64,
     }
    println!("{}", a ^ b);
}


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
int main(int argc, const char * argv[]) {
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    ll cnt = 0;  
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        if (v[i] > x) {
            cnt += v[i] - x;
            v[i] = x;
        }
    }
    
      
    for (int i = 0; i < n - 1; i++) {
        if (v[i] + v[i+1] > x) {
            cnt += v[i] + v[i+1] - x;
            v[i+1] -= v[i] + v[i+1] - x;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
cnt = 0
while True:
    isBreak = False
    for i in range(len(A)):
        if int(A[i]) % 2 == 0:
            A[i] = A[i]/2
        else:
            isBreak = True
            break
    if isBreak:
        break
    cnt += 1
print(cnt)


Measured memory_bytes: 2940