akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int graph[200][200];
int V;

int main() {

    int M, R;
    cin >> V >> M >> R;
    int r[8];
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }
    sort(r, r + R);

    rep(i, V)rep(j, V)graph[i][j] = INF - 1000000000;
    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--, B--;
        graph[A][B] = graph[B][A] = C;
    }
    rep(k, V)rep(i, V)rep(j, V)graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);

    int ans = INF;
    do {
        int sum = 0;
        rep(i, R - 1)sum += graph[r[i]][r[i + 1]];

        ans = min(ans, sum);
    } while (next_permutation(r, r + R));

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

const int INF = 1e9;

int GetResult(const vector<int>& values) {
    const int n = values.size();
    int result = INF;
    int zeroCount = 0;
    for (int i = 0; i < n; ++i) {
        zeroCount += (values[i] == 0);
    }
    int curResult = 0;
    for (int i = 0; i < n; ++i) {
        if (values[i] == 0) {
            --zeroCount;
        } else {
            result = min(result, curResult + zeroCount);
            ++curResult;
        }
    }
    result = min(result, curResult);
    return result;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

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

    vector<int> minValuePos(n);
    minValuePos[0] = 0;
    for (int i = 1; i < n; ++i) {
        minValuePos[i] = minValuePos[i - 1];

        if (a[i] < a[minValuePos[i]]) {
            minValuePos[i] = i;
        }
    }

    vector<int> maxValuePos(n);
    maxValuePos[n - 1] = n - 1;
    for (int i = n - 2; i >= 0; --i) {
        maxValuePos[i] = maxValuePos[i + 1];

        if (a[i] > a[maxValuePos[i]]) {
            maxValuePos[i] = i;
        }
    }

    int maxDiff = 0;
    for (int i = 1; i < n; ++i) {
        maxDiff = max(maxDiff, a[i] - a[minValuePos[i]]);
    }

    int result = 0;
    vector<int> values;
    for (int i = 0; i < n; ++i) {
        if (a[maxValuePos[i]] - a[i] == maxDiff) {
            int l = i;
            int r = maxValuePos[i];

            values.clear();
            for (int t = l; t <= r; ++t) {
                if (a[t] == a[i]) {
                    values.push_back(1);
                } else if (a[t] == a[maxValuePos[i]]) {
                    values.push_back(0);
                }
            }

            result += GetResult(values);
            i = r;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1408
fun main(args: Array<String>) {
    val num = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val dice = DiceI(num[0],num[1],num[2],num[3],num[4],num[5])
    val count = readLine()?.toInt() ?: return
    for (i in (0 until count)) {
        val tempList = readLine()?.split(" ")?.map { it.toInt() } ?: return
        println(dice.getRight(top = tempList[0], front = tempList[1]))
    }
}

class DiceI (val one:Int,
             val two:Int,
             val three:Int,
             val four:Int,
             val five:Int,
             val six:Int){

    fun getRight(top: Int, front: Int) : Int {
        return when (top) {
            one -> when (front) {
                two   -> three
                three -> five
                four  -> two
                else  -> four
            }
            two   -> when (front) {
                one   -> four
                three -> one
                four  -> six
                else  -> three
            }
            three -> when (front) {
                one   -> two
                two   -> six
                five  -> one
                else  -> five
            }
            four  -> when (front) {
                one   -> five
                two   -> one
                five  -> six
                else  -> two
            }
            five  -> when (front) {
                one   -> three
                three -> six
                four  -> one
                else  -> four
            }
            else  -> when (front) {
                two   -> four
                three -> two
                four  -> five
                else  -> three
            }
        }
    }
}


Measured memory_bytes: 31100
#include <bits/stdc++.h>
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++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
  int  a[3][3];
  bool ans[3][3];
  REP(i,3)REP(j,3){
    cin>>a[i][j];
    ans[i][j]=0;
  }
 int n; cin>>n;
  REP(k,n){
    int b; cin>>b;

    REP(i,3)REP(j,3)if(a[i][j]==b)ans[i][j]=true;
  }
  bool flag=0;
  REP(i,3){
   if(ans[i][0]&&ans[i][1]&&ans[i][2])flag=1;
   if(ans[0][i]&&ans[1][i]&&ans[2][i])flag=1;
  }

  if(ans[0][0]&&ans[1][1]&&ans[2][2])flag=1;
  if(ans[0][2]&&ans[1][1]&&ans[2][0])flag=1;
  
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
   
}

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

using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    int a[n], total = 0;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        total += a[i];
    }
    double votes[n], counter = 0;
    for(int i=0; i<n; i++)
    {
         votes[i] = (double)a[i] / (double)total;
         if(votes[i] >= 1.0/(4.0*(double)m)) counter++;
    }
    if(counter >= m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    n -= a;
  }
  if (n < 0) cout << -1 << '\n';
  else cout << n << '\n';
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,e;
    cin>>a;
    e=a%10;
    d=a/10%10;
    c=a/100%10;
    b=a/1000;
    if(b+c+d+e==7)
        cout<<b<<"+"<<c<<"+"<<d<<"+"<<e<<"="<<"7"<<endl;
    else if(b+c+d-e==7)
        cout<<b<<"+"<<c<<"+"<<d<<"-"<<e<<"="<<"7"<<endl;
    else if(b+c-d+e==7)
        cout<<b<<"+"<<c<<"-"<<d<<"+"<<e<<"="<<"7"<<endl;
     else if(b-c+d+e==7)
        cout<<b<<"-"<<c<<"+"<<d<<"+"<<e<<"="<<"7"<<endl;
    else if(b-c-d+e==7)
        cout<<b<<"-"<<c<<"-"<<d<<"+"<<e<<"="<<"7"<<endl;
    else if(b-c+d-e==7)
        cout<<b<<"-"<<c<<"+"<<d<<"-"<<e<<"="<<"7"<<endl;
    else if(b+c-d-e==7)
        cout<<b<<"+"<<c<<"-"<<d<<"-"<<e<<"="<<"7"<<endl;
    else if(b-c-d-e==7)
        cout<<b<<"-"<<c<<"-"<<d<<"-"<<e<<"="<<"7"<<endl;
    return 0;
}


Measured memory_bytes: 256
using CompLib.Util;
using System;
using System.Runtime.InteropServices.ComTypes;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        string t = sc.Next();


        if (s.Length < t.Length)
        {
            Console.WriteLine("UNRESTORABLE");
            return;
        }

        bool flag = false;
        string ans = "";
        for (int i = 0; i < s.Length - t.Length + 1; i++)
        {
            bool f = true;
            char[] tmp = s.ToCharArray();
            for(int j = 0; j < t.Length; j++)
            {
                if(s[i+j] == '?')
                {
                    tmp[i + j] = t[j];
                }
                else
                {
                    if(s[i+j]!= t[j])
                    {
                        f = false;
                        break;
                    }
                }
            }

            if (f)
            {
                for (int j = 0; j < s.Length; j++)
                {
                    if(tmp[j] == '?')
                    {
                        tmp[j] = 'a';
                    }
                }
                string ss = new string(tmp);
                if (flag)
                {
                    ans = ans.CompareTo(ss) < 0 ? ans : ss;
                }
                else
                {
                    ans = ss;
                    flag = true;
                }
            }
        }
        Console.WriteLine(flag ? ans : "UNRESTORABLE");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  ll n,i;
  cin>>n;
  ll a[n+1];
  ll dp[n+1];
  dp[1]=0;
  for(i=1;i<=n;i++){
    cin>>a[i];
  }
  if(n==1){
    cout<<dp[1]<<endl;
  }
  else if(n==2){
    cout<<abs(a[1]-a[2])<<endl;
  }
  else{
    dp[2]=abs(a[1]-a[2]);
    dp[3]=min(abs(a[1]-a[3]),dp[2]+abs(a[2]-a[3]));
    for(i=4;i<=n;i++){
      dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
  }
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
char s[200000];
char c;
int t=0;

int main()
{
    while (1)
    {
        scanf("%c",&c);
        if (c!='0' && c!='1') break;
        s[t++]=c;
    }
    int ans1=0;
    int ans2=0;
    for (int i=0; i<t; ++i)
    {
        ans1+=(s[i]==((i%2)+'0'));
        ans2+=(s[i]==((i+1)%2+'0'));
    }
    cout<<min(ans1,ans2)<<endl;

    return 0;
}



Measured memory_bytes: 384
/* *	Argorithms and Data Structures
 *	Lectuire 8 
 *	Binary Search Tree II
 */

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>

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

void insert (int);
void print (Node *);
void printInorderTree (Node *);
void printPreorderTree (Node *);
void find (Node *,int);

struct Node *NIL, *root;

int main (void) {
	int i, m, k;
	char order[10];

	scanf("%d", &m);
	
	for (i=0; i<m; i++) {
		scanf("%s ", order);
		if (!strcmp (order, "insert") ){
			scanf("%d", &k);
			insert (k);
		} else if (!strcmp (order, "find")) {
			scanf("%d", &k);
			find (root, k);
		} else {
			print (root);
		}
	}
	return 0;
}

void insert (int key){
	Node *x = root,
		*y = NIL,
		*z;

	z = (Node*) malloc( sizeof(Node) );
	z->key = key;
	z->left = z->right = NIL;

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

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

void print(Node *T){
	printInorderTree (T);
	printf("\n");
	printPreorderTree (T);
	printf("\n");
}

void printInorderTree (Node* x) {
	if (x != NIL){
		printInorderTree (x->left);
		printf(" %d", x->key);
		printInorderTree (x->right);
	}
}

void printPreorderTree (Node* x) {
	if (x != NIL){
		printf(" %d", x->key);
		printPreorderTree (x->left);
		printPreorderTree (x->right);
	}
}

void find (Node *x, int key){
	while (x != NIL && key != x->key) {
		if (key < x->key)
			x = x->left;
		else if (key > x->key)
			x = x->right;
	}
	if (x != NIL){
		printf("yes\n");
	} else {
		printf("no\n");
	}
}

Measured memory_bytes: 19368
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
  int x[3];
  REP(i,0,2) cin>>x[i];
  sort(x,x+3);
  if(x[0]==5 && x[1]==5 && x[2]==7) cout<<"YES";
  else cout<<"NO"; 
}
int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3588
#include <iostream>
#include <queue>
#include <map>
#define N 100
#define NN 200
using namespace std;
#define S pair<int,int>

int main(){
  int t,n,x,y;
  int dx[6] = {1,0,1,-1,0,-1};
  int dy[6] = {0,1,1,0,-1,-1};

  while( cin>>t>>n && (t|n) ){
    int d[NN][NN];
    for( int i=0;i<NN;i++ )
      for( int j=0;j<NN;j++ )
	d[i][j] = 0;
    for( int i=0;i<n;i++ ){
      cin >> x >> y;
      d[y+N][x+N] = -1; // 障害物
    }
    cin >> x >> y; // 開始位置
    x+=N; y+=N;
    queue<S> q; q.push( S(x,y) ); d[y][x]=1;
    int ans=1; // 初期位置
    while( !q.empty() ){
      S s = q.front(); q.pop();
      if( d[s.second][s.first]<=t ){
	for( int i=0,nt=d[s.second][s.first]+1;i<6;i++ ){
	  int nx=s.first+dx[i], ny=s.second+dy[i];
	  if( d[ny][nx]==0 ){
	    q.push( S(nx,ny) ); d[ny][nx]=nt;
	    ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;




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

    vector<ll> A(N,0);
    vector<ll> B(N,0);
    ll Max=0;
    for(int i=0;i<N;i++){
        cin>>A[i];Max=max(Max,A[i]);B[i]=A[i]
    ;}
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    if(A[0]==A[1]){
        for(int i=0;i<N;i++){cout<<A[0]<<endl;
        ;}
    }
    else{
        ll mark=0;
        for(int i=0;i<N;i++){
            if(B[i]==Max){mark=i;break;}
        ;}
        for(int i=0;i<N;i++){
            if(i!=mark){cout<<Max<<endl;}
            else cout<<A[1]<<endl;
        ;}



    }


return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
 
template<typename key> using ordered_set = tree <key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
 
int main () {
   IO;
   int n;
   cin >> n;
   map< string, int > m;
   for(int i = 0; i < n; i++) {
      string s = "";
      cin >> s;
      m[s]++;
   }
   vector< pair< int, string > > v;
   for(auto &e : m)
      v.push_back({e.second, e.first});
   sort(v.rbegin(), v.rend());
   int mx = v[0].first;
   int i = 0;
   m.clear();
   while(i < v.size() && v[i].first == mx)
      m[v[i++].second]++;
   for(auto &e : m)
      cout << e.first << endl;
   return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  double ans = a[0];
  for (int i = 1; i < n; i++) {
    ans = (ans + a[i])/2;
  }
  cout << ans;
  return 0;
}

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

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

  int H, N;
  cin >> H >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  int sum = 0;
  rep(i,N) sum += A[i];
  if(H <= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+5, inf = 1e18+5;
int n, A[N], rt1, rt2, l, r, mid;
int get(int x){ for(int i=0;i<n;i++) x=x/A[i]*A[i]; return(x); }
int32_t main(){
    scanf("%lld", &n);
    for(int i=0;i<n;i++) scanf("%lld", &A[i]);
    l = 2, r = inf;
    while(r-l>0){
        mid = ((l+r)>>1LL);
        if(get(mid)>=2) r = mid;
        else l = mid+1;
    }
    rt1 = l;
    l = 2, r = inf;
    while(r-l>0){
        mid = ((l+r+1LL)>>1LL);
        if(get(mid)<=2) l = mid;
        else r = mid-1;
    }
    rt2 = l;
    if(get(rt2)^2) return !printf("-1");
    printf("%lld %lld", rt1, rt2);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
using P = pair <int, int>;


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
using namespace std;
using LL = long long;

int main(){
    int s;cin>>s;
    int yy,mm;
    yy = s/100;
    mm = s%100;

    if(yy <= 12 && yy>0 && mm <=12 && mm>0)cout<<"AMBIGUOUS"<<endl;
    else if(yy <= 12 && yy>0)cout<<"MMYY"<<endl;
    else if(mm<=12 && mm>0)cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
}

Measured memory_bytes: 256
import java.util.*; 
import java.lang.*; 
 
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
                int K = scan.nextInt();
                
                long[] cnt = new long[N+1];
                long ans = 0;
                
                long[] p = new long[N+1];
                long[] q = new long[N+1];
                
                p[0]=0;
                q[0]=N;
                cnt[0]=q[0]-p[0]+1;
                
                for(int i=1; i<=N; i++){
                      p[i] = p[i-1] + i;
                      q[i] = q[i-1] + N-i;
                      cnt[i] = q[i]-p[i]+1;
                }
                
                for(int i=K-1; i<=N; i++){
                ans = ans + cnt[i];
                }
               ans = ans%((10*10*10*10*10*10*10*10*10)+7);
                
                System.out.println(ans);
                
	}
}

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

using namespace std;

void solve(){
		
			
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int N,X,T;
    cin>>N>>X>>T;
    
    if(N%X==0)
		cout<<(N/X) * T;
	else
		cout<<((N/X)+1)*T;
    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    printf("%d\n",a[n/2+1]-a[n/2]);
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int x,y,s,i,j,max,bef1,bef2,aft1,aft2;

  for(;;){
    scanf("%d %d %d", &x, &y, &s);
    if(!(x|y|s)) break;

    max=0;
    for(i=1;i<s+1;i++){
      bef1=i*(100+x)/100;
      for(j=s;j>0;j--){
	bef2=j*(100+x)/100;
	if(bef1+bef2==s){
	  aft1=i*(100+y)/100;
	  aft2=j*(100+y)/100;
	  if(aft1+aft2>max) max=aft1+aft2;
	}
      }
    }
    printf("%d\n", max);
  }

  return 0;
}


Measured memory_bytes: 600
#include <functional>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 2000000000
int p[100100],c[100100],e[100100];
int dp[2][100100];//dp[i+1][j]:=i番目までの箱を使ってj個の饅頭
int main()
{
    int n,m;
    cin >> n >> m;
    int sum=0;
    for(int i=0;i<n;i++)cin >> p[i];
    for(int i=0;i<m;i++)cin >> c[i] >> e[i];
    sort(p,p+n,greater<int>());
    for(int i=0;i<n;i++)p[i+1]+=p[i];
    for(int i=0;i<2;i++)for(int j=0;j<=n;j++)dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=0;i<m;i++)for(int j=0;j<=n;j++)dp[(i+1)%2][j]=min(dp[i%2][j],dp[i%2][max(j-c[i],0)]+e[i]);
    int ans=0;
    for(int i=1;i<=n;i++)ans=max(ans,p[i-1]-dp[m%2][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1320
import numpy as np
# -*- coding: utf-8 -*-
A, B, C, K = map(int, input().split())
W = np.array([[0,1,1], [1,0,1], [1,1,0]])
bef_X = np.array([A, B, C])
aft_X = np.dot(np.linalg.matrix_power(W, K),  bef_X)

ans = aft_X[0] - aft_X[1]

print("{0}".format(ans if ans <= 10**18 else 'unfair'))

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

int main(void){
    long long n, a, b;
    long long ans;
    
    cin >> n >> a >> b;
    
    if(abs(a-b)%2 == 0){
        ans = abs(a-b)/2;
    } else {
        if(a < b){
            if(a-1 < n-b){
                ans = a-1 + abs((b-(a-1))/2);
            }else{
                ans = n-b + abs(((n-a+1)-(n-b))/2);
            }
        if(b <= a){
            if(b-1 < n-a){
                ans = b-1 + abs((a-(b-1))/2);
            }else{
                ans = n-a + abs(((n-b+1)-(n-a))/2);
            }
        }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

typedef long long ll;
ll ans;

void solve(string s, ll t) {
    if(s.empty()) {
        ans += t;
        return;
    }
    ll n = 0;
    for(int i = 0; i < (int)s.size(); i++) {
        n = n*10 + (s[i]-'0');
        solve(s.substr(i+1), t+n);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    while(cin >> s) {
        ans = 0;
        solve(s, 0);
        cout << ans << '\n';
    }
    return 0;
}

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

typedef long long ll;
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

long long GCD(long long x, long long y){
   long long r, tmp;
   if(x < y){
       tmp = x;
       x = y;
       y = tmp;
   }
   while(y!=0){
       r = x%y;
       x = y;
       y = r;
   }
   return x;
}
long long LCM(long long x, long long y){
   long long lcm = (x*y)/GCD(x, y);
   return lcm;
}

int bubblesort(int n){
    vector<int> data(n);
    int num=0;
    for(int end = n-1; end>0; end--){
        for(int j=0; j<end; j++){
            if(data[j+1] < data[j]){
                int temp = data[j];
                data[j] = data[j+1];
                data[j+1] = temp;
                num++;
            }
        }
    }
    return num;
}

int main(){
    int x;
    cin >> x;
    if(x==0){
        cout << 1 << endl;
    }
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3592
s = str(input())                                                
s_list = list(s)
answer = []
 
for i in range(len(s_list)):
    if s_list[i] == '0':
        answer.append('0')
    elif s_list[i] == '1':
        answer.append('1')
    elif s_list[i] == 'B':
        if len(answer) != 0:
            answer.pop(-1)
 
new_str = ''.join(answer)
print(new_str)

Measured memory_bytes: 3064
import heapq
N, M = map(int, input().split())

jobs = [[] for _ in range(M + 1)]
for _ in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue # M日の期間を越えるような仕事は請けない
    jobs[a].append(-b)

heap = []
salary = 0

for day in range(1, M + 1):
  for i in jobs[day]:
    heapq.heappush(heap, i)

  if len(heap) > 0:
    salary += abs(heapq.heappop(heap)) # heappopは常に最小のもの(一番絶対値の大きい)を返す

print(salary)

Measured memory_bytes: 17604
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = n;
    for(int i = 1; i <= 1e6; i++){
        if(n % i == 0){
            ll cand = i + n / i - 2;
            ans = min(ans, cand);
        }
    }
    cout << ans << '\n';
}


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


void solve(long long A, long long B){
    for(int i = 0; i < 1000000; i++)  {
        if(int(i * 0.08 ) == A && int(i * 0.1) == B) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
    return ;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
map<string, int> mp;
string s;
bool f;
int p;
int parse();
bool valid(int p) { return p < s.size(); }

int num()
{
	int res = 0;
	if (!valid(p) || !isdigit(s[p])) res = 1;
	else
	{
		while (isdigit(s[p]))
		{
			res *= 10;
			res += s[p] - '0';
			p++;
		}
	}
	return res;
}

int mol()
{
	int res = 0;
	if (valid(p) && isupper(s[p]))
	{
		string tmp;
		tmp += s[p];
		p++;
		if (valid(p) && islower(s[p]))
		{
			tmp += s[p];
			p++;
		}
		int n = num();
		if (mp.find(tmp) == mp.end()) f = false;
		else res += mp[tmp] * n;
	}
	return res;
}

int unit()
{
	int a, res;
	if (s[p] == '(')
	{
		p++;
		a = parse();
		p++;
		res = a*num();
	}
	else res = mol();
	return res;
}

int parse()
{
	int res = 0;
	while (valid(p)&&s[p]!=')') 
		res += unit();
	return res;
}

void solve()
{
	p = 0; f = true;
	int ans = parse();
	if(f) cout << ans << endl;
	else puts("UNKNOWN");
}

int main()
{
	string t;
	while (cin >> t&&t != "END_OF_FIRST_PART")
	{
		int n; cin >> n;
		mp[t] = n;
	}
	while (cin >> s&&s != "0") solve();
	return 0;
}

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

int main()
{
	int a[10];
	int data_size = sizeof(a) / sizeof(a[0]) - 1;
	for (int i=0;i<=data_size;i++)
		cin >> a[i];
	sort(a,a+sizeof(a) / sizeof(a[0]));
	for (int j=0;j<=3-1;j++)
		cout << a[data_size-j] << endl;
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll n,p[200000],count=0,max=pow(10,9);
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>p[i];
    if(p[i]<max){
      max=p[i];
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}

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

typedef long long ll;
ll lh[100001];
ll n, a, b;

bool check(ll k) {
  ll attack = 0;
  ll damage_b = b*k;
  for (int i = 0; i < n; ++i) {
    ll h = max((ll)0, lh[i] - damage_b);
    attack += (h+a-b-1)/(a-b);
    if (attack > k) return false;
  }
  // cout << k << " " << damage_b << " " << attack << endl;
  return attack <= k;
}

// 汎用的な二分探索のテンプレ
int binary_search() {
    ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = 1e9+1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (check(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) {
    cin >> lh[i];
  }
  ll ans = binary_search();
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){
int n, m, l;
	cin >> n >> m >> l;

	int **A = new int*[n];
	int **B = new int*[m];
	long **C = new long*[n];

	for (int i = 0; i < n; i++)
		A[i] = new int[m];
	for (int i = 0; i <m; i++)
		B[i] = new int[l];
	for (int i = 0; i < n; i++)
		C[i] = new long[l];


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

	for (int i = 0; i < n; i++)
		for (int j = 0; j < l; j++)
			C[i][j] = 0;


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			    cout  << C[i][j];
                            if(j < l-1) cout << " ";
		}
		cout << endl;
	}


	for (int i = 0; i < n; i++)
		delete[] A[i];
	for (int i = 0; i < m; i++)
		delete[] B[i];
	for (int i = 0; i < n; i++)
		delete[] C[i];


	delete[] A;
	delete[] B;
	delete[] C;
 return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int main()
{
     string s;
     cin>>s;
     int c=0;
     for(int i=0;i<6;i++)
     {

         if(s[2]==s[3]&& s[4]==s[5])
         {
             c++;
         }
     }
     if(c>0){
         cout<<"Yes"<<endl;
         }
         else
            cout<<"No"<<endl;
}


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

int main()
{
    ll n ,counter=0;
    cin >> n;
    vector<ll> l(n);
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
  	reverse(l.begin(), l.end());
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(l[i] < l[j] + l[k]){
                    counter ++;
                }else{
                    break;
                }
            }
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] str;
        int a, b, temp;
        for (var i = 1; ; i++)
        {
            str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if (a==0&&b==0) break;
            else if (a > b) { temp = a; a = b; b = temp; }
            Console.WriteLine("{0} {1}", a, b);
         }
    }
}


Measured memory_bytes: 8632
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int m, f, r;
	int s;

	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;

		if (m < 0 || f < 0) puts("F");
		else {
			s = m + f;
			if (s >= 80) puts("A");
			else if (s >= 65) puts("B");
			else if (s >= 50) puts("C");
			else if (s < 30) puts("F");
			else puts(r >= 50 ? "C" : "D");
		}
	}
	return 0;
}



Measured memory_bytes: 2044
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii,
       std.typecons;
// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {}
  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n = cin.next!int;
  auto s = cin.nextArray!(string)(n);
  int m = cin.next!int;
  auto t = cin.nextArray!(string)(m);
  auto a = s ~ t;
  int ma = 0;
  foreach(i; a) {
    int cnt;
    foreach(j; s) {
      if (j == i) cnt++;
    }
    foreach(j; t) {
      if (j == i) cnt--;
    }
    ma = max(ma, cnt);
  }
  writeln(ma);
}


Measured memory_bytes: 256
n = int(input())
s = []
if n != 0:
    while abs(n) > 0:
        if n%2 != 0:
            s.append(str(-(n%(-2))))
            n = n//(-2) + 1
        else:
            s.append(str(-(n%(-2))))
            n = n//(-2) 
else:
    s = "0"
print("".join(s[::-1]))

Measured memory_bytes: 3060
N = input()
T, A = map(int, input().split())
temperatures = list(map(int, input().split()))
 
r = 50000000000000
results = ''
 
list = [T - t * 0.006 for t in temperatures]
for index, avg_temp in enumerate(list):
    ondo_sa = avg_temp - A
 
    if ondo_sa < 0:
        ondo_sa = - ondo_sa
 
    if r > abs(ondo_sa):
        r = ondo_sa
        results = index + 1
print(results)

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    int mul = (n + x - 1) / x;
    cout << mul * t << '\n';
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;

signed main(){
    int A,B,K;
    cin >> A >> B >> K;
    REP(i,K/2){
        B+=A/2;
        A/=2;
        A+=B/2;
        B/=2;
    }
    if(K%2==1){
        B+=A/2;
        A/=2;
    }
    
    cout << A << " " << B << endl;
    
    return 0;
}   


Measured memory_bytes: 764
c = [list(map(int, input().split())) for _ in range(3)]

flag = True
for i in range(3):
    if abs(sum(c[i - 1]) - sum(c[i])) % 3 != 0:
        flag = False
        break

if flag:
    SUM = [
        c[0][0] + c[1][0] + c[2][0],
        c[0][1] + c[1][1] + c[2][1],
        c[0][2] + c[1][2] + c[2][2],
    ]
    for i in range(3):
        if abs(SUM[i - 1] - SUM[i]) % 3 != 0:
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

typedef pair<int,int> PA;
typedef pair<long long,PA> PPA;

const long long INF = 1000010000100001;

int r,w,h;
long long masu[510][510];
bool b[510][510];
long long min_cost[2][100010];
priority_queue<PPA,vector<PPA>,greater<PPA> > pq;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

void solve(int k){
    
    for(int i=1;i<=r;i++){
        min_cost[k][i] = INF;
    }
    min_cost[k][0] = 0;
    
    long long ma = 1;
    int cnt = 1;
    while(!pq.empty() && cnt <= r){
        
        PPA pp = pq.top();
        pq.pop();
        PA p = pp.second;
        if(b[p.second][p.first]) continue;
        b[p.second][p.first] = true;
        
        ma = max(ma,pp.first);
        min_cost[k][cnt] = ma;
        
        for(int i=0;i<4;i++){
            int x = p.first + dx[i];
            int y = p.second + dy[i];
            if(x<1 || y<1 || x>w || y>h) continue;
            pq.push( PPA(masu[y][x],PA(x,y)) );
        }
        cnt++;
    }
    
    while(!pq.empty()) pq.pop();
    
}

int main(){
    
    int x,y;
    
    while(cin >> r,r!=0){
        cin >> w >> h >> x >> y;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> masu[i][j];
                b[i][j] = false;
            }
        }
    
        pq.push( PPA(1,PA(x,y)) );
        solve(0);
    
        cin >> w >> h >> x >> y;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> masu[i][j];
                b[i][j] = false;
            }
        }
    
        pq.push( PPA(1,PA(x,y)) );
        solve(1);
    
        long long ans = INF;
        for(int i=0;i<=r;i++){
            ans = min(ans,min_cost[0][i]+min_cost[1][r-i]);
        }
    
        cout << ans << endl;
    }
    return(0);
}


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

typedef long long ll;

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

    ll asum = 0;
    ll bsum = 0;
    for(int i=0; i<N; i++) asum += A[i];
    for(int i=0; i<N; i++) bsum += B[i];

    if(asum < bsum){
        cout<<-1<<endl;
    }

    else{
        ll ans = 0;
        ll sum = 0;
        vector<ll> dif;
        for(int i=0; i<N; i++){
            if(B[i] > A[i]){
                sum += abs(A[i] - B[i]);
                ans++;
            }
            else if(B[i] < A[i]) dif.push_back(A[i] - B[i]);
        }

        if(ans == 0){
            cout<<ans<<endl;
            return 0;
        }

        sort(dif.begin(),dif.end(),greater<ll>());

        for(auto a : dif){
            if(sum > a){
                ans++;
                sum -= a;
            }else{
                ans++;
                break;
            }
        }

        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 5468
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
const int MN=2e5+5;
int n,nxt[MN][26],f[MN];
char S[MN];
int main(){
	scanf("%s",S+1);n=strlen(S+1);
	memset(nxt,-1,sizeof(nxt));
	for(register int i=n;i;i--)
		for(register int j=0;j<26;j++)
			nxt[i][j]=(S[i]==j+'a'?i:nxt[i+1][j]);
	memset(f,0x3f,sizeof(f));
	for(register int i=n;i;i--){
		for(register int j=0;j<26;j++){
			if(nxt[i][j]==-1){f[i]=1;break;}
			f[i]=min(f[i],f[nxt[i][j]+1]+1);
		}
	}
	register int len=f[1],pos=1;
	while(len--){
		if(!len)for(register int i=0;i<26;i++)
				if(nxt[pos][i]==-1)return 0*putchar(i+'a');
		for(register int i=0;i<26;i++)
			if(f[pos]==f[nxt[pos][i]+1]+1){
				pos=nxt[pos][i]+1;
				putchar(i+'a');break;
			}
	}
	return 0;
}

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

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;

	bool ok = false;

	for(int i = 0; i <= x; ++i) {
		if(2 * i + 4 * (x - i) == y) {
			ok = true;
		}
	}

	if(ok) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <iomanip>

using namespace std;
typedef long long ll;

int main() {
  double a, b, x;
  
  cin >> a >> b >> x;
  cout<<std::fixed<<std::setprecision(10);
  
  double m = x / a;
  if((a * b / 2) >= m) {
    double h = m / b * 2;
    cout << 90 - atan(h / b) * 180 / M_PI;
    return 0;
  }
  
  m = m - (a*b)/2;
  m = (a*b)/2 - m;
  
  double h = m / a * 2;
  cout << atan(h / a) * 180 / M_PI;
 
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M == 2:
    print(0)
elif M == 1 and N == 2:
    print(0)
elif N == 1 and M > 2:
    print(M-2)
elif M == 1 and N > 2:
    print(N-2)
elif N == 2 and M == 2:
    print(0)

elif N == 2 and M > 2:
    print(0)
elif M == 2 and N > 2:
    print(0)
else:
    print(N*M-(N*2+M*2)+4)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
void solve()
{

}
int main()
{
    int n; cin >> n;
    int ar[n+5] = {};
    for(int i = 1; i <= n; i++)
    {
        cin >> ar[i];
    }
    int Count = 0;
    for(int i = 1; i <= n-2; i++)
    {
        for(int j = i+1; j <= n-1; j++)
        {
            set<int>ss;
            for(int k = j+1; k <= n; k++)
            {

                ss.insert(ar[i]);
                ss.insert(ar[j]);
                ss.insert(ar[k]);
                if(ss.size() == 3)
                {
                    //cout << i << " " << j << " " << k << endl;
                    if((ar[i]+ar[j]) > ar[k] && (ar[i]+ar[k]) > ar[j] && (ar[j]+ar[k]) > ar[i])
                    {
                        Count++;
                    }
                    //Count++;
                }
                ss.clear();
            }
        }
    }
    cout << Count << endl;
    return 0;
}


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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    } else {
      string row1(W, '#');
      string row_intermediate(W - 2, '.');
      string row2 = "#" + row_intermediate + "#";

      cout << row1 << endl;
      for (int i = 0; i < H - 2; i++) {
        cout << row2 << endl;
      }
      cout << row1 << endl << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
using namespace std;

int main(){
	int N,T,i,a,cnt;

	vector<int> t;

	cin>>N>>T;
	
	cnt=T;

	REP(i,N){
		cin>>a;
		t.pb(a);
	}

	REP(i,N-1){
		cnt+=min(t[i+1]-t[i],T);
	}
	
	cout<<cnt<<endl;
   	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;





int main()
{
	int a[4], b[4];
	int u[4];
	int hit, blow;
	while (cin >> a[0]) {
		cin >> a[1] >> a[2] >> a[3];
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		fill(u, u + 4,-1);
		hit = blow = 0;
		for (int i = 0; i < 4; i++) {
			if (a[i] == b[i]) {
				hit++;
				u[i] = 1;
			}
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if ( u[i] == -1&&a[i]==b[j]) {
					blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
}

Measured memory_bytes: 1156
local x, k, d = io.read("*n", "*n", "*n")
x = math.abs(x)
local a = x // d
if k <= a then
  print(x - d * k)
else
  k = k - a
  x = x - d * a
  if k % 2 == 0 then
    print(x)
  else
    print(d - x)
  end
end


Measured memory_bytes: 2796
#include <bits/stdc++.h>
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (T&& t) noexcept
      : T(std::forward<T>(t)) {}
    template<typename... Args>
    constexpr decltype(auto) operator()(Args&&... args) const
      {return T::operator()(*this, std::forward<Args>(args)...);}
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{std::forward<T>(t)};
}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (auto& x : a){std::cin >> x;}
  auto dfs = fix ([&](
      auto dfs,
      int l, int r, int lw, int rw
    ) -> long long
    {
      assert(l < r);
      if (l + 1 == r) return 0LL;
      constexpr long long inf = 1LL << 60;
      long long ret = inf;
      for (int c = l + 1; c < r; c++) {
        ret = std::min(ret,
            dfs(l, c, lw, lw + rw) +
            dfs(c, r, lw + rw, rw) +
            (long long)a.at(c) * (lw + rw)
          );
      }
      return ret;
    });
  std::cout << dfs(0, n - 1, 1, 1) + a.front() + a.back() << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

bool judge(int i) {
  int digit0 = i % 10;
  int digit1 = (i % 100) / 10;
  int digit3 = (i % 10000) / 1000;
  int digit4 = (i % 100000) / 10000;

  return digit4 == digit0 && digit3 == digit1;
}

int main() {
  int a, b;

  std::cin >> a;
  std::cin >> b;

  int ans=0;
  for (int i=a; i<=b; i++) {
    if (judge(i)) ans++;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256