akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())

result = ["" for _ in range(N)]

ls = [list(map(int, input().split())) for _ in range(M)]

save = []

result = -1

if N == 1:
    START = 0
else:
    START = 10 ** (N - 1)
END = 10 ** (N)

for n in range(START, END):
    if all([str(n)[e[0] - 1] == str(e[1]) for e in ls]):
        result = n
        break

print(result)


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

using namespace std;

int main(){
    int n, k, m;
    while (cin >> n >> k >> m && n | k | m){
        vector<int> rest(n);
        for (int i = 0; i < n; i++){
            rest[i] = i + 1;
        }
        int cur = m - 1;
        while (rest.size() != 1){
            // cout << *(rest.begin() + cur) << endl;
            rest.erase(rest.begin() + cur);
            cur = (cur + k - 1) % rest.size();
        }
        cout << rest.front() << endl;
    }
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
typedef pair<int, int> pii;
vector<pii> adj[maxn];
int ans[maxn], k;
void dfs(int cur, int p, int color) {
    int col = 1;
    for (int i = 0; i < adj[cur].size(); ++i) {
        int next = adj[cur][i].first, ind = adj[cur][i].second;
        if (next == p)
            continue;
        if (col == color)
            ++col;
        ans[ind] = col;
        k = max(k, ans[ind]);
        ++col;
        dfs(next, cur, ans[ind]);
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b;
        adj[a].emplace_back(b, i);
        adj[b].emplace_back(a, i);
    }
    dfs(1, -1, 0);
    cout << k << '\n';
    for (int i = 0; i < n - 1; ++i)
        cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 9344
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

class peak():
    def __init__(self, loc, elevation):
        self.loc = loc
        self.elevation = elevation
        self.next_high = None


def peak_append(peak_list, loc, elevation):
    p = peak(loc, elevation)
    peak_list.append(p)
    return

def peak_set_next_high(peak_list):
    next_high = peak_list[-1]   # last peak
    for i in range(len(peak_list)-2, -1, -1):
        peak_list[i].next_high = next_high
        if peak_list[i].elevation >= next_high.elevation:
            next_high = peak_list[i]


def find_flood(elev_list, peak_list):
    peak_p = peak_list.pop(0)
    next_high = peak_p.next_high
    if not next_high:
        return None, None
    q_elev = next_high.elevation
    p_elev = peak_p.elevation

    if p_elev > q_elev:
        q_offset = next_high.loc
        p_offset = peak_p.loc
        while p_offset < len(elev_list):
            if elev_list[p_offset] == elev_list[q_offset]:
                return p_offset, q_offset
            p_offset += 1
        else:
            return None, None
    else:
        p_offset = peak_p.loc
        q_offset = elev_list.index(p_elev, p_offset+1)
        return p_offset, q_offset
    raise "Logic Error"


def calc_area(p, q, elev_list):
    elev_0 = elev_list[p]
    area = 0

    prev_elev = 0
    for x in range(p, q+1):
        elev = elev_list[x] - elev_0
        area += elev

    return (abs(area))


def adjust_peak_list(q, peak_list):
    while peak_list:
        if peak_list[0].loc >= q:
            return
        peak_list.pop(0)


s = list(sys.stdin.readline().strip())

flood_area = list()
peak_list = list()

ascending = True
elevation = 0
elev_list = list()

for i in range(len(s)):
    elev_list.append(elevation)

    if s[i] == '_':
        pass
    elif s[i] == '/':
        ascending = True
        elevation += 1
    elif s[i] == '\\':
        if ascending:
            peak_append(peak_list, i, elevation)
        ascending = False
        elevation -= 1

elev_list.append(elevation)

if ascending:
    peak_append(peak_list, len(s), elevation)

peak_set_next_high(peak_list)

while peak_list:
    p, q = find_flood(elev_list, peak_list)
    if p == None:
        break
    flood_area.append(calc_area(p, q, elev_list))
    adjust_peak_list(q, peak_list)
    
print(sum(flood_area))
print(len(flood_area), end='')
for i in range(len(flood_area)):
    print(' ', flood_area[i], sep='', end='')
print()



Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	double x, y; cin >> x >> y;
	cout << ceil((x + y) / 2) << endl;
	return 0;
}

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

ll now,n,k;

ll mnhtn(ll xx,ll yy,ll x0,ll y0){
  return abs(xx-x0)+abs(y0-yy);
}

int main(){
  ll x,y,myx=0LL,myy=0LL;
  cin >> k>>x>>y;
  if (k%2==0){
    if ((x+y+200000)%2==1){
      cout<<"-1"<<endl;
      return 0;
    }
  }
  vector<ll> ansy(200001);
  vector<ll> ansx(200001);
  ll answ=0;

  ll kk=k;
  ll le=mnhtn(x,y,myx,myy);

  REP(i,200002){
    if ((myy==y)&(myx==x))break;
    kk=k;
    le=mnhtn(x,y,myx,myy);
    if (le<k*2){
      if (le==k){
        ansx[answ]=x;ansy[answ]=y;answ++;
        break;
      }
      
    if (k%2==1){
          if (le%2==1){
            //なるべくxを近づける
            kk=min(abs(x-myx),k);
            myx+=kk*((x>myx)*2LL-1);
            kk=k-kk;//y移動分
            myy+=kk*((y>myy)*2LL-1);
            ansx[answ]=myx;ansy[answ]=myy;answ++;
            continue;
          }
        }
      //距離微調整

      int s=(2*k-le)/2;
      int flg=0;
      if (mnhtn(x,y,myx+k-s,myy  -s)==k){ansx[answ]=myx+k-s;ansy[answ]=myy-s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      if (mnhtn(x,y,myx+k-s,myy  +s)==k){ansx[answ]=myx+k-s;ansy[answ]=myy+s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      if (mnhtn(x,y,myx  -s,myy+k-s)==k){ansx[answ]=myx-s;ansy[answ]=myy+k-s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      if (mnhtn(x,y,myx  +s,myy+k-s)==k){ansx[answ]=myx+s;ansy[answ]=myy+k-s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      if (mnhtn(x,y,myx-k+s,myy  -s)==k){ansx[answ]=myx-k+s;ansy[answ]=myy-s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      if (mnhtn(x,y,myx-k+s,myy  +s)==k){ansx[answ]=myx-k+s;ansy[answ]=myy+s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      if (mnhtn(x,y,myx  -s,myy-k+s)==k){ansx[answ]=myx-s;ansy[answ]=myy-k+s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      if (mnhtn(x,y,myx  +s,myy-k+s)==k){ansx[answ]=myx+s;ansy[answ]=myy-k+s;answ++;ansx[answ]=x;ansy[answ]=y;answ++;break;}
      
      //ansx[answ]=myx;ansy[answ]=myy;answ++;
      //ansx[answ]=x;ansy[answ]=y;answ++;
      //break;
    }else{
    
      /*
      if (myx==x){
        ll y2=(y-myy)/2;
        myy+=y2;
        myx+=(k-abs(y2));
        ansx[answ]=myx;ansy[answ]=myy;answ++;
        myy+=y2;
        myx-=(k-abs(y2));
        ansx[answ]=myx;ansy[answ]=myy;answ++;
        break;
      }
      if (myy==y){
        ll x2=(x-myx)/2;
        myx+=x2;
        myy+=(k-abs(x2));
        ansx[answ]=myx;ansy[answ]=myy;answ++;
        myx+=x2;
        myy-=(k-abs(x2));
        ansx[answ]=myx;ansy[answ]=myy;answ++;
        break;
      }
      if ((myx!=x)&(myy!=y)){
        kk=min(abs(x-myx),k);
        myx+=kk*((x>myx)*2-1);
        kk=k-kk;//y移動分
        myy+=kk*((y>myy)*2-1);
        ansx[answ]=myx;ansy[answ]=myy;answ++;
      }
       */

    
      //なるべくxを近づける
      kk=min(abs(x-myx),k);
      myx+=kk*((x>myx)*2-1);
      kk=k-kk;//y移動分
      myy+=kk*((y>myy)*2-1);
      ansx[answ]=myx;ansy[answ]=myy;answ++;
    }

    
  }



  cout<<answ<<endl;
  REP(i,answ){
    cout<<ansx[i]<<" "<<ansy[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 5376
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,a,b,count=0;
    cin>>n>>a>>b;
    if(a==0){
    	cout<<0<<endl;
    	return 0;
    }else{
        count=((n/(a+b))*a);
        if((n%(a+b))==0){
        	cout<<count<<endl;
        	return 0;
        }else{
        	long long int x=(n%(a+b));
             if(x>=a){
             	count+=a;
             }else{
             	count+=x;
             }
        }
    }
    cout<<count<<endl;
    return 0;
  }

Measured memory_bytes: 3592
k = 0
a = 0
b = 0
for i in range(6):
  t = int(input())
  if(i == 0):
    a = t
  elif(i == 4):
    b = t
  elif(i == 5):
    k = t

if(b - a > k):
  print(':(')
else:
  print('Yay!')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int D, c[27];
int s[366][27];

chrono::steady_clock::time_point program_begin;

double runtime() {
	chrono::steady_clock::time_point program_end = chrono::steady_clock::now();

	return chrono::duration_cast<chrono::microseconds>(program_end - program_begin).count() / 1000000.0;
}

int calc(vector<int> sc) {
	vector<int> last(27, 0);
	int val = 0;
	rep(d, 1, D + 1) {
		val += s[d][sc[d]];
		last[sc[d]] = d;
		rep(i, 1, 27)
			val -= c[i] * (d - last[i]);
	}
	return val;
}

int myrand(int a, int b) {
	return a + rand() % (b - a + 1);
}

void solve() {
	vector<int> ans(366), best_ans(366);
	int best_ans_val = -50000000;
	int cur_val = calc(ans);

	for (int i = 1; i <= 365; i++)
		ans[i] = i % 26 + 1;

	{
		int val = calc(ans);
		if (val > best_ans_val) {
			best_ans_val = val;
			best_ans = ans;
		}
	}

	double T1 = 0.5;

	auto rng = default_random_engine {};
	while (runtime() <= 0.2) {
		for (int i = 1; i + 25 <= 365; i += 26) {
			shuffle(ans.begin() + i, ans.begin() + i + 26, rng);
		}

		int val = calc(ans);
		if (val > best_ans_val) {
			best_ans_val = val;
			best_ans = ans;
		}
	}
	while (runtime() <= T1) {
		for (int i = 1; i <= 365; i++)
			ans[i] = myrand(1, 26);

		int val = calc(ans);
		if (val > best_ans_val) {
			best_ans_val = val;
			best_ans = ans;
		}
	}

	ans = best_ans;
	cur_val = best_ans_val;

	while (runtime() <= 1.8) {
		int d = myrand(1, 365), n = myrand(1, 26);
		if (ans[d] == n)
			continue;
		vector<int> new_ans = ans;
		new_ans[d] = n;
		int new_val = calc(new_ans);
		double base_proc = exp(-10.0 * (runtime() - T1) / 1.8);
		double rand_double = 1.0 * rand() / RAND_MAX;
		bool accept =
			rand_double < base_proc * (1.0 * new_val / best_ans_val);
		if (new_val > cur_val || accept) {
			ans = new_ans;
			cur_val = new_val;

			if (chmax(best_ans_val, cur_val)) {
				best_ans_val = cur_val;
				best_ans = ans;
			}
		}
	}

	rep(i, 1, D + 1)
		write(best_ans[i]);
}

void test() {}

int main(int argc, char *argv[]) {
	//cin.tie(0)->sync_with_stdio(0);
	//cin.exceptions(cin.failbit);

	srand(time(NULL));

	program_begin = chrono::steady_clock::now();

	read(D);
	rep(i, 1, 27) read(c[i]);
	rep(i, 1, D + 1) rep(j, 1, 27) read(s[i][j]);
	
	solve();
}


Measured memory_bytes: 4356
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
using namespace atcoder;
void Main()
{
    ll n, Q;
    cin >> n >> Q;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    fenwick_tree<ll> fw(n);
    rep(i, n) {
        fw.add(i, a[i]);
    }
    
    rep (i, Q) {
        ll x, y, z;
        cin >> x >> y >> z;
        if (x == 0) {
            fw.add(y, z);
        }
        else {
            put(fw.sum(y, z));
        }
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 12128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  char A[H][W],R[H][W],B[H][W];
  REP(i,H){
    REP(j,W){
      cin>>A[i][j];
      R[i][j]='.';
      B[i][j]='.';
    }
  }
  
  REP(i,H){
    R[i][0]='#';
    B[i][W-1]='#';
    if(i%2==0) RREP(j,W-2) R[i][j]='#';
    else RREP(j,W-2) B[i][j]='#';
  }
  
  REP(i,H){
    REP(j,W){
      if(A[i][j]=='#'){
        R[i][j]='#';
        B[i][j]='#';
      }
    }
  }
  
  
  REP(i,H){
    REP(j,W) cout<<R[i][j];
    cout<<endl;
  }
  
  cout<<endl;
  
  REP(i,H){
    REP(j,W) cout<<B[i][j];
    cout<<endl;
  }
  
  return 0;
}

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

using namespace std;

int l[100005], r[100005], a[100005];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	
	for (int i = 1; i <= n; i++) l[i] = __gcd(a[i], l[i - 1]);
	for (int i = n; i >= 1; i--) r[i] = __gcd(a[i], r[i + 1]);
	
	int res = 0;
	
	for (int i = 1; i <= n; i++) {
		int gcd = __gcd(l[i - 1], r[i + 1]);
		res = max(res, gcd);
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 1408
#include<stdio.h>
int main() {
  int a[4], b[5];
  int i, j, hit, blow;
  b[4] = -1;
  while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) {
    hit = 0; blow = 0;
    scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
    for (i = 0; i < 4; i ++) {
      for (j = 0; a[i] != b[j] && j < 4; j ++);
      if (j < 4) {
	if (i == j) hit += 1;
	else blow += 1;
      }
    }
    printf("%d %d\n", hit, blow);
  }
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
using namespace std;
string s;
bool b[26];
int main(){
  cin>>s;
  for(int i=0;i<s.size();i++){
    b[s[i]-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!b[i]){
      cout<<char(i+'a');
      return 0;
    }
  }
  cout<<"None";
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a<b){
		    System.out.println("a < b");
		}else if(a>b){
		    System.out.println("a > b");
		}else if(a == b){
		    System.out.println("a == b");
		}
    }
}


Measured memory_bytes: 26196
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define bitget(a, b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(), x.end())

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

int main() {
	string s,ans;
	cin >> s;
	rep(i, 0, s.length()){
		cout << s[i];
		++i;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define arr_ip for(int i=0;i<n;i++){cin>>a[i]}
#define arr_op for(int i=0;i<n;i++) {cout<<a[i]}
#define SS second
#define ll long long int
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl; 
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main() 
{
 
 
 
 int n;
 cin>>n;
 int a[n];
  ll sum=0;
 int min=0;
 for(int i=0;i<n;i++)
 {
     cin>>a[i];
     
 }

 for(int i=1;i<n;i++)
 {
     if(a[i]<a[i-1])
     {
         sum+=a[i-1]-a[i];
         a[i]=a[i-1];
     }
     else
     {
         
     }
     
 }



 cout<<sum<<endl;
 
return 0;
   
}

Measured memory_bytes: 4376
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0297

NIn = input()
N = int(NIn.split(" ")[0])
NTime = []
for i in range(N):
	NTime.append(int(NIn.split(" ")[(i + 1) * 2 - 1]) * 60 + int(NIn.split(" ")[(i + 1) * 2]))
#print(NTime)

MIn = input()
M = int(MIn.split(" ")[0])
MTime = []
for i in range(M):
	MTime.append(int(MIn.split(" ")[(i + 1) * 2 - 1]) * 60 + int(MIn.split(" ")[(i + 1) * 2]))
#print(MTime)

AllTime = NTime + MTime
AllTime = sorted(list(set(AllTime)))

AllTime2 = []
for i in range(len(AllTime)):
	hour = AllTime[i] // 60
	minute = AllTime[i] % 60
	if minute < 10:
		AllTime2.append(str(hour) + ":0" + str(minute))
	else:
		AllTime2.append(str(hour) + ":" + str(minute))
for i in range(len(AllTime2)):
	if i == 0:
		results = AllTime2[i]
	else:
		results += " " + AllTime2[i]
print(results)

Measured memory_bytes: 7784
import java.io.*;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String w = br.readLine();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24408
//FIRST THINK, THEN CODE.


#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}
 
const ll mxn=1e6+5;





int main()
{ 
IOS;


ll n,k;
cin>>n>>k;

vl a(n);

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

  sort(all(a));
ll ans=0;

for(int i=0;i<k;i++)ans+=a[i];
cout<<ans<<endl;

 return 0;
 
 
 
}

Measured memory_bytes: 3660
// https://atcoder.jp/contests/agc034/tasks/agc034_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

type Test = (i64, i64, i64);

fn isok(time: i64, x: i64, tests: &Vec<Test>) -> bool {
    let n = tests.len();
    let ocnt = (time / x) as usize;
    let md = time % x;
    if ocnt >= n {
        return true;
    }

    let mut ok = false;

    let mut ls = 0;
    for i in 0..n {
        ls += tests[i].0 * tests[i].1;
    }
    let mut rs0 = 0;
    let mut rs1 = 0;
    for i in 0..ocnt+1 {
        let w = tests[i].0 * tests[i].1 + (x - tests[i].0) * tests[i].2;
        if i < ocnt {
            rs0 += w;
        }
        rs1 += w;
    }

    for i in 0..n {
        let mut rs = rs0;
        if ocnt > i {
            rs = rs1;
            rs -= tests[i].0 * tests[i].1 + (x - tests[i].0) * tests[i].2;
        }
        if md < tests[i].0 {
            rs += md * tests[i].1;
        } else {
            rs += tests[i].0 * tests[i].1 + (md - tests[i].0) * tests[i].2;
        }
        ok |= rs >= ls;
    }
    ok
}

fn main() {
    input! {
        n: usize, x: i64,
        tests: [(i64, i64, i64); n]
    };

    let mut tests = tests;
    tests.sort_by(|t0, t1| {
        let a = (x - t0.0) * t0.2 + t0.0 * t0.1;
        let b = (x - t1.0) * t1.2 + t1.0 * t1.1;
        return b.partial_cmp(&a).unwrap();
    });


    let mut ok = n as i64 * x;
    let mut ng = -1;
    while ok - ng > 1 {
        let med = (ok + ng) / 2;
        if isok(med, x, &tests) {
            ok = med;
        } else {
            ng = med;
        }
    }
    println!("{}", ok);
}


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

const int maxn=1e5+7;
int n,a[maxn];
long long s[maxn],m,ans,cnt;

int main()
{
	scanf("%d %lld",&n,&m);
	for(int i=1;i<=n;++i) {
		scanf("%d",a+i);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i) {
		s[i]=s[i-1]+a[i];
	}
	int l=0,r=3e5;
	while(l+1<r) {
		int mid=(l+r)>>1;
		cnt=0;
		for(int i=1;i<=n;++i) {
			int c=lower_bound(a+1,a+n+1,mid-a[i])-a;
			cnt+=n-c+1;
		}
		if(cnt>=m) l=mid;
		else r=mid;
	}
	cnt=0;
	for(int i=1;i<=n;++i) {
		int c=upper_bound(a+1,a+n+1,l-a[i])-a;
		ans+=1ll*(n-c+1)*a[i]+s[n]-s[c-1];
		cnt+=n-c+1;
	}
	ans+=(m-cnt)*l;
	printf("%lld",ans);
}

Measured memory_bytes: 1408
n = gets.to_i
h = gets.split.map(&:to_i)
a = Array.new(n,0)

num = 0
r = 0
loop do
    l = false
    break if a==h
    n.times do |i|
        if a[i] < h[i] then
            a[i] += 1
            l = true if l == false
        else
            if l then
                l = false
                num += 1
            else
            end
        end
    end
    num += 1 if l
end
puts num

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

int main()
{
	// start_routine();
	fastio;
	// #ifndef ONLINE_JUDGE
 //        freopen("input.txt", "rt", stdin);
 //        freopen("output.txt", "wt", stdout);
 //    #endif

    ll a[4];
    for(ll i=0;i<4;i++)
    	cin>>a[i];
    sort(a,a+4);
    if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9)
    	cout<<"YES";
    else
    	cout<<"NO";


	// end_routine();
}

Measured memory_bytes: 256
N, M = map(int, input().split())
lists = [list(map(int, input().split())) for i in range(N)]
lists_pop = [i.pop(0) for i in lists]

# print(lists)

like_food = {}
for i in range(N):
    for j in range(len(lists[i])):
        j = lists[i][j]
        if j not in like_food.keys():
            like_food[j] = 1
        elif j in like_food.keys():
            like_food[j] += 1
# print(like_food)

count = 0
for i in like_food.values():
    if i == N:
        count += 1
    else:
        continue

print(count)

Measured memory_bytes: 3064
/**
*    author:  boutarou
*    created: 11.07.2020 21:19:24
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using ll = long long;
using P = pair<ll, ll>;

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

const double PI = 3.1415926535897932;

void solve() {
    ll n;
    ll ans = 0;
    cin >> n;
    vector<ll> k(n),v(n);
    vector<ll> left, right;
    rep(i, n) {
        ll l, r;
        cin >> k[i] >> l >> r;
        v[i] = l - r;
        ans += l;
        if (v[i] >= 0) left.push_back(i);
        else right.push_back(i);
    }
    
    // left
    {
        priority_queue<ll> que;
        vector<P> kouho;
        rep(i, n) {
            if (v[i] >= 0) kouho.push_back({k[i], i});
        }
        if (kouho.size() == 0) goto bou1;
        sort(kouho.begin(), kouho.end());
        for (int i = left.size() - 1; i >= 0; i--) {
            while(!kouho.empty() && kouho[kouho.size() - 1].first > (ll)i) {
                que.push(v[kouho[kouho.size() - 1].second]);
                kouho.pop_back();
            }
            if (!que.empty()) que.pop();
        }
        while(!que.empty()) {
             ans -= que.top();
             que.pop();
        }
    }
    bou1:;

    // right
    {
        priority_queue<ll, vector<ll>, greater<ll>> que;
        vector<P> kouho;
        rep(i, n) {
            if (v[i] < 0) kouho.push_back({k[i], i});
        }
        if (kouho.size() == 0) goto bou2;
        sort(kouho.rbegin(), kouho.rend());
        for (int i = left.size(); i < n; i++) {
            while(!kouho.empty() && kouho[kouho.size() - 1].first <= i) {
                que.push(v[kouho[kouho.size() - 1].second]);
                kouho.pop_back();
            }
            if (!que.empty()) {
                ans -= que.top();
                que.pop();
            }
        }
    }

    bou2:;

    cout << ans << endl;
    return;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int t;
    cin >> t;
    rep(i, t) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 11620
#include<stdio.h>
 
int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  if((A==5 && B==5 && C==7) || (A==5 && B==7 && C==5) || (A==7 && B==5 && C==5)){
    printf("YES\n");}
  else
    printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int n,k,i;
    char a[51];
    scanf("%d",&n);
    scanf("%d ",&k);
    for(i=0; i<n; i++)
    {
        scanf("%c",&a[i]);
    }
    for(i=0; i<k-1; i++)
    {
        printf("%c",a[i]);
    }
    printf("%c",a[k-1]+32);

     for(i=k; i<n; i++)
    {
        printf("%c",a[i]);
    }
    return 0;
}

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

using namespace std;

#define ll long long

int main(){
   int n,x,sum=0;
   cin>>n>>x;
   int a[n];
   for(int i=0; i<n; i++){
       cin>>a[i];
   }
   sort(a,a+n);
   while(x--){
       sum=sum+a[n-1];
       n--;
   }
   cout<<sum<<endl; 

}

Measured memory_bytes: 256
x,y=map(int,input().split())
ans=0

if x==1:
  ans+=300000
elif x==2:
  ans+=200000
elif x==3:
  ans+=100000

if y==1:
  ans+=300000
elif y==2:
  ans+=200000
elif y==3:
  ans+=100000
    
if x==1 and y==1:
  ans+=400000
  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        if (t == 0)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    mint inv() const
    {
        return pow(p - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

struct comb
{
    vector<mint> fact, invs;
    comb(int n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

int main()
{
    int n, k;
    cin >> n >> k;
    comb c(n);
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    mint ans;
    rep(i, n)
    {
        ans += mint(a[i]) * c(i, k - 1);
        ans -= mint(a[i]) * c(n - i - 1, k - 1);
    }

    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stdlib.h>
using namespace std;


int main(){
    string s , b;
    cin >> s;
    cin >> b;
    s = s + b;
    int n;
    n = atoi(s.c_str());
    for(int i = 1; i < 320; i++){
        if( n == i * i){
            cout << "Yes";
            return 0;
        }
        if(i * i > n){
            cout << "No";
            return 0;
        }
    }
}


Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const M=input[0].split(' ')[1]-0;
  var success=0;
  var penalty=0;
  var WA=new Array(N+1);
  WA.fill(0);
  for(var i=1;i<input.length;i++){
    if(input[i].split(' ')[1]==="WA"){
      if(WA[input[i].split(' ')[0]-0]!==-1){
        WA[input[i].split(' ')[0]-0]++;
      }
    }else{
      if(WA[input[i].split(' ')[0]-0]!==-1){
        penalty+=WA[input[i].split(' ')[0]-0];
        success++;
        WA[input[i].split(' ')[0]-0]=-1;
      }
    }
  }
  console.log(success,penalty);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 45288
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 310000;

int n;
string s;
int dp[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> s;
	int cur = 0;
	for (int i = 0; i < s.size(); ++i) {
		dp[i] += cur;
		if (s[i] == 'W')
			++cur;
	}
	cur = 0;
	for (int i = s.size() - 1; i >= 0; --i) {
		dp[i] += cur;
		if (s[i] == 'E')
			++cur;
	}
	int ans = s.size();
	for (int i = 0; i < n; ++i)
		ans = min(ans, dp[i]);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1812
#!/usr/bin/env python3
import sys
import heapq
from collections import deque

def solve(H: int, W: int, s: "List[str]"):
    minScore = 10**16
    def isBlock(x,y):
        return s[y][x] == "#"
    first = isBlock(0,0)
    current = set([(0,0)])
    next = set()
    map = [[None for j in range(H)] for i in range(W)]
    map[0][0] = (1,True) if first else (0,False)
    def addNextIfCan(x,y,prevScore,prevBlock):
        if x >= W or y >= H:
            return
        c = isBlock(x,y)
        next.add((x,y))
        cScore = prevScore + 1 if c and not prevBlock else prevScore
        if map[x][y] == None:
            map[x][y] = (cScore,c)
        if map[x][y][0] > cScore:
            map[x][y] = (cScore,c)
        elif c and map[x][y][0] == cScore:
            map[x][y] = (cScore,c)
    while len(current) > 0:
        while len(current) > 0:
            n = current.pop()
            prevScore = map[n[0]][n[1]][0]
            prevBlock = map[n[0]][n[1]][1]
            addNextIfCan(n[0]+1,n[1],prevScore,prevBlock)
            addNextIfCan(n[0],n[1]+1,prevScore,prevBlock)
        current = next
        next = set()
    print(map[W-1][H-1][0])
    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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, t;
  cin >> a >> b >> t;
  int x = (t + 0.5) / a;
  // i * a <= t + 0.5
  // i <= (t + 0.5) / a
  int bis = b * x;
  
  cout << bis << endl;
}


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

namespace _0641
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] line = ReadIntAr();
            int setA = line[0] % line[1] == 0 ? line[0] / line[1] : line[0] / line[1] + 1;
            int setB = line[0] % line[3] == 0 ? line[0] / line[3] : line[0] / line[3] + 1;
            Console.WriteLine(Math.Min(setA * line[2],  setB * line[4]));
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 17912
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	arr := []int{a, b, c}
	cnt := 0

	for {
		sort.Ints(arr)
		if arr[0] == arr[2] {
			break
		}
		cnt++

		if arr[0] == arr[1] {
			arr[0]++
			arr[1]++
		} else {
			arr[0] += 2
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <cstdio>

int main(){
    int N;
    scanf("%d",&N);
    char CN[3];
    CN[0] = 'A';
    CN[1] = 'B';
    CN[2] = 'C' + (N + N / 1000) / 1000;
    printf("%c%c%c\n",CN[0],CN[1],CN[2]);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

const ll mod=1e9+7;
const int maxn=300050;

char a[maxn];
ll f[maxn][4][4];
int s[maxn],tail;


int main()
{
	scanf("%s",a);
	f[0][0][0]=1;
	int n=strlen(a);
	for(register int i=1;i<=n;++i)
		if(a[i-1]=='1')
		{
			f[i][1][0]+=f[i-1][0][0]+f[i-1][1][1],f[i][1][0]%=mod;
			f[i][0][0]+=f[i-1][0][1],f[i][0][0]%=mod;
			f[i][2][0]+=f[i-1][2][1]+f[i-1][1][0]+f[i-1][2][0],f[i][2][0]%=mod;
			f[i][2][1]+=f[i-1][2][2],f[i][2][1]%=mod;
			f[i][1][1]+=f[i-1][1][2],f[i][1][1]%=mod;
			f[i][0][1]+=f[i-1][0][2],f[i][0][1]%=mod;
		}
		else if(a[i-1]=='0')
		{
			f[i][0][1]+=f[i-1][0][0]+f[i-1][0][2],f[i][0][1]%=mod;
			f[i][0][2]+=f[i-1][0][1],f[i][0][2]%=mod;
			f[i][1][1]+=f[i-1][1][0]+f[i-1][1][2],f[i][1][1]%=mod;
			f[i][2][1]+=f[i-1][2][0]+f[i-1][2][2],f[i][2][1]%=mod;
			f[i][1][2]+=f[i-1][1][1],f[i][1][2]%=mod;
			f[i][2][2]+=f[i-1][2][1],f[i][2][2]%=mod;
		}
		else 
		{
			f[i][1][0]+=f[i-1][0][0]+f[i-1][1][1],f[i][1][0]%=mod;
			f[i][0][0]+=f[i-1][0][1],f[i][0][0]%=mod;
			f[i][2][0]+=f[i-1][2][1]+f[i-1][1][0]+f[i-1][2][0],f[i][2][0]%=mod;
			f[i][2][1]+=f[i-1][2][2],f[i][2][1]%=mod;
			f[i][1][1]+=f[i-1][1][2],f[i][1][1]%=mod;
			f[i][0][1]+=f[i-1][0][2],f[i][0][1]%=mod;
			f[i][0][1]+=f[i-1][0][0]+f[i-1][0][2],f[i][0][1]%=mod;
			f[i][0][2]+=f[i-1][0][1],f[i][0][2]%=mod;
			f[i][1][1]+=f[i-1][1][0]+f[i-1][1][2],f[i][1][1]%=mod;
			f[i][2][1]+=f[i-1][2][0]+f[i-1][2][2],f[i][2][1]%=mod;
			f[i][1][2]+=f[i-1][1][1],f[i][1][2]%=mod;
			f[i][2][2]+=f[i-1][2][1],f[i][2][2]%=mod;

		}	
	printf("%lld\n",(f[n][1][1]+f[n][2][2]+f[n][0][0]+f[n][1][0]+f[n][2][0]+f[n][2][1])%mod);
	return 0;
}


Measured memory_bytes: 38016
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
constexpr ll MOD = 1e9 + 7;



int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    ll ans = 0;
    rep(i, n-k) ans += v[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<double> x(n),y(n);
	rep(i,n){
		cin>>x[i]>>y[i];
	}
	vector<int> a(n);
	rep(i,n) a[i]=i;
	double ans=0;
	do{
		double now=0;
		double nx=x[a[0]],ny=y[a[0]];
		FOR(i,1,n){
			now+=sqrt((nx-x[a[i]])*(nx-x[a[i]])+(ny-y[a[i]])*(ny-y[a[i]]));
			nx=x[a[i]];
			ny=y[a[i]];
		}
		ans+=now;
	}while(next_permutation(begin(a),end(a)));
	FOR(i,1,n+1){
		ans/=(double)i;
	}
	cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 1100000
#define MAX_V 900010
#define vec vector<int>
using namespace std;
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);
    }
};
#define umap unordered_map<ll,int,custom_hash>

int par[N],grade[N];
void init(int n){
    rep(i,n){
        par[i]=i;
        grade[i]=0;
    }
}
int root(int x){
    return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
    return root(x)==root(y);
}
void unite(int x,int y){
    x=root(x); y=root(y);
    if(x==y)return;
    if(grade[x]<grade[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(grade[x]==grade[y]) grade[x]++;
    }
}
main(){
    int n;
    cin>>n;
    ll a[N],b[N];
    rep2(i,1,n)cin>>a[i]>>b[i];
    vector<pair<ll,ll>> v;
    rep2(i,1,n){
        v.pb({a[i],i});
        v.pb({b[i],-i});
    }
    ll ans1=0,ans2=0;
    sort(v.begin(),v.end());
    int t=n,pos=0;
    int used[N]={};
    bool flag=false;
    rep(i,n){
        if(used[abs(v[i].second)]){
            flag=true;
        }
        ans1+=v[i].first;
        used[abs(v[i].second)]=1;
    }
    if(flag){
        cout<<ans1;return 0;
    }
    if(v[n-1].second==-v[n].second){
        ans1=ans1-v[n-1].first+v[n+1].first;
        ans1=min(ans1,ans1-v[n+1].first-v[n-2].first+v[n].first+v[n-1].first);
    }
    else{
        ans1=ans1-v[n-1].first+v[n].first;
    }
    ll sum1=0,sum2=0;
    rep2(i,1,n){
        sum1+=a[i];
        sum2+=b[i];
    }
    cout<<min(ans1,min(sum1,sum2));
    return 0;
}


Measured memory_bytes: 13932
N = int(input())
a = list(map(int, input().split()))
a.sort()
t = 0
for m in range(N):
    if a[m] < 0:
        t += 1
if N > 2:
    if t == 0:
        c = a[0]
        for i in range(N - 2):
            c = c - a[N - 1 - i]
        d = a[1] - c
        print(d)
        e = a[0]
        f = a[N - 1]
        for j in range(N - 2):
            print(e, end = ' ')
            print(f)
            e = e - f
            f = a[N - 2 - j]
        print(a[1], end = ' ')
        print(e)
    elif t > 0 and t < N - 1:
        c = 0
        for i in range(t):
            c += a[i] 
        for j in range(N - t -1):
            c = c - a[t + 1 + j]
        d = a[t] - c
        print(d)
        e = a[0]
        f = a[N - 1]
        for k in range(N - t - 1):
            print(e, end = ' ')
            print(f)
            e = e - f
            f = a[N - 2 - k]
        a[0] = e
        g = a[t]
        for l in range(t):
            print(g, end = ' ')
            print(a[l])
            g = g - a[l]
    elif t == N - 1 or t == N:
        c = a[N - 1]
        for i in range(N - 1):
            c = c - a[i]
        print(c)
        d = a[N - 1]
        for j in range(N - 1):
            print(d, end = ' ')
            print(a[j])
            d -= a[j]
else:
    print(a[1] - a[0])
    print(a[1], end = ' ')
    print(a[0])

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

#define NMAX 101

int v[NMAX];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    long long x, sum = 0;

    // ifstream cin("code.in");
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        sum = 0LL + sum + v[i];
    }
    if (sum == x) {
        cout << n << '\n';
        return 0;
    }
    sort(v + 1, v + n + 1);
    int cnt = 0;
    sum = 0;
    for (int i = 1; i <= n; i++) {
        if (sum >= x)
            break;
        sum = 0LL + sum + v[i];
        if (sum > x)
            break;
        cnt++;
    }
    cout << min(cnt, n - 1) << '\n';
    return 0;
}


Measured memory_bytes: 256