akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    int N;
    cin >> N;
    vector<int> P(N), R(N);

    REP(i, N) {
        cin >> P[i];
        P[i]--;
        R[P[i]] = i;
    }

    vector<vector<int>> big(N, vector<int>(4));
    set<int> cul;
    ll sum = 0;

    for(int i = N - 1; i >= 0; i--){
        int ii = R[i];
        cul.insert(ii);
        auto iter = cul.find(ii);
        if (iter == cul.begin()){
            big[i][0] = -1;
            big[i][1] = -1;
        }else{
            big[i][0] = *(--iter);
            if (iter == cul.begin()) big[i][1] = -1;
            else big[i][1] = *(--iter);
        }

        iter = cul.find(ii);
        if (++iter == cul.end()){
            big[i][2] = N;
            big[i][3] = N;
        }else{
            big[i][2] = *iter;
            if (++iter == cul.end()) big[i][3] = N;
            else big[i][3] = *iter;
        }
        ll tmp1 = big[i][0] - big[i][1];
        tmp1 *= (big[i][2] - ii);
        ll tmp2 = (big[i][3] - big[i][2]);
        tmp2 *= (ii - big[i][0]);

        sum += (i + 1) * (tmp1 + tmp2);
    }
/*
    REP(i, N){
        cout << i << ": ";
        REP(j, 4) cout << big[i][j] << " ";
        cout << endl;
    }
*/
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 11136
import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm;
import std.bigint;

int[32] dp;

void main()
{
  while (true){
    int n = readln().chomp().to!int;
    if (n == 0) break;
    dp[0 .. 32] = -1;
    int pat = shinobu(n);
    pat /= 10;
    if (pat % 10 != 0){
      pat++;
    }

    writeln(pat / 365 + 1);
  }
}

int shinobu(int n)
{
  if (dp[n] != -1){
    return (dp[n]);
  }
  if (n == 1) return (1);
  if (n == 2) return (2);
  if (n == 3) return (4);

  return (dp[n] = shinobu(n - 1) + shinobu(n - 2) + shinobu(n - 3));
}

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

int main() {
  long long D,N;
  cin >> D >> N;
  if(N == 100){
    N = 101;
  }
  if(D == 0){
    cout << N << endl;
  }
  else if(D == 1){
    cout << N*100 << endl;
  }
  else{
    cout << N*10000 << endl;
  }
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int H,W;
	cin>>H>>W;
	int i,j,h=0;
	vector<string> S;
	string str;
	bool bFind;
	for (i=0;i<H;i++){
		cin>>str;
		bFind=false;
		for (j=0;j<W;j++){
			if (str[j]=='#'){
				bFind=true;
				break;
			}
		}
		if (bFind){
			S.push_back(str);
			h++;
		}
	}
	vector<int> col(W,0);
	for (j=0;j<W;j++){
		bFind=false;
		for (i=0;i<h;i++){
			if (S[i][j]=='#'){
				bFind=true;
				break;
			}
		}
		if (!bFind){
			col[j]=1;
		}
	}
	for (i=0;i<h;i++){
		for (j=0;j<W;j++){
			if (col[j]==0){
				cout<<S[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll d[222222];

bool cmp(ii a, ii b)
{
	if(d[a.fi]!=d[b.fi]) return d[a.fi]<d[b.fi];
	if(d[a.se]!=d[b.se]) return d[a.se]<d[b.se];
	return a<b;
}

int color[222222];
int W[222222];
map<ii,int> ma;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<n;i++) cin>>d[i];
	vector<ii> edges;
	for(int i=0;i<m;i++)
	{
		int u,v; cin>>u>>v; u--; v--;
		if(d[u]<d[v]) swap(u,v);
		ma[{u,v}]=i;
		edges.pb({u,v});
	}
	memset(color,-1,sizeof(color));
	sort(edges.begin(),edges.end(),cmp);
	for(int i=0;i<m;i++)
	{
		int u=edges[i].fi; int v=edges[i].se;
		ll du = d[u]; ll dv = d[v];
		if(color[u]==-1&&color[v]==-1)
		{
			if(du!=dv){cout<<-1<<'\n'; return 0;}
			color[u]=1; color[v]=0; W[ma[{u,v}]]=du;
		}
		else if(color[u]==-1)
		{
			color[u]=color[v]^1;
			W[ma[{u,v}]]=du;
		}
		else if(color[v]==-1)
		{
			if(du!=dv){cout<<-1<<'\n'; return 0;}
			W[ma[{u,v}]]=dv; color[v]=color[u]^1;
		}
		else
		{
			W[ma[{u,v}]]=int(1e9);
		}
	}
	
	for(int i=0;i<n;i++)
	{
		cout<<(color[i]?"W":"B");
	}
	cout<<'\n';
	for(int i=0;i<m;i++)
	{
		cout<<W[i]<<'\n';
	}
}


Measured memory_bytes: 18928
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

a, b= LI()
if a <= b:
    print(a)
else:
    print(a-1)

Measured memory_bytes: 3896
C=[]

for _ in range(3):
    C.append(list(map(int,input().split())))

TC=[[0 for i in range(3)] for j in range(3)]
for i in range(3):
    for j in range(3):
        TC[i][j]=C[j][i]


for b1 in range(101):
    for b2 in range(101):
        for b3 in range(101):
            a1=(sum(C[0])-(b1+b2+b3))/3
            a2=(sum(C[1])-(b1+b2+b3))/3
            a3=(sum(C[2])-(b1+b2+b3))/3
            if a1+a2+a3+3*b1==sum(TC[0]) and a1+a2+a3+3*b2==sum(TC[1]) and a1+a2+a3+3*b3==sum(TC[2]):
                print("Yes")
                exit()

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) int((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int, int > pi;

const int MAX_N = (int)1e5 + 123;
const int inf = (int)1e9 + 123;

using namespace std;

bool p[2 * MAX_N];
int h[2 * MAX_N];
int t[3];

int get_m(int a, int b, int c) {
	t[0] = a, t[1] = b, t[2] = c;
	sort(t, t + 3);
	return t[1];
}

int main() {
	#ifdef Nick
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
	#endif
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No\n";
		return 0;
	}
	p[x] = 1;
	vector < int > q;
	for (int i = 1; i < 2 * n; i++)
		if (!p[i]) {
			q.pb(i);
			p[i] = 1;
			if (sz(q) == n - 1)
				break;
		}
	reverse(q.begin(), q.end());
	cout << "Yes\n";
	for (int i = 0; i < sz(q); i++)
		h[i] = q[i], cout << q[i] << '\n';
	cout << x << '\n';
	h[n - 1] = x;
	q.clear();
	for (int i = x; i < 2 * n; i++)
		if (!p[i]) {
			q.pb(i);
			p[i] = 1;
			break;
		}
	for (int i = 1; i < 2 * n; i++)
		if (!p[i]) {
			p[i] = 1;
			q.pb(i);
		}
	for (int i = 0; i < sz(q); i++)
		h[i + n] = q[i], cout << q[i] << '\n';
/*	for (int step = n - 1; step > 0; step--)
		for (int i = 0; i < 2 * step - 1; i++)
			h[i] = get_m(h[i], h[i + 1], h[i + 2]);
	assert(h[0] == x);*/
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int M;
	cin >> M;
	vector<Int> d(M), c(M);
	for (int i = 0; i < M; ++i) {
		cin >> d[i] >> c[i];
	}

	Int ans = 0;
	vector<Int> v;
	for (int i = 0; i < M; ++i) {
		Int x = d[i] * c[i] / 10;
		Int y = d[i] * c[i] % 10;
		ans += (c[i] - 1);
		
		while (x >= 10) {
			ans += (x / 10) * 10;
			x = (x / 10) + (x % 10);
		}
		ans += max(Int(0), x - 1);

		y += x;
		if (x > 0) { ans += 1; }
		if (y >= 10) {
			y = (y / 10) + (y % 10);
			ans += 1;
		}
		v.emplace_back(y);
	}

	if (v.size() > 0) {
		Int x = v[0];
		for (int i = 1; i < v.size(); ++i) {
			x += v[i];
			ans += 1;
			if (x >= 10) {
				x = (x / 10) + (x % 10);
				ans += 1;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5492
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cmath>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int modinv(Int a, Int m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

Int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int root_sum(int target, vi &parents, vi &nodes_value, vi &memo, int sum){
    if(memo[target] != -1){
        sum += memo[target];
        return sum;
    }
    if (parents[target] == target){
        sum+=nodes_value[target];
        return sum;
    }else{
        sum+=nodes_value[target];
        return root_sum(parents[target],parents, nodes_value, memo, sum);
    }
}

// memoには数え上げた素数を入れていく
bool is_prime(Int n, map<Int,Int> &memo){
    if(memo[n] == 1){
        return false;
    }else if(memo[n] == 2){
        return true;
    }

    bool prime = true;
    for(Int i =2; i<=sqrt(n)+2; i++){
        if(memo[i]==2 && n%i==0){
            prime = false;
        }
    }
    if(prime){
        memo[n] = 2;
    }else{
        memo[n] = 1;
    }

    return prime;
}



int main() {
    Int N;
    cin >> N;

    vi a = vi(N);
    vi cand;

    rep(i,N){
        cin >> a[i];
    }

    Int ans = 0;
    Int now =1;

    rep(i,N){
        if(a[i]==now){
            now++;
            cand.push_back(now);
        }else{
            ans++;
        }
    }


    if(cand.empty()){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }



    return 0;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define lint __int128
#define vi vector<int>
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define pii pair<int,int>
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E5 ;

struct problem {
    int wa = 0 ;
    string ver = "WA" ;
};

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    int n , m ; cin >> n >> m ;
    if(m == 0) cout << "0 0\n" ;
    else {
        set<int> ids ;
        problem p[n + 1] ;
        lp(i, 1, m) {
            int id ; string verdict ; cin >> id >> verdict ;
            ids.insert(id) ;

            if(verdict == "AC") p[id].ver = verdict ;
            else {
                if(p[id].ver == "WA") p[id].wa ++ ;
            }
        }
        int ac = 0 , penalty = 0 ;
        for(auto x : ids) {
            // cout << x << ' ' << p[x].ver << ' ' << p[x].wa << endl ;
            if(p[x].ver == "AC") {
                ac ++ ;
                penalty += p[x].wa ;
            }
        }
        cout << ac << ' ' << penalty << endl ;
    }
}


Measured memory_bytes: 11136
#include <iostream>
#include <string.h>
using namespace std;
bool if_753(int n){
    int x;
    bool if3=false;
    bool if5=false;
    bool if7=false;
    while(n>0){
        x=n%10;
        if(x==3){
            if3=true;
        }else if(x==5){
            if5=true;
        }else if(x==7){
            if7=true;
        }else{
            return false;
        }
        n/=10;
    }
    return if3&&if5&&if7;
}
int main(void){
    int N;
    int c=0;
    cin>>N;
    int i=357;
    int m=2;
    while(i<=N){
        if(if_753(i))c++;
        if(++m==3){
          m=0;
          i+=4;
        };
        i+=2;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 384
import numpy as np
import sys

input = sys.stdin.readline

S = input()

S = sorted(list(set(S[:-1])))


alpha = ['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']


j = 0
for i in range(len(alpha)):
    if  S[j]== alpha[i] :
        if len(S)-1 != j:j+=1
    else:
        print(alpha[i])
        exit()


print("None")

Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  vector<int>record(10);
  for(int i=0;i<S.size();i++){
    int count=0;
    for(int j=i;j<S.size();j++){
      if(S.at(j)=='A'||S.at(j)=='T'||S.at(j)=='G'||S.at(j)=='C'){
        if(j==S.size()-1){
          count++;
          record.at(i)=count;
        }
        else{
          count++;
        }
      }
      else{
        record.at(i)=count;
        break;
      }
    }
  }
  sort(record.begin(),record.end());
  reverse(record.begin(),record.end());
  cout<<record.at(0)<<endl;
}

Measured memory_bytes: 256
h, w = [int(num) for num in input().split()]
pic = []

for i in range(h):
  pic.append([str for str in input()])

new_pic = []
for one_line in pic:
  new_pic.append("".join(one_line))
  new_pic.append("".join(one_line))

for one_line in new_pic:
  print(one_line)
  


Measured memory_bytes: 38896
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;




namespace contest
{

    class contest
    {


        static void Main(string[] args)
        {


            //int n = int.Parse(Console.ReadLine());
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();


            //int n = int.Parse(Console.ReadLine());


            var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = num[0];
            int q = num[1];
            var arr = new long[n];
            for (long i = 0; i < arr.Length; i++) arr[i] = 2147483647;
            var input = new int[q][];
            for(int i=0; i< q; i++)
            {
                input[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            int size = (int)Math.Sqrt(arr.Length) + 1;
            var deco = new long[size];
            for (int i = 0; i < size; i++) deco[i] = int.MaxValue;
            for(int i = 0; i< n; i++)
            {
                deco[i / size] = Math.Min(deco[i/size],arr[i]);
            }

            for(int i =0; i< q; i++)
            {
                int dir = input[i][0];
                int l = input[i][1];
                int r = input[i][2];

                long min = int.MaxValue;
                if(dir == 1)
                {
                    for(int j = l; j<= r; )
                    {
                        if(j%size ==0 && j+size-1 <=r)
                        {
                            min = Math.Min(deco[j/size], min);
                            j += size;
                        }
                        else
                        {
                            min = Math.Min(arr[j], min);
                            j++;
                        }
                    }
                    Console.WriteLine(min);
                }
                else
                {
                    arr[l] = r;
                    long mm = int.MaxValue;
                    for(int j = l-(l%size); j<arr.Length && j<(l-l%size)+size; j++)
                    {
                        mm = Math.Min(mm, arr[j]);
                    }
                    deco[l / size] = mm;
                }

            }





            

        }


        


        static void OPintArr(int[] a)
        {
            string[] ans = a.Select(c => c.ToString()).ToArray();
            Console.WriteLine(string.Join(" ",ans));
        }


    }


}

Measured memory_bytes: 18948
#include<stdio.h>
#include<string.h>

int main(void)
{
  char x,y,dammy;
  scanf("%c%c%c",&x,&dammy,&y);
  if(x>y)
    printf(">\n");
  else if(x<y)
    printf("<\n");
  else
    printf("=\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
#define INF 999999999999999999

int main(){
  ll N, M, R;
  cin >> N >> M >> R;

  vector<ll> r(N);
  for(ll i=0; i<R; ++i) cin >> r[i];

  vector<ll> row(N, INF);
  vector<vector<ll>> D(N, row);

  ll A, B, C;
  for(ll m=0; m<M; ++m) {
    cin >> A >> B >> C;
    D[A-1][B-1] = D[B-1][A-1] = C;
  }

  // for(ll i=0; i<N; ++i){
  //   for(ll j=0; j<N; ++j) cout << D[i][j] << " ";  cout<<endl;
  // }

  
  for(ll k=0; k<N; ++k)
  for(ll j=0; j<N; ++j)
  for(ll i=j+1; i<N; ++i)
    D[i][j] = D[j][i] = min(D[i][j], D[i][k]+D[k][j]);

  // for(ll i=0; i<N; ++i){
  //   for(ll j=0; j<N; ++j) cout << D[i][j] << " ";  cout<<endl;
  // }
  
  ll ans = INF;
  vector<ll> stack(100, -1);
  vector<bool> remove(100, false);
  ll nstack = R;
  for(ll ir=0; ir<R; ++ir) stack[ir]=ir;
  
  vector<bool> visited(R, false);
  vector<ll> path(R);
  ll npath = 0;

  while(nstack>0) {
    //for(ll j=0; j<nstack; ++j) cout << stack[j] << " "; cout << endl;
    
    ll ir = stack[nstack-1];
    if(remove[nstack-1]) {
      visited[ir] = false;
      --npath;
      --nstack;
      continue;
    }
    path[npath++] = ir;
    visited[ir] = true;
    remove[nstack-1] = true;
    for(ll i=0; i<R; ++i) if(!visited[i]) {
        stack[nstack] = i;
        remove[nstack] = false;
        ++nstack;
    }

    
    if(npath==R){
      ll dist = 0;
      for(ll i=0; i<R-1; ++i) dist += D[r[path[i]]-1][r[path[i+1]]-1];
      ans = min(ans, dist);
    }
    
  }

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


Measured memory_bytes: 512
#include <iostream>

using namespace::std;

int main()
{

	int N, K;
	cin >> N;
	cin >> K;

	int min_N = 2 * K - 1;

	if (N < min_N) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,ans;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	ans=a+(b*5)+(c*10)+(d*50)+(e*100)+(f*500);
	if(ans>=1000){
		printf("1\n");
	}
	else {
		printf("0\n");
	}
	//printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int main(){
    int n, t;
    double rez = 0;
    cin >> n;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> t, rez += 1.0 / t;
    printf("%.10f\n", 1 / rez);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n, k; cin >> n >> k;
    vi rsp(3); rep(i, 3) cin >> rsp[i];
    string t; cin >> t;
    vector<vi> T(k);
    rep(i, t.size()) {
        if (t[i] == 'r') T[i%k].push_back(0);
        if (t[i] == 's') T[i%k].push_back(1);
        if (t[i] == 'p') T[i%k].push_back(2);
    }

    int ans = 0;
    rep (j, k) {
        int sum = 0, former = 1;
        sum += rsp[(T[j][0] + 2) % 3];
        // cout << sum << endl;

        for (int i = 1; i < T[j].size(); i++) {

            if (T[j][i-1] == T[j][i]) {
                if (former) {
                    former = 0;
                    // cout << sum << endl;
                    continue;
                }
                else {
                    sum += rsp[(T[j][i]+2) % 3];
                    former = 1;
                }
            }
            else {
                sum += rsp[(T[j][i]+2) % 3];
                former = 1;
            }
            // cout << sum << endl;
        }
        ans += sum;
        // cout << endl;
    }
    
    cout << ans << endl;


    return 0;
}

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

int main() {
  string S;
  cin>>S;
  if(S[2]==S[3] and S[4]==S[5]){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int f(char *s,int a,int b){//printf("%d %d\n",a,b);
  int i;
  for(i=0;i+a<b;i++){//printf("%c %c\n",s[a+i],s[b-i-1]);
    if(s[a+i]!=s[b-i-1])return 0;
  }
  return 1;
}
int main(){
  char s[100010];
  int i;
  scanf("%s",s);
  for(i=0;s[i];i++);
  printf("%s\n",f(s,0,i)*f(s,0,(i-1)/2)*f(s,((i+3)/2)-1,i)?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
def fun(n,num,count):

    if count == (num*2)-1:
        return
    print(n,end=" ")
    count +=1
    fun(n+1,num,count)
xnum=list(map(int,input().split()))
x=xnum[1]
num=xnum[0]

m=x-(num-1)

fun(m,num,0)




Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s,ans="";
    cin>>s;
    int loop=s.size()/2;
    if(s.size()%2!=0)loop++;
    REP(i,loop){
        if(i==0){
            ans+=s[0];
            continue;
        }
        ans+=s[(2*i)];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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;}

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    cin >> s;
    
    if((ll)s.size()>=4&&s.substr(0,4)=="YAKI")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main () {

	int A[6];
  	int n = 5;
  
  	for (int i = 0; i < n; i++) {
    	scanf("%d", &A[i]);
    }
  
  	int a;
  	for (int i = 0; i < n; i++) {
    	if (A[i] == 0) {
        	a = i+1;
          	break;
        }
    }
  
  	std::cout << a << std::endl;
  	return 0;
}

Measured memory_bytes: 3672
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


int main() {
    int n, x;
    ll N,K;cin>>N>>K;
    if(K%2==0){
        vector<ll>G[N];
        for(int i=0;i<N-1;i++){
            ll a,b;cin>>a>>b;a--;b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        ll ans=INF;
        for(int i=0;i<N;i++){
            //iを中心とする直径距離を求める
            vector<ll>d(N,-1);
            queue<pair<ll,ll>>que;
            que.push(make_pair(i,0));
            d[i]=0;
            while(!que.empty()){
                ll u=que.front().first;
                ll dis=que.front().second;
                que.pop();
                for(int j=0;j<G[u].size();j++){
                    ll v=G[u][j];
                    if(d[v]!=-1)continue;
                    d[v]=dis+1;
                    que.push(make_pair(v,dis+1));
                }
            }
            ll num=0;
            for(int j=0;j<N;j++){
                if(d[j]>K/2)num++;
            }
            ans=min(num,ans);
        }
        cout<<ans<<endl;
        return 0;
    }
    
    //奇数
    vector<pair<ll,ll>>edge;
    vector<ll>G[N];
    for(int i=0;i<N-1;i++){
        ll a,b;cin>>a>>b;a--;b--;
        edge.push_back(make_pair(a,b));
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll ans=INF;

    for(int i=0;i<edge.size();i++){
        //iの辺が中心として距離を求める
        vector<ll>d(N,-1);
        queue<pair<ll,ll>>que;
        ll a=edge[i].first;
        ll b=edge[i].second;
        que.push(make_pair(a,0));
        que.push(make_pair(b,0));
        d[a]=0;
        d[b]=0;
        while(!que.empty()){
            ll u=que.front().first;
            ll dis=que.front().second;
            que.pop();
            for(int j=0;j<G[u].size();j++){
                ll v=G[u][j];                   
                if(d[v]!=-1)continue;
                d[v]=dis+1;
                que.push(make_pair(v,dis+1));
            }
        }
        ll num=0;
        for(int j=0;j<N;j++){
            if(d[j]>K/2)num++;
        }
        ans=min(num,ans);
    }

    cout<<ans<<endl;

    
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
 
typedef struct point{
  double x;
  double y;
} point;
 
int koch(int, point, point);
 
int num;
 
int main(){
  point p1, p2;
 
  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
 
  scanf("%d" ,&num);
 
  printf("%.8f ",p1.x);
  printf("%.8f\n", p1.y);
   
  koch(num, p1, p2);
 
  printf("%.8f ",p2.x);
  printf("%.8f\n", p2.y);
}
 
int koch(int n, point p1, point p2){
 
  point s, t, u;
  if(n == 0){
    return 0;
  }
   
  s.x = (2*p1.x + p2.x)/3;
  s.y = (2*p1.y + p2.y)/3;
  t.x = (p1.x + 2*p2.x)/3;
  t.y = (p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y) * sin(M_PI/3) + s.x;
  u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y) * cos(M_PI/3) + s.y;
   
 
  koch(n-1, p1, s);
  printf("%.8f ", s.x);
  printf("%.8f\n", s.y);
   
  koch(n-1, s, u);
  printf("%.8f ", u.x);
  printf("%.8f\n", u.y);
   
  koch(n-1, u, t);
  printf("%.8f ", t.x);
  printf("%.8f\n", t.y);
   
  koch(n-1, t, p2);
 
}



Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define mx 1e18
#define mod 1000000007
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll powe(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return powe(((x%mod)*(x%mod))%mod,n/2);
    else                             //n is odd
        return ((x%mod*(powe(((x%mod)*(x%mod))%mod,(n-1)/2))%mod)%mod);
}
int main()
{io
int n;cin>>n;vector<ll>a(n);vector<vector<ll>>dp(3005,vector<ll>(3005,0));
for(int i=0;i<n;i++)cin>>a[i];
for(int i=n-1;i>=0;i--)
{
    for(int j=i;j<=n-1;j++)
    {
        if(i==j)dp[i][j]=a[i];
        else
        dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
    }
}
cout<<dp[0][n-1]<<endl;


}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
    //dp[i][j] denotes the least weight to get a value of
   // j from the first i objects
   dp[0][0]=0;//It takes 0 weight here
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
      // Just set it arbitrarily large
       //because it's not possible 
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
                //Either don't choose this object(dp[i][j]) or choose this object
                //The value without it would be j-object[i].value
                //the minimum weight would be the minimum weight needed to
                //get a value of j- object[i].value and add the weight of this object.
           }
           else{
               //If I choose this object the value will go over j
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){//Is it possible to get value of j in less than w weight
               ans=max(ans,j);//Find maximum such j
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}


Measured memory_bytes: 82396
# coding: utf-8
# Your code here!


def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n:
                return n
    return i
    
def solve():
    left = 0
    right = 100000 * 10000
    mid = 0
    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right
    
tmp = list(map(int, input().split())) 
n = tmp[0]
k = tmp[1]
T = []
for i in range(n):
    T.append(int(input()))
ans = solve()
print(ans)
    






Measured memory_bytes: 9560
program ABC084B
    implicit none
    integer(8)::i,A,B
    integer(8)::flg=0
    character(11)::S
    read(5,*)A,B,S
    
    do i=1,A+B+1
        if(i==A+1)then
            if(S(i:i)/="-")then
                flg=1
                exit
            end if
        else if(S(i:i)/="0".and.S(i:i)/="1".and.S(i:i)/="2".and.S(i:i)/="3".and.S(i:i)/="4".and.S(i:i)/="5".and.S(i:i)/="6")then
            if(S(i:i)/="7".and.S(i:i)/="8".and.S(i:i)/="9")then
                flg=1
                exit
            end if
        end if            
    end do

    if(flg==0)then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
end program ABC084B

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    char prev = ' ';
    cin >> S;
    iter(c, S) {
        if(prev == 'A' && c == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
        prev = c;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    char S[100007];
    int y1=0,y0=0;
    cin >> S;
    rep(i,strlen(S)){
        if(S[i]=='1') y1++;
        else y0++;
    }
    cout << 2*min(y0,y1) <<endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;

const int jenny[] = {4, 1, 4, 1, 2, 1, 2, 1};

int main(void)
{
    int p[8];

    while (~scanf("%d", p)){
        int mini[8] = {max(p[0] - jenny[0], 0)};
        int sum = mini[0];
        int num = 0;

        for (int i = 1; i < 8; i++){
            scanf("%d", p + i);
            mini[i] = max(p[i] - jenny[i], 0);
            sum += mini[i];
        }
#ifdef DEBUG
        for (int i = 0; i < 8; i++) printf("%d ", p[i]);
        puts("");
#endif

        for (int i = 1; i < 8; i++){
            int tmp[8];
            int tsum = 0;
            for (int j = 0; j < 8; j++){
                tmp[j] = max(p[j] - jenny[(i + j) % 8], 0);
                tsum += tmp[j];
            }
#ifdef DEBUG
            printf("\n%d\n", i);
            for (int j = 0; j < 8; j++) printf("%d ", tmp[j]);
            printf(" %d\n", tsum);
            for (int j = 0; j < 8; j++) printf("%d ", jenny[(i + j) % 8]);
            puts("");
#endif
            if (sum > tsum){
                for (int j = 0; j < 8; j++) mini[j] = tmp[j];
                sum = tsum;
                num = i;
            }
            else if (sum == tsum){
                int v1 = 0, v2 = 0;
                for (int j = 0; j < 8; j++){
                    v1 = v1 * 10 + jenny[(num + j) % 8];
                    v2 = v2 * 10 + jenny[(i + j) % 8];
                }
                if (v1 > v2){
                    for (int j = 0; j < 8; j++) mini[j] = tmp[j];
                    num = i;
                }
            }
        }

        printf("%d", jenny[num]);
        for (int i = 1; i < 8; i++) printf(" %d", jenny[(num + i) % 8]);
        puts("");
    }

    return 0;
}

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

using namespace std;

int main(){
	int t=0;
	cin>>t;
	while(t-->0){
		int n=0,k=0,location=0,ans=0;
		vector<int> dist;
		cin>>n>>k>>location;
		for(int i=0;i<n-1;i++){
			int tmp=0;
			cin>>tmp;
			dist.push_back(tmp-location);
			location=tmp;
		}
		if(k>=n){
			cout<<0<<endl;
			continue;
		}
		sort(dist.begin(),dist.end());
		for(int i=0;i<dist.size()-k+1;i++){
			ans+=dist[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ok = true;
  if(s.at(2)!=s.at(3)){
    ok = false;
  }
  if(s.at(4)!=s.at(5)){
    ok = false;
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  int k;
  cin >> k >> s;
  if(s.size()<=k){
    cout << s << endl;
  }
  if(s.size()>k){
    for(int i=0;i<k;i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;

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

    int ans = 0;
    do {
        if (ord[0] != 0) continue;
        bool flag = true;
        for (int i = 0; i < N - 1; i++) {
            auto Iter = find(G[ord[i]].begin(), G[ord[i]].end(), ord[i + 1]);
            if (Iter == G[ord[i]].end()) flag = false;
        }
        if (flag) ans++;
    } while(next_permutation(ord.begin(), ord.end()));

    cout << ans << endl;
}


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

int main(){
	int n,r;
	while(cin>>n>>r &&n && r){
		vector<int>data;
		for(int i=1;i<=n;i++)data.push_back(i);
		for(int i=0;i<r;i++){
			int p,c;
			cin>>p>>c;
			stack<int>st;
			for(int j=0;j<c;j++){
				
				int tmp=data[n-p];
				data.erase(data.begin()+n-p++);
				st.push(tmp);
				
				}
			
			while(!st.empty()){
				data.push_back(st.top());st.pop();
			}
		}
		cout<<data[n-1]<<endl;
	}
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	string s; 
	cin >>n >>q >>s;
	VI sm(n+1);
	rep(i, n) sm[i+1] = sm[i] + (s.substr(i,2) == "AC");
	rep(i, q){
		int l, r;
		cin >>l >>r;
		cout << sm[r-1] - sm[l-1] <<"\n";
	}

	return 0;
}


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

int main(){
    string s,t,sc="",tc="";
    cin>>s>>t;
    vector<char> vs(s.size()),vt(t.size());
    for(int i=0;i<s.size();i++) vs[i]=s[i];
    for(int i=0;i<t.size();i++) vt[i]=t[i];
    sort(vs.begin(),vs.end());
    sort(vt.begin(),vt.end(),greater<char>());
    for(int i=0;i<s.size();i++) sc+=vs[i];
    for(int i=0;i<t.size();i++) tc+=vt[i];
    cout<<(sc<tc?"Yes":"No")<<endl;
    return 0;
}

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

//ABC174D

//ABC174C
int main(void) {
  int n, k, i, cou=0, tmp=0;
  scanf("%d", &k);
  while(tmp!=0||cou==0){
    tmp=tmp*10+7;
    tmp%=k;
    cou++;
    if(cou>1000100) break;
  }
  if(cou==1000101)printf("-1");
  else printf("%d", cou);
}

Measured memory_bytes: 1736
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std; 
int flag, n, A[100], N, s = 0; int j;
int main() {
	cin >> N;
	for (int i = 0; i < N;i++) {
		cin >> A[i];
	}
	flag = 1; // ????????£??\????´?????????¨??????
		while (flag) {
			flag = 0;
			for (j = N - 1; j > 0;j--) {
				if (A[j] < A[j - 1])
				{
					n=A[j];A[j] = A[j-1];A[j - 1] = n;
						flag = 1;
						s++;
				}
			}
			j = N - 1;
		}
		for (size_t j = 0; j < N-1; j++)
		{
			cout << A[j]<<" ";
		}
		cout << A[N - 1] << endl<<s<<endl;
			return 0;
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
char str[10];
int ans[4];
int main(void)
{
   cin>>str;
   int l = strlen(str);
   char op[4];
   for(int i = 0;i < 4;i++)
   {
   	ans[i] = str[i] - '0';
   }
   if(ans[0] + ans[1] + ans[2] + ans[3] == 7)
      printf("%d+%d+%d+%d=7",ans[0],ans[1],ans[2],ans[3]);
   else if(ans[0] + ans[1] + ans[2] - ans[3] == 7)
    printf("%d+%d+%d-%d=7",ans[0],ans[1],ans[2],ans[3]);
    else if(ans[0] + ans[1] - ans[2] + ans[3] == 7)
    printf("%d+%d-%d+%d=7",ans[0],ans[1],ans[2],ans[3]);
    else if(ans[0] + ans[1] - ans[2] - ans[3] == 7)
    printf("%d+%d-%d-%d=7",ans[0],ans[1],ans[2],ans[3]);
    else if(ans[0] - ans[1] + ans[2] - ans[3] == 7)
    printf("%d-%d+%d-%d=7",ans[0],ans[1],ans[2],ans[3]);
    else if(ans[0] - ans[1] + ans[2] + ans[3] == 7)
    printf("%d-%d+%d+%d=7",ans[0],ans[1],ans[2],ans[3]);
    else if(ans[0] - ans[1] - ans[2] + ans[3] == 7)
    printf("%d-%d-%d+%d=7",ans[0],ans[1],ans[2],ans[3]);
    else if(ans[0] - ans[1] - ans[2] - ans[3] == 7)
    printf("%d-%d-%d-%d=7",ans[0],ans[1],ans[2],ans[3]);
    return 0; 
}

Measured memory_bytes: 256
$n = gets.to_i
a,b,c = 3.times.map{gets.chomp.split(" ").map(&:to_i).sort}
cpb = Array.new(0)+b
b.reverse!
c.reverse!
count = 0
d = 0
for i in 0..$n-1
  if !(a.empty?) && cpb[i] > a[0]
    if cpb[i] <= a[-1]
      d = a.index{|num|num >= cpb[i]}
    else
      d = a.size
    end
    count += d
    a = a.drop(d)
  end
  cpb[i] = count
end
count = 0
for i in 0..$n-1
  if !(c.empty?) && b[i] < c[0]
    if b[i] >= c[-1]
      d = c.index{|num|num <= b[i]}
    else
      d = c.size
    end
    count += d
    c = c.drop(d)
  end
  b[i] = count
end
ans = 0
cpb.reverse!
for i in 0..$n-1
  ans += b[i]*cpb[i]
end
puts ans

Measured memory_bytes: 33448
import bisect

N = int(input())
a = list(map(int,input().split()))
a.sort()
a_max = a.pop()
idx = bisect.bisect_left(a,a_max/2)
if 1 <= idx and idx != N-1:
    if a_max/2-a[idx-1] < a[idx]-a_max/2:
        idx -= 1
print(a_max,a[idx] if idx < N-1 else a[N-2])

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

int main() {
int n,a,b;
cin >> n >> a>> b;
int ans = 0;
for(int i = 0;i < (n+1);i++){
  int p = i/10000+i%10000/1000+i%1000/100+i%100/10+i%10;

  if(p >= a&&b >= p){
    //cout << i <<endl;
    ans += i;
  }
}

cout << ans <<endl;
}



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

int isEmpty();
void push(int);
int pop();

int top=0,s[100];

int main(){
  int t1,t2;
  char c[10];

  while(scanf("%s",c)!=EOF){
    if(c[0]=='+'||c[0]=='-'||c[0]=='*'){
      t1=pop();
      t2=pop();
      if(c[0]=='+')t2+=t1;
      else if(c[0]=='-')t2-=t1;
      else if(c[0]=='*')t2*=t1;
      push(t2);
    }
    else push(atoi(c));
  }
  printf("%d\n",pop());
  return 0;
}

int isEmpty(){
  if(top==0)return 1;
  else return 0;
}

void push(int x){
  top++;
  s[top]=x;
}

int pop(){
  if(isEmpty()){
    fprintf(stderr,"underflow\n");
    exit(1);
  }
  else {
    top--;
    return s[top+1];
  }
}

Measured memory_bytes: 548
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;


int func(int n) {
    if (n % 2 == 0) {
        return n/2;
    }
    else {
        return 3*n + 1;
    }
}

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

    int s;
    cin >> s;
    int m = 1;
    unordered_map<int, bool> a;
    a[s] = true;
    while (true) {
        m++;
        s = func(s);
        auto itr = a.find(s);
        if (itr != a.end()) {
            break;
        }
        a[s] = true;
    }
    P(m);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main(){
	stack<char> s;
	string X;
	cin>>X;
	int N=(int)X.length();

	for (int i = 0; i < N; i++) {
		if(X[i]=='S'){
			s.push('S');
		}else{
			if(s.empty()){
				s.push('T');
			}else{
				if(s.top()=='S'){
					s.pop();
				}else{
					s.push('T');
				}
			}
		}
	}
	cout<<(int)s.size()<<endl;

	return 0;
}

Measured memory_bytes: 644
def main():
    A, B, C = map(int, input().split())
    lst = [False] * B

    num = 0
    for _ in range(B):
        num += A
        d = num % B

        if d == C:
            flag = True
            break

        if lst[d] == True:
            flag = False
            break

        lst[d] = True

    if flag == True:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    bool flag[1000000 + 1];
    int s;
    scanf("%d", &s);
    for (int j = 0; j <= 1000000; j++) {
        flag[j] = false;
    }
    flag[s] = true;

    int i = 1;
    while (true) {
        i++;
        s = (s % 2 == 0 ? s / 2 : 3 * s + 1);
        if (flag[s]) break;
        flag[s] = true;
    }
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
            c++;
            break;
        }
    }
    if(c==0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
ll ans;
int main(){
	scanf("%d%d",&n,&m);
	for(int b=m+1;b<=n;++b){
		int lim=n/b;
		for(int t=0;t<=lim;++t) {
			if(t*b+b-1<=n) ans+=b-m;
			else if(t*b+m<=n) ans+=n-t*b-m+1;
		}
//		cerr<<b<<' '<<ans<<endl;
	}
	if(m==0) ans-=n;
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, s, t);
  sort(all(s));
  sort(all(t), greater<>());
  print(s < t ? "Yes" : "No");
}


Measured memory_bytes: 256