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

using namespace std;
typedef long long ll;

ll M;
deque<ll> d;
deque<ll> c;
deque<ll> e;

int main(){
    cin >> M;
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        d.push_back(a);
        c.push_back(b);
    }
    ll count = 0;
    while(d.size() > 0){
        if(c[0] == 1){
            e.push_back(d[0]);
            c.pop_front();
            d.pop_front();
            continue;
        }
        ll dd = d[0];
        ll cc = c[0];
        c.pop_front();
        d.pop_front();
        if(dd < 5){
            if(cc % 2 == 1){
                c.push_front(1);
                d.push_front(dd);
            }
            c.push_front(cc/2);
            d.push_front(dd*2);
            count += cc/2;
            continue;            
        }
        if(cc % 2 == 1){
            c.push_front(1);
            d.push_front(dd);
        }
        dd = (dd*2)/10 + (dd*2)%10;
        c.push_front(cc/2);
        d.push_front(dd);
        count += cc/2 * 2;
    }
    while(e.size() > 1){
        ll a = e[0];
        ll b = e[1];
        e.pop_front();
        e.pop_front();
        if(a+b < 10){
            count++;
            e.push_front(a+b);
        }else{
            count += 2;
            e.push_front((a+b)/10 + (a+b)%10);
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 26932
if __name__ == '__main__':
	Sa = input()
	Sa = [s.split()[0] for s in Sa]
	Sb = input()
	Sb = [s.split()[0] for s in Sb]
	Sc = input()
	Sc = [s.split()[0] for s in Sc]

	turn_next = 'a'
	turn = 'a'

	while(True):
		turn = turn_next

		if turn == 'a':
			S = Sa
		elif turn == 'b':
			S = Sb
		elif turn == 'c':
			S = Sc

		if len(S) == 0:
			break

		turn_next = S.pop(0)

		if turn == 'a':
			Sa = S
		elif turn == 'b':
			Sb = S
		elif turn == 'c':
			Sc = S

	if turn == 'a':
			print('A')
	elif turn == 'b':
			print('B')
	elif turn == 'c':
			print('C')

Measured memory_bytes: 3064
import bisect as bs
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
m = bs.bisect_left(a, 0)
a.insert(m, 0)
ans = 10 ** 9
for i in range(K + 1):
    if m - i >= 0 and m + K - i < N + 1:
        ans = min(a[m + K - i] - a[m - i] + min(a[m + K - i], -a[m - i]), ans)
print(ans)

Measured memory_bytes: 58608
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int g = sc.nextInt();
    long[] p = new long[d];
    long[] c = new long[d];

    for (int i = 0; i < d; i++) {
      p[i] = sc.nextLong();
      c[i] = sc.nextLong();
    }

    long ans = Long.MAX_VALUE;

    for (int i = 0; i < Math.pow(2,d); i++) {
      long sum = 0;
      long count = 0;
      for (int j = 0; j < d; j++) {
        if ((1&i >> j) == 1) {
          sum += p[j]*100*(j+1)+c[j];
          count += p[j];
          // System.out.println(count);
        }
      }

      // sum >= gかどうかで場合分け

      if (sum >= g) {
        ans = Math.min(ans,count);
      } else {
        for (int j = d-1; j >= 0; j--) {
          if ((1&i >> j) != 1) {
            for (int k = 0; k < p[j]; k++) {
              sum += 100*(j+1);
              count++;
              // System.out.println(sum+"   "+count);
              if (sum >= g) {
                // System.out.println(sum);
                ans = Math.min(ans,count);
              }
            }
          }
        }
      }
    }

    System.out.println(ans);

  }

}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}

void cmb_init(int n, vll &fac, vll &finv) {
  ll x, y;
  for (int i = 2; i <= n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    extgcd(i, MOD, x, y);
    finv[i] = finv[i - 1] * (MOD + x % MOD) % MOD;
  }
}

// void cmb_init(int n, vll &fac, vll &finv) {
//   vll inv(n + 1, 1);
//   for (int i = 2; i <= n; 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;
//   }
// }

ll cmb(int n, int k, vll &fac, vll &finv) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve() {
  int N, K;
  cin >> N >> K;
  vi A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vll fac(N + 1, 1), finv(N + 1, 1);
  cmb_init(N, fac, finv);
  sort(all(A));
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum -= A[i] * cmb(N - i - 1, K - 1, fac, finv) % MOD;
    sum += A[i] * cmb(i, K - 1, fac, finv) % MOD;
    sum %= MOD;
  }
  cout << sum << endl;
}

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

  solve();

  return 0;
}


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

int main() {
	int s;
	cin >> s;
	vector<int> data(1000000);
	data[0] = s;
	bool f = false;
	int ans;

		for(int i = 1; i < data.size(); i++){
			if(f) break;
			else if (data[i-1] % 2 == 0) {
				data[i] = data[i-1] / 2;
			}
			else {
				data[i] = 3 * data[i-1] + 1;
			}
				for (int j = 0; j < i; j++) {
					if (data[j] == data[i]) {
						ans = i + 1;
						f = true;
						break;
					}
				}
		}
	cout << ans << endl;
}


Measured memory_bytes: 4096
//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 205
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

//------BEAST MODE ON------------
//-----fuck rating

int main()
{
	fast;
	string n;
	cin>>n;
	ll i;
	ll ans=0;
	for(i=0;i<n.size();i++)
	{
		ans+=n[i]-'0';
	}
	if(ans%9)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	
	return 0;	
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    int n = S.size();
    ll dp[n + 1][4] = {0};

    for (int i = n; i >= 0; --i)
    {
        for (int j = 3; j >= 0; --j)
        {
            if (i == n)
            {
                if (j == 3) dp[i][j] = 1;
                else dp[i][j] = 0;
            }
            else
            {
                if (j == 3)
                {
                    if (S[i] == '?') dp[i][j] = 3 * dp[i + 1][j];
                    else dp[i][j] = dp[i + 1][j];
                }
                else
                {
                    // i番目に丸を付けない
                    if (S[i] == '?') dp[i][j] = 3 * dp[i + 1][j];
                    else dp[i][j] = dp[i + 1][j];
                    // i番目に丸を付ける
                    if (S[i] == '?') dp[i][j] += dp[i + 1][j + 1];
                    else if (S[i] == 'A' && j == 0) dp[i][j] += dp[i + 1][j + 1];
                    else if (S[i] == 'B' && j == 1) dp[i][j] += dp[i + 1][j + 1];
                    else if (S[i] == 'C' && j == 2) dp[i][j] += dp[i + 1][j + 1];
                }
            }
            
            dp[i][j] = dp[i][j] % MOD;
        }
    }

    cout << dp[0][0] << endl;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        if (L[i] <= R[j])
        {
            A[k] = L[i];
            i++;
        }
        else
        {
            A[k] = R[j];
            j++;
        }
    }
}

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

    cin>>n;
    for (int i = 0; i < n; i++)
        cin >> A[i];

    mergeSort(A, n, 0, n);

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

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6908
import bisect
import sys
input = sys.stdin.readline
A, B, Q = map(int, input().split())

s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]

for i in range(Q):
    x = int(input())
    ret = 2 * 10**10
    a = bisect.bisect_left(s, x)
    tmp = 0
    if a < len(s):
        tmp = abs(s[a] - x)
        ab = bisect.bisect_left(t, s[a])
        if ab < len(t):
            tmp2 = abs(t[ab] - s[a])
            ret = min(ret, tmp + tmp2)

        if ab > 0:
            tmp2 = abs(t[ab - 1] - s[a])
            ret = min(ret, tmp + tmp2)
    if a > 0:
        a -= 1
        tmp = 0
        tmp = abs(s[a] - x)
        ab = bisect.bisect_left(t, s[a])
        if ab < len(t):
            tmp2 = abs(t[ab] - s[a])
            ret = min(ret, tmp + tmp2)

        if ab > 0:
            tmp2 = abs(t[ab - 1] - s[a])
            ret = min(ret, tmp + tmp2)

    b = bisect.bisect_left(t, x)
    tmp = 0
    if b < len(t):
        tmp = abs(t[b] - x)
        ba = bisect.bisect_left(s, t[b])
        if ba < len(s):
            tmp2 = abs(s[ba] - t[b])
            ret = min(ret, tmp + tmp2)
        if ba > 0:
            tmp2 = abs(s[ba - 1] - t[b])
            ret = min(ret, tmp + tmp2)
    if b > 0:
        b -= 1
        tmp = abs(t[b] - x)
        ba = bisect.bisect_left(s, t[b])
        if ba < len(s):
            tmp2 = abs(s[ba] - t[b])
            ret = min(ret, tmp + tmp2)

        if ba > 0:
            tmp2 = abs(s[ba - 1] - t[b])
            ret = min(ret, tmp + tmp2)
    print(ret)


Measured memory_bytes: 12196
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

max_score = 0
for s_ in s:
    score = s.count(s_) - t.count(s_)
    if score > max_score:
        max_score = score

print(max_score)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<ll,plpl> plplp;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    unordered_map<ll,ll> d[n+1];
    unordered_map<ll,vector<plpl>> v[n+1];
    
    vector<pll> w[n+1];
    rep(i,0,m){
        ll a,b,c;cin>>a>>b>>c;
        w[a].push_back({b,c});
        w[b].push_back({a,c});
    }
    rep(i,1,n+1){
        unordered_map<ll,ll> used;
        d[i][-1]=inf;
        rep(j,0,w[i].size()){
            ll aite=w[i][j].first;
            ll kai=w[i][j].second;
            if(used[kai]==0){
                v[i][kai].push_back({0,{i,-1}});
                used[kai]=1;
                d[i][kai]=inf;
            }
            v[i][-1].push_back({1,{aite,kai}});
            v[i][kai].push_back({0,{aite,kai}});
            
        }
    }
    priority_queue<plpl,vector<plpl>,greater<plpl>> q;
    q.push({0,{1,-1}});
    d[1][-1]=0;
    while(q.size()>0){
        plpl p=q.top();q.pop();
        ll dis=p.first;
        ll now=p.second.first;
        ll kai=p.second.second;
        rep(i,0,v[now][kai].size()){
            plpl pp=v[now][kai][i];
            ll co=pp.first;
            ll ne=pp.second.first;
            ll neka=pp.second.second;
            if(d[ne][neka]>dis+co){
                d[ne][neka]=dis+co;
                q.push({dis+co,{ne,neka}});
            }
        }
    }
    if(d[n][-1]==inf)cout<<-1<<endl;
    else cout<<d[n][-1]<<endl;
}


Measured memory_bytes: 121196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, tmp;
  tmp = 1;
  cin >> N;
  ll ans = 1;
  ll A[N] = {0};
  ll tmp1;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    if (A[i] == 0) {
      tmp = 0;
    }
  }
  for (int i = 0; i < N; ++i) {
    tmp1 = ans;
    ans *= A[i];
    if (ans > 1000000000000000000 || tmp == 0) {
      // ans = 0;
      break;
    }
    if (ans < tmp1) {
      ans = 1000000000000000001;
      break;
    }
  }
  if (tmp == 0) {
    ans = 0;
  }
  if (ans > 1000000000000000000) {
    printf("-1\n");
  } else {
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
typedef long long ll;
int a[100005], b[100005], app[200005];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", a + i, b + i);
		app[i << 1] = a[i];
		app[i << 1 | 1] = b[i];
	}
	std::sort(app, app + (n << 1));
	ll sa = 0, sb = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		sa += a[i];
		sb += b[i];
		sum += app[i];
	}
	ll ans = std::min(sa, sb);
	for (int i = 0; i < n; i++) {
		int cur = n - 1;
		ll res = sum;
		if (a[i] < b[i]) {
			std::swap(a[i], b[i]);
		}
		if (a[i] > app[cur]) {
			res += a[i] - app[cur--];
		}
		if (b[i] > app[cur]) {
			res += b[i] - app[cur--];
		}
		ans = std::min(ans, res);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

int main() {
  int arr[3];
  int s = 0;
  for(int i = 0; i < 3; i++) 
  {
  	 std::cin>>arr[i];
     if(arr[i] == 7){
       s++;
     }
  }
  if(s == 1){
    std::cout << "YES";
  }else {
   	std::cout << "NO";
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    a, b, c, d = input_int_list()
    ans = max(a * c, a * d, b * c, b * d)
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61740
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    xs = list(map(int, input().split()))
    xs_sorted = sorted(xs)
    medians_small = xs_sorted[n // 2 - 1]
    medians_large = xs_sorted[n // 2]
    for x in xs:
        if x <= medians_small:
            print(medians_large)
        else:
            print(medians_small)


if __name__ == '__main__':
    main()

Measured memory_bytes: 26540
#include <iostream>
#include <vector>

using namespace std;

vector<int> map, dice,output;
int trout,ogle;
int player,turn;
int input;
int answer=0;

int main()
{
	while (true)
	{
		cin >> trout >> ogle;
		if (trout == 0 && ogle == 0)break;
		player = 0;
		for (int i = 0; i < trout; i++)
		{
			cin >> input;
			map.push_back(input);
		}
		for (int i = 0; i < ogle; i++)
		{
			cin >> input;
			dice.push_back(input);
		}

		for (turn = 0; turn < ogle; turn++)
		{
			player += dice[turn];
			if (player >= trout-1)break;
			player += map[player];
			if (player >= trout-1)break;
		}
		output.push_back(turn + 1);
		answer++;
		map.clear();
		dice.clear();
	}
	for (int i = 0; i < answer; i++)
	{
		cout << output[i] << endl;
	}
        return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}


int main(){
    sieve(2e5);
    ll n;
    cin >> n;
    while(1){
        if(IsPrime[n]){
            cout << n;
            return 0;
        }
        n++;
    }
}   

Measured memory_bytes: 256
/**
*    created: 03.07.2020 16:12:16
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#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++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int p = -1;
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int l = t.size();
    if (n < l) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string> vec;
    rep(i,n-l+1) {
        string tmp = s.substr(i,l);
        bool ok = true;
        rep(j,l) if (tmp[j] != '?' && t[j] != tmp[j]) ok = false;
        if (ok) {
            p = 1;
            string ans = s.substr(0,i) + t + s.substr(i+l,n-i-l);
            rep(j,n) if (ans[j] == '?') ans[j] = 'a';
            vec.push_back(ans);
        }
    }
    if (p == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(all(vec));
    cout << vec[0] << endl;
    return 0;
}

Measured memory_bytes: 3636
S=input()

ans='NO'
# print(S.find('k'))
if S.find('k')==0 and S.rfind('eyence')==len(S)-6:
    ans='YES'
elif S.find('ke')==0 and S.rfind('yence')==len(S)-5:
    ans='YES'
elif S.find('key')==0 and S.rfind('ence')==len(S)-4:
    ans='YES'
elif S.find('keye')==0 and S.rfind('nce')==len(S)-3:
    ans='YES'
elif S.find('keyen')==0 and S.rfind('ce')==len(S)-2:
    ans='YES'
elif S.find('keyenc')==0 and S.rfind('e')==len(S)-1:
    ans='YES'

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define mp make_pair
#define hello cout<<"h1"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define it(s)	for(auto itr:s)
#define dbg(s) 	for(auto itr:s)	cout<<itr<<" ";cout<<endl;
#define dvg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;
typedef unsigned long long int ulli;
const int INF=INT_MAX;
const lli MOD=10e8+7;

	
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout.precision(6);

    int a,b,c;
	cin>>a>>b>>c;
	int temp=c;int temp1=a;
	c=b;
	a=temp;
	b=temp1;
	cout<<a<<" "<<b<<" "<<c<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
    int n,i;
    int* a;

    scanf("%d",&n);

    a=(int*)malloc(sizeof(int)*n);

    for(i=0;i<n;i++){
        scanf("%d ",&a[i]);
    }
    
    for(i=0;;i++){
        if(i>=(n-1)-i) break;

        int tmp=a[i];
        a[i]=a[(n-1)-i];
        a[(n-1)-i]=tmp;
    }

   for(i=0;;i++){
       printf("%d",a[i]);

       if(i==n-1){
           printf("\n");
           break;
       }else{
           printf(" ");
       }
   }

   free(a);

   return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int K;
  cin >> K;
  int odd = (K+1) / 2;
  int even = K - odd;
  cout << odd * even << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main()
{
    int min_reminder = 10, accum = 0;
    int a, reminder;
    REP(i, 5) {
        cin >> a;
        reminder = a % 10;
        accum += (reminder == 0) ? a : (a / 10 + 1) * 10;
        if (reminder != 0) min_reminder = min(min_reminder, reminder);
    }
    if (min_reminder != 10) accum = accum - 10 + min_reminder;

    cout << accum << endl;

    return 0;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    if (a.size() > b.size()){
        cout << "GREATER" << endl;
        return 0;
    }else if(a.size() < b.size()){
        cout << "LESS" << endl;
        return 0;
    }

    for (int i = 0; i < a.size(); i++){
        if (a[i] - '0' == b[i] - '0'){
            continue;
        }else if (a[i] - '0' > b[i] - '0'){
            cout << "GREATER" << endl;
            return 0;
        }else{
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var c [3][3]int
	var a, b [3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			scanner.Scan()
			c[i][j], _ = strconv.Atoi(scanner.Text())
		}
	}

	b[0] = c[0][0] - a[0]
	b[1] = c[0][1] - a[0]
	b[2] = c[0][2] - a[0]
	a[1] = c[1][0] - c[0][0]
	a[2] = c[2][0] - c[0][0]
	if a[1] == c[1][1] - c[0][1] && a[1] == c[1][2] - c[0][2] &&
		a[2] == c[2][1] - c[0][1] && a[2] == c[2][2] - c[0][2] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

using namespace std;

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

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<": "
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int a, b; cin>>a>>b;
    int cur = 1, cnt = 0;
    while(cur < b){
        cur--;
        cur += a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
typedef pair<int, int> P;
int mod;
const int maxN = 200000;
vector<int>G[200006];
int kj[200006];
int dp1[200006];
int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res * a%mod;
		a = a * a%mod;
		x >>= 1;
	}
	return res;
}
void setkj() {
	kj[0] = 1;
	for (int i = 1; i <= maxN; i++)kj[i] = kj[i - 1] * i%mod;
}

void dfs1(int now, int par) {
	dp1[now] = 1;
	for (int e : G[now]) {
		if (e == par)continue;
		dfs1(e, now);
		dp1[now] *= dp1[e] + 1;
		dp1[now] %= mod;
	}
}
void dfs2(int now, int par,int nowdp=0) {
	int N = G[now].size();
	vector<int>dpl(N), dpr(N);
	rep(i, N) {
		int u = G[now][i];
		if (u == par) {
			dpl[i] = dpr[i] = (nowdp + 1) % mod;
			dp1[now] *= nowdp + 1;
			dp1[now] %= mod;
		}
		else {
			dpl[i] = dpr[i] = (dp1[u] + 1) % mod;
		}
	}
	rep(i, N - 1)dpl[i + 1] = dpl[i + 1] * dpl[i] % mod;
	for (int i = N - 1; i > 0; i--)dpr[i - 1] = dpr[i - 1] * dpr[i] % mod;

	rep(i, N) {
		int u = G[now][i];
		if (u == par)continue;
		int na = 1, nb = 1;
		if (i)na = dpl[i - 1];
		if (i != N - 1)nb = dpr[i + 1];
		dfs2(u, now, na*nb%mod);
	}
}

signed main() {
	int n; cin >> n >> mod;
	setkj();
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs1(0, -1); dfs2(0, -1);
	rep(i, n)cout << dp1[i] << endl;

}


Measured memory_bytes: 21632
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=5e5+100;
int n,a[N]; ll Min,f[N],g[N],sum[N],sum0[N],sum1[N],ans;
int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+a[i];
		sum1[i]=sum1[i-1]+(a[i]&1)+2*(a[i]==0);
		sum0[i]=sum0[i-1]+(!(a[i]&1));
	}
	f[0]=0; Min=0;
	rep (i,1,n){
		f[i]=min(sum[i],Min+sum1[i]);
		Min=min(Min,sum[i]-sum1[i]);
	}
	g[0]=0; Min=0;
	rep (i,1,n){
		g[i]=min(f[i],Min+sum0[i]);
		Min=min(Min,f[i]-sum0[i]);
	}
	f[0]=0; Min=0;
	rep (i,1,n){
		f[i]=min(g[i],Min+sum1[i]);
		Min=min(Min,g[i]-sum1[i]);
	}
	ans=f[n];
	rep (i,1,n-1) ans=min(ans,f[i]+sum[n]-sum[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 20224
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int min_diff = INT_MAX;;
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n-2;i++){
        //string res = "";
        string res =  s.substr(i,3);
        //cout<<res<<endl;
        int x = stoi(res);
        min_diff = min(min_diff,abs(753-x));
    }
    cout<<min_diff<<endl;
    return 0;
}



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  ll ans = -1;
  ll n, s; cin >> n >> s;
  for(ll x = 1; x < sqrt(n); x++){
    //p進数の二桁
    //x+y == s;
    //px+y == n;
    if((n-s) % x) continue;
    ll p = (n-s) / x + 1;
    ll y = s - x;
    if(0 <= y && y < p){
      if(ans == -1) ans = p;
      else ans = min(ans, p);
    }
  }
  //三桁以上
  for(int p = 2; p <= sqrt(n); p++){
    //p進数
    ll sum = 0;
    ll N = n;
    while(N > 0){
      sum += N % p;
      N /= p;
    }
    if(sum == s){
      if(ans == -1) ans = p;
      else ans = min(ans, p);
    }
  }
  if(n == s){
    if(ans == -1) ans = n + 1;
    else ans = min(ans, n+1);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long a,b,c,d=0,e=0,i=0;
    string s;
    cin>>s;
    if(s[0]=='S' && s[1]=='U'){cout<<'7'; return 0;}
    if(s[0]=='M'){cout<<'6'; return 0;}
    if(s[0]=='T' && s[1]=='U'){cout<<'5'; return 0;}
    if(s[0]=='W'){cout<<'4'; return 0;}
    if(s[0]=='T' && s[1]=='H'){cout<<'3'; return 0;}
    if(s[0]=='F'){cout<<'2'; return 0;}
    if(s[0]=='S' && s[1]=='A'){cout<<'1'; return 0;}
    return 0;
}


Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a;
  cin >> a;
 
  vector<int> p = {1};
  
  for(int i=2; i<32; i++){
    for(int j=2; j<32; j++){
      if(pow(i,j)>1025)break;
      p.pb(pow(i,j));
    }
  }
  
  sort(all(p));
  
  repo(i,1025){
    if(p[i]>a) {
      cout << p[i-1] << endl;
      return 0;
    }
  }
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,c;

  while(scanf("%d %d",&a,&b)!=EOF){
    int count=0;
    c=a+b;
    while(c>0){
      c/=10;
      count+=1;
    }
    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int seisu = scan.nextInt();
		int count = 0;

		for(int i=1;i<=seisu;i++) {
			int suretu = scan.nextInt();

			if(i!=suretu) {
				count++;
			}
		}

		System.out.println(count <= 2?"YES":"NO");
		scan.close();

	}

}


Measured memory_bytes: 27044
using System;

class D
{
	static void Main()
	{
		var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int h = a[0], w = a[1], k = a[2] - 1;

		var f = new int[w + 1];
		f[0] = f[1] = 1;
		for (int i = 2; i <= w; i++) f[i] = f[i - 1] + f[i - 2];

		var dp = new long[h + 1, w];
		dp[0, 0] = 1;
		for (int i = 1; i <= h; i++)
			for (int j = 0; j < w; j++)
			{
				dp[i, j] = f[j] * f[w - 1 - j] * dp[i - 1, j];
				if (j > 0) dp[i, j] += f[j - 1] * f[w - 1 - j] * dp[i - 1, j - 1];
				if (j < w - 1) dp[i, j] += f[j] * f[w - 2 - j] * dp[i - 1, j + 1];
				dp[i, j] %= 1000000007;
			}
		Console.WriteLine(dp[h, k]);
	}
}


Measured memory_bytes: 13140
N = gets.to_i
digits = N.to_s.size

def dfs(digits_size, digits = [], &block)
  if digits.size == digits_size
    block.call(digits)
    return
  end
  [7, 5, 3].each do |n|
    d = digits.dup
    dfs(digits_size, d.push(n), &block)
  end
end

ans = 0
(3..digits).each do |d|
  dfs(d) do |list|
    is_ok = list.join('').to_i <= N &&
      list.count { |n| n == 7 } >= 1 &&
      list.count { |n| n == 5 } >= 1 &&
      list.count { |n| n == 3 } >= 1
    ans += 1 if is_ok
  end
end
puts ans


Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << endl)

using namespace std;
using ll = unsigned long long;


int main() {
	int N, M;
	cin >> N >> M;
	vector<int> K(N);
	vector<vector<int>> A(N);
	int i, j, a;
	for(i = 0; i < N; i++) {
		cin >> K[i];
		for(j = 0; j < K[i]; j++) {
			cin >> a;
			A[i].push_back(a);
		}
	}
	
	map<int, int> m;
	
	for(i = 1; i <= M; i++) {
		m[i] = 0;
	}
	
	for(i = 0; i < N; i++) {
		for(j = 0; j < K[i]; j++) {
			m[A[i][j]]++;
		}
	}
	
	int count = 0;
	
	for(i = 1; i <= M; i++) {
		if(m[i] == N) {
			count++;
		}
	}
	
	cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                sb.AppendLine(SearchReslt(input).ToString());
            }
            Console.Write(sb);
        }

        static char SearchReslt(string map)
        {
            if (map[0] != 's')
            {
                if (map[0] == map[4] && map[0] == map[8]) return map[0];
            }

            if (map[2] != 's')
            {
                if (map[2] == map[4] && map[2] == map[6]) return map[2];
            }

            for (int i = 0; i < 9; i += 3)
            {
                if (map[i] != 's')
                {
                    if (map[i] == map[i + 1] && map[i] == map[i + 2]) return map[i];
                }
            }

            for (int i = 0; i < 3; i++)
            {
                if (map[i] != 's')
                {
                    if (map[i] == map[i + 3] && map[i] == map[i + 6]) return map[i];
                }
            }
            return 'd';
        }
    }
}

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

int main() {
	int n;
	scanf("%d", &n);
	int x;
	int f = 0;
	int so = 0, sg = 0;
	while (n) {
		f = 0;
		scanf("%d", &x);
		if (x % 2 == 0) {
			so++;
			if (x % 3 == 0 || x % 5 == 0)
				sg++;
		}
		n--;
	}
	if (so == sg) {
		printf("APPROVED");
	}
	else
		printf("DENIED");
}


Measured memory_bytes: 128
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
    
def lcm(a, b):
	return a * b // gcd (a, b)
	
	
a = input().split()
a = [int(i) for i in a]

string1 = input()
string2 = input()

num = lcm(len(string1), len(string2))

counter = 0

one = num//len(string1)
two = num//len(string2)

ok = True
while counter*two < len(string1) and counter*one < len(string2):
	if string1[two*counter] == string2[one*counter]:
		pass
	else:
		ok = False
		break
	counter +=1
	
if ok == True:
	print(num)
else:
	print(-1)
	

Measured memory_bytes: 3316
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()

for i in range(50001):
  if int(i * 1.08) == N:
    print(i)
    break
else:
  print(":(")

Measured memory_bytes: 39408
#include<stdio.h>

int n;
int A[1000000];


int  solve(int i, int m)
{
	int res;
	
	if(m==0) return 1;
	else if(i>=n) return 0;
	
	res = solve(i+1,m)|| solve(i+1,m-A[i]);
	return res;
}
	
int main()
{
	int i;
	scanf("%d",&n);
	for( i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	
	int q,m;
	
	scanf("%d",&q);
	
	for(i=0;i<q;i++)
	{
		scanf("%d",&m);
		if(solve(0,m)==1)
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	
	}
return 0;
}

	


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

char s[3007];
char t[3007];
int dp[3007][3007];
int main()
{
    scanf("%s",&s[1]);
    scanf("%s",&t[1]);

    for(int i=1; i<=strlen(&s[1]);i++)
    {
        for(int k=1; k<=strlen(&t[1]);k++)
        {
            if(s[i]==t[k]){ dp[i][k]=dp[i-1][k-1]+1; }
            else{ dp[i][k]=max(dp[i-1][k], dp[i][k-1]); }
        }
    }


    char ans[3007];
    int i=strlen(&s[1]), k=strlen(&t[1]);
    ans[dp[i][k]+1]='\0';
    while(dp[i][k])
    {
        if(s[i]==t[k])
        {
            ans[dp[i][k]]=s[i]; i--; k--;
        }
        else
        {
            if(dp[i][k]==dp[i][k-1]){ k--; }
            else{ i--; }
        }
    }

    printf("%s",&ans[1]);
    //printf("%d\n",dp[strlen(&s[1])][strlen(&t[1])]);
    return 0;
}

Measured memory_bytes: 35456
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

bool solve(vector<int> data) {
	vector<int> B(1, 0), C(1, 0);
	int b=-1, c=-1;
	for (int i=0; i<10; i++) {
		if (b == -1) {
			B[0] = data[i];
			b++;
		} else if (B[b] > data[i]) {
			if (c == -1) {
				C[0] = data[i];
				c++;
			} else if (C[c] < data[i]) {
				C.push_back(data[i]);
				c++;
			} else {
				return false;
			}
		} else {
			B.push_back(data[i]);
			b++;
		}
	}
	return true;
}

int main() {
	int N; cin >> N;
	vector<int> data(10); bool b;
	for (int i=0; i<N; i++) {
		cin >> data[0] >> data[1] >> data[2] >> data[3] >> data[4] >> data[5] >> data[6] >> data[7] >> data[8] >> data[9];
		b = solve(data);
		if (b) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char alp[]={"abcdefghijklnmopqrstuvwxyz"};
  string s;
  map<char,bool>death;
  for(int i=0;i<26;i++){
    death[alp[i]]=true;
  }
  cin >> s;
  for(int i=0;i<s.size();i++){
    death[s[i]]=false;
  }
  for(int i=0;i<26;i++){
    if(death[alp[i]]==true){
      cout << alp[i] << endl;
      break;
    }
    if(i==26-1){
      cout << "None" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 512
def main():
    s = input()
    K = int(input())
    new_s = ""

    l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    d = {
        "a": 0,
        "b": 25,
        "c": 24,
        "d": 23,
        "e": 22,
        "f": 21,
        "g": 20,
        "h": 19,
        "i": 18,
        "j": 17,
        "k": 16,
        "l": 15,
        "m": 14,
        "n": 13,
        "o": 12,
        "p": 11,
        "q": 10,
        "r": 9,
        "s": 8,
        "t": 7,
        "u": 6,
        "v": 5,
        "w": 4,
        "x": 3,
        "y": 2,
        "z": 1,
    }

    for i in range(len(s)-1):
        if d[s[i]] <= K:
            K -= d[s[i]]
            new_s += 'a'
        else:
            new_s += s[i]

    new_s += l[(l.index(s[-1]) + K) % 26]

    print(new_s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <cstdio>
#include <cmath>
#include <vector>

int main(){
  int N,K;
  scanf("%d%d", &N, &K);

  int k=2*K+1;

  std::vector<int> sec_arr;
  char before = '1', s;
  int ncount = 0, ntotal = 0;
  for(int i = 0; i < N; i++){
    scanf(" %c", &s);
    if(s!=before){
      sec_arr.push_back(ncount);
      if(sec_arr.size() <= k) ntotal += ncount;
      ncount = 0;
      before = s;
    }
    ncount++;
  }
  sec_arr.push_back(ncount);
  if(sec_arr.size() <= k) ntotal += ncount;
  if(s=='0') sec_arr.push_back(0);

  if(sec_arr.size() < k){
    printf("%d\n", N);
    return 0;
  }

  int ans = ntotal;
  int b=0, e=k;
  while(true){
    ntotal -= sec_arr[b]+sec_arr[b+1];
    ntotal += sec_arr[e]+sec_arr[e+1];
    ans = std::max(ans, ntotal);
    b+=2;
    e+=2;
    if(e+1 >= sec_arr.size()) break;
  }

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

  return 0;
}



Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            int q = int.Parse(ReadLine());
            long[] t = ReadLine().Split(' ').Select(long.Parse).ToArray();

            long ans = 0;
            for (int i = 0; i < q; i++)
            {
                if (BinarySearch(s, t[i])) ans++;
            }
            WriteLine(ans);
        }


        static bool BinarySearch(long[] a, long target)
        {
            var left = 0;
            var right = a.Length;
            while (left < right)
            {
                var mid = (left + right) / 2;
                if (a[mid] == target) return true;
                if (a[mid] > target)
                {
                    right = mid;
                }
                else left = mid+1;
            }
            return false;
        }
    }
}



Measured memory_bytes: 33448
#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 INF = 1001001001;

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4000
import java.util.*;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        //入力
    	Scanner sc = new Scanner(System.in);
    	String str = sc.next();
    	for(int i = 0 ; i < 3; i++) {
    		if(str.substring(i,i+1).equals("7")) {
    			System.out.println("Yes");
    			System.exit(0);
    		}
    	}
    	System.out.println("No");
    }
}

Measured memory_bytes: 35604
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int val = scanner.nextInt();
            int val1 = val + 1;
            int val2 = val - 1;
            int count = map.getOrDefault(val , 0) + 1;
            map.put(val, count);
            int count1 = map.getOrDefault(val1 , 0) + 1;
            map.put(val1, count1);
            int count2 = map.getOrDefault(val2 , 0) + 1;
            map.put(val2, count2);
        }

        List<Map.Entry<Integer, Integer>> list = new ArrayList<>(map.entrySet());
        list.sort((e1,e2) -> e2.getValue() - e1.getValue());
        System.out.println(list.get(0).getValue());
    }
}

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

int n,m;
int arr[100][100] = {};
bool flag[100] = {};

bool check(){
    for(int i = 1; i <= n; i++){
        if(flag[i] == false)
            return false;
    }
    return true;
}

int solve(int i,int a){
    
    //cout << i << " " << a << endl;
    
    if(flag[i] == true){
        return 0;
    }
    
    flag[i] = true;
    int count = 1;
    
    for(int j = 1; j <= n; j++){
        if(arr[i][j] != 0 && arr[i][j] != a){
            //cout << i << " " << j << endl;
            count += solve(j,a);
        }
    }
    
    return count;
}

int main(void){
    
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        arr[a][b] = i+1;
        arr[b][a] = i+1;
    }
    
    int count = 0;
    
    for(int i = 0; i < m; i++){
        if(solve(1,i+1),!check()){
            count++;
        }
        //cout << check() << endl;
        for(int j = 1; j <= n; j++){
            flag[j] = false;
        }
    }
    
    cout << count << endl;
    
}


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

int arr [100005];

bool cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.second<b.second)return a.second >b.second;
    if(a.second == b.second)return a.first>b.first;
    else return true;
}

int main()
{   //freopen("in.txt","r",stdin);

    std::ios_base::sync_with_stdio(0);cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector <ll> v;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    vector <pair<ll,ll>> p;
    for(int i=0;i<m;i++){
        ll b,c;
        cin>>b>>c;
        p.push_back({b,c});

    }
    sort(p.begin(),p.end(),cmp);
    int j=0;
    for(int i=0;i<p.size();i++){
        while(p[i].first--){
                if(j==v.size())break;
            if(v[j]< p[i].second)v[j++]=p[i].second;
            else break;
        }
    }
    ll ans =0;
    for(int i=0;i<v.size();i++)
       ans+=v[i];//cout<<v[i]<<" ";
        cout<<ans<<endl;
}


Measured memory_bytes: 3188
import numpy

D = int(input())
c_list = list(map(int, input().split()))
s_list = []

for i in range(D):
    s_list.append(list(map(int, input().split())))

t_list = []
score = 0
past_list = [0] * 26

for i in range(D):
    t_list.append(int(input()) - 1)

for i in range(D):
    for j in range(26):
        if(t_list[i] == j):
            score += s_list[i][j]
            past_list[j] = i + 1
        else:
            score -= c_list[j] * (i + 1 - past_list[j])
    print(score)

Measured memory_bytes: 27060