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

using namespace std;

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);
const long double PI = acos(-1);
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<double> pnt;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

/* START */

#define int long long

int c[11][11];

int32_t main() { _
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < 10; ++i)
		for (int j = 0; j < 10; ++j)
			cin >> c[i][j];
	for (int k = 0; k < 10; ++k)
		for (int i = 0; i < 10; ++i)
			for (int j = 0; j < 10; ++j) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
	int ans = 0;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			int a;
			cin >> a;
			if (a != -1)
				ans += c[a][1];
		}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>                                                             
#include <vector>                                                               
#define N 10000                                                                 
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int z;                                                                        
  vector<int> x;                                                                
  for (int i=0; i<N; i++) {                                                     
    cin >> z;                                                                   
    if (z==0) {                                                                 
      break;                                                                    
    }                                                                           
    x.push_back(z);                                                             
  }                                                                             
  for (int i=0; i<x.size(); i++) {                                              
    cout << "Case" << " " << i+1 << ":" << " " << x[i] << endl;                 
  }                                                                             
}                                                                     

Measured memory_bytes: 3136
#include <cstdio>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;

int n, k;
bool num[100000];

int main(){
	while(scanf("%d%d", &n, &k),n||k){
		rep(i,100000) num[i] = false;
		bool ch = false;
		rep(i,k){
			int tmp; scanf("%d", &tmp);
			if(tmp == 0){
				ch = true;
				continue;
			}
			tmp--;
			num[tmp] = true;
		}
		int ans = 0;
		if(!ch){
			int cnt = 0;
			rep(i,n){
				if(!num[i]){
					if(ans < cnt) ans = cnt;
					cnt = 0;
					continue;
				} else cnt++;
			}
			printf("%d\n", ans);
			continue;
		}
		vector<int> v;
		int cnt = 0;
		rep(i,n){
			if(!num[i]){
				if(cnt > 0) v.pb(cnt);
				cnt = 0;
				v.pb(0);
			} else{
				cnt++;
			}
		}
		if(cnt > 0) v.pb(cnt);
		rep(i,v.size()){
			int tmp = 1;
			if(v[i] > 0){
				if(ans < v[i]) ans = v[i];
			} else{
				if(i != 0) tmp += v[i-1];
				if(i != v.size()-1) tmp += v[i+1];
				if(ans < tmp) ans = tmp;
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1400
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)
#define cio ios::sync_with_stdio(false);

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    ll n,k;
    scanf("%lld %lld",&n,&k);
    ll m = n % k;
    ll mm = abs(m - k);
    printf("%lld\n",min(m,mm));
    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  string s;
  int n;

  cin >> n >> s;
  
  int ans = 0, q = 0;

  for(int i=0;i<n;i++){
    if(s[i] == '('){
      q++;
    }else{
      if(q){
        q--;
      }else{
        ans++;
      }
    }
  }

  for(int i=0;i<ans;i++){
    printf("(");
  }
  printf("%s",s.c_str());
  for(int i=0;i<q;i++){
    printf(")");
  }
  puts("");
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  string str;
  
  getline(cin,str);

  for(int i=0;i<str.size();i++){

    if(str[i]=='p'&&str[i+1]=='e'&&str[i+2]=='a'&&str[i+3]=='c'&&str[i+4]=='h'){
      str[i] = 'a';
      str[i+1] = 'p';
      str[i+2] = 'p';
      str[i+3] = 'l';
      str[i+4] = 'e';
    }
    else if(str[i]=='a'&&str[i+1]=='p'&&str[i+2]=='p'&&str[i+3]=='l'&&str[i+4]=='e'){
      str[i] = 'p';
      str[i+1] = 'e';
      str[i+2] = 'a';
      str[i+3] = 'c';
      str[i+4] = 'h';
    }
  }

  cout << str << endl;
  return (0);
}

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

int main() {
  int A, B, ans;
  string op;
  cin >> A >> op >> B;
  
  if (op=="+") {
    ans = A+B;
  }
  else {
    ans = A-B;
  }
  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    double x[n], sum = 0;
    string u[n];
    for (int i = 0; i < n; i++){
        cin >> x[i] >> u[i];
    }

    for (int i = 0; i < n; i++){
        if (u[i] == "JPY") sum += x[i];
        else sum += 380000 * x[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

void selectionsort(vector<string> &A){
  int minj,i,j;
  int n=A.size();
  for(i=0;i<n-1;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j][1]<A[minj][1]){
	minj=j;
      }
    }
    swap(A[i],A[minj]);
  }
}
void bubblesort(vector<string> &A){
  bool flag=1;
  int n=A.size();
  while(flag){
    flag=0;
    for(int j=n-1;j>0;j--){
      if(A[j][1]<A[j-1][1]){
	swap(A[j],A[j-1]);
	flag=1;
      }
    }
  }

}
void comp(vector<string> &a,vector<string> &b){
  bool jud=1;
  int n=a.size();
  for(int i=0;i<n;i++){
    if(a[i].compare(b[i])!=0){
      jud=0;
      break;
    }
  }
  if(!jud)cout<<"Not stable"<<endl;
  else cout<<"Stable"<<endl;
}
void print(vector<string> &a,vector<string> &b){
  int i,n=a.size();
  for(i=0;i<n-1;i++)
    cout<<a[i]<<" ";
  cout<<a[i]<<endl;
  comp(a,a);
  for(i=0;i<n-1;i++)
    cout<<b[i]<<" ";
  cout<<b[i]<<endl;
  comp(a,b);
}

int main(){
  vector<string> a;
  string tmp;
  int n,i;
  cin>>n;
  for (i=0;i<n;i++){
    cin>>tmp;
    a.push_back(tmp);
  }
  vector<string> b(a);
  bubblesort(a);
  selectionsort(b);
  print(a,b);
  return 0;
}



Measured memory_bytes: 3168
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

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

int ar[222222];
int n;
int pos[222222], neg[222222];
int np, nn;
long long k;

long long calc_rank(long long c) {
  int i = 0, j = np;
  long long ans = 0;
  while (i < j) {
    if (pos[j-1] * (long long)pos[i] > c) j--;
    else {
      ans += j-i-1, i++;
    }
  }
  i = 0, j = nn;
  while (i < j) {
    if (neg[j-1] * (long long)neg[i] > c) j--;
    else {
      ans += j-i-1, i++;
    }
  }
  i = 0, j = np;
  long long bns = 0;
  while (i < nn && j > 0) {
    if (-neg[i] * (long long)pos[j-1] <= c) j--;
    else bns += np-j, i++;
  }
  if (!j) bns += (nn-i)*(long long)np;

  /*
  long long cns = 0;
  FOR(i,nn) FOR(j,np) if (-neg[i]*(long long)pos[j] <= c) cns++;
  //printf("%lli %lli %lli\n", bns, cns, c);
  if (bns != cns) abort();
  long long dns = 0;
  FOR(i,np) FOR(j,i) if (pos[i]*(long long)pos[j] <= c) dns++;
  FOR(i,nn) FOR(j,i) if (neg[i]*(long long)neg[j] <= c) dns++;
  if (ans != dns) {
    printf("%lli ans %lli cns %lli\n");
    exit(-1);
  }
  //printf("%lli %lli %lli %lli\n", c, ans, bns, ans+bns);
  */

  return ans+bns;
}

int main() {
  scanf("%i%lli", &n, &k);
  k--;
  FOR(i,n) {
    scanf("%i", ar+i);
    if (ar[i] < 0) neg[nn++] = -ar[i];
    else pos[np++] = ar[i];
  }
  sort(neg, neg+nn);
  sort(pos, pos+np);
  long long lo = -0x3fffffffffffffff, hi = 0x3fffffffffffffff;
  while (lo < hi) {
    long long c = lo + (hi-lo)/2;
    long long r = calc_rank(c);
    //printf("the rank of %lli is %lli\n", c, r);
    if (r > k) hi = c;
    else lo = c+1;
  }
  printf("%lli\n", lo);
}


Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		ll N, K;

		cin >> N >> K;
		if (cin.fail()) break;

		ll n = N / K;
		if (K & 1) {
			cout << n * n * n << endl;
		} else {
			ll n2 = (N / (K / 2)) - n;
			cout << (n * n * n) + (n2 * n2 * n2) << endl;
		}
	}

	return 0;
}


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

R = [(0, 0)] * N
for n in range(N):
  x, y = map(int, input().split())
  R[n] = (x, y)

B = [[0, 0]] * N
for n in range(N):
  x, y = map(int, input().split())
  B[n] = (x, y)

R = sorted(R, key=lambda x: (x[0], x[1]))
B = sorted(B, key=lambda x: (x[0], x[1]))

ans = 0

for (bx, by) in B:
  max_y = -1
  idx = 0
  for i, (rx, ry) in enumerate(R):
    if rx < bx and max_y < ry < by:
      max_y = ry
      idx = i
  if max_y > -1:
    ans += 1
    R.pop(idx)

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * 
 * @author morisin
 * 
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int L[] = new int[100];
		
		int sum = 0;
		int max = 0;
		boolean writable = false;
		
		for(int i=0;i<N;i++) {
			int input = sc.nextInt();
			L[i] = input;
			sum += L[i];
			if (L[i] > max) {
				max = L[i];
			}
		}
		
		if (max < sum - max) {
			writable = true;
		}
		
		System.out.println(writable ? "Yes" : "No");
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){
  string s;
  cin>>s;
  int n,w,so,e;
  n = w = so = e = 0;
  for(int i = 0;i<s.size();i++){
    switch(s[i]){
    case 'N':
      n++;
      break;
    case 'W':
      w++;
      break;
    case 'S':
      so++;
      break;
    case 'E':
      e++;
      break;
    }
  }
  if(n>0){
    if(so==0){
      cout<<"No"<<endl;
      return 0;
    }
  }else if(so>0){
    if(n==0){
      cout<<"No"<<endl;
      return 0;
    }
  }

  if(e > 0){
    if(w == 0){
      cout<<"No"<<endl;
      return 0;
    }
  }else if(w >0 ){
    if(e == 0){
      cout<<"No"<<endl;
      return 0;
    }
  }
    
  cout<<"Yes"<<endl;
  
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    string T = "";
    int idx = 0;
    while(idx < S.length()){
        if(idx == S.length()-1){
            T += S[idx];
            idx++;
        }
        else{
            if(S[idx] == 'B' && S[idx+1] == 'C'){
                T += 'X';
                idx += 2;
            }
            else{
                T += S[idx];
                idx++;
            }
        }
    }
    //Aより右側にあるXの個数(ただし途中にBやCが出ない)
    ll ans = 0;
    int right = 0;
    for(int left = 0; left < T.length(); left++){
        ll appear_a = 0;
        while(right < T.length() && (T[right] == 'A' || T[right] == 'X')){
            if(T[right] == 'A'){
                appear_a++;
            }
            else{
                ans += appear_a;
            }
            right++;
        }
        left = right;
        right++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define MAXN 300005
 
typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

vector<lli> v[100000 + 5];
bool vis[100000 + 5]={0};

void dfs(lli q)
{
    vis[q]=1;

    for(auto x:v[q])
        if(!vis[x])
            dfs(x);
}

int main()
{
/////////////////
 
    lli n,m;
    cin>>n>>m;

    loopl(i,0,m)
    {
        lli x,y,z;
        cin>>x>>y>>z;

        v[x].pb(y);
        v[y].pb(x);
    }

    lli cnt=0;

    loopl(i,1,n+1)
    {
        if(!vis[i])
        {
            dfs(i);
            cnt++;
        }
    }

    cout<<cnt<<endl;

}

Measured memory_bytes: 8960
R,C,K=map(int,input().split())
rcv=[list(map(int,input().split())) for _ in range(K)]
mat=[[0]*C for _ in range(R)]
for r,c,v in rcv:
  mat[r-1][c-1]=v
dp=[0]*C
for i in range(R):
  ndp=[0]*C
  wdp=[0]*4
  for j in range(C):
    wdp[0]=max(wdp[0],dp[j])
    if mat[i][j]>0:
      v=mat[i][j]
      wdp[3]=max(wdp[3],wdp[2]+v)
      wdp[2]=max(wdp[2],wdp[1]+v)
      wdp[1]=max(wdp[1],wdp[0]+v)
    ndp[j]=max(wdp)
  dp=ndp.copy()
print(max(wdp))

Measured memory_bytes: 187980
#include <iostream>
#include <vector>
#include <map>

using namespace std;

map<int, int> cnt;
int n, q;
long long sum = 0;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        cnt[a]++;
        sum += a;
    }

    scanf("%d", &q);
    for (int i = 0; i < q; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        sum += (y - x) * cnt[x];
        cnt[y] += cnt[x];
        cnt[x] = 0;
        printf("%lld\n", sum);
    }
    return 0;
}


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

int main()
{
  int n,k,d;
  d=1;
  cin >> n >> k;
  while(n>=k)
  {
    //cout << d << endl;
    d=d+1;
   // cout << d << endl;
    n=(n-n%k)/k;
    //cout << n << endl;
  }
  cout << d << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    char C;
    cin >> C;
    C++;
    cout << C << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define vi vector<int>
#define vii vector<pair<int,int> >

using namespace std;
typedef long long ll;

string s,t,rev;

int dp[3005][3005];

int val(int x, int y){
    if(x < 0 || y < 0){
        return 0;
    }
    else{
        return dp[x][y];
    }
}

int main(){
    cin >> s;
    cin >> t;

    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < t.size(); j++){
            if(s[i] == t[j]){
                dp[i][j] = max(dp[i][j], 1+val(i-1,j-1));
            }
            dp[i][j] = max(dp[i][j], max(val(i-1,j),val(i,j-1)));
        }
    }
    int x = s.size()-1, y = t.size()-1;
    while(x >= 0 && y >= 0){
        if(s[max(x,0)] == t[max(y,0)]){
            rev += s[max(x,0)];
           // cout<<rev<<"\n";
            x--; y--;
        }
        else{
            if(val(x,y-1) > val(x-1,y)){
                y--;
            }
            else{
                x--;
            }
        }
    }

    for(int i = 0; i < rev.size()/2; i++){
        char tmp = rev[i];
        rev[i] = rev[rev.size()-1-i];
        rev[rev.size()-1-i] = tmp;
    }
    cout<<rev;
	return 0;
}

Measured memory_bytes: 35456
function Main(input) {
  var input = input.split(" ");
  var maxNum = [];
  
  maxNum.push(parseInt(input[0]) + parseInt(input[1]));
  maxNum.push(parseInt(input[0]) - parseInt(input[1]));
  maxNum.push(parseInt(input[0]) * parseInt(input[1]));
  
  console.log(maxNum.reduce((a,b)=>a>b?a:b));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
   cin>>n>>m;
   if(n>=10||m>=10)
   {
       cout<<-1<<endl;
   }
   else{cout<<m*n<<endl;}




    }



Measured memory_bytes: 3656
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		long n = sc.nextLong();
		long s = sc.nextLong();

		if (n == s) {
			pr.println(n + 1);

			pr.close();
			sc.close();
			return;
		}

		for (long b = 2; b < 1_000_000; b++) {
			long ret = 0;
			long tmp = n;
			while (tmp > 0) {
				ret += tmp % b;
				tmp /= b;
			}

			if (ret == s) {
				pr.println(b);

				pr.close();
				sc.close();
				return;
			}
		}

		if (n - s > 0) {
			for (long p = Math.min(1_000_000, s); p >= 1; p--) {
				long b = (n - s) / p + 1;
//				if (b < 1_000_000) {
//					continue;
//				}
				if (b * p + s - p == n && s - p < b) {
					pr.println(b);

					pr.close();
					sc.close();
					return;
				}
			}
		}

		pr.println(-1);

		pr.close();
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
//					it = Arrays.asList(br.readLine().split(" ")).iterator();
					it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9680
/**
 * File    : E.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-3-11 21:22:55
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const ll dx[4] = {1, 0, -1, 0};
// const ll dy[4] = {0, 1, 0, -1};

// const ll C = 1e6+10;
// const ll M = 1000000007;

ll N, A, B;

bool ok()
{
  return (1 <= A && A <= N && 1 <= B && B <= N && A + B <= N+1 && A * B >= N);
}

vector<ll> V;
vector<ll> W;
map<ll, ll> M;

int main()
{
  cin >> N >> A >> B;
  if (!ok())
  {
    cout << -1 << endl;
    return 0;
  }
  ll now = 0;
  for (auto j = 0; j < A; j++)
  {
    if ((ll)V.size() >= N)
      break;
    V.push_back(now);
    now++;
  }
  now -= N * N * N;
  for (auto i = 0; i < B-1; i++)
  {
    if ((ll)V.size() >= N)
      break;
    V.push_back(now);
    now--;
  }
  now = -4 * A;
  for (auto i = 0; i < B-1; i++)
  {
    for (auto j = 0; j < A-1; j++)
    {
      if ((ll)V.size() >= N)
        break;
      V.push_back(now);
      now++;
    }
    if ((ll)V.size() >= N)
      break;
    now -= 4 * A;
  }
  W = V;
  sort(W.begin(), W.end());
  for (auto i = 0; i < N; i++)
  {
    M[W[i]] = i+1;
  }
  for (auto i = 0; i < N; i++)
  {
    V[i] = M[V[i]];
  }
  for (auto i = 0; i < N; i++)
  {
    cout << V[i];
    if (i < N-1)
    {
      cout << " ";
    }
    else
    {
      cout << endl;
    }
  }
}

Measured memory_bytes: 26732
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] a = new double[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextDouble();
		}
		double shita = 0;
		for (int i = 0; i < n; i++) {
			shita += 1 / a[i];
		}
		System.out.println(1 / shita);
	}
}


Measured memory_bytes: 23508
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    string res;
    if(S == "Sunny") res = "Cloudy";
    if(S == "Cloudy") res = "Rainy";
    if(S == "Rainy") res = "Sunny";
    cout << res << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

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

int dp[100005];

int main() {
	int n;
	cin >> n;
	vector<int> six, nine;
	int fs = 6;
	int fn = 9;
	while(fs <= n) {
		six.pb(fs);
		fs *= 6;
	}
	while(fn <= n) {
		nine.pb(fn);
		fn *= 9;
	}
	rep(i, n+1) dp[i] = INF;
	dp[0] = 0;
	repl(i, 1, n+1) {
		chmin(dp[i], dp[i-1] + 1);
		for(int x : six) {
			if(i - x < 0) break;
			chmin(dp[i], dp[i - x] + 1);
		}
		for(int x : nine) {
			if(i - x < 0) break;
			chmin(dp[i], dp[i - x] + 1);
		}
	}
	cout << dp[n] << endl;
    return 0;
}


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

int main(void) {
long long  n, m, count = 0;

std::cin >> n >> m;
if (m < 2 ) {
  std::cout << count << '\n';
  return 0;
}

if (m/2 <= n) {
  count = m/2;
  std::cout << count << '\n';
  return 0;
}

if (m/2 > n) {
  count = n;
  m = m - 2*n;
  count = count + m/4;
  std::cout << count << '\n';
  return 0;
}

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	vi out(n,inf);
	out[0]=0;
	vi t;t.pb(0);
	vector<bool>dame(n,0);
	while(t.size()){
		vi tt;
		rep(i,t.size()){
			loop(j,1,7){
				int d=t[i]+j;
				if(d<n&&dame[d])continue;
				vector<bool>h(n,0);
				if(d<n)while(in[d]&&h[d]==0){h[d]=true;d+=in[d];}
				if(d<n&&h[d]){
					rep(k,n)if(h[k])dame[k]=true;
					continue;
				}
				if(d>=n){
					out[n-1]=min(out[n-1],out[t[i]]+1);
					continue;
				}
				if(out[d]>out[t[i]]+1){
					out[d]=out[t[i]]+1;
					tt.pb(d);
				}				
			}
		}
		t=tt;
	}
	cout<<out[n-1]<<endl;
}

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

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	int to0=0, toA = 0;
	for (int i = 0; i < M; i++)
	{
		int tmp;
		cin >> tmp;
		if (tmp < X)
			to0++;
		else
			toA++;
	}
	cout << min(to0, toA)<<endl;
	return 0;
}


Measured memory_bytes: 256
MOD =1000000007 
N = int(input())
S1 = input()
S2 = input()

Data = []
i = 0
while i < N:
    if S1[i] == S2[i]:
        Data.append(1)
        i += 1
    else:
        Data.append(2)
        i += 2

ans = 0
for i in range(len(Data)):
    if i == 0:
        if Data[i] == 1:
            ans = 3
        else:
            ans = 6
    else:
        if Data[i] == 1:
            if Data[i-1] == 1:
                ans = (ans * 2) % MOD
            else:
                pass 
        else:
            if Data[i-1] == 1:
                ans = (ans * 2) % MOD
            else:
                ans = (ans * 3) % MOD
print(ans)

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

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

    vector<int> res;
    map<int, int> m;

    for(int i = 0; i < 1000007; ++i) {
        if(i == 0) {
            res.push_back(s);
            m.insert(make_pair(res[i], 1));
        } else {
            if(res[i - 1] % 2 == 0) {
                res.push_back(res[i - 1] / 2);
            } else {
                res.push_back(3 * res[i - 1] + 1);
            }

            if(m.count(res[i]) == 0) {
                m.insert(make_pair(res[i], 1));
            } else {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import math


def main():
    a, b = map(int, input().split(" "))
    # eight = a // 0.08
    # ten = b // 0.1
    # print("%d %d" % (eight, ten))
    # if eight == ten:
    #     print("%d" % eight)
    # else:
    #     print("-1")
    for i in range(1, 1001):
        eight = math.floor(i * 0.08)
        ten = math.floor(i * 0.1)
        if eight == a and ten == b:
            print(i)
            return
    print("-1")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
(* https://atcoder.jp/contests/atc001/tasks/unionfind_a *)
open Printf
open Scanf

class unionfind size =
  object(self)
    val mutable forest = [|(0,0)|]
    initializer begin
      forest <- Array.init size (fun x -> (x,1))
    end
    method forest () = begin
      forest
    end
    method print_forest () = begin
      let _ = Array.iter (fun x -> Printf.printf "(%d,%d);" (fst x) (snd x)) forest in
      print_newline()
    end
    method group_count () = begin
      let count = ref 0 in
      let _ = Array.iteri (fun i x -> if i = fst x then count := !count + 1) forest in
      !count
    end
    method find i = begin
      let (index, size) = forest.(i) in
      if (i = index) then (i, size)
      else
        let (nxt_index, nxt_size) = self#find index in
        forest.(i) <- (nxt_index, nxt_size);
        (nxt_index, nxt_size)
    end

    method union i j = begin
      let (x, x_size) = self#find i in
      let (y, y_size) = self#find j in

      if (x = y) then ()
      else
        let () = forest.(x) <- (y, x_size + y_size) in
        forest.(y) <- (y, x_size + y_size)
    end
  end

(*
let t = new unionfind 5;;
t#union 0 1;;
t#union 3 4;;
t#forest();;
t#find 0;;
*)

let (n,m) = sscanf (read_line ()) "%d %d" (fun a b -> (a,b))
let query = Array.make m (0,0,0);;
let () = 
for i = 0 to m-1 do
  query.(i) <- sscanf (read_line ()) "%d %d %d" (fun x y z-> (x-1,y-1,z))
done;;

let forest = new unionfind n;;
let () = Array.iter (fun t -> let (x,y,z) = t in forest#union x y) query;;
let () = print_int (forest#group_count ()) in print_newline();;

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();

        string answer = a + b >= c ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 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 decimal NextDecimal() => decimal.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();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  string b;
  cin >> a >> b;
  int y = 0;
  if(a.at(0)==b.at(0))y++;
  if(a.at(1)==b.at(1))y++;
  if(a.at(2)==b.at(2))y++;
  cout << y << endl;}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    ll n;
    string alph = "abcdefghijklmnopqrstuvwxyz";
    cin >> n;
    // n--;
    string ans = "";
    ll num = 0;
    ll pw = 1;
    while(n > num + 26 * pw){
        pw *= 26;
        num += pw;
        // cout << num << endl;
        // cout << pw << endl;
    }
    // cout << num << endl;
    n -= num;
    n--;
    // cout << n << endl;
    while(pw > 0){
        ll idx;
        idx = n / pw;
        n -= pw * (idx);
        pw /= 26;
        ans += alph[idx];
        // cout << num << endl;
        // cout << ans << endl;
        // cout << idx << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    int a,b,c,k,mymax,n=1;
    cin >> a >> b >> c >> k;
    mymax = max(a,max(b,c));
    FOR(i,0,k)n *= 2;
    cout << a + b + c + mymax * (n-1);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
using vec = vector<int>;
int sum(int n){
    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        ans += i;
    }
    return ans;
}
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int len;
    int ans = 0;
    int cmp = 0;
    string s;
    cin >> s;
    len = s.size();
    len++;
    vec d(len);
    d[0] = 1;
    d[len-1] = 1;
    for(int i = 1; i < len-1; i++)    
     {
        if(s[i] != s[i - 1])         
        {
            d[i] = 1;
            if(s[i] == '>')             
            {
                cmp = d[i - 1];
                ans += sum(d[i - 1]);
            }
            else            
            {
                ans += sum(d[i - 1]);
                ans -= min(cmp,d[i - 1]);
            }
        }
        else
        {
            d[i] = d[i - 1] + 1;
        }
    }
    ans += sum(d[len - 2]);
    if(s[len - 2] == '>')    ans -= min(d[len - 2],cmp);
    cout << ans << endl;
    return 0;
}


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

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
 int n;
  cin>> n;
  int c1=0,c2=0,c3=0;
int t=0;
  for(int i =0 ; i<n ;i++)
  {

    string s;
    cin >> s;
    if(s[0]=='B')
    {
      if(s[s.size()-1]=='A')
        c1++;
      else c2++;
      
    }
     if(s[0]!='B' && s[s.size()-1]=='A')
        c3++;
    for(int i=0;i<s.size()-1;i++)
{
if(s[i]=='A' && s[i+1]=='B')
{
    t++;
}
}
  }
  if(c1==0) {cout<<t+min(c2,c3);return 0;}
 t+= c1+ (c3+c2==0?-1:0)+min(c2,c3);
  cout << t;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 923372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int N;
VI G[1 << 18];
int V[1 << 18];
int W[1 << 18];
int dp[1 << 9][100010];

int solve(int now, int L) {
	if (now < (1 << 9)) return dp[now][L];
	
	int pa = (now + 1) / 2;
	pa--;

	int res = -INF;
	chmax(res, solve(pa, L));

	if (L - W[now] >= 0)chmax(res, solve(pa, L - W[now]) + V[now]);

	return res;
}


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

	cin >> N;
	
	REP(i, N) cin >> V[i] >> W[i];

	eREP(i, 100000)if (i >= W[0])dp[0][i] = V[0];
	FOR(i,1, min(N, 1 << 9)) {
		int pa = (i + 1) / 2;
		pa--;
		eREP(j, 100000) {
			if (j != 0)chmax(dp[i][j], dp[i][j - 1]);

			if (j - W[i] >= 0 && i != 0) {		
				chmax(dp[i][j], dp[pa][j - W[i]] + V[i]);
			}

			if (i != 0)chmax(dp[i][j], dp[pa][j]);
		}
	}
	int Q; cin >> Q;
	while (Q--) {
		int v, L; cin >> v >> L;
		v--;
		cout << solve(v, L) << endl;
	}

	return 0;
}



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

int N, M;
vector<vector<int> > S;
vector<int> P;
vector<bool> isOn;


int rec(int n){
    if(n == 0){  // すべて条件を満たしているか判定を行う
        int ok = 1;
        for(int i=0;i<M;i++){
            int cnt = 0;
            for(int j : S[i]){
                if(isOn[j]) cnt++;
            }
            if(cnt%2 != P[i]) ok = 0;
        }
        return ok;
    }

    int res = 0;
    // スイッチをつけない
    res += rec(n-1);

    // スイッチをつける
    isOn[n-1] = true;
    res += rec(n-1);
    isOn[n-1] = false;

    return res;
}

int main(){
    cin >> N >> M;
    S.resize(M);
    for(int i=0;i<M;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int x;
            cin >> x;
            S[i].push_back(x-1);
        }
    }
    P.resize(M);
    for(int i=0;i<M;i++){
        cin >> P[i];
    }

    isOn.resize(N, false);

    cout << rec(N) << endl;

    return 0;
}

Measured memory_bytes: 256
n, m , q = list(map(int, input().split()))
lists = []
sequence = [1] * n
output = 0
for i in range(q):
  lists.append(list(map(int, input().split())))
  
while (True):
  score = 0
  limit_digit = -1
  for i in range(q):
    if sequence[lists[i][1] - 1] - sequence[lists[i][0] - 1] == lists[i][2]:
      score += lists[i][3]
  if output < score:
    output = score
  for i in range(n):
    if sequence[n - i - 1] == m:
      limit_digit = n - i - 1
  if limit_digit == 0:
    break
  elif limit_digit == -1:
    sequence[n - 1] += 1
  else:
    if limit_digit == 1:
      sequence = [sequence[0] + 1] * n
    else:
      sequence[limit_digit - 1] += 1
      for k in range(limit_digit, n):
        sequence[k] = sequence[limit_digit - 1]

print(output)
      

Measured memory_bytes: 9244
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,ta,tb,s,i,j,k,min,a,b,c;
  while(scanf("%d %d %d %d %d",&n,&m,&s,&ta,&tb),n){
    int d[110][110]={0};
    for(i=0;i<110*110;i++)min=d[i/110][i%110]=100000000;
    for(i=0;i<m;i++){
      scanf("%d %d %d",&a,&b,&c);
      d[a-1][b-1]=c;
    }//printf("a\n");
    for(i=0;i<n;i++)d[i][i]=0;
    for(k=0;k<n;k++){
      for(i=0;i<n;i++){
	for(j=0;j<n;j++)d[i][j]=MIN(d[i][j],d[i][k]+d[k][j]);
      }
    }
    /*for(i=0;i<n;i++){
      for(j=0;j<n;j++)printf("%2d ",d[i][j]);printf("\n");
      }//*/
    for(i=0;i<n;i++)min=MIN(min,d[s-1][i]+d[i][ta-1]+d[i][tb-1]);
    printf("%d\n",min);
  }
  return 0;
}

Measured memory_bytes: 652
n=int(input())
a=list(map(int,input().split()))
cnt=1
flag=0
for i in range(n-1):
    if flag==0:
        if a[i]<a[i+1]:
            flag=1
        elif a[i]>a[i+1]:
            flag=-1
    elif flag==1:
        if a[i]>a[i+1]:
            cnt+=1
            flag=0
    else:
        if a[i]<a[i+1]:
            cnt+=1
            flag=0
print(cnt)

Measured memory_bytes: 14252
#include <iostream>

#define ll long long
#define mod 1000000007

using namespace std;

int main() {
  ll N;
  cin >> N;
  ll dp[105][4][4][4];
  for (int i = 0; i < 105; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          dp[i][j][k][l] = 0;
        }
      }
    }
  }
  dp[0][0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          for (int m = 0; m < 4; m++) {
            if (k == 1 && l == 2 && m == 3)
              continue;
            if (k == 2 && l == 1 && m == 3)
              continue;
            if (k == 1 && l == 3 && m == 2)
              continue;
            if (j == 1 && l == 2 && m == 3)
              continue;
            if (j == 1 && k == 2 && m == 3)
              continue;

            dp[i + 1][k][l][m] += dp[i][j][k][l];
            dp[i + 1][k][l][m] %= mod;
          }
        }
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        ans += dp[N][i][j][k];
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val arr: Array[String] = Array.fill(N)(sc.next())
    val arrBubble: Array[String] = arr.clone()
    val arrSelect: Array[String] = arr.clone()

    println(bubbleSort(arrBubble))
    checkStable(arr, arrBubble)
    println(selectionSort(arrSelect))
    checkStable(arr, arrSelect)
  }

  def bubbleSort(arr: Array[String]): String = {
    for(i <- 0 until arr.length) {
      for(j <- arr.length-1 until i by -1) {
        if(arr(j).last.toInt < arr(j-1).last.toInt) {
          val t = arr(j); arr(j) = arr(j-1); arr(j-1) = t  // swap
        }
      }
    }
    return arr.mkString(" ")
  }

  def selectionSort(arr: Array[String]): String = {
    for((x, i) <- arr.zipWithIndex) {
      var minj = i
      for(j <- i until arr.length) {
        if(arr(minj).last.toInt > arr(j).last.toInt) minj = j
      }
      val t = arr(i); arr(i) = arr(minj); arr(minj) = t
    }
    return arr.mkString(" ")
  }

  def checkStable(arrOrigin: Array[String], arrSorted: Array[String]): Unit = {
    for((a, i) <- arrOrigin.zipWithIndex) {
      for((b, j) <- arrOrigin.zipWithIndex if i != j && a.last.toInt == b.last.toInt) {
        for((c, k) <- arrSorted.zipWithIndex if a == c) {
          for((d, l) <- arrSorted.zipWithIndex if b == d) {
            if((i - j) * (k - l) < 0) {
              println("Not stable")
              return
            }
          }
        }
      }
    }
    println("Stable")
  }
}

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

int main() {
  vector<int> N(3);
  for (int i = 0; i < 3; i++) {
    cin >> N[i];
  }
  sort(begin(N), end(N), greater<int>());
  cout << N[0] * 10 + N[1] + N[2] << endl;
  return 0;
}


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


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

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	p := make([]int, N)
	for i := range p {
		fmt.Scan(&p[i])
	}
	for i := range p {
		if i == 0 {
			continue
		}
		p[i] += p[i-1]
	}
	max := 0
	for start := 0; start <= N-K; start++ {
		end := start + K - 1
		sum := 0
		if start == 0 {
			sum = p[end]
		} else {
			sum = p[end] - p[start-1]
		}
		if max < sum {
			max = sum
		}
	}
	fmt.Printf("%.12f\n", float64(max+K)/2.)
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

const ll mod = 1000000007;

int main()
{
	ll N;
	ll A[200200];
	ll sum = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		sum += A[i];
	}
	ll ans = 0;
	for(int i = 0; i < N; i++){
		sum -= A[i];
		ans += (sum % mod) * A[i];
		ans %= mod;
	}
	cout << ans <<endl;
	
	return 0;
}


Measured memory_bytes: 5184
def swap(a, i, j)
  a[i] = a[i] ^ a[j]
  a[j] = a[i] ^ a[j]
  a[i] = a[i] ^ a[j]
end

def selection_sort(a, n)
  swap_count = 0
  (0...n).each {|i|
    minj = i
    (i...n).each {|j|
      minj = j if a[j] < a[minj]
    }
    if i != minj
      swap(a, i, minj)
      swap_count += 1
    end
  }
  swap_count
end

n = gets.to_i
a = gets.split(" ").map(&:to_i)
swap_count = selection_sort(a, n)
puts a.join(" ")
puts swap_count

Measured memory_bytes: 8648