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

#define st first
#define nd second

using namespace std;

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

const int MAXN = 1E5 + 10;

int n;
int a[MAXN];
ll ans[MAXN];

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	vector<int> lst(1, 0);
	for (int i = 1; i <= n; ++i)
		if (a[i] > a[lst.back()])
			lst.push_back(i);
	lst.push_back(n + 1);

	priority_queue<PII> Q;
	ll cnt = 0;
	for (int i = lst.size() - 3; i >= 0; --i){
		int u = lst[i], v = lst[i + 1], w = lst[i + 2];
		for (int j = v; j < w; ++j)
			Q.emplace(PII(a[j], j));

		ans[v] = cnt * (a[v] - a[u]);
		for (; !Q.empty() && Q.top().st > a[u]; Q.pop())
			ans[v] += a[Q.top().nd] - a[u], ++cnt;
	}

	for (int i = 1; i <= n; ++i)
		printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 2808
//  Author : Fuad Ashraful Mehmet ,University of Asia Pacific
// https://codeforces.com/contest/1370/problem/D
#include<bits/stdc++.h>
using namespace std;

void HalfDead()
{
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int &x:a)cin>>x;
    sort(a.begin(),a.end());
    int cost=0;
    for(int i=0;i<k;++i)cost+=a[i];
    cout<<cost<<endl;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    int tc=1; 
    //cin>>tc;
    while(tc--)HalfDead();
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    private class City {
        int id;
        long x, y;

        public City(int id, long x, long y) {
            this.id = id;
            this.x = x;
            this.y = y;
        }
    }

    private class Road {
        int src, dst;
        long cost;

        public Road(int src, int dst, long cost) {
            this.src = src;
            this.dst = dst;
            this.cost = cost;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        City city[] = new City[n];
        int data[] = new int[n];
        for (int i = 0; i < n; i++) {
            city[i] = new City(i, sc.nextLong(), sc.nextLong());
            data[i] = i;
        }

        Queue<Road> queue = new PriorityQueue<>((o1, o2) -> Long.compare(o1.cost, o2.cost));
        Arrays.sort(city, (o1, o2) -> Long.compare(o1.x, o2.x));
        for (int i = 0; i < n - 1; i++) {
            queue.add(new Road(city[i].id, city[i + 1].id, city[i + 1].x - city[i].x));
        }
        Arrays.sort(city, (o1, o2) -> Long.compare(o1.y, o2.y));
        for (int i = 0; i < n - 1; i++) {
            queue.add(new Road(city[i].id, city[i + 1].id, city[i + 1].y - city[i].y));
        }

        long sum = 0;
        while (!queue.isEmpty()) {
            Road r = queue.poll();
            int src = r.src;
            int dst = r.dst;
            if (isSame(src, dst, data)) {
                continue;
            }

            link(src, dst, data);
            sum += r.cost;
        }

        System.out.println(sum);
    }

    public void link(int x, int y, int data[]) {
        data[root(x, data)] = root(y, data);
    }

    public boolean isSame(int x, int y, int data[]) {
        return root(x, data) == root(y, data);
    }

    public int root(int p, int data[]) {
        return (data[p] == p) ? p : (data[p] = root(data[p], data));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 100336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
void solve(){
    string s;
    cin >> s;
    int l = 0;
    int mx = 0;
    while(l < 3) {
        while(l < 3 && s[l] == 'S'){
            ++l;
        }
        int cnt = 0;
        while(l < 3 && s[l] == 'R'){
            ++l;
            ++cnt;
        }
        mx = max(mx, cnt);
    }
    cout << mx << '\n';
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
 using namespace std;
 typedef long long ll;
 int main()
 {
 	ll n,k;
 	cin>>n>>k;
 	int cnt=0;
 	while(n){
 		n/=k;
 		cnt++;
	 }
	cout<<cnt<<endl;
 }

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 n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  map<char, char> win;
  win['r'] = 'p';
  win['s'] = 'r';
  win['p'] = 's';

  map<char, int> pt;
  pt['r'] = r;
  pt['s'] = s;
  pt['p'] = p;

  string u = "";
  int max_p = 0;
  rep(i, n) {
    if (i - k < 0) {
      u += win[t[i]];
      max_p += pt[win[t[i]]];
      continue;
    }
    if (u[i-k] == win[t[i]]) {
      u += '*';
      continue;
    }
    u += win[t[i]];
    max_p += pt[win[t[i]]];
  }
  cout << max_p << endl;
  return 0;
}

Measured memory_bytes: 3984
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    import numpy as np
    *s, = input()
    s = np.array(s)
    n = len(s)
    to_r = np.array([0]*n)
    to_l = np.array([0]*n)
    cnt = 1
    for i in range(1, n):
        if s[i-1]=="R" and s[i]=="L":
            to_r[i-1] = cnt-cnt//2
            to_r[i] = cnt//2
            cnt = 0
        if s[i]=="R":
            cnt += 1
    s = s[::-1]
    cnt = 1
    for i in range(1, n):
        if s[i-1]=="L" and s[i]=="R":
            to_l[i-1] = cnt-cnt//2
            to_l[i] = cnt//2
            cnt = 0
        if s[i]=="L":
            cnt += 1
    print(*(to_r+to_l[::-1]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 19928
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;

ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }

const int maxn=100005;
vi G[maxn];
ll dp[maxn];

int dfs(int src)
{
    //visited[src]=1;
    if(dp[src]) return dp[src];
    if(G[src].empty()) return 0;

    int len=0;
    for(auto v: G[src])
    {
        len=max(len,1+dfs(v));
    }
    return dp[ src ] = len;
}

int main()
{
    fast_cin
    int n,m;

    cin>>n>>m;
    for(int i = 1 ; i <= m ; i++)
    {
        int u,v;
        cin >> u >> v;
        G[u].pb(v);
    }
    for(int i=n;i>=1;i--)
    {
        if(G[i].size())//there is an edge leading from this to v.
            dfs(i);
    }
    cout << *max_element(dp,dp+n+1)<<endl;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main()
{
	while(true){
		int X,Y;
		scanf("%d%d",&X,&Y);
		if(X==0&&Y==0)return 0;
		int grid[17][16];
		int DP1[17][16];
		int DP2[17][16];
		for(int i=0;i<17;i++){
			for(int j=0;j<16;j++){
				grid[i][j]=0;DP1[i][j]=0;DP2[i][j]=0;
			}
		}
		
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				scanf("%d",&grid[i][j]);
			}
		}
		for(int j=0;j<X;j++){
			if(grid[0][j]==0)DP1[0][j]=1;
			else DP1[0][j]=0;
		}
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				if(grid[i][j]==0){
					if(j-1>=0&&grid[i+1][j-1]!=1)DP2[i+1][j-1]+=(DP1[i][j]+DP2[i][j]);
					if(grid[i+1][j]!=1)DP1[i+1][j]+=(DP1[i][j]+DP2[i][j]);
					if(j+1<X&&grid[i+1][j+1]!=1)DP2[i+1][j+1]+=(DP1[i][j]+DP2[i][j]);
				}
				else if(grid[i][j]==2){
					if(grid[i+2][j]!=1)DP1[i+2][j]+=DP1[i][j];
				}
			}
		}
		/*
		printf("\n");
		for(int i=0;i<Y+2;i++){
			for(int j=0;j<X;j++){
				printf("%d ",DP1[i][j]);
			}
			printf("\n");
		}
		printf("\n");
		for(int i=0;i<Y+2;i++){
			for(int j=0;j<X;j++){
				printf("%d ",DP2[i][j]);
			}
			printf("\n");
		}*/
		int ans=0;
		for(int i=Y;i<Y+2;i++){
			for(int j=0;j<X;j++){
				ans+=DP1[i][j];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1192
S = input()
ANS = []
for i in range(ord("a"),ord("z")+1) :
    p = chr(i)
    T = list(S.split(p))
    U = []
    for j in range(len(T)) :
        U.append(len(T[j]))
    ANS.append(max(U))
print(min(ANS))


Measured memory_bytes: 2940
import kotlin.system.exitProcess

fun main(args: Array<String>) {
  readLine()
  val list = IO.readIntList().asReversed()
  var old = list[0]
  list.forEachIndexed { index: Int, value:Int ->
      if (index != 0) {
          var v = value
          if (v > old) v = v - 1
          if (v > old) {
              println("No")
              exitProcess(0)
          }
          old = v
      }
  }
    println("Yes")
}

object IO {
    fun readIntList(): List<Int> {
        return readLine()!!.split(" ").map(String::toInt)
    }
}

Measured memory_bytes: 59336
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int dat[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int k;
    cin >> k;
    k--;
    cout << dat[k] << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

int main() {
    int A, B;

    cin >> A >> B;

    if (A >= 13) 
        cout << B;
    else if (6 <= A && A << 12)
        cout << B/2;
    else
        cout << 0;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=1e5+100;

void solve(){
	int n;scd(n);
	ll ans=0;
	rep1(i,n)
		if(i%5)
			if(i%3)
				ans+=1ll*i;ac;
}
int main(){
    //IOS;
    //freopen("fenwick.in","r",stdin);
    //freopen("fenwick.out","w",stdout);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 2e5;
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll a[MAX];

int main(){
	fastio;
	ll tc,n,m;
	string s;
	cin >> s;
	ll x= 0;
	f(i,0,3) if(s[i] == 'A') x++; 	
	if(x == 0 || x == 3) cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    System.out.println(str[0].substring(0,1) + str[1].substring(0,1) + str[2].substring(0,1));
  }
}

Measured memory_bytes: 37092
n=int(input())

s=[]
if n%2==0:
    s.append(0)
else:
    s.append(1)
nn=n
ii=0
while nn<=-1 or 2<=nn:
    nn=(nn-s[ii])//(-2)
    if nn%2==0:
        s.append(0)
    else:
        s.append(1)
    ii+=1

ss=""
for i in range(len(s)):
    ss=str(s[i])+ss
print(ss)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int x;
    cin>>x;
    if(x>=30)
    	cout<<"Yes\n";
    else
    	cout<<"No\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
  int N;
  string S;
  int K;
  cin>>N>>S>>K;
  char A=S[K-1];
  rep(i,N){
      if(S[i]!=A){
          S[i]='*';
      }
  }
  cout<<S<<endl;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	vi vc, v, c;
	int n, i, j, k;

	cin >> n;
	SIZE(vc, n);
	SIZE(v, n);
	SIZE(c, n);

	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	rep(i, n) {
		vc[i] = v[i] - c[i];
	}
	sort(ALL(vc), greater<int>());

	k = 0;
	rep(i, n) {
		if (vc[i] < 0)break;
		k += vc[i];
	}

	cout << k;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

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

	if (a*b % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

long next_l(char S[], long l)
{
    while (S[l] == '1') {
        l++;
    }
    while (S[l] == '0') {
        l++;
    }
    return l;
}

int main()
{
    long N, K;
    char S[100001];
    if (scanf("%ld %ld", &N, &K) == EOF) return -1;
    if (scanf("%s", S) == EOF) return -1;

    long answer = 0;
    long l[100000];
    l[0] = 0;
    if (S[0] == '0') K--;
    for (long i = 1; i < N; i++) {
        if (S[i] == '1') {
            l[i] = l[i - 1];
        } else if (S[i] == '0') {
            if (S[i - 1] == '1') {
                if (K > 0) {
                    K--;
                    l[i] = l[i - 1];
                } else {
                    l[i] = next_l(S, l[i - 1]);
                }
            } else {
                l[i] = l[i - 1];
            }
        } else {
            break;
        }
    }
    for (long i = 0; i < N; i++) {
        long if_i = i - l[i] + 1;
        answer = if_i < answer ? answer : if_i;
    }
    printf("%ld\n", answer);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
#define FAST_IO {ios::sync_with_stdio(0);cin.tie(0);}
using namespace std;
signed main() {
  int N; cin >> N;
  string s, t; cin >> s >> t;
  for (int i = 0; i < N; i++) {
    cout << s[i] << t[i];
  }
  cout << endl;  
}



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

using namespace std;
#define MAX 500000
#define INF 1000000001

struct Card {
    char suit;
    int value;
};

struct Card L[MAX/2], R[MAX/2];


void merge(struct Card A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int i;
    for (i = 0 ; i < n1 ; i++) L[i] = A[left + i];
    for (i = 0 ; i < n2 ; i++) R[i] = A[mid  + i];
    L[n1].value = R[n2].value = INF;
    i = 0;
    int j = 0;

    for (int k = left ; k < right ; k++) {
        if(L[i].value <= R[j].value) {
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

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

int partition (struct Card A[], int p, int r) {
    int i, j;
    struct Card t, x;

    x = A[r];
    i = p-1;
    for (j = p ; j < r ; j ++ ) {
        if (A[j].value <= x.value) {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }

    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
    return i+1;
}

void quickSort(struct Card A[], int p, int r) {
    int q;
    if(p < r) {
        q = partition(A, p, r);
        quickSort(A, p , q-1);
        quickSort(A, q+1, r);
    }
}

int main (void) {
    int n , i , v;
    struct Card A[MAX], B[MAX];
    char s[10];

    int stable = 1;

    scanf("%d", &n);

    for (i = 0 ; i < n ; i++) {
        scanf("%s %d", s, &v);
        A[i].suit = B[i].suit = s[0];
        A[i].value = B[i].value = v;
    }

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

    for( i = 0 ; i < n ; i++) {
        // ????????????mergeSort??¨??????????????????????????????
        if(A[i].suit != B[i].suit ) stable = 0;
    }

    if (stable == 1) printf("Stable\n");
    else printf("Not stable\n");

    for (i = 0 ; i < n ; i ++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }

    return 0;
}

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

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

const int INF = 1e9 + 7;

using namespace std;

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

    vector<int> p(n);
    rep (i, 0, n)
	cin >> p[i];

    int res = 0;
    rep (i, 0, n - 2) {
	if (p[i + 1] != min({p[i], p[i + 1], p[i + 2]}) &&
	    p[i + 1] != max({p[i], p[i + 1], p[i + 2]}))
	    res++;
    }

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    long long ans = 1e18;
    vector<long long> sum;
    cin >> n;
    sum.assign(n+1, 0);
    for(int i=1;i<=n;i++){
        int a;
        cin >> a;
        sum[i] = sum[i-1] + a;
    }
    for(int i=1;i<=n;i++){
        ans = min(ans, abs(sum[n]-sum[i]*2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import heapq
n, m = map(int,input().split())
d = {}
for i in range(n):
    a,b = map(int,input().split())
    if not a in d:
        d[a] = []
    d[a].append(b)
que = []
ans = 0
for i in range(1,m+1):
    if i in d:
        for dx in d[i]:
            heapq.heappush(que,-dx)
    if len(que)>0:
        ans -= heapq.heappop(que)
print(ans)


Measured memory_bytes: 27348
integer N,K
integer(16),allocatable,dimension(:)::H
integer(16) ans
read*,N,K
allocate(H(N))
do i=1,N
  read*,H(i)
end do
call Heapsort(N,H)
ans=huge(ans)
do i=1,N-K+1
  ans=min(ans,H(i+K-1)-H(i))
end do
print"(i0)",ans
contains
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  integer(16),intent(inout) :: array(1:n)
  integer::i,k,j,l
  integer(16):: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end

Measured memory_bytes: 1792
import fractions

N,X=map(int,input().split())
x=[int(i) for i in input().split()]

x.append(X)
x.sort()

for i in range(len(x)-1):
    dif=x[i+1]-x[i]
    if i==0:
        ans=dif
    elif dif<ans:
        ans=dif
    elif dif%ans!=0:
        ans=fractions.gcd(ans,dif)

print(ans)

Measured memory_bytes: 16300
def dec(n):
    for i in range(14):
        if n <= 10 * i:
            return 10 * (i)

t_order = [0] * 5
for i in range(5):
    t_order[i] = int(input())
#print(t_order)
#print('---')

t_min = dec(max(t_order)) * 5
for i in range(5):
    t_sum = 0
    for j in range(5):
        if j == i:
            t_sum += t_order[j]
        else:
            t_sum += dec(t_order[j])
    #print(t_sum)

    t_min = min(t_min, t_sum)

print(t_min)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    if(s[0] != s[n-1]){
        if(n % 2 == 0)
            cout << "Second" << endl;
        else
            cout << "First" << endl;
    }
    else{
        if(n % 2 == 0)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// leave to tomorrow anything that can be done today
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    vector<ll> a,b;
    rep(i,0,n){
        ll x,y;
        cin>>x>>y;
        a.push_back(x);
        b.push_back(y);
    }
    if(n&1){
        n--;
        nth_element(a.begin(),a.begin()+((n+1)/2),a.end());
        nth_element(b.begin(),b.begin()+((n+1)/2),b.end());
        ll mini=a[(n+1)/2];
        ll maxi=b[(n+1)/2];
        cout<<maxi-mini+1<<'\n';
    }
    else{
        n--;
        nth_element(a.begin(),a.begin()+n/2,a.end());
        ll mini = a[n/2];
        nth_element(a.begin(),a.begin()+(n/2+1),a.end());
        mini+=a[n/2+1];
        nth_element(b.begin(),b.begin()+n/2,b.end());
        ll maxi = b[n/2];
        nth_element(b.begin(),b.begin()+(n/2+1),b.end());
        maxi+=b[n/2+1];
        cout<<maxi-mini+1<<"\n";
    }
    return 0;   
}   

Measured memory_bytes: 6708
using System;

public class Test
{
	public static void Main()
	{
            string[] data = Console.ReadLine().Split();//????????\?????????
            int W = 0,H=0; //????????¢??????????????§?¨?(W,H)
            int x = 0, y = 0, r = 0;    //??????????????§?¨?(x,y)??¨??????r
            W=int.Parse(data[0]);
            H=int.Parse(data[1]);
            x=int.Parse(data[2]);
            y=int.Parse(data[3]);
            r=int.Parse(data[4]);
            if ((x - r) >= 0 && (x + r) <= W&&(y+r)<=H&&(y-r)>=0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
	}
}

Measured memory_bytes: 8868
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			int k = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			if (s.Length > k) {
				Console.WriteLine($"{s.Substring(0,k)}...");
			} else {
				Console.WriteLine(s);
			}
		}

	}
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	long long tot=0;
	int t,l;
	cin>>l; tot+=l;
	for(int i=1;i<n;i++)
	{
		cin>>t;
		if(t>l) tot+=(t-l);
		l=t;
	}
	cout<<tot<<"\n";
	return 0;
}

Measured memory_bytes: 256
from itertools import product
n, m, x = map(int, input().split())
C = []
A = []
for _ in range(n):
    temp = list(map(int, input().split()))
    C.append(temp[0])
    A.append(temp[1:])

ans = float('inf')
for i in product([True, False], repeat=n):
    alg = [0]*m
    cost = 0
    for id, j in enumerate(i):
        c = C[id]
        a = A[id]
        if j:
            for k in range(m):
                alg[k]+=a[k]
            cost+=c
    if min(alg)>=x: ans=min(ans, cost)
if ans==float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9244
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;



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

	if (n!="abc"&&n!="acb"&&n!="bac"&&n != "bca"&&n != "cab"&&n != "cba") {
		cout << "No";
	}
	else
	{
		cout << "Yes";
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	for i := range d {
		fmt.Scan(&d[i])
	}

	sort.Ints(d)
	fmt.Println(d[n/2] - d[n/2-1])
}


Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#define maxn 300010
#define int long long

using namespace std;

int n, p[maxn];
int odd[maxn], even[maxn];
int cnto, cnte;
struct BIT{
	int c[maxn];
	void clear()
	{
		memset(c, 0, sizeof c);
	}
	
	void add(int x, int d)
	{
		for (; x <= n; x += x & -x) c[x] += d;
	}
	
	int query(int x)
	{
		int ans = 0;
		for (; x; x -= x & -x) ans += c[x];
		return ans;
	}
}bit;

signed main()
{
	cin.tie(0), cout.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i ++ ) cin >> p[i];
	for (int i = 1; i <= n; i += 2) odd[++cnto] = p[i];
	for (int i = 2; i <= n; i += 2) even[++cnte] = p[i];
	
	int ansp = 0, anso = 0, anse = 0;
	
	bit.clear();
	for (int i = n; i; i -- )
	{
		ansp += bit.query(p[i] - 1);
		bit.add(p[i], 1);
	}
	
	bit.clear();
	for (int i = cnto; i; i -- )
	{
		anso += bit.query(odd[i] - 1);
		bit.add(odd[i], 1);
	}
	
	bit.clear();
	for (int i = cnte; i; i -- )
	{
		anse += bit.query(even[i] - 1);
		bit.add(even[i], 1);
	}
	
	bool yes = 1;
	if (ansp % 3) yes = 0;
	if (3 * (anso + anse) != ansp) yes = 0; 
	for (int i = 1; i <= cnto; i ++ )
		if (odd[i] % 2 == 0)
		{
			yes = 0;
			break;
		}
	for (int i = 1; i <= cnte; i ++ )
		if (even[i] % 2)
		{
			yes = 0;
			break;
		}
	
	puts(yes ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100;
int N;
int a[MAX_N+1];

const int MAX_V = MAX_N+2, INF = 1e9;

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
  G[from].push_back((edge){to, cap, (int)G[to].size()});
  G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

ll dfs(int v, int t, int f) {
  if (v == t) return f;
  used[v] = true;
  for (int i = 0; i < G[v].size(); ++i) {
    edge &e = G[v][i];
    if (!used[e.to] && e.cap > 0) {
      ll d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(int s, int t) {
  ll flow = 0;
  for (;;) {
    memset(used, 0, sizeof(used));
    ll f = dfs(s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}

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

  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> a[i];

  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (a[i] < 0) add_edge(0, i, -a[i]);
    else {
      add_edge(i, N+1, a[i]);
      ans += a[i];
    }
  }

  for (int i = 1; i <= N; ++i) {
    for (int k = 2; i*k <= N; ++k) {
      add_edge(i, i*k, INF);
    }
  }

  cout << ans - max_flow(0, N+1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        p.push_back(a);
    }
    sort(p.begin(), p.end());
    long sum = 0;
    for(int i=0;i<K;i++){
        sum += (long)p[i];
    }
    cout << sum << endl;
    

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(){
	int n;
	int h[100001];
	int hk[100001];
	int ind=0, c=0, nc=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&h[i]);
		//if(h[i-1] > h[i]) nc++;
		if(h[i-1]<h[i]) {
			hk[ind] = i;
			ind++;
		}
	}
	
	for(int i=1;i<ind-1;i++){
		if(c < hk[i] - hk[i-1]) c = hk[i] - hk[i-1] - 1;
	}
	
	if(c < n - hk[ind-1]) c = n -( hk[ind - 1] + 1);
	
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 4010, mod = 1000000007, inv2 = mod + 1 >> 1, M = N * 50;
ll a[M], b[M], fac[N * 2], n, x, inv[N * 2], ans, num[N][N];
ll qow(ll a, ll b)
{
	ll ans = 1;
	for (; b; b >>= 1)
	{
		if (b & 1)
			ans = ans * a % mod;
		a = a * a % mod;
	}
	return ans;
}
ll f(ll i, ll j)
{
	return fac[i + j] * inv[i] % mod * inv[j] % mod;
}
ll& upd(ll &a, ll b)
{
	a = a + b < mod ? a + b : a + b - mod;
	return a;
}
int main()
{
	fac[0] = 1;
	for (ll i = 1; i < 8001; i++)
		fac[i] = fac[i - 1] * i % mod;
	inv[8000] = qow(fac[8000], mod - 2);
	for (ll i = 7999; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % mod;
	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++)
	{
		scanf("%lld%lld", a + i, b + i);
		num[2000 - a[i]][2000 - b[i]]++;
	}
	for (ll i = 0; i < 4001; i++)
		for (ll j = 0; j < 4001; j++)
		{
			if (i > 0)
				upd(num[i][j], num[i - 1][j]);
			if (j > 0)
				upd(num[i][j], num[i][j - 1]);
		}
	for (ll i = 1; i <= n; i++)
	{
		upd(ans, num[a[i] + 2000][b[i] + 2000]);
		upd(ans, mod - f(a[i] * 2, b[i] * 2));
	}
	cout << ans * inv2 % mod;
}

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

int main() {
  string S;
  cin >> S;
  bool ans = false;
  for(int i = 0; i < 3; i++) {
    if(S[i] == S[i + 1]) ans = true;
  }
  if(ans) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
x, y = map(int, input().split())
if x * 4 < y:
    print("No")
else:
    if y % 2 == 1:
        print("No")
    else:
        if y - 2 * x < 0:
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 9196
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    ll N;
    vector<vector<int>> A(15);

    cin >> N;

    rep(i, 0, N){
        ll Aidx;
        cin >> Aidx;
        vector<int> tmp(15);
        rep(ii, 0, Aidx){
            ll x, y;
            cin >> x >> y;
            tmp[x - 1] = y + 1;
        }
        A[i] = tmp;
    }

    ll max = pow(2, N) - 1;
    ll ans = 0;
    repR(cnt, max, -1){
        bool flg = true;
        vector<set<bool>> Atmp(15);
        rep(i, 0, N){
            if ((cnt >> i) & 1){
                Atmp[i].insert(true);
            }
            else{
                Atmp[i].insert(false);
            }
        }
        rep(i, 0, N){
            if ((cnt >> i) & 1){
                rep(ii, 0, N){
                    if (A[i][ii] != 0){
                        Atmp[ii].insert(A[i][ii] - 1);
                    }
                }
            }
        }
        rep(i, 0, N){
            if (Atmp[i].size() > 1){
                flg = false;
            }
        }
        if (flg == true){
            ll tmpCnt = 0;
            rep(i, 0, N){
                if ((cnt >> i) & 1){
                    tmpCnt++;
                }
            }
            if (tmpCnt > ans) ans = tmpCnt;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main () {

    int N;

    cin >> N;

    int a[N];

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

    int magic_cnt = 0;

    for (int i = 1; i < N; i++) {
        if (a[i] - a[i-1] == 0) {
            a[i] = 0;
            magic_cnt++;
        }
    }
    cout << magic_cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int K,N,D=0;
  scanf("%lld%lld",&K,&N);
  
  long long int A[N];
  for (int i = 0 ; i<N; i++){
    scanf("%lld",&A[i]);
    
  }
  long long int d = K- A[N-1]+A[0];
  for (int i=0;i<N-1;i++){
    d=max(d,A[i+1]-A[i]);
  }
  
  
 
  printf("%lld", K-d);
  
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define ASC(vec) vec.begin(), vec.end()			// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
const long long INF = 1LL << 60;
typedef long long ll;

int N, A, B, C;
int _min = 1000000000;
vector<int> L;

int dfs(int n, int a, int b, int c, int mp)
{
	if (n == N)
	{
		if (!a || !b || !c) return 0;
		else
		{
			int tmp = abs(a - A) + abs(b - B) + abs(c - C);
			tmp += mp - 30;
			_min = min(_min, tmp);
			return 0;
		}
	}

	dfs(n + 1, a, b, c, mp);
	dfs(n + 1, a + L[n], b, c, mp + 10);
	dfs(n + 1, a, b + L[n], c, mp + 10);
	dfs(n + 1, a, b, c + L[n], mp + 10);
}

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

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

	dfs(0, 0, 0, 0, 0);
	cout << _min << endl;

	return 0;
}


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;


string a, b;

void wrong() {
	cout << "No";
	exit(0);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> a >> b;
	for(int i=0; i<a.size(); i++) if(a[i] != b[i]) wrong();
	if(a.size() + 1 == b.size()) cout << "Yes";
	else wrong();
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long unsigned int ll;
int main() {
    ll n, k;
    cin >> n >> k;

    vector<ll> arr(n);
    for (auto &a: arr) {
        cin >> a;
    }

    vector<int> next(n, -1);
    int cur = 0;
    vector<int> steps;
    while (next[cur] == -1) {
        next[cur] = arr[cur] - 1; // 0-based indexing
        cur = next[cur];
        steps.push_back(cur);
    }
    // for(auto it:steps)
    // {
    //     cout<<it<<" ";
    // }
    // cout<<endl;
    //cout<<cur<<endl;
    int cycle = cur; // start of cycle
    int len = 1; // length of cycle
    cur = next[cycle];
    while (cur != cycle) {
        cur = next[cur];
        ++len;
    }
    
    // already covered before cycle start
    int done = steps.size() - len;
    // remaining steps
    int rem = (k - done) % len;

    if (k <= steps.size()) { // if before cycle starts
        cout << 1 + steps[k - 1] << endl; // 1-based indexing
    } else { // simulate for remaining steps
        cur = cycle;
        while (rem) {
            cur = next[cur];
            --rem;
        }
        cout << 1 + cur << endl; // 1-based indexing
    }
}

Measured memory_bytes: 6676
/*
    Author : Simanta Deb Turja
*/
#include <bits/stdc++.h>
using namespace std;

#define Professor

using ll = long long;
using i64 = unsigned long long;

template <typename T> inline T Min (T a, T b, T c) { return min(a, min(b, c)); }
template <typename T> inline T Min (T a, T b, T c, T d) { return min(a, min(b, min(c, d))); }
template <typename T> inline T Max (T a, T b, T c) { return max(a, max(b, c)); }
template <typename T> inline T Max (T a, T b, T c, T d) { return max(a, max(b, max(c, d))); }

template <typename T> inline T Ceil(T a, T b) { return ((a % b == 0) ? (a / b) : (a / b + 1)); } 
template <typename T> inline T Floor(T a, T b) { return a / b; }

template <typename T> inline T Power (T a, T p) { T res = 1, x = a; while ( p ) { if ( p & 1 ) res = ( res * x ); x = ( x * x ); p >>= 1;}return res; }
template <typename T> inline T BigMod (T a,T p,T M) { a %= M;T ret = 1; while (p) { if (p & 1) ret = (ret * a) % M; a = (a * a) % M; p = p >> 1; } return ret; }
template <typename T> inline T InverseMod (T a,T M) { return BigMod (a, M - 2, M); }

template <typename T> inline T gcd ( T a, T b ) { a = abs(a); b = abs(b); while ( b ) { a = a % b; swap ( a, b ); } return a; }
template <typename T> inline T lcm(T x,T y) { return (((x)/gcd((x),(y)))*(y)); }


#define endl '\n'
#define eb emplace_back

const int N = (int)4e5 + 10;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e15+1;
const int INF = (int)1e9+1;
const ll MOD = (ll)1e9 + 7;

template <typename T> bool cmp (const pair <T, T> &a, const pair <T, T> &b) { return a.first < b.first; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    auto Solve = [&]() {
        #ifdef __APPLE__
            cout << "Running\n";
        #endif
        int n, W;
        cin >> n >> W;
        vector <ll> w(n), v(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> w[i] >> v[i];
            sum += v[i];
        }
        vector <ll> dp(sum + 1, LLINF);
        dp[0] = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = sum; j >= v[i]; --j) {
                dp[j] = min(dp[j], w[i] + dp[j - v[i]]);
            }
        }
        ll mx = -1;
        for (int i = sum; i >= 0; --i) {
            if (dp[i] <= W) {
                mx = i;
                break;
            }
        }
        cout << mx << endl;
    };
    Solve();
    
    return 0;
}



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

int main() {
    int N;
    cin >> N;
    int INF = 1001001;
    vector<int> A(N, INF), B(N, INF);
    for (int i = 0; i < N - 1; i++) cin >> B[i];

    A[0] = B[0];
    for (int i = 0; i < N - 1; i++) {
        int x = min(B[i], B[i + 1]);
        A[i + 1] = x;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) ans += A[i];

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

int main()
{
	rep(i, 9) rep(ii, 9)
	{
		printf("%dx%d=%d\n", i + 1, ii + 1, (i + 1) * (ii + 1));
	}
	return 0;
}

Measured memory_bytes: 924
#include<bits/stdc++.h>
#define si( x ) scanf("%d", &x)
#define sll( x ) scanf("%lld", &x)
#define mp make_pair
#define pb push_back
#define INF 1e18
using namespace std;

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

ll dis[101][101];
int n, m;

int main( int argc, char *argv[] )
{
	cin >> n >> m;
	for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < n ; j++){
		if(i == j) dis[i][i] = 0;
		else dis[i][j] = INF;
	}
	
	for(int i = 0 ; i < m ; i++){
		int _a, _b, _w;
		cin >> _a >> _b >> _w;
		dis[_a][_b] = _w;
	}
	
	for(int k = 0 ; k < n ; k++){
		for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < n ; j++){
			dis[i][j] = min( dis[i][j], dis[i][k] + dis[k][j] );
		}
	}
	
	for(int i = 0 ; i < n ; i++){
		if( dis[i][i] < 0 ) return !printf("NEGATIVE CYCLE\n");
	}
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			if( j ) printf(" ");
			if( dis[i][j] > 2e9 ){
				printf("INF");
			}
			else printf("%d", dis[i][j]);
		}
		printf("\n");
	}
}



Measured memory_bytes: 3280
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
const ll mod=1000000007;
 
ll power(ll a, ll b) {
	ll r=1;
	for(ll i=0; i<b; i++) {
		r = (r*a)%mod;
	}
	return r;
}
 
int main(){
	ll n, r;
	scanf("%lld", &n);
	r=0;
	r += power(10,n);
	r -= 2*power(9,n);
	r += power(8,n);
	r %= mod;
	r = (r+mod)%mod;
	printf("%lld\n", r);
}

Measured memory_bytes: 3736
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	
	char txt[110];
	int n;
	bool flag = true;

	cin >> n >> txt;
	
	if (n == 1) {
		flag = false;
	}

	for (int i = 0; i < (n / 2) ; i++) {
		if (txt[i] != txt[i + n / 2] || n%2 == 1) {
			flag = false;
			//cout << "F";
			break;
		}
	}
	if (flag) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

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

int main () {
  int h, w;
  cin >> h >> w;
  int a[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }  
  }  
  vector<pair<int, int> > xx, yy;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j != w - 1) {
        if (a[i][j] % 2 == 1) {
          a[i][j + 1]++;
          xx.push_back(make_pair(j + 1, j + 2));
          yy.push_back(make_pair(i + 1, i + 1));    
        }    
      }  
    }  
  }
  for (int i = 0; i < h; i++) {
    if (i != h - 1 && a[i][w - 1] % 2 == 1) {
      a[i + 1][w - 1]++;
      xx.push_back(make_pair(w, w));
      yy.push_back(make_pair(i + 1, i + 2));  
    }  
  }
  cout << xx.size() << endl;
  for (int i = 0; i < xx.size(); i++) {
    cout << yy[i].first << " " << xx[i].first << " " << yy[i].second << " " << xx[i].second <<  endl;  
  }
}

Measured memory_bytes: 5228
n = input()
k = int(input())
l = len(n)

dp = [[[0 for a in range(k+1)] for b in range(2)] for c in range(l+5)]

dp[0][0][0] = 1
#print(dp)

for a in range(l) :
    for b in range(2) :
        for c in range(k+1) :
            for d in range(10) :
                na = a
                nb = b
                nc = c
                if b == 0 :
                    if d > int(n[a]) :
                        continue
                    if d < int(n[a]) :
                        nb = 1
                if c == k and d > 0 :
                    continue
                if d != 0 :
                    nc += 1
                #print(a,b,c,na,nb,nc)
                dp[na+1][nb][nc] += dp[a][b][c]

#print(dp[l][0][k])
#print(dp[l][1][k])
print(dp[l][0][k]+dp[l][1][k])


Measured memory_bytes: 3064
import bisect

N = int(input())
al = [int(a) for a in input().split()]
bl = [int(b) for b in input().split()]
cl = [int(c) for c in input().split()]

al.sort()
bl.sort()
cl.sort()
su = 0
for b in bl:
    su += bisect.bisect_left(al, b) * (len(cl) - bisect.bisect_right(cl, b))
print(su)


Measured memory_bytes: 99704
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;

int main()
{
	int N; 
	scanf("%d",&N);
	
    for(int i=0;i<=N/7;i++)
	for(int j=0;j<=N/4;j++)
	if(i*7+j*4==N)
	{
		printf("Yes");
		return 0;
	}
	
	printf("No");
} 

Measured memory_bytes: 256