akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n, m; cin >> n >> m;
    vector<int> nums;
    ll sum = 0;
    for(int i = 0; i < n; ++i){
    	int x; cin >> x;
    	sum += x;
    	nums.pb(x);
    }
    ll y = sum / (4 * m);
    sort(nums.begin(), nums.end());
    reverse(nums.begin(), nums.end());
    int flag = 0;
    for(int i = 0; i < m; ++i){
    	if(nums[i] * 4 * m < sum){
    		flag = 1;
    		break;
    	}
    }
    if(flag == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
} 

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

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 

double EPS=1e-9; 
int INF=1000000005; 
long long INFF=1000000000000000005ll; 
double PI=acos(-1); 
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 }; 
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define OUT(x) cout << x << endl 
#define OUTH(x) cout << x << " " 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a)) 
#define EACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a=max(a, b) 
#define MIN(a, b) a=min(a, b) 
#define SQR(x) ((ll)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--) 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

int main()  
{ 
    FAST_INP;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
    #endif
    
    string n;
    cin >> n;
    int ans=0;
    ll sum=0;
    EACH(c,n){
        int d = c-'0';
        sum+=d;
    }
    if(sum%9==0) OUT("Yes");
    else OUT("No");
    return 0; 
} 


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

int main(){
	int n,sum=0,x,y,z;
	string str;
	cin>>n>>str;
	for(int i=0;i<=9;i++){
		for(x=0;x<n&&str[x]-'0'!=i;x++);
		if(x==n)continue;
			for(int j=0;j<=9;j++){
				for(y=x+1;y<n&&str[y]-'0'!=j;y++);
				if(y==n)continue;
					for(int k=0;k<=9;k++){
						for(z=y+1;z<n&&str[z]-'0'!=k;z++);
						if(z<n)sum++;
					}			
			}
	}		
	cout<<sum<<endl;
	return 0;
} 

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

int main(){
    string s;
    cin >> s;
    int many0 = 0 ,many1 = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0') many0++;
        else many1++;
    }
    cout << min(many0 ,many1) * 2 << endl;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if( A + B < C + D){
    cout << "Right";
  }else if( A + B == C + D){
    cout << "Balanced";
  }else if( A + B > C + D){
    cout << "Left";
  }
}


Measured memory_bytes: 256
from collections import defaultdict


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


if __name__ == '__main__':
    n, m, k = list(map(int, input().split()))
    friends = UnionFind(n)
    ng_dict = defaultdict(list)

    for i in range(m):
        data = list(map(int, input().split()))
        x = data[0] - 1
        y = data[1] - 1

        friends.union(x, y)
        ng_dict[x].append(y)
        ng_dict[y].append(x)

    for i in range(k):
        data = list(map(int, input().split()))
        x = data[0] - 1
        y = data[1] - 1

        if friends.same(x, y):
            ng_dict[x].append(y)
            ng_dict[y].append(x)

    for i in range(n):
        print(friends.size(i) - len(ng_dict[i]) - 1, end=" ")

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


int main() {
    ll l,r;
    cin >> l >> r;
    ll res = 4000;
    for(ll i = l;i < r;i++){
        for(ll j = i+1;j <= r;j++){
            res = min(res,i*j%2019);
            if(res == 0)break;
        }
        if(res == 0)break;
    }
    cout << res << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a[10005];
int main()
{
	for(int i=1;i<=100;++i)
	{int x;
		for(int j=1;j<=100;++j)
		{
			for(int k=1;k<=100;++k)
			{
				x=i*i+j*j+k*k+i*j+j*k+k*i;
				if(x<=10000)
				a[x]++;
				else break;
			}	
		}
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
	cout<<a[i]<<endl;
 } 

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	int L=0,R=n;
	for(int i=0;i<m;++i){
		int l,r; cin>>l>>r;
		L=max(L,l);
		R=min(R,r);
	}
	cout<<(R-L<0?0:R-L+1)<<"\n"s;
}


Measured memory_bytes: 3636
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def generate_graph(v_info):
    for info in v_info:
        adj_info = info[2:]
        assert len(adj_info) == int(info[1])
        for each in adj_info:
            adj_matrix[int(info[0]) - 1][int(each) - 1] = 1
    return adj_matrix


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertex_num = int(_input[0])
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    # assert len(vertex_info) == vertex_num

    ans = generate_graph(vertex_info)
    for v_result in ans:
        print(*v_result)

Measured memory_bytes: 8344
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node
{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node *Node;

Node root;

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

Node treeMaximum(Node x)
{
    while (x->right != NIL)
    {
        x = x->right;
    }
    return x;
}

Node treeSearch(Node u, int k)
{
    if (u == NIL || k == u->key)
        return u;
    if (k < u->key)
        return treeSearch(u->left, k);
    else
        return treeSearch(u->right, k);
}

Node treeSuccessor(Node x)
{
    Node y;
    if (x->right != NIL)
        return treeMinimum(x->right);

    y = x->parent;
    while ((y != NIL) && x == y->right)
    {
        x = y;
        y = y->parent;
        return y;
    }
}

void treeDelete(Node z)
{
    Node y; // node to be deleted
    Node x; // child of y

    if ((z->left == NIL) || z->right == NIL)
        y = z;
    else
        y = treeSuccessor(z);

    if (y->left != NIL)
        x = y->left;
    else
        x = y->right;

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

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

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

    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

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

    z->parent = y;

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

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

int main()
{
    int n, i, x;
    char com[20];
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%s", com);
        if (com[0] == 'f')
        {
            scanf("%d", &x);
            Node t = treeSearch(root, x);
            if (t != NIL)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if (com[0] == 'i')
        {
            scanf("%d", &x);
            insert(x);
        }
        else if (com[0] == 'p')
        {

            inorder(root);
            // if(i != n-1)printf(" ");//空白処理
            printf("\n");

            preorder(root);
            // if(i != n-1) printf(" ");//空白処理
            printf("\n");
        }
        else if (com[0] == 'd')
        {
            scanf("%d", &x);
            treeDelete(treeSearch(root, x));
        }
    }

    return 0;
}



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

int dp[101][10001];
int v[100], w[100];
int main() {
	int N, W; scanf("%d%d", &N, &W);
	rep(i, N)scanf("%d%d", &v[i], &w[i]);
	rep(i, N)rep(j, W + 1) {
		if (w[i] > j)dp[i + 1][j] = dp[i][j];
		else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
	}
	printf("%d\n", dp[N][W]);
}

Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
typedef vector<long long> poly;
long long mod;
long long powmod(long long px, long long py, long long pmod){
	if(py == 0) return 1;
	if(py % 2 == 0) return powmod((px * px) % pmod, py / 2, pmod);
	else return (px * powmod(px, py - 1, pmod)) % pmod;
} 
const long long c_max = 10000003;
long long fac[c_max], finv[c_max], inv[c_max];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < mod; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
long long COM(long long comn, long long comk){
    if (comn < comk) return 0;
    if (comn < 0 || comk < 0) return 0;
    if (comn >= c_max){
        long long cret = finv[comk];
        for (long long i = 0; i < comk; i++) cret = (cret * (comn - i)) % mod;
        return cret;
    }
    return fac[comn] * (finv[comk] * finv[comn - comk] % mod) % mod;
}
poly poly_plus(poly a, poly b){
    ll as, bs;
    as = a.size(); bs = b.size();
    poly c(max(as, bs));
    rep(i,0,as-1) c[i] = a[i];
    rep(i,0,bs-1) c[i] = (c[i] + b[i]) % mod;
    return c;
}

poly poly_minus(poly a, poly b){
    ll as, bs;
    as = a.size(); bs = b.size();
    poly c(max(as, bs));
    rep(i,0,as-1) c[i] = a[i];
    rep(i,0,bs-1) c[i] = (c[i] + mod - b[i]) % mod;
    return c;
}

poly poly_mul(poly a, poly b){
    ll as, bs;
    as = a.size(); bs = b.size();
    poly c(min(as+bs-1, mod), 0);
    rep(i,0,as-1){
        rep(j,0,bs-1){
            c[(i+j)%mod] = (c[(i+j)%mod] + a[i] * b[j] % mod) % mod;
        }
    }
    return c;
}

poly poly_pow(poly a, ll x){
    if(x == 0){
        poly c; c.push_back(1);
        return c;
    }
    if(x % 2 == 1) return poly_mul(poly_pow(a, x-1), a);
    else return poly_mul(poly_pow(a, x/2), poly_pow(a, x/2));
}

int main(){
    cin >> mod;
    COMinit();
    ll aa,m;
    poly ans(mod,0);
    ll po[3000][3000];
    rep(i,0,mod-1){
        ll mp=1;
        po[i][0]=1;
        rep(j,1,mod-1){
            mp=(mp*i)%mod;
            po[i][j]=mp;
        }
    }
    rep(i,0,mod-1){
        cin >> aa;
        if(aa==1){
            poly mm(mod,0);
            m=(mod-i)%mod;
            rep(j,0,mod-1){
                mm[j]=po[m][mod-1-j];
                mm[j]=mm[j]*COM(mod-1,j)%mod;
            }
            ans=poly_minus(ans,mm);
            ans[0]=(ans[0]+1)%mod;
        }
    }
    for(auto u:ans) cout << u << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 74880
#include<iostream>
#include<algorithm>
using namespace std;
 
int main()
{
  string s, c;
  string pre = "", suf = "";
  int n, t, f;
  int rc = 0;

  
  cin >> s;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
      cin >> t;
      if (t == 1) rc++;
      else {
          cin >> f >> c;
          if ((f+rc) % 2 == 1) pre = c + pre;
          else suf = suf + c;
      }
  }
  s = pre + s + suf;
  if (rc % 2 == 1) reverse(s.begin(), s.end());
  cout << s << endl;
  
  return 0;
}

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

signed main() {
  int A[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }

  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b[i];
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (A[j][k] == b[i]) {
          A[j][k] = -1;
        }
      }
    }
  }

  for (int i = 0; i < 3; i++) {
    if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  for (int i = 0; i < 3; i++) {
    if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) {
    cout << "Yes" << endl;
    return 0;
  }

  if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 998244353;

template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a += mod - rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        is >> rhs.a;
        return is;
    }
};
using mint = ModInt<MOD>;

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

    vector<vector<mint>> dp(n + 1, vector<mint>(s + 1));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i + 1][j] += dp[i][j] * 2;
            if (j + a[i] <= s) dp[i + 1][j + a[i]] += dp[i][j];
        }
    }

    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73700
def main():
    N, K, Q = (int(i) for i in input().split())
    A = [int(input()) for _ in range(Q)]
    P = [0 for i in range(N)]
    winner = -1
    for a in A:
        P[a-1] += 1
    for i in range(N):
        if K - (Q - P[i]) <= 0:
            print("No")
        else:
            print("Yes") 

if __name__ == "__main__":
    main()

Measured memory_bytes: 56536
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const int MOD = 1000000007;
const int INF = 1000000;
int N,M,x,y,ans=1,temp,A[45],B[45],C[60];
int dp[41][401][401]={1000000};

int main(){
    REP(i,41)REP(j,401)REP(k,401){
        dp[i][j][k]=INF;
    }
    dp[0][0][0]=0;
    scanf("%d %d %d",&N,&x,&y);
    REP(i,N){
        scanf("%d %d %d",&A[i],&B[i],&C[i]);
    }
    REP(i,N){
        REP(a,401){
            REP(b,401){
                if(dp[i][a][b]==INF)continue;
                dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b]);
                dp[i+1][a+A[i]][b+B[i]]=min(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b]+C[i]);
                    //    cout<<dp[i+1][a][b]<<endl;
            }
        }
    }
    ans=INF;
    EREP(i,400){
        EREP(j,400){
        if(x*j==y*i)ans=min(ans,dp[N][i][j]);

        }
    }
    if(ans==INF)ans=-1;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 25984
def gcd(a,b):#最大公約数を返す。Euclid
    if a<b:
        a,b=b,a
    c=a%b
    if c==0:
        return b
    return gcd(b,c)
A,B,C,D=map(int,input().split())

nc=B//C-(A-1)//C
nd=B//D-(A-1)//D
cd=int(C*D/gcd(C,D))
ncd=B//cd-(A-1)//cd
print(B-A+1-nc-nd+ncd)


Measured memory_bytes: 3060
def solution():
    n = int(input())
    s = input()

    ans = s.count('R') * s.count('G') * s.count('B')
    for i in range(n):
        for j in range(i+1, n+1):
            k = (j - i) + j
            if k < 1 or k >= n:
                continue
            if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:              
                ans -= 1
    print(ans)

solution()


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

typedef long long ll;

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail) { std::cout << head << " ", print(tail...); }


int main(int argc, char* argv[])
{
  std::string s;
  ll K;
  std::cin >> s >> K;

  std::vector< std::string > vs;
  for (ll i = 0; i < (ll)s.size(); i++) {
    for (ll j = 1; j <= K; j++) {
      vs.push_back(s.substr(i, j));
    }
  }
  std::sort(vs.begin(), vs.end());
  vs.erase(std::unique(vs.begin(), vs.end()), vs.end());

  print(vs[K-1]);

  return 0;
}


Measured memory_bytes: 1660
n = int(input())
h = list(map(int,input().split()))
dp = [0,abs(h[0]-h[1])]

for i in range(2,n):
  dp.append(min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])))

print(dp[-1])

Measured memory_bytes: 13900
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll i,n,ans=0;
    cin>>n;
    bool ok=0;
    for(i=1; i<=10; i++)
    {
     if(i*1000==n)
     {
         ok=1;
         ans=0;break;
     }
     if(i*1000>n){
        ans=i*1000;break;
     }
    }
if(ok)
    cout<<ans<<'\n';
  else  cout<<ans-n<<'\n';





    return 0;
}




Measured memory_bytes: 3648
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
    }
    d[s] = 0;
    int u;
    while( !q.empty()) {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << ( (d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {
    int u, k, v;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) M[i][j] = 0;
    }
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs(0);
    
    return 0;
}


Measured memory_bytes: 3144
//
// Created by yamunaku on 2020/05/10.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n, m, x;
    cin >> n >> m >> x;
    vi c(n);
    mti a(n, vi(m));
    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    ll ans = LINF;
    rep(t, 1 << n){
        vi b(m);
        ll cost = 0;
        rep(i, n){
            if(t & (1 << i)){
                cost += c[i];
                rep(j, m){
                    b[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        rep(i, m){
            if(b[i] < x) ok = false;
        }
        if(ok) ans = min(ans, cost);
    }
    if(ans == LINF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main()
{
	int l, r, d;
	int count = 0;
	std::cin >> l >> r >> d;
	for (int i = l; i <= r; i++)
	{
		if (i %d == 0)
			++count;
	}
	std::cout << count << '\n';
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N, M;
	cin >> N >> M;
	ll sum = 0;
	vector<pair<ll, ll>> A(N + M);
	rep(i, N){
		cin >> A[i].first;
		A[i].second = 1;
	}
	rep(i, M)cin >> A[i + N].second >> A[i + N].first;
	REVSORT(A);
	
	ll see = 0;
	ll cnt = 0;
	while(cnt < N){
		if(A[see].second > 0){
			sum += A[see].first;
			A[see].second--;
			cnt++;
		} else {
			see++;
		}
	}
	cout << sum << endl;
}

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

int main() {
	long long n, sum[10000000] = {},j=1,ans=0;
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; i*j <= n; j++) {
			sum[i * j]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		ans += sum[i] * i;
	}
	printf("%lld", ans);

	return 0;
}

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

using namespace std;

int main(void){
  int k,x; cin >> k >> x;
  if(500*k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;

				
int main(){
	int n;
	cin>>n;
	n=n%10;
	if(n==3){
		cout<<"bon"<<endl;
		return 0;
	}
	if(n==0||n==1||n==6||n==8){
		cout<<"pon"<<endl;
		return 0;
	}
	
		cout<<"hon"<<endl;
	
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main() {

	int N;
	cin>>N;
	if(N<105)cout<<0<<endl;
	else if(N<135)cout<<1<<endl;
	else if(N<165)cout<<2<<endl;
	else if(N<189)cout<<3<<endl;
	else if(N<195)cout<<4<<endl;
	else cout<<5<<endl;

	return 0;
}




/*
105
135
165
189
195


*/

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int[] A = new int[N];
    Arrays.fill(A, K-Q);
    for (int i = 0; i < Q; i++) {
      int a = sc.nextInt();
      A[a-1]++;
    }
    for (int a : A) {
      if (a > 0) {
        System.out.println("Yes"); 
      } else {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 56900
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int h = in.nextInt();
            final int w = in.nextInt();
            final int d = in.nextInt();

            Map<Integer, Integer> x = new HashMap<>();
            Map<Integer, Integer> y = new HashMap<>();
            Map<Integer, Integer> max = new HashMap<>();
            Set<Integer> container = new HashSet<>();
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    int n = in.nextInt();
                    container.add(n);
                    y.put(n, i);
                    x.put(n, j);
                    int nk = n % d;
                    if (!max.containsKey(nk)) max.put(nk, n);
                    else if (n > max.get(nk)) max.put(nk, n);
                }
            }

            Map<Integer, Integer> dist = new HashMap<>();
            for (int nk : max.keySet()) {
                int n = max.get(nk);
                int cd = 0;
                int next = n - d;
                int nX = x.get(n);
                int nY = y.get(n);
                while (container.contains(next)) {
                    int nextX = x.get(next);
                    int nextY = y.get(next);
                    dist.put(n, cd);
                    container.remove(n);
                    cd += Math.abs(nX - nextX) + Math.abs(nY - nextY);
                    n = next;
                    nX = nextX;
                    nY = nextY;
                    next -= d;
                }
                dist.put(n, cd);
                container.remove(n);
            }

            final int q = in.nextInt();
            for (int i = 0; i < q; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                out.println(dist.get(l) - dist.get(r));
            }
        }

    }
}



Measured memory_bytes: 128300
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let s: Vec<_> = s.next().unwrap().chars().collect();
	let ans = (s.len() + 1) / 2
		+ s[..s.len() / 2]
			.iter()
			.rev()
			.zip(s[(s.len() + 1) / 2..].iter())
			.take_while(|(&a, &b)| a == b && a == s[s.len() / 2])
			.count();
	println!("{}", ans);
}


Measured memory_bytes: 2508
main = do
    s <- getLine
    putStrLn $ if analyze (reverse s) then "YES" else "NO"

analyze "" = True
analyze ('m':'a':'e':'r':'d':k) = analyze k
analyze ('r':'e':'m':'a':'e':'r':'d':k) = analyze k
analyze ('e':'s':'a':'r':'e':k) = analyze k
analyze ('r':'e':'s':'a':'r':'e':k) = analyze k
analyze _ = False

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


int main(){
    while(1){
        int m,f,r;
        string grade;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1)
            break;
        int s = m + f;
        if(s >= 80) grade = "A";
        else if(s >= 65) grade = "B";
        else if(s >= 50) grade = "C";
        else if(s>=30){
            if(r >= 50) grade = "C";
            else grade = "D";
        }
        else grade = "F";
        if(m == -1 ||f == -1) grade = "F";
        cout << grade << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int K;
    string S;
    cin >> K >> S;
    string ans = (S.length() <= K) ? S : S.substr(0, K) + "...";
    cout << ans << endl;
}

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

/*
#include <chrono>
int main()
{
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();

    resolve();

    end = chrono::system_clock::now();
    double time = static_cast<double>(
        chrono::duration_cast<chrono::microseconds>(end - start).count() /
        1000.0);
    cout << "resolve(): " << time << "[ms]" << endl;

    return 0;
}
*/


Measured memory_bytes: 3640
import sys
readline = sys.stdin.readline

# A + Bの組み合わせはせいぜい1～30のうち作れる数字のみなので全探索

A,B,C,D,E,F = map(int,readline().split())

ans = [0,0]
maxrate = 0.0
for a in range(0,F,100 * A):
  for b in range(0,F,100 * B):
    if a == 0 and b == 0:
      continue
    if a + b > F:
      break
    water = a + b
    # waterに対して溶ける最大量は (a + b) * E
    limit = min(((a + b) // 100) * E, F - water)
    maxsugar = 0
    for c in range(0,limit + 1,C):
      for d in range(0,limit + 1,D):
        if c + d > limit:
          break
        if c + d > maxsugar:
          maxsugar = c + d
          rate = maxsugar / (water + maxsugar)
          if rate > maxrate:
            maxrate = rate
            ans = [water + maxsugar, maxsugar]

if maxrate == 0.0:
  print(min(A,B) * 100, 0)
  exit(0)

print(*ans)

Measured memory_bytes: 3064
N,M=list(map(int,input().split()))
A=[]
for i in range(N):
    A.append(input())
B=[]
for i in range(M):
    B.append(input())
eflag=False
for i in range(N-M+1):
    for j in range(N-M+1):
        flag=True
        for k in range(M):
            for l in range(M):
                if B[k][l]!=A[i+k][j+l]:
                    flag=False
                    break
            if flag==False:
                break
        if flag:
            eflag=True
if eflag:
    print("Yes")
else:
    print("No")

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

int main() {
    string s;
    cin >> s;
    vector<int> As, Zs;
    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'A'){
            As.push_back(i);
        }
        else if (s[i] == 'Z') {
            Zs.push_back(i);
        }
    }
    cout << Zs[Zs.size() - 1] - As[0] + 1 << endl;
}


Measured memory_bytes: 1364
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    static vector<int> table(n + 10, 0);
    for(int k = 1; k <= n; k++) {
        for(int j = k; j <= n; j += k) {
            table[j]++;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += (ll)table[i] * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 42204
def submit():
    n, m, q = map(int, input().split())
    rng = {i: [0 for _ in range(n + 1 - i)] for i in range(1, n + 1)}
    for _ in range(m):
        l, r = map(int, input().split())
        rng[l][r - l] += 1
    
    for i in range(1, n + 1):
        for j in range(n - i):
            rng[i][j + 1] += rng[i][j]

    ans = []
    for _ in range(q):
        pl, pr = map(int, input().split())
        # plから始まり, pr - pl以下で終わる列車を数える
        cnt = 0
        for i, ppl in enumerate(range(pl, pr + 1)):
            cnt += rng[ppl][pr - pl - i]
        ans.append(cnt)

    for a in ans:
        print(a)
            

submit()

Measured memory_bytes: 64984
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
using namespace std;
struct node
{
    int l,r;
} num[100009];
int main()
{
    int n,a[100009],dp[100009];
    ll ans=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    a[0]=inf,a[n+1]=inf;
    num[0].l=0,num[n+1].r=n+1;
    for(int i=1; i<=n; i++)
    {
        int tmp=i-1;
        while(a[tmp]<a[i])
        {
            tmp=num[tmp].l;
        }
        num[i].l=tmp;
    }
    for(int i=n; i>=1; i--)
    {
        int tmp=i+1;
        while(a[tmp]<a[i])
        {
            tmp=num[tmp].r;
        }
        num[i].r=tmp;
    }
    //for(int i=1; i<=n; i++)
        //printf("%d %d\n",num[i].l,num[i].r);
    for(int i=1; i<=n; i++)
    {
        if(!num[i].l&&num[i].r==n+1)
            continue;
        int tmp,tmp1;
        if(num[i].l)
        {
            int x=num[i].l-1;
            while(a[x]<a[i])
            {
                x=num[x].l;
            }
            tmp=x;
            ans+=(ll)(a[i])*(num[i].l-tmp)*(num[i].r-i);
        }
        if(num[i].r!=n+1)
        {
            int x=num[i].r+1;
            while(a[x]<a[i])
            {
                x=num[x].r;
            }
            tmp1=x;
            ans+=(ll)(a[i])*(tmp1-num[i].r)*(i-num[i].l);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSuccessiveSubtraction solver = new CSuccessiveSubtraction();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSuccessiveSubtraction {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            Arrays.sort(a);
            StringBuilder sb = new StringBuilder();
            int m;
            if (a[0] > 0) {
                // all > 0
                int pr = a[0];
                for (int i = 1; i < n - 1; i++) {
                    sb.append(pr).append(" ").append(a[i]).append("\n");
                    pr -= a[i];
                }
                sb.append(a[n - 1]).append(" ").append(pr).append("\n");
                m = a[n - 1] - pr;
            } else if (a[n - 1] < 0) {
                // all < 0
                int tmp = a[n - 1];
                for (int i = 0; i < n - 1; i++) {
                    sb.append(tmp).append(" ").append(a[i]).append("\n");
                    tmp -= a[i];
                }
                m = tmp;
            } else {
                m = a[n - 1];
                int tmp = a[0];
                for (int i = 1; i < n - 1; i++) {
                    if (a[i] < 0) {
                        sb.append(m).append(" ").append(a[i]).append("\n");
                        m -= a[i];
                    } else {
                        sb.append(tmp).append(" ").append(a[i]).append("\n");
                        tmp -= a[i];
                    }
                }
                sb.append(m).append(" ").append(tmp).append("\n");
                m -= tmp;
            }

            out.println(m);
            out.print(new String(sb));
        }

    }
}



Measured memory_bytes: 60612
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) (v.begin(),v.end())
#define vi vector<int>
int ans = 0;
vi xa = {0,-1,1,0};
vi ya = {1,0,0,-1};
int h,w;
vector<vector<char>> s;
 
 
void dfs(int x,int y){
    vector<vector<bool>> vis(h,vector<bool>(w));
    queue<pair<int,pair<int,int>>> q;
    q.push({0,{x,y}});
    while(!q.empty()){
        x = q.front().second.first;
        y = q.front().second.second;
        int dist = q.front().first;
        vis[x][y] = true;
        q.pop();
        for(int i = 0;i < 4; ++i){
            int nx = x + xa[i];
            int ny = y + ya[i];
            if((nx < h) && (ny < w) && (nx >= 0 && ny >= 0) && (!vis[nx][ny]) && (s[nx][ny] != '#')){
                q.push({dist + 1,{nx,ny}});
				vis[nx][ny] = true;
                ans = max(ans,dist + 1);
            }
        }
    }
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin >> h >> w;
    s.resize(h,vector<char>(w));
    ffor(i,h){
        ffor(j,w){
            cin >> s[i][j];
        }
    }
 
    for(int i = 0;i < h;++i){
        for(int j = 0;j < w; ++j){
            if(s[i][j] == '#') continue;
            dfs(i,j);
        }
    }
 
    cout << ans;
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> a(3);
  
  for(int i = 0; i < 3; i++){
    a.at(i) = n % 10;
    n /= 10;
  }
  
  if ( a.at(0) == a.at(2) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

bool check(int val, int N, const vector<PII> &req) {
  string s = to_string(val);
  if ((int)s.size() != N)
    return false;
  for (PII p : req) {
    if ((s[p.F - 1] - '0') != p.S)
      return false;
  }
  return true;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<PII> req;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    req.PB(MP(s, c));
  }
  for (int t = 0; t < 1000; t++) {
    if (check(t, N, req)) {
      cout << t << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    /*
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    int n;
    cin >> n;
    
    set<pii> s;
    rep3(i, 1, n) {
        int j = n - i;
        if (i == j) continue;
        if (i + j == n) s.insert(pii(min(i, j), max(i, j)));
    }
    cout << sz(s) << endl;
    
    
}


Measured memory_bytes: 23680
#include <cstdio>
#include <cmath>
#include <algorithm>

long long factorial(long long n)
{
  if (n == 0) return 1;
  else return n * factorial(n - 1);
};

int main()
{
  int n;
  scanf("%d", &n);
  int x[8], y[8];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d", x + i, y + i);
  }
  double ans = 0;
  int perm[8] = {0, 1, 2, 3, 4, 5, 6, 7};
  auto dist = [&](int i, int j)
  {
    return std::sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
  };
  
  do
  {
    for (int i = 0; i < n - 1; ++i)
    {
      ans += dist(perm[i], perm[i + 1]);
    }
  } while (std::next_permutation(perm, perm + n));

  printf("%.12f\n", ans / factorial(n));
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  int m1,d1,m2,d2;
  scanf("%d %d %d %d", &m1, &d1, &m2, &d2);
  if (d2 == 1) {
    printf("1\n");
  } else {
    printf("0\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define ll long long int

int main(){
	double S, Tar, V; //Jarak, Target, Kecepatan;
	scanf("%lf %lf %lf", &S, &Tar, &V);
	double t = S/V;
	if (t > Tar){
		printf("No\n");
	}
	else {
		printf ("Yes\n");
	}
return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <map>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iterator>
#include <deque>
#include <bitset>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <fstream>
#include <ios>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <bitset>
#include <queue>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
	long long a, b, ans=0, maxr=0;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b;
		if (b >= maxr) {
			maxr = b;
		}
		else 
			ans += maxr - b;
	}
	cout << ans;
}

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

typedef long long int ll;
int arr[100005];
int arr2[100005];
int arr3[100005];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,sum=0;
cin>>n;
for(int i=1;i<=n;i++)
    cin>>arr[i];
for(int i=1;i<=n;i++)
    cin>>arr2[i];
for(int i=1;i<=n-1;i++)
    cin>>arr3[i];

sum+=arr2[arr[1]];
for(int i=2;i<=50;i++)
{
    sum+=arr2[arr[i]];
    if(arr[i]==arr[i-1]+1)
        sum+=arr3[arr[i]-1];
}

cout<<sum<<endl;

}


Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var n = parseInt(input[0][0], 10);
	var vec_a = input[1].map(e => parseInt(e, 10));
	var vec_s = [];
	var tmp = 0;
	for (var i = 0; i < n; i++){
		tmp += vec_a[i];
		vec_s.push(tmp);
	}

	var ans1 = 0;
	var tmpMovedAbs = 0
	var tmpMovedAll = 0;
	for (var i = 0; i < n; i ++){
		if (i % 2 === 0){
			tmpMovedAbs = Math.max(vec_s[i] + 1 + tmpMovedAll, 0);
			tmpMovedAll -= tmpMovedAbs;
		} else {
			tmpMovedAbs = Math.max(1 - vec_s[i] - tmpMovedAll, 0);
			tmpMovedAll += tmpMovedAbs;
		}
		ans1 += tmpMovedAbs;
	}
	var ans2 = 0;
	tmpMovedAbs = 0
	tmpMovedAll = 0;
	for (var i = 0; i < n; i ++){
		if (i % 2 === 1){
			tmpMovedAbs = Math.max(vec_s[i] + 1 + tmpMovedAll, 0);
			tmpMovedAll -= tmpMovedAbs;
		} else {
			tmpMovedAbs = Math.max(1 - vec_s[i] - tmpMovedAll, 0);
			tmpMovedAll += tmpMovedAbs;
		}
		ans2 += tmpMovedAbs;
	}
	console.log(Math.min(ans1, ans2));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 44476