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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

vector<vector<int> > G;
vector<bool> P;
int ans = 0;
int N, M;

void search(int p, int cnt) {
  if (cnt == N) {
    ans++;
  }

  P[p] = true;
  for (int i = 0; i < G[p].size(); i++) {
    if (!P[G[p][i]]) {
      search(G[p][i], cnt + 1);
    }
  }

  P[p] = false;
}

int main() {
  cin >> N >> M;
  G.resize(N);
  P.resize(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  search(0, 1);

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

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

// ll T,N;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
//     if (A.size() == n) {
//         return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  ll n;
  cin>>n;
  // vector<ll> a(n);
  // rep(i, n){
  //   cin >> a[i];
  // }
  
  cout << n+n*n+n*n*n << endl;


  return 0;
}

Measured memory_bytes: 3648
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

# 1...Nまでを回して、同じ番号をA2...ANまで探索するとO(N^2)となって間に合わない
#そのため、A2...ANを探索して社員番号をカウントしてく方針とする
#その方針だとO(N)となり、間に合う

n = int(input())
a = list(map(int, input().split()))


ans = [0]*n
for i in range(n-1):
    ans[a[i] -1] += 1

for i in range(n):
    print(ans[i])






Measured memory_bytes: 32260
function main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var values = input[1].split(" ").map(function(v) { return parseInt(v); });
  var count = bubbleSort(values, N);
  console.log(values.join(" "));
  console.log(count);
  return;
}

function bubbleSort(a, N) {
  var count = 0;
  var flag = true;
  while (flag) {
    flag = false;
    for (var j = N-1; j >= 1; j--) {
      if (a[j] < a[j-1]) {
        var v = a[j];
        a[j] = a[j-1];
        a[j-1] = v;
        flag = true;
        count++;
      }
    }
  }
  return count;
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7904
mod = 1000000007
n = int(input())
a = list(map(int, input().split()))
ans = 0
a_sum = sum(a) 
a_total = a_sum*a_sum
lat = 0
for i in a:
    lat = lat + i*i
ans = (a_total - lat) // 2
ans = ans%mod
print(ans)

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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
  	int a, b; cin>>a>>b;
  	cout<<(a * b);
	return 0;
}

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

int main(void)
{
  string s;
  cin >> s;
  
  int ans = 0;
  if (s[0] == '1') ans++;
  if (s[1] == '1') ans++;
  if (s[2] == '1') ans++;
  cout << ans << endl;  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

#include <stdio.h>
using namespace std;

int main(void) {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;

		int s[1000] = {};
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			sum += s[i];
		}
		double ave = (double) sum / n;

		double squareSum = 0;
		for (int i = 0; i < n; i++) {
			squareSum += ((double) s[i] - ave) * ((double) s[i] - ave);
		}
		double standard = sqrt(squareSum / n);
		printf("%.7f\n", standard);
	}
	return 0;
}



Measured memory_bytes: 3144
#include <cstdio>
int x[4][3][10];

int main(){
    int n,b,f,r,v;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d%d%d%d",&b,&f,&r,&v);
        x[b-1][f-1][r-1] += v;
    }
    
    for(int i = 0;i < 4 ;i++){
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < 10;k++){
                printf(" %d",x[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3){
            for(int l = 0;l < 20;l++)
                printf("#");
            printf("\n");
        }
    }
    
    return 0;
}


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

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll a;
	ll b;
	ll sum = 0;
	
	cin >> a >> b;
	
	REP(i, b - a) {
		sum += i;
	}
	cout << sum - a;

	return 0;


}

Measured memory_bytes: 256
h,w=map(int,input().split())
dist=[list(map(int,input().split())) for _ in range(10)]
#print(dist)
for k in range(10):
    for i in range(10):
        for j in range(10):
            if dist[i][j]>dist[i][k]+dist[k][j]:
                dist[i][j]=dist[i][k]+dist[k][j]
ans=0
#print(dist)
#print(dist[1][8],end=' dist 1 to 8 \n')
a=[list(map(int,input().split())) for _ in range(h)]
for j in a:
    for i in j:
        if i!=-1:
            ans+=dist[i][1]
print(ans)


Measured memory_bytes: 3316
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

"""
・両端のマンション → どういうルートをたどっても順序が決まる → 彼らの意見は常に一致するとしてよい
"""

N,S,*XP = map(int,read().split())
X = XP[::2]
P = XP[1::2]

leftN = sum(x<S for x in X)
leftX = X[leftN-1::-1] # 内側から順にもつ
leftP = P[leftN-1::-1] # 内側から順にもつ
rightN = N-leftN
rightX = X[leftN:]
rightP = P[leftN:]

visit = [] # 後ろ側から訪問順
while leftN and rightN:
    p1 = leftP[-1]; x1 = leftX[-1]
    p2 = rightP[-1]; x2 = rightX[-1]
    if p1 < p2:
        visit.append(x1)
        leftP.pop(); leftX.pop(); leftN -= 1
        rightP[-1] = p1 + p2
    else:
        visit.append(x2)
        rightP.pop(); rightX.pop(); rightN -= 1
        leftP[-1] = p1 + p2

if leftN:
    visit += leftX[::-1]
else:
    visit += rightX[::-1]
visit.append(S)

answer = sum(x-y if x>y else y-x for x,y in zip(visit,visit[1:]))
print(answer)

Measured memory_bytes: 21932
n = int(input())
w = []
for i in range(0, n):
    w.append(input())

if len(w) != len(set(w)):
    print('No')
else:
    flag = True
    for i in range(0, n-1):
        if w[i][-1] != w[i+1][0]:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3188
def main():
    N = int(input())

    t = [0] * (N + 1)
    x = [0] * (N + 1)
    y = [0] * (N + 1)

    for i in range(1, N+1):
        t[i], x[i], y[i] = map(int, input().split())
        diff_t = t[i] - t[i-1]
        dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
        if diff_t < dist:
            print('No')
            exit()
        elif diff_t >= dist:
            if diff_t % 2 == dist % 2:
                continue
            else:
                print('No')
                exit()
    print('Yes')


main()

Measured memory_bytes: 48472
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

INT dp[2010];

const UINT mod = 1000000007;

UINT Pow(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = Pow(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = Pow(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return Pow(N, mod - 2);
}

int main()
{
	INT N, K;

	cin >> N >> K;

	vector<UINT> mod_inv(K + 10);

	//mod_inv[K] = getModInv(K);

	//for (size_t i = K-1; i >= 1; i--)
	//{
	//	mod_inv[i] = mod_inv[i + 1] * (i + 1) % mod;
	//}

	for (size_t i = 1; i <= K; i++)
	{
		mod_inv[i] = getModInv(i);
	}

	UINT T = N - K + 1;
	UINT C = 1;

	for (size_t i = 1; i <= T; i++)
	{
		C *= i;
		C %= mod;
	}
	for (size_t i = 1; i <= K-1; i++)
	{
		C *= i;
		C %= mod;
	}

	INT ansi = T;
	cout << ansi << endl;
	for (size_t i = 2; i <= K; i++)
	{
		ansi *= (T + 1 - i);
		ansi %= mod;
		ansi *= (K + 1 - i);
		ansi %= mod;
		ansi *= mod_inv[i];
		ansi %= mod;
		ansi *= mod_inv[i-1];
		ansi %= mod;
		cout << ansi << endl;
	}
}


Measured memory_bytes: 256
/**
 * @author: Jun
 * @date  : 03-18-2019
 **/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

ll getres(ll a){
        switch(a%4){
            case 1:
                return 1;
                break;
            case 3:
                return 0;
                break;
            case 0:
                return a;
                break;
            case 2:
                return a+1;
                break;
        }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin >> a >> b;
    ll res = getres(b)^getres(a-1);
    cout << res << el;
    return 0;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 00:11:42
*/

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


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int rect1 = a*b;
    int rect2 = c*d;
    if(rect1 >= rect2) cout << rect1 << endl;
    else cout << rect2 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);


    int n;
    cin >> n;
    long long ans = 1;
    for(int i = 1; i <= n; ++i) {
        ans *= i;
        ans %= mod;
    }
    cout << (uli)ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;



int main(){
  int N;
  cin >> N;
  if(N == 1){
    cout << 0 << endl;
    return 0;
  }
  if(N == 2){
    cout << 2 << endl;
    return 0;
  }
  
  ll cnt = 1;
  rep(i, N){
    cnt *= 10;
    cnt %= MOD;
  }
  ll tmp = 1;
  rep(i, N){
    tmp *= 9;
    tmp %= MOD;
  }
  ll tmp2 = 1;
  rep(i, N){
    tmp2 *= 8;
    tmp2 %= MOD;
  }
  tmp = tmp * 2 % MOD;
  tmp -= tmp2;
  if(tmp < 0)
    tmp += MOD;
  cnt -= tmp;
  cnt %= MOD;
  if(cnt < 0)
    cnt += MOD;
  cout << cnt << endl;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,k;
int a[2521];
int cnt[2521];
int sum[2521];

int main(){
    scanf("%d%d",&n,&k);
    REP(i,n)scanf("%d",a+i);
    // normal
    ll po = 0;
    REP(i,n)REP(j,i)if(a[j]>a[i])po++;
    // other
    REP(i,n)cnt[a[i]]++;
    REP(i,2520)sum[i+1] = sum[i]+cnt[i];
    po = po * k % MOD;
    REP(i,n){
        po += sum[a[i]] * 1ll * (1ll * (k-1) * k / 2 % MOD) % MOD;
    }
    cout<<(po % MOD)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    string s;
    cin>>s;
    int count = 0;
    int mval = 0;
    rep(i,0,3){
        if (s[i]=='R')count++;
        else{
            mval = max(count,mval);
            count = 0;
        }
    }
    mval = max(count,mval);
    cout<<mval<<endl;
	return;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

Measured memory_bytes: 3632
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>    
using namespace std;
#define LL long long
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
char str[MAXN+5];
int main(){
	int n,r=0,g=0,ans=0;
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=1;i<=n;i++){
		if(str[i]=='g'){
			if(r<g) ans++,r++;
			else g++;
		}
		else{
			if(r<g) r++;
			else ans--,g++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

parent_node = None

        
def getParent():
    tmp_node = Nodes
    while Nodes.parent != None:
        tmp_node = tmp_node.parent
    return tmp_node    

def printPreorder(u):
    if u == None:
        return
    print(" ", u.key, sep="", end="")
    printPreorder(u.left)
    printPreorder(u.right)
    
def printInorder(u):
    if u == None:
        return
    printInorder(u.left)
    print(" ", u.key, sep="", end="")
    printInorder(u.right)

n = int(input())

# メモリの確保
Nodes = []
for i in range(n):
    tmp_node = Node(0)
    Nodes.append(tmp_node)

for i in range(n):
    cmd = input().split()
    if cmd[0] == 'insert':
        key = int(cmd[1])

        insert_node = Nodes[i]
        insert_node.key = key
        key_parent = None
        x = parent_node
            
        while x != None:
            key_parent = x
            if insert_node.key < x.key:
                x = x.left
            else:
                x = x.right
        insert_node.parent = key_parent
            
        if key_parent == None:
            parent_node = insert_node
        elif insert_node.key < key_parent.key:
            key_parent.left = insert_node
        else:
            key_parent.right = insert_node
        # printInorder(parent_node)
        # print("")
        # printPreorder(parent_node)
        # print("")
    else:
        printInorder(parent_node)
        print("")
        printPreorder(parent_node)
        print("")


Measured memory_bytes: 109300
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[200001] = {};
int main() {
	ll n, k; cin >> n >> k;

	rep(i, 0, n) {
		ll x; cin >> x;
		a[x]++;
	};

	sort(a, a + 200001);

	ll cnt = 0;
	rep(i, 0, 200001) {
		if (a[i] != 0) cnt++;
	}
	ll ans = 0;
	ll cnt1 = cnt - k;
	rep(i, 0, 200001) {
		if (cnt1 <= 0) {
			break;
		}
		if (a[i] != 0) {
			ans += a[i];
			cnt1--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(final String[] args){
    
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();

    for(int i = 0; i < q ; i++){
        list.add(sc.nextInt());
    }
    for(int i = 0; i < n ; i++){
        list2.add(k);
    }
    for(int i = 0; i < n ; i++){
        list2.set(i,k-q);
    }
    for(int i = 0; i < q ; i++){
        list2.set(list.get(i)-1,list2.get(list.get(i)-1)+1);
    }



    for(int i = 0; i < n ; i++){
        if(list2.get(i) <= 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }

    }
}

Measured memory_bytes: 63500
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#ifdef LOCAL
	#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
	#define debug(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using ull = uint64_t; using ld = long double;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

const int N = 1e5 + 5;
int n, m;
int c[N], p[N];

void func() {
	cin >> n >> m;
	p[1] = 1;
	for (int i = 1; i <= n; ++i) c[i] = 1;
	for (int i = 0; i < m; ++i) {
		int x, y; cin >> x >> y;
		p[y] |= p[x];
		if (c[x] == 1) p[x] = 0;
		--c[x]; ++c[y];
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) ans += p[i];
	cout << ans << endl;
}

int main() {
	fast_io; cout_precision;
	int t = 1; // cin >> t;
	for (int i = 1; i <= t; ++i) {
		func();
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

string s;
int K;
vector<string> ans;

int main(){
    cin>>s>>K;
    string z="{";
    rep(i,5) ans.push_back(z);

    rep(i,s.size()){
        string t;
        int cnt=0;
        bool flag=true;
        while(flag && i+cnt<s.size()){
            char c=s[i+cnt++];
            t+=c;
            rep(j,5){
                if(t==ans[j]){
                    goto a;
                }
                if(t<ans[j]){
                    ans.pop_back();
                    ans.insert(ans.begin()+j,t);
                    goto a;
                }
            }
            flag=false;
            a:;
        }
    }
    
    cout<<ans[K-1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll mod =1e9+7;
 
int main(){
    int n;cin>>n;
    int sum=0;
    int sum1=0;
    for(int i=1;i<n;i++){
        int a=n-i;
        sum1=0;
        int k=0;
        for(int j=1;j*j<=a;j++){
            if(a%j==0) sum1+=2;
            k=j;        
        }
        if(a==k*k)sum1-=1;
        sum+=sum1;
    }
    cout <<sum;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main (void){
int a[5];
for(int i=0;i<5;i++){
  scanf("%d",&a[i]);
}
int b[5];
for(int i=0;i<5;i++){
  b[i]=a[i]%10;
}
int min=10;
for(int i=0;i<5;i++){
  if(b[i]!=0&&b[i]<min){
    min=b[i];
  }
}
int c[5];
int d[5];
int sum=0;
for(int i=0;i<5;i++){
if(b[i]==0){
  c[i]=a[i]/10;
}else{
  c[i]=a[i]/10+1;
}
  d[i]=c[i]*10;
  sum=sum+d[i];
}
if(min<10){
sum=sum+min-10;
}
printf("%d",sum);

return 0;
}

Measured memory_bytes: 128
s = input()
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"\
        , "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

ans = 0
i = 1
while i * 2 < len(s):
  if s[:i] == s[i:2 * i]: ans = i * 2
  i += 1
print(ans)


Measured memory_bytes: 3060
#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;

int main(){
  int n;cin >> n;
  int k;cin >> k;
  int ans = 0;
  int a[n];rep(i,n)cin >> a[i];
  rep(i,n){
    if(a[i] >= k)ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
readInt :: String -> Int
readInt = read

main = do
    s <- map readInt.tail.words<$>getContents
    print $ solve s

solve s = foldr gcd v (convert s)
 where
  v = head (convert s)

convert [] = []
convert [a] = []
convert (a:b:x) = [abs(a-b)] ++ convert (b:x)

Measured memory_bytes: 4092
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
public class Main{
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
    	int num1 = sc.nextInt();
        int num2 = sc.nextInt();
		String pc = sc.next();
        Pattern p = Pattern.compile("^[0-9]{"+ num1 +"}-[0-9]{"+ num2 +"}$");
        Matcher m = p.matcher(pc);
        if(m.find()){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


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

    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3608
from fractions import gcd
inf = input().split()
A = int(inf[0])
B = int(inf[1])
C = int(inf[2])
D = int(inf[3])

num = B-A+1
target = B
X = C*D//gcd(C,D)

total = B//C + B//D - B//X
lim = (A-1)//C + (A-1)//D - (A-1)//X
print(num-total+lim)

Measured memory_bytes: 5048
#include <iostream>
#include <string>

using namespace std;

int main ( void )
{
	string in;

	while ( cin >> in )
	{
		string out = "";

		for (int i = 0; i < in.size(); ++i)
		{
			out += (in[i] - 'A' + 23) % 26 + 'A';
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, long long K){
    cout << N-K+1<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a, b;
    char s[10];
    while(true){
        scanf("%d%s%d", &a, s, &b);
        if(s[0] == '+') printf("%d\n", a+b);
        else if(s[0] == '-') printf("%d\n", a-b);
        else if(s[0] == '*') printf("%d\n", a*b);
        else if(s[0] == '/') printf("%d\n", a/b);
        else break;
    }
}


Measured memory_bytes: 2752
#include <stdio.h>
#include <math.h>

int bit[11];

void bitplus(int[]);

int main(){
    int N, M, K[10], S[10][10], P[10];
    int i, j, k, l, sum, cnt, ans, bitn;

    scanf("%d %d", &N, &M);

    for(i=0; i<M; i++){
        scanf("%d", &K[i]);
        for(j=0; j<K[i]; j++){
            scanf("%d", &S[i][j]);
        }
    }
    for(i=0; i<M; i++){
        scanf("%d", &P[i]);
    }

    for(i=0; i<10; i++){
        bit[i] = 0;
    }

    bitn = pow(2, N);
    
    for(i=0; i<bitn; i++){
        cnt=0;

        for(j=0; j<M; j++){
            sum=0;
            for(k=0; k<K[j]; k++){
                if(bit[S[j][k]-1] == 1)
                    sum++;
            }

            if(sum % 2 == P[j])
                cnt++;
        }
        
        if(cnt == M)
            ans++;

        bitplus(bit);
    }

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

    return 0;
}

void bitplus(int a[]){
    int i;

    a[0] += 1;
    for(i=0; i<10; i++){
        if(a[i] == 2){
            a[i] = 0;
            a[i+1] += 1;
        }
    }
}

Measured memory_bytes: 128
def magic_2():
    R, G, B = map(int, input().split())
    K = int(input())

    if isSucess(R, G, B):
        print('Yes')
        return

    for _ in range(K):

        if B <= G or B <= R:
            B *= 2
        elif G <= R:
            G *= 2

    if isSucess(R, G, B):
        print('Yes')
    else:
        print('No')


def isSucess(R, G, B):
    if B > G > R:
        return True
    else:
        return False


def main():
    magic_2()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#%%
N, M = map(int, input().split())

import sys
num = ['9' for _ in range(N)]

# 問答無用でゼロ
if M == 0 and N == 1:
    print(0)
    sys.exit()
#%%
for _ in range(M):
    s, c = map(int, input().split())
    # indexをゼロ始まり
    s -= 1
    # 先頭が0は絶対にだめ
    if s == 0  and c == 0 and N != 1:
        print(-1)
        sys.exit()

    # 重複して同じ値じゃないときはだめ
    if num[s] != '9' and num[s] != c:
        print(-1)
        sys.exit()
    else:
        num[s] = c
#%%
# 先頭に値が入れられなかったときは1で埋める
if num[0] == '9':
    num[0] = 1
# 他のところはゼロで埋める
for i in range(N):
    if num[i] == '9':
        num[i] = 0

ans = int(''.join(map(str, num)))
print(ans)




Measured memory_bytes: 38256
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
int main(void){
    int n,i,j;
    int d[2],c=0,ans=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>d[0]>>d[1];
        if(d[0]==d[1])c++;
        else c=0;
        if(c==3)ans=1;
    }
    if(ans==0)cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 3636
use std::io::BufRead;
use std::str::FromStr;

fn main() {
    let stdin = std::io::stdin();
    let mut t = Tokenizer::new(stdin.lock().lines().map(|x| x.unwrap()));

    let mut s = t.take::<String>().into_bytes();
    let mut num = 0u64;
    let mut index = 0;
    let mut a: Option<usize> = None;
    if s.len() >= 3 {
        while index < s.len() - 2 {
            if s[index + 2] == b'C' && s[index] == b'A' && s[index + 1] == b'B' {
                if let Some(x) = a {
                    s[x] = b'B';
                    s[x + 1] = b'C';
                    s[x + 2] = b'A';
                    s[index+1] = b'A';
                    s[index+2] = b'A';
                    num += index as u64 - x as u64 + 1;
                    a = Some(x+2);
                    index = index + 2;
                }
                else {
                    s[index] = b'B';
                    s[index + 1] = b'C';
                    s[index + 2] = b'A';
                    num += 1;
                    index += 2;
                }
            } else {
                if s[index] == b'A' {
                    if a.is_none() {
                        a = Some(index);
                    }
                }
                else {
                    a = None;
                }
                index += 1;
            }
        }
    }
    println!("{}", num);
}

struct Tokenizer<S: Iterator<Item = String>> {
    input: S,
    items: Vec<String>,
}

impl<S: Iterator<Item = String>> Tokenizer<S> {
    pub fn new(input: S) -> Self {
        Tokenizer {
            input: input,
            items: Vec::new(),
        }
    }

    pub fn take<T: FromStr>(&mut self) -> T {
        loop {
            if let Some(r) = self.items.pop() {
                return r.parse().ok().expect("parse failed");
            }
            let mut items = self
                .input
                .next()
                .unwrap()
                .split_whitespace()
                .map(|x| x.to_string())
                .collect::<Vec<String>>();
            items.reverse();
            self.items = items;
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

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

int main(void){
  int N, K;

  cin >> N >> K;

  int counter = 0;

  for (int i = 0; i < N; i++) {
    if (i + K <= N) counter ++;
    else break;
  }

  cout << counter << '\n';

  return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, k;
    cin >> n >> k;
    if(k == 1) cout << 0 << endl;
    else cout << n-k << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n,h;cin>>n>>h;
    ll sum=0;
    rep(i,h){
        ll a;cin>>a;
        sum+=a;
    }
    if(sum>=n)out("Yes");
    else out("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1000010;
 
char s[N];
int n, a[N], b[N];
 
int main() {
  scanf("%d %s", &n, s + 1); --n;
  bool isOne = 0;
  for (int i = 1; i <= n; ++i) {
    a[i] = abs(s[i] - s[i + 1]);
    if (a[i] == 1) isOne = 1;
  }
  // cout << brute() << " ";
  int fac = 1;
  if (!isOne) {
    for (int i = 1; i <= n; ++i) a[i] >>= 1;
    fac = 2;
  } 
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
  	if( ((n-1) | (i-1)) == (n-1) ) {
  		sum += (a[i] & 1), sum &= 1;
  	}
  }
  cout << sum * fac << '\n';
  return 0;
}
 

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

int main(){
  int K, A, B;
  string ans= "NG";
  cin >> K >> A >> B;
  int a = (A/K);
  int b = (B/K);
  if ((b - a) >= 1) ans = "OK";
  if ((A%K) == 0) ans = "OK";
  if ((B%K) == 0) ans = "OK";
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int d;
  cin>>d;
  cout<<"Christmas";
  for(Int i=25;i>d;i--){
    cout<<" Eve";
  }
  cout<<endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<long long> acc(n+1, 0);
    priority_queue<long long> pq;
    pq.push(0);
    for (int i = 0; i < n; i++) {
        acc[i+1] = acc[i] + a[i];
        pq.push(acc[i+1]);
    }

    long long now = pq.top(); pq.pop();
    long long cnt = 1;
    long long ans = 0;
    for (int i = 0; i < n; i++){
        if (now == pq.top()) cnt++;
        else {
            if (cnt > 1) ans += cnt * (cnt - 1) / 2;
            now = pq.top();
            cnt = 1;
        }
        pq.pop();
    }
    if (cnt > 1) ans += cnt * (cnt - 1) / 2;
    
    cout << ans << endl;
}


Measured memory_bytes: 5620
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <climits>
#include <utility>
#include <deque>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> wls(n);
	for (auto& w : wls)cin >> w;

	int s1 = 0, s2 = 0;
	for (auto w : wls)s2 += w;

	int minNum = 100000;
	for (int i = 0; i < n - 1; ++i) {
		s1 += wls[i];
		s2 -= wls[i];
		minNum = min(minNum, abs(s2 - s1));
	}

	cout << minNum << endl;
	return 0;
}

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


int main(void){
  int x,n,a;
  bool found;
  
  cin >> x;
  
  n=x;
  while (1){
    found=true;
    for (a=2;a*a<=n;a++){
      if (n%a==0){
        found=false;
        break;
      }
    }
    
    if (found) break;
    
    n++;
    
  }
  
  cout << n << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*

val sc = Scanner(System.`in`)

fun main(args : Array<String>) {
    val (n, k) = listOfInt(2)
    val hh = listOfInt(n).sorted().toIntArray()

    var min = Int.MAX_VALUE

    for (i in 0..n-k) {
        val diff = hh[i+k-1] - hh[i]
        if (diff < min) min = diff
    }

    println(min)
}

fun listOfInt(n: Int) = (1..n).map { sc.nextInt() }

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int h, w;
    cin >> h >> w;

    vvb grid(h, vb(w, false));

    rep(i, 0, h) {
        rep(j, 0, w) {
            char c;
            cin >> c;
            if (c == '#') { grid[i][j] = true; }
        }
    }

    vvi L(h, vi(w, 0)), R(h, vi(w, 0)), U(h, vi(w, 0)), D(h, vi(w, 0));
    rep(i, 0, h) {
        int cnt = 0;
        rep(j, 0, w) {
            if (grid[i][j]) {
                cnt = 0;
            } else {
                L[i][j] = ++cnt;
            }
        }
    }

    rep(i, 0, h) {
        int cnt = 0;
        rrep(j, 0, w) {
            if (grid[i][j]) {
                cnt = 0;
            } else {
                R[i][j] = ++cnt;
            }
        }
    }

    rep(j, 0, w) {
        int cnt = 0;
        rep(i, 0, h) {
            if (grid[i][j]) {
                cnt = 0;
            } else {
                U[i][j] = ++cnt;
            }
        }
    }

    rep(j, 0, w) {
        int cnt = 0;
        rrep(i, 0, h) {
            if (grid[i][j]) {
                cnt = 0;
            } else {
                D[i][j] = ++cnt;
            }
        }
    }

    int ans = 0;
    rep(i, 0, h) {
        rrep(j, 0, w) {
            if (grid[i][j]) { continue; }
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 65792
import collections
import sys
a,b,c= map(int,input().split())
if a == b and a%c==0:
	print(1)
	sys.exit()
elif a == b and a%c!=0:
	print(0)
	sys.exit()
if c!=1 :
    print(b//c-a//c)
    sys.exit()
elif c == 1:
    print(b-c+1)
    sys.exit()

Measured memory_bytes: 9392
N,K,Q = list(map(int, input().split()))



a=[]
nScore=[]

for x in range(N):
    nScore.append(0)

for x in range(Q):
    nScore[int(input())-1]+=1

# if(K>Q):
#     for x in range(N):
#         print("Yes")

for x in range(N):
    if K-Q+nScore[x]>0:
        print("Yes")
    else:
        print("No")





Measured memory_bytes: 4620
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<char> fmr(n);
  vector<char> ltr(n);
  for (int i = 0; i < n; i++) {
    cin >> fmr[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> ltr[n - 1 - i];
  }
  long long ret = 0;
  const int BSM = (1 << n);
  for (int bs = 0; bs < BSM; bs++) {
    vector<char> a;
    vector<char> b;
    int k(0), l(0);
    for (int i = 0; i < n; i++) {
      if (bs & (1 << i)) {
        a.push_back(fmr[i]);
        k++;
      } else {
        b.push_back(fmr[i]);
        l++;
      }
    }
    vector<vector<int>> dp(k + 1, vector<int>(l + 1, 0));
    dp[0][0] = 1;
    for (int d = 1; d <= n; d++) {
      for (int i = max(0, d - l); i <= min(k, d); i++) {
        int j = d - i;
        if (i && ltr[d - 1] == a[i - 1]) {
          dp[i][j] += dp[i - 1][j];
        }
        if (j && ltr[d - 1] == b[j - 1]) {
          dp[i][j] += dp[i][j - 1];
        }
      }
    }
    ret += dp[k][l];
  }
  cout << ret << '\n';
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<long long int> vec(n);
    for(int i=0; i<n; i++){
        cin >> vec.at(i);
        vec.at(i) -= i+1;
    }
    
    sort(vec.begin(), vec.end());

    long long int ans = 0;

    for(int i=0; i<n; i++){
        ans += abs(vec.at(i) - vec.at(n/2));
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
int a,b,c;
cin>>a;
cin>>b;
cin>>c;
if(a==b && a!=c || a==c && a!=b || b==c && b!=a)
cout<<"Yes";

else if(b==c==a)
cout<<"No";

else
cout<<"No";

    return 0;
}


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

int main() {
	string s, s1, s2, s3;
	
	cin >> s;
	
	for(int i = 0; i < 5; i++){
		s1 += s[i];
	}
	
	for(int i = 6; i < 13; i++){
		s2 += s[i];
	}
	
	for(int i = 14; i < 19; i++){
		s3 += s[i];
	}
	
	cout << s1 << " " << s2 << " " << s3;
	
	return 0;
}

Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  s=chomp(readline())
  k=pI(readline())
  if length(s)<k
    for i=s
      if i!='1'
        println(i)
        break
      end
    end
  elseif s[1:k]!="1"^k
    for i=s
      if i!='1'
        println(i)
        break
      end
    end
  else
    println(1)
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

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

using namespace std;

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

int mod=1e9+7;
const int N=2e5+100;


int main()
{
    int x,f=1;

   for(int i=1;i<=3;i++)
   {
       scanf("%1d",&x);
       if(x==7) f=0;
   }
   if(f==0) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> a;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.emplace_back(tmp);
    }
    sort(a.begin(), a.end(), [](int l, int r) {return l > r;});

    int A_sum = 0, B_sum = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            A_sum += a[i];
        }else
        {
            B_sum += a[i];
        }
        
    }
    
    cout << (A_sum - B_sum) << endl;
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i < n; i++)
    cin >> v.at(i);
  sort(v.begin(), v.end());
  for(int i = 0; i < n-1; i++)
    v.at(i+1) = (v.at(i)+v.at(i+1))/2;
  cout << v.at(n-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    set<char> st;
    rep(i, s.size()) {
        st.insert(s[i]);
    }

    if(st.size() == 1) {
        out("No");
    }
    else {
        out("Yes");
    }

    re0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()

l=a[0]
r=a[-1]

ans=float('inf')
for pin in range(l,r+1):
  cnt=0
  for i in range(n):
    cnt+=(a[i]-pin)**2
    
  ans=min(ans,cnt)
  
print(ans)

Measured memory_bytes: 63868
///*.......................Shadman Sakib Utshob............................*///

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define inf             1e9+8
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;

int main()
{
    Boost;
    char s;
    cin>>s;
    if(s=='A')
    {
        cout<<'T'<<endl;
    }
    if(s=='T')
    {
        cout<<'A'<<endl;
    }
    if(s=='G')
    {
        cout<<'C'<<endl;
    }
    if(s=='C')
    {
        cout<<'G'<<endl;
    }




}


Measured memory_bytes: 3572
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;


int main(){
  string s,t;cin>>s>>t;
  bool ok=false;
  int n=s.size();
  rep(i,0,n){
    s.insert(s.begin(),s[n-1]);
    bool ok2=true;
    rep(i,0,n){
      if(s[i]!=t[i]){ok2=false;}
    }
    if(ok2){ok=true;break;}
  }
  if(ok){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256