akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 998244353;
const int N = 3e3 + 5;
const int M = 1e6 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
ll a[N][N];
ll dp[N][N][4];

int main(){
    ios;
    cin>>n>>m>>k;
    rep(i,1,k){
        int x,y,w;
        cin>>x>>y>>w;
        a[x][y]=w;
    }
    rep(i,1,n) rep(j,1,m){
        rep(p,0,3){
            dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][p]);
            dp[i][j+1][p]=max(dp[i][j+1][p],dp[i][j][p]);
        }
        if(a[i][j]==0) continue;
        rep(p,0,2){
            dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][p]+a[i][j]);
            dp[i][j+1][p+1]=max(dp[i][j+1][p+1],dp[i][j][p]+a[i][j]);
        }
    }
    ll ans=0;
    rep(p,0,3){
        ans=max(ans,max(dp[n+1][m][p],dp[n][m+1][p]));
    }
    cout<<ans;
    return 0;
}

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

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int res = 0;
	for (int i = 1; i <= N; i++) {
		int t = i, d = 0;
		while (t) {
			d += t % 10;
			t /= 10;
		}
		if (A <= d && d <= B) res += i;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dfs(int cnt,int now){
  int rec;
  if(cnt==n)return now;
  rec=min(dfs(cnt+1,now+k),dfs(cnt+1,now*2));
  return rec;
}

int main(){
  cin>>n>>k;
  cout<<dfs(0,1)<<endl;
  return(0);
}


Measured memory_bytes: 256
N = int(input())

ans = 0
a = [3, 5, 7]
i = 0
while a[i] <= N:
    x10 = a[i] * 10
    a.append(x10+3)
    a.append(x10+5)
    a.append(x10+7)
    i += 1

for j in range(i):
    s = str(a[j])
    if "3" in s and "5" in s and "7" in s:
        ans += 1

print(ans)


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

int main(){
  int R;
  cin >> R;
  cout << R * 2 * M_PI << endl;
}

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

using namespace std;

vector <int> a;

long long f(int x){
    int n = a.size();
    long long res = 0;
    for (int i = 0; i < n; i++)
        res += fabs(a[i] - (x + 1 + i));
    return res;
}

int main(){
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int l = -1e9, r = 1e9;
    for (int i = 0; i < 200; i++){
        int len = r - l + 1;
        int x1 = l + len / 3;
        int x2 = r - len / 3;
        long long fx1 = f(x1);
        long long fx2 = f(x2);
        if (fx1 > fx2)
            l = x1;
        else
            r = x2;
    }
    long long res = 1e18;
    int x;
    for (int i = l - 100; i <= l + 100; i++){
        long long cur = f(i);
        if (cur < res){
            res = cur;
            x = i;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  int total = a+b+c;
  if(total>=22){
    System.out.println("bust");
  }else{
    System.out.println("win");
  }

}
}

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

int main(){
  int a, b, k;
  cin >> a >> b >>k;
  for(int i=a; i<=b; i++){
    if(abs(i-a)<k || abs(i-b)<k)cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 125
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> v(n);
    vector<int> c(n);
    REP(i, n) cin >> v[i];
    REP(i, n) cin >> c[i];

    int ans=0;
    REP(i, n){
        if (v[i]>c[i]) ans += v[i]-c[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int n = 0;
  std::vector<int> l;
  
  std::cin >> n;
  for(int i = 0; i < n * 2; ++i)
  {
    int _l = 0;
    std::cin >> _l;
    l.push_back(_l);
  }
  
  std::sort(l.begin(), l.end());
  
  int x = 0;
  for(int i = 0; i < n * 2; i += 2)
  {
    x += l[i];
  }
  
  std::cout << x;
      
  return 0;
}

Measured memory_bytes: 256
card_num, gate_num = map(int, input().split())

ans_start, ans_end = map(int, input().split())
for _ in range(gate_num-1):
    s, e = map(int, input().split())
    if e < ans_start or ans_end < s:
        print(0)
        exit()
    elif s < ans_start and ans_start < e < ans_end:
        ans_end = e
    elif ans_start < s < ans_end and ans_end < e:
        ans_start = s
    elif ans_start == e:
        ans_end = e
    elif ans_end == s:
        ans_start = s

print(ans_end - ans_start + 1)


Measured memory_bytes: 44760
#include <iostream>

using namespace std; 


void Trace(int* A, int N) {
	for (int i = 0; i < N; i++)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}

	cout << "\n";
}

void SortingAlgorithm( int* A, int N) {
	int j, i, v;
	for (i = 1; i < N; i++)
	{
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		Trace(A, N);
	}
}

int main()
{
	int N, i, j;
	int A[100];

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

	Trace(A, N);
	SortingAlgorithm(A, N);

	return 0;

}


Measured memory_bytes: 3124
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  int ans = A[N - 1] - A[0], len = N - 1;
  for (int i = 1; i < N; i++) {
    ans = min(K - A[i] + A[i - 1], ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
SP = []
for i in range(N):
	s =rs()
	S, P = s.split(' ')
	P = int(P)
	SP.append((S, -P, i+1))

SP.sort()
for s, p, n in SP:
	print(n)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_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 VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

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

    vl v(n+5,1);

    ll ans=1;//1の約数の数
    FOR(i,2,n+1){
      //DEBUG_VEC(v);
        v[i]++; //自身を約数として加える
        ans += i*v[i];

        ll j=i+i;
        while(j <= n){
            //DEBUG(j);
            v[j] += 1;
            j += i;
        }
    }

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

Measured memory_bytes: 81344
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve()
{
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;

    loop(i, 0, n)
    {
        cin >> a[i];
        if (i+1 & 1 && a[i] & 1)
        {
            cnt++;
        }
    }

    cout << cnt << "\n";
}

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

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

typedef long long ll;

int main() {
    string O, E;
    cin >> O >> E;
    int m = O.size(), n = E.size();
    rep(i, m) {
        cout << O[i];
        if (i < n) cout << E[i];
    }
    cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
#define sign(a) ((a>0)-(a<0))
#define LL long long
#define INF (LL)(1LL<<60)


void solve(long long N, long long M, long long R, std::vector<long long> r, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    vector<vector<LL>> d(N, vector<LL>(N, INF));
    for(LL i=0; i<N; i++)d[i][i]=0;
    for(LL i=0; i<M; i++){
        d[A[i]-1][B[i]-1]=C[i];
        d[B[i]-1][A[i]-1]=C[i];
    }

    for(int k=0; k<N; k++)
        for(auto i=0; i<N; i++)
            for(auto j=0; j<N; j++)
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
    LL ans=INF;
    sort(r.begin(), r.end());
    do{
        LL tmp=0;
        for(int i=1; i<R; i++)tmp+=d[r[i]-1][r[i-1]-1];
        ans = min(ans, tmp);
    }while(next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long R;
    scanf("%lld",&R);
    std::vector<long long> r(R);
    for(int i = 0 ; i < R ; i++){
        scanf("%lld",&r[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, R, std::move(r), std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 1024
import sys
a, b, c = [int(w) for w in input().split()]

ans = 0


def is_fin(a, b, c):
    global ans
    if a % 2 or b % 2 or c % 2:
        return True
    elif a == b == c:
        ans = -1
        return True
    else:
        return False


while not is_fin(a, b, c):
    ta = (b+c)/2
    tb = (a+c)/2
    tc = (a + b) / 2
    a, b, c = ta, tb, tc
    ans += 1

print(ans)


Measured memory_bytes: 9256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	string s;
	cin >> s;
	if (s == "SUN")cout << 7 << endl;
	elif(s == "MON")cout << 6 << endl;
	elif(s == "TUE")cout << 5 << endl;
	elif(s == "WED")cout << 4 << endl;
	elif(s == "THU")cout << 3 << endl;
	elif(s == "FRI")cout << 2 << endl;
	else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <random>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl


using namespace std;

#ifdef LOCAL
static struct __timestamper {
    string what;
    __timestamper(const char* what) : what(what){};
    __timestamper(const string& what) : what(what){};
    ~__timestamper(){
        TIMESTAMPf("%s", what.data());
    }
} __TIMESTAMPER("end");
#else
struct __timestamper {};
#endif

typedef long long ll;
typedef long double dbl;

int main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
#endif

    int T;
    scanf("%d", &T);
    while (T--) {
        int n;
        scanf("%d", &n);
        vector<ll> a(n);
        for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
        static char s[(int)1.01e5];
        scanf("%s", s);

        int ok = 1;
        vector<ll> b;
        vector<int> wh(64, -1);
        for (int i = n - 1; i >= 0; i--) {
            ll x = a[i];
            for (int j = 0; j < 64; j++) {
                if ((x & (1LL << j)) && wh[j] != -1) {
                    x ^= b[wh[j]];
                }
            }
            if (x != 0) {
                if (s[i] == '1') ok = 0;
                else {
                    b.push_back(x);
                    for (int j = 0; j < 64; j++) {
                        if (wh[j] == -1 && x & (1LL << j)) {
                            wh[j] = b.size() - 1;
                            break;
                        }
                    }
                }
            }
        }
        printf("%d\n", 1-ok);
    }

    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    int len = s.length();
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    for(int i=0;i<len;i++) {
        int nextIdx = (s[i] - 65) + n;
        //cout << nextIdx << '\n';
        if(nextIdx >= 26) nextIdx -= 26;
        s[i] = toupper(alpha[nextIdx]);
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  ll sum = 0;
  int endnum = 0;
  for(int i=0; i<=N; i++) {
     if(sum >= N) break;
     else {
       sum += i;
       endnum = i;
      }
  }
  int def = sum - N;
  for(int i=1; i<=endnum; i++){
    if(i != def) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	string s;
	cin >> s;
	if(s == "keyence"){
		cout << "YES" << endl;
		return 0;
	}
	for (int i = 0; i < s.size(); i++) {
		for (int j = i; j < s.size(); j++) {
			string t = s;
			t.erase(i, j-i+1);
			if(t == "keyence"){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())

s = list(map(int, input().split()))
longest = 0
for i in range(n - 1):
    long = s[i + 1] - s[i]
    if long > longest:
        longest = long
if longest >= k - s[n - 1] + s[0]:
    print(k - longest)
else:
    print(s[n - 1] - s[0])

Measured memory_bytes: 26436
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstdio>

using namespace std;

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

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;
typedef vector<string> vs;

typedef long long ll;

int main(){
  vi a(1001,0);
  REP(i,2,1000){
    REP(j,1,1000){
      int su = 0;
      rep(k,i){
        su += j + k;
      }
      if(su>1000) break;
      a[su]++;
    }
  }

  while(1){
    int n; cin>>n;
    if(n==0) break;
    cout<<a[n]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3116
s=input()
N=len(s)
K=int(input())
L=[]
for i in range(1,K+1):
    for j in range(N-i+1):
        L.append(s[j:j+i])
L.sort()
M=len(L)
R=[L[0]]
k=0
for i in range(1,M):
    if L[i] !=R[k]:
        R.append(L[i])
        k+=1
print(R[K-1])

        

Measured memory_bytes: 4468
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n, -1);
  bool flag = true;
  rep(i, m){
    int s, c;
    cin >> s >> c;
    if(s > n){
      flag = false;
    }
    if(n > 1 && s == 1 && c == 0){
      flag = false;
    }
    if (vec[s-1] == c || vec[s-1] < 0){
      vec[s-1] = c;
    }else{
      flag = false;
    }
  }
  if(!flag){
    cout << -1 << endl;
    return 0;
  }
  if (n >= 2 && vec[0] == -1) vec[0] = 1;
  rep(i, n){
    if(vec[i] < 0){
      cout << 0;
    }else{
      cout << vec[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 504
n,w_max = map(int,input().split())
w = [0]
v = [0]
for _ in range(n):
    W,V = map(int,input().split())
    w.append(W)
    v.append(V)

dp = [[0]*(w_max+1) for i in range(n+1)]
for i in range(1,n+1):
    for u in range(w_max+1):
        if u>=w[i]:
            dp[i][u] = max(dp[i-1][u-w[i]]+v[i],dp[i-1][u])
        else:###
            dp[i][u] = dp[i-1][u]


print(dp[n][w_max])


Measured memory_bytes: 120044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  string S; cin >> S;
  rep(i, 0, S.size() - 1){
    if(S[i] == S[i + 1]){
      cout << i + 1 << " " << i + 2 << endl;
      return;
    }
    if(i == S.size() - 2) continue;
    if(S[i] == S[i + 2]){
      cout << i + 1 << " " << i + 3 << endl;
      return;
    }
  }
  cout << -1 << " " << -1 << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8320
N, M = map(int, input().split(' '))
H = tuple(map(int, input().split(' ')))
one_hops = [0] * N

for _ in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    one_hops[a] = max(one_hops[a], H[b])
    one_hops[b] = max(one_hops[b], H[a])

print(len([0 for i in range(N) if H[i] > one_hops[i]]))


Measured memory_bytes: 20112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,X; cin>>N>>X;
  if(X==1||X==2*N-1) cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    deque<int> ans;
    if(N<X){
      bool flag=1;
      for(int i=X+1;1<=i;i--){
        if(flag) ans.push_front(i);
        else ans.pb(i);
        flag=!flag;
      }
      for(int i=2*N-1;X+1<i;i--){
        if(flag) ans.push_front(i);
        else ans.pb(i);
        flag=!flag;
      }
    }
    else{
      bool flag=1;
      rep(i,X-1,2*N){
        if(flag) ans.push_front(i);
        else ans.pb(i);
        flag=!flag;
      }
      rep(i,1,X-1){
        if(flag) ans.push_front(i);
        else ans.pb(i);
        flag=!flag;
      }
    }
    rep(i,0,2*N-1) cout<<ans[i]<<" ";
    cout<<endl;
  }
  }


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

count = 0

for i in range (0, N):
	if A[i] >= B[i]:
		count+=B[i]
	else:
		B[i]-=A[i]
		count+=A[i]
		if A[i+1] >= B[i]:
			count+=B[i]
			A[i+1]-=B[i]
		else:
			count+=A[i+1]
			A[i+1]=0

print(count)

Measured memory_bytes: 97776
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int N;
    cin >> N;
    if(N==10||N==100||N==1000||N==10000||N==100000)    cout << 10 << endl;
    else{
        int sum=0;
        while(true){
            if(N/10==0){
                sum+=N;
                break;
            }
            else{
                sum+=N%10;
                N/=10;
            }
            
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

struct edge{
	int to;
	ll cost;
};

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll d[100100];
bool visited[100100];
vector<edge> g[100100];

void dfs(int u){
	int i;
	edge e;
	visited[u] = true;
	for(i=(g[u].l_ength()-1); i>=0; --i){
		e = g[u][i];
		if(visited[e.to]){
			continue;
		}
		d[e.to] = d[u]+e.cost;
		dfs(e.to);
	}
}

int main(void){
	int n,i,u,v;
	ll w;
	edge e;
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> u >> v >> w; --u; --v;
		e.cost = w; e.to = u; g[v].push_back(e);
		e.to = v; g[u].push_back(e);
	}
	d[0] = 0ll; dfs(0);
	for(i=0; i<n; ++i){
		cout << d[i]%2 << endl;
	}
	return 0;
}


Measured memory_bytes: 10240
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
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 (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D;
    string S,T;
    ll X[100];
int main(){
    cin>>A>>B;
    cout<<(A%B==0?"0":"1")<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define S second
using namespace std;
int x[1000000];
string s;
int n;
int nCr(int a, int b) {
	if (a < b)return 0;
	int z = 1;
	for (int i = a; i > a - b; i--) {
		z *= i;
	}
	for (int i = 1; i <= b; i++) {
		z /= i;
	}
	return z;
}
int mutu(int x,int y) {
	if (y == n)return 1;
	if (x >= s.size())return 0;
	if (s[x] == '0') {
		return mutu(x + 1, y);
	}
	else {
		return nCr((int)s.size() - x - 1, n - y)*pow(9, n - y) + nCr((int)s.size() - x - 1, n - y - 1)*(s[x] - '1')*pow(9, n - y - 1) + mutu(x + 1, y + 1);
	}
}
signed main() {
	cin >> s >> n;
	cout<<mutu(0, 0)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <vector>

int main()
{
  int N,M,X,Y;
  std::cin >> N >> M >> X >> Y;
  int xmax = -1000;
  for (int i=0; i<N; ++i) {
	int x;
    std::cin >> x;
    xmax = xmax < x ? x : xmax;
  }
  int ymin = 1000;
  for (int i=0; i<M; ++i) {
	int y;
    std::cin >> y;
    ymin = y < ymin ? y : ymin;
  }
  xmax = X > xmax ? X : xmax;
  ymin = Y < ymin ? Y : ymin;
  if (xmax < ymin) {
    std::cout << "No War" << std::endl;
  } else {
    std::cout << "War" << std::endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N; cin >> N;
  if(N == 3) {
    cout << "2 5 63" << endl;
  } else {
    if(N & 1) {
      int a[8] = {6, 2, 10, 3, 9, 4, 8, 12};
      for(int i = 0; i < N; ++i) {
        cout << a[i % 8] + i / 8 * 12 << endl;
      }
    } else {
      int a[8] = {2, 10, 3, 9, 4, 8, 6, 12};
      for(int i = 0; i < N; ++i) {
        cout << a[i % 8] + i / 8 * 12 << endl;
      }
    }
  }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] arr = new int[n+1][3];
        for(int i=1 ; i<=n ;++i){
            for (int j = 0 ; j<3 ; ++j){
                arr[i][j] = scanner.nextInt();
            }
        }
        int[][] dp= new int[n+1][3];
        for(int i=1 ; i<=n ; ++i){
            dp[i][0] = arr[i][0] + Math.max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = arr[i][1] + Math.max(dp[i-1][0],dp[i-1][2]);
            dp[i][2] = arr[i][2] + Math.max(dp[i-1][1],dp[i-1][0]);
        }
        System.out.println(Math.max(dp[n][0],Math.max(dp[n][1],dp[n][2])));
    }
}


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

int main() {
    int n, y, x;
    string p;
    int total = 0;
    queue<int> myQueueNumbers;
    queue<string> myQueueName;
    cin >> n >> y;

    for (int i = 0; i < n; i++) {
        cin >> p;
        cin >> x;
        myQueueNumbers.push(x);
        myQueueName.push(p);
    }

    while(!myQueueNumbers.empty()) {
        if (myQueueNumbers.front() - y <= 0) {
            total += myQueueNumbers.front();
            cout << myQueueName.front() << " " << total << endl;
            myQueueNumbers.pop();
            myQueueName.pop();
        } else {
            total += y;
            myQueueNumbers.front() -= y;
            myQueueNumbers.push(myQueueNumbers.front());
            myQueueNumbers.pop();
            myQueueName.push(myQueueName.front());
            myQueueName.pop();
        }
    }

}


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

const int MAX_N = (1<<17);
typedef pair<int,int> P;
class RMQ{
  int n;
  P dat[2*MAX_N-1];

public:
  void init(int _n = MAX_N){ 
    n = 1;
    while(n < _n) n *= 2;
    fill(dat,dat+2*n-1,P(1,1));
  }

  int get(int k){
    k += n - 1;
    P ret = dat[k];
    while(k > 0){
      k = (k - 1) / 2;
      ret = max( ret, dat[k] );
    }
    return ret.second;
  }

  void query(int a, int b,P x){ query(a, b, x, 0, 0, n);}
  void query(int a, int b, P x, int k, int l, int r){
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) dat[k]=max(dat[k],x);
    else{
      query(a, b, x, k*2+1, l, (l+r)/2);
      query(a, b, x, k*2+2, (l+r)/2, r);      
    }
  }
};

RMQ seg;
vector<int> G[100003];
P L[100003];
int R[100003];
int cnt;
void dfs(int id,int h){
  L[id] = P(cnt++,h); 
  for(int i=0;i<(int)G[id].size();i++){
    dfs(G[id][i],h+1);
  }
  R[id] = cnt;
}

int main(){
  int n,q;
  while(cin >> n >> q && (n||q) ){
    seg.init(n+1);
    for(int i=1;i<=n;i++)G[i].clear();
    for(int i=2;i<=n;i++){
      int p; cin >> p;
      G[p].push_back( i );
    }
    cnt = 0;
    dfs(1,0);
    long long res = 0;
    for(int i=0;i<q;i++){
      char c; cin >> c;
      int d; cin >> d;
      if( c  == 'Q' ){
	res += (long long)seg.get(L[d].first);
      } else {
	seg.query(L[d].first,R[d],P(L[d].second,d));
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 15152
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007


int main()
{
	ll h, n, a, b, i;
	cin>>h>>n;
	vector<ll> dp(h+1, INT32_MAX);
	dp[0] = 0;
	while(n--)
	{
		cin>>a>>b;
		for(i=0;i<h;i++)
			dp[min(i+a, h)] = min(dp[min(i+a, h)], dp[i] + b);
	}
	cout<<dp[h]<<"\n";
	
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String b = sc.next();
 
	if(b.equals("A")){
		System.out.println("T");
	}else if(b.equals("T")){
		System.out.println("A");
	}else if(b.equals("C")){
		System.out.println("G");
	}else{
		System.out.println("C");	    
	}
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	auto a = vector<int>(n + 2);
	int total = 0;
	for(auto i = 1; i < n + 1; ++i){
		cin >> a[i];
		total += abs(a[i] - a[i - 1]);
	}
	total += abs(a[n]);
	for(auto i = 1; i < n + 1; ++i){
		cout << total - (abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i])) + abs(a[i + 1] - a[i - 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(){
	int x,y,ary1[4][14];
	int n;
	int i,a;
	char card;
	for (y=0;y<4;y++){
		for (x=1;x<=13;x++){
		ary1[y][x]=0;
		}
	}
	scanf("%d%*c",&n);
	for (i=0;i<n;i++){
		scanf ("%c %d%*c",&card ,&a);
		if (card=='S'){
			ary1[0][a]=1;
		}
		else if (card=='H'){
			ary1[1][a]=1;
		}
		else if (card=='C'){
			ary1[2][a]=1;
		}
		else if (card=='D'){
			ary1[3][a]=1;
		}
	}
	for (y=0;y<4;y++){
		for (x=1;x<=13;x++){
			if(ary1[y][x]==0){
				if(y==0){
					printf("S %d\n",x) ;
				}
				else if(y==1){
					printf ("H %d\n",x);
				}
				else if (y==2){
					printf ("C %d\n",x);
				}
				else if (y==3){
					printf ("D %d\n",x);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n, sum = 0;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        sum += s[i];
    }
    sort(begin(s), end(s));

    if (sum % 10 == 0) {
        for (int i = 0; i < n; ++i) {
            if (s[i] % 10 != 0) {
                cout << sum - s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    } else {
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 888
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]

s = [(a+b, a, b) for a, b  in ab]
s.sort(reverse = True)
# print(s)

t = 0
a = 0
for i in range(n):
    if i % 2 == 0:
        t += s[i][1]
    else:
        a += s[i][2]

print(t-a)

Measured memory_bytes: 75736
use std::io::Read;

const MOD: u64 = 1_000_000_007;

fn matmul(a: &Vec<Vec<u64>>, b: &Vec<Vec<u64>>) -> Vec<Vec<u64>> {
    let n = a.len();
    let mut c = vec![vec![0; n]; n];
    for i in 0..n {
        for k in 0..n {
            for j in 0..n {
                c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
            }
        }
    }
    c
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut k: u64 = it.next().unwrap().parse().unwrap();
    let a: Vec<Vec<u64>> = (0..n).map(|_| (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect()).collect();
    let mut t = vec![vec![0; n]; n];
    for i in 0..n {
        t[i][i] = 1;
    }
    let mut s = a.clone();
    while k > 0 {
        if k & 1 == 1 {
            t = matmul(&t, &s);
        }
        s = matmul(&s, &s);
        k >>= 1;
    }
    let ans = t.iter().fold(0, |s, a| s + a.iter().fold(0, |s, v| s + *v)) % MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
/*
ЗАПУСКАЕМ ВЫСОКОГО
░ГУСЯ░▄▀▀▀▄░РАБОТЯГИ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
template<typename T> 
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h <<"\n"; 
}
template<typename T, typename... Ts>
void _dbg(const char* _s, T _h, Ts... _t) {
    int _b = 0;
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++; 
    cerr << " = " << _h << ","; 
    _dbg(_s+1, _t...);
}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        #ifdef LOCAL
        srand(300); 
        #else
        using namespace std::chrono;
        srand(duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch()).count()); 
        #endif
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

const int MAXN = 1e5 + 1;
vector<pii> g[MAXN];
struct q{
    int l, r, x;
} qs[MAXN*2];
int w[MAXN];
bool used[MAXN];
void dfs(int v, int pos) {
    used[v] = 1;
    w[v] = pos;
    for (pii to : g[v]) 
        if (!used[to.ff]) 
            dfs(to.ff, pos + to.ss);
}


int main() {
    
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> qs[i].l >> qs[i].r >> qs[i].x;
        g[qs[i].l].pb(qs[i].r, qs[i].x);
        g[qs[i].r].pb(qs[i].l, -qs[i].x);
    }

    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            dfs(i, 228);
        }
    }


    for (int i = 0; i < m; ++i) {
        if (w[qs[i].r] - w[qs[i].l] != qs[i].x) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    
    return 0;
}


Measured memory_bytes: 13056
import java.util.*

fun main(args:Array<String>?): Unit {
    val isPrime = BooleanArray(1000002){true}
    for (i in 2 .. 1001) if (isPrime[i]){
        for (j in i * i .. 1000001 step i){
            isPrime[j] = false
        }
    }
    isPrime[0] = false
    isPrime[1] = false
    val length = IntArray(1000002){-1}
    while(true){
        val (m, n) = readLine()!!.trim().split(' ').map(String::toInt)
        if (m == 0 && n == 0) return
        val start = fromNumber(n)
        val queue: Queue<Triple<Int, Int, Int>> = LinkedList()
        queue.add(Triple(start.first, start.second, n))
        length[n] = if (isPrime[n]) 1 else 0
        var maxPrime = if (isPrime[n]) n else 0
        var maxLength = length[n]
        while(queue.isNotEmpty()){
            val (x, y, current) = queue.poll()
            for (nx in x - 1 .. x + 1) {
                val suspect = fromPosition(nx, y + 1)
                if (suspect <= m) {
                    if (length[suspect] == -1){
                        queue.add(Triple(nx, y + 1, suspect))
                    }
                    if (isPrime[suspect]) {
                        length[suspect] = Math.max(length[current] + 1, length[suspect])
                        if (maxLength == length[suspect] && maxPrime < suspect) maxPrime = suspect
                        else if (maxLength < length[suspect]) {
                            maxPrime = suspect
                            maxLength = length[suspect]
                        }
                    }else {
                        length[suspect] = Math.max(length[current], length[suspect])
                    }
                }
            }
        }
        (0 .. m).forEach { length[it] = -1 }
        println(if(maxLength == 0) "0 0" else "$maxLength $maxPrime")
    }

}
fun fromPosition(x: Int, y: Int): Int {
    val max = Math.max(Math.abs(x), Math.abs(y))
    return if (y > 0 && y == max) (max * 2 + 1) * (max * 2 + 1) - max + x
    else if (y < 0 && y == - max) (max * 2 - 1) * (max * 2 - 1) + max * 2 + max - x
    else if (x > 0) (max * 2 - 1) * (max * 2 - 1) + max - y
    else (max * 2 - 1) * (max * 2 - 1) + 5 * max + y
}
fun fromNumber(number: Int): Pair<Int, Int> {
    val size = (0 until number).find { (it * 2 + 1) * (it * 2 + 1) >= number }!!
    for (x in -size .. size) {
        if (fromPosition(x, size) == number) return Pair(x, size)
        if (fromPosition(x, -size) == number) return Pair(x, -size)
    }
    for (y in -size .. size){
        if (fromPosition(size, y) == number) return Pair(size, y)
        if (fromPosition(-size, y) == number) return Pair(-size, y)
    }
    TODO()
}



Measured memory_bytes: 73728
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi(x) vector<x>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
#define int long long
using namespace std;
//typedef long long ll;
void solve()
{
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(i%2 && x%2)
		sum++;
	}
	cout<<sum<<endl;
}
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
solve();
}

return 0;
}
// Problem : B - An Odd Problem
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 3612
#include <iostream>
#include <vector>
int main() {
	int64_t n; std::cin >> n;
	std::vector<int64_t> a (n);
	int64_t sum = 0;
	for (int64_t& x : a) {std::cin >> x; sum += x;}
	int64_t s1 = (n * int64_t(n+1)) / 2;
	if (sum % s1 != 0) {std::cout << "NO\n"; return 0;}
	int64_t n_op = sum / s1, actual_op = 0;
	for (int64_t ax = 0; ax < n; ++ax) {
		int64_t bx = ax + 1; if (bx == n) bx = 0;
		int64_t diff = a[ax] - a[bx];
		// diff + n_op - n * nOpA == 0
		int64_t tmp = diff + n_op;
		if (tmp % n != 0 || tmp < 0) {std::cout << "NO\n"; return 0;}
		actual_op += tmp / n;
	}
	if (n_op != actual_op) {std::cout << "NO\n"; return 0;}
	std::cout << "YES\n";
}


Measured memory_bytes: 1152
n,m = map(int,input().split())
f = lambda k:[input() for _ in range(k)]
ln,lm = f(n),f(m)
for i in range(n-m+1):
  for j in range(n-m+1):
    lk = [s[j:j+m] for s in ln[i:i+m]]
    if lk==lm:
      print('Yes')
      break
  else:
    continue
  break
else:
  print('No')

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int K;
  cin >> K;
  string S;
  cin >> S;
  S[K - 1] -= 'A' - 'a';
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int64_t mod=1000000007;
int64_t powermod(int k,int d){
  int64_t m=1;
  for(int i=0;i<k;i++){
    m=m*d%mod;
  }
  return m;
}
int main(){
  int n;
  cin >> n;
  int64_t ans=powermod(n,10)-powermod(n,9)-powermod(n,9)+powermod(n,8);
  ans%=mod;
  ans=(ans+mod)%mod;
  cout << ans << endl;
}

Measured memory_bytes: 3576