akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1e9+5
#define mx 200005
//#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
const int inf = 1e9+5;
//i  = current stair
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i] ;
    int dp[n] ;
    for(int i=0;i<n;i++)
        dp[i] = inf;
    dp[0] = 0 ;
    for(int i=0;i<n;i++)
    {
        for(int j= (i+1);j<=(i+k);j++)
        {
            if(j<n)
            {
                dp[j] = min(dp[j],(abs(h[j]-h[i]) + dp[i]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

int cal(int a, int b) {
  if (a <= b) return b - a;
  else return 2e9;
}

void MAIN() {
  int a, b;
  cin >> a >> b;
  cout << min(
    min(cal(a, b), cal(-a, b) + 1),
    min(cal(a, -b) + 1, cal(-a, -b) + 2)
  );
}

signed main() {
  // ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
	int N,dir,D[100005]={0},maxD=0;
	long long sum;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>dir;
		if(i==0&&dir!=0){
			cout<<0;
			return 0;
		}	
      	if(dir>maxD)maxD=dir;
		D[dir]++;
	}
	if(D[0]!=1){
		cout<<0;
		return 0;
	}
    long mod = 998244353;
	sum=1;
	for(int i=2;i<=maxD;i++){
		if(D[i]!=0){
			for (int j=0;j<D[i];j++){
				sum*=D[i-1];
				sum%=mod;
			}
		}else{
			sum=0;
			break;
		}
	}
	cout<<sum;
	return 0;
}


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

void trans(char *x, char *y, int v)
{
    while (v++ < 81) *x = '0', x++;
    strcat(x, y);
}
 
int main(void)
{
    int n;
    char a[128], b[128];
    char x[128], y[128];
 
    scanf("%d", &n);
    while (n--){
        scanf("%81s %81s", a, b);
        if (fmax(strlen(a), strlen(b)) < 81){
            int carry, i;
 
            memset(x, 0, sizeof(x));
            memset(y, 0, sizeof(y));
 
            trans(x, a, strlen(a));
            trans(y, b, strlen(b));
             
            for (carry = i = 0; i < 81; i++){
                int v = x[80 - i] - '0' + y[80 - i] - '0' + carry;
                carry = v > 9;
                x[80 - i] = v % 10 + '0';
            }
            for (i = 0; i < 80 && x[i] == '0'; i++);
            puts(i ? x + i : "overflow");
        }
        else puts("overflow");
    }
    return (0);
}

Measured memory_bytes: 596
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    
    
    int k=100;
    int c = 0;
    int  n ;
    cin>>n ;
     while( k < n){
            c++;
         k = k +   k/100;
     }
     cout<<c<<endl;
     
}

Measured memory_bytes: 3612
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
 
d1 = []
d2 = []
 
for ind,i in enumerate(A):
    d1.append(ind+i)
    d2.append(ind-i)
    
c1 = Counter(d1)
c2 = Counter(d2)

ans = 0
for i in c1.keys():
    ans += (c1[i]*c2[i])
 
print(ans)

Measured memory_bytes: 63524
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,y,z;
  cin >> n >> m;
  vector<int> x(n,10);
  for (int i = 0; i < m; i++) {
    cin >> y >> z;
    if(y==1&&z==0&&n!=1) {
      cout << -1 << endl;
      exit(0);
    }
    if(x[y-1]!=10&&x[y-1]!=z) {
      cout << -1 << endl;
      exit(0);
    }
    x[y-1]=z;
  }
  if(x[0]==10) {
    if(n!=1){
      x[0]=1;
    }else{
      x[0]=0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << x[i]%10;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 998244353;

ll sums[305][305];
ll sum1[305][305];

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  string s;
  int n, k;
  cin >> s >> k;
  s = '0' + s;
  n = s.size();
  vi a;
  for (int i = 0; i < n; ++i) if (s[i] == '0') {
    int c = 0;
    for (int j = i + 1; j < n && s[j] == '1'; ++j) ++c;
    a.push_back(c);
  }
  vi sa(a.size() + 1);
  for (int i = 0; i < a.size(); ++i) {
    sa[i + 1] = sa[i] + a[i];
//    cerr << sa[i + 1] << endl;
  }
  vvl d(sa.back() + 1, vl(min(n, k) + 1));
  d[0][0] = 1;
  for (int i = 1; i < sa.size(); ++i) {
    vvl nd(d.size(), vl(d[0].size()));
    for (int j = 0; j < d[0].size(); ++j) {
      for (int t = 0; t < d.size(); ++t) {
        sums[j][t + 1] = (sums[j][t] + d[t][j]) % mod;
        if (t - sa[i - 1] <= j) {
          int x = j - t + sa[i - 1];
          sum1[x][t + 1] = (sum1[x][t] + d[t][j]) % mod;
        }
      }
    }
    for (int t = sa[i]; t <= sa.back(); ++t) {
      int ds = t - sa[i];
      for (int j = ds; j < d[t].size(); ++j) {
        nd[t][j] = (sums[j][t + 1] - sums[j][sa[i - 1] + ds] + sum1[j - ds][sa[i - 1] + ds] - sum1[j - ds][sa[i - 1]]) % mod;
//        cerr << t << ' ' << j << ' ' << (mod + nd[t][j]) % mod << ' ' << sums[j][t + 1] - sums[j][sa[i - 1] + ds] << endl;
      }
    }
    d.swap(nd);
  }
  ll res = 0;
  for (int i = 0; i < min(k + 1, (int)d.back().size()); ++i) {
//    cerr << i << ' ' << d.back()[i] << endl;
    res = (res + d.back()[i]) % mod;
  }
  cout << (res + mod) % mod << endl;
  return 0;
}


Measured memory_bytes: 6080
n,k = map(int,input().split())

x = list(map(int,input().split()))

ans = 1e9

for i in range(len(x)-k+1):
    l = abs(x[i+k-1]-x[i]) + min(abs(x[i]),abs(x[i+k-1]))
    ans = min(ans,l)

print(ans)

Measured memory_bytes: 14228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static final int FIRST_NUMBER = 0;
    public static final int SECOND_NUMBER = 1;

    public static void main(String[] args) throws NumberFormatException, IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	// ???????????°
	int vertical = Integer.parseInt(br.readLine());
	// ?¨?????????°
	int horizontal = Integer.parseInt(br.readLine());

	// ???????????????????´?????????°??????????????????
	List<int[]> changeRequests = new ArrayList<>();
	for (int i = 0; i < horizontal; i++) {
	    String[] changeRequestStr = br.readLine().split(",");
	    int[] changeRequest = new int[2];
	    changeRequest[FIRST_NUMBER] = Integer.parseInt(changeRequestStr[FIRST_NUMBER]);
	    changeRequest[SECOND_NUMBER] = Integer.parseInt(changeRequestStr[SECOND_NUMBER]);
	    changeRequests.add(changeRequest);
	}

	// ?????\???????????????????´???????????????????????????????
	int[] outputArray = getDrawedArray(changeRequests, vertical, horizontal);

	// ???????????????????????????????????¨????????????????????????????????????1??????????????????
	for (int i = 1; i < outputArray.length; i++) {
	    System.out.println(outputArray[i]);
	}

    }

    /**
     * ?????? ???????????????????????????????????\??????????????????
     * 
     * @param changeRequests
     * @param vertical
     * @param horizontal
     * @return ?????\?????????
     */
    private static int[] getDrawedArray(List<int[]> changeRequests, int vertical, int horizontal) {
	// ?????\?????????????????????????????????????????????
	// ?????????????????????????????¨?????\????????????????????´???????????????outputArray[0]????????¨?????????
	int[] outputArray = new int[vertical + 1];
	for (int i = 1; i < outputArray.length; i++) {
	    outputArray[i] = i;
	}

	// ?????????????????????????£????????????\????????????
	for (int[] changeRequest : changeRequests) {
	    int mediator = 0;
	    mediator = outputArray[changeRequest[FIRST_NUMBER]];
	    outputArray[changeRequest[FIRST_NUMBER]] = outputArray[changeRequest[SECOND_NUMBER]];
	    outputArray[changeRequest[SECOND_NUMBER]] = mediator;

	}

	return outputArray;

    }

}

Measured memory_bytes: 24324
#include<bits/stdc++.h>
using namespace std;
double dp[35][1<<8],INF=999999999;
double edge[35][35]={};
int n,m,p,a,b;
int t[10];


void dfs(int pt,int bit){
  for(int j=0;j<m;j++){
    if(edge[pt][j]!=0){
      //cout<<"edge"<<edge[p][j]<<endl;
      //cout<<"bit"<<bit<<endl;
      for(int k=0;k<n;k++){
        //cout<<"k;"<<k<<" bit&"<<(bit&(1<<k))<<endl;
        if((bit&(1<<k))==(1<<k)){
          //cout<<"x"<<endl;
          int rebit=bit-(1<<k);
          //cout<<"rebit"<<rebit<<endl;
          //cout<<dp[j][rebit]<<endl;
          //cout<<dp[p][bit]+(edge[p][j]/t[k])<<endl;
          if(dp[j][rebit]>dp[pt][bit]+(edge[pt][j]/t[k])){
            dp[j][rebit]=dp[pt][bit]+(edge[pt][j]/t[k]);
            dfs(j,rebit);
          }
        }
      }
    }
  }
}

int main(){
  while(true){
    cin>>n>>m>>p>>a>>b;
    if(n==0&&m==0&&p==0&&a==0&&b==0) break;
    for(int i=0;i<35;i++){
      for(int j=0;j<(1<<8);j++){
        dp[i][j]=INF;
      }
    }
    for(int i=0;i<35;i++){
      for(int j=0;j<35;j++){
        edge[i][j]=0;
      }
    }
    for(int i=0;i<8;i++){
      t[i]=0;
    }


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

    for(int i=0;i<p;i++){
      int x,y;
      double z;
      cin>>x>>y>>z;
      edge[x-1][y-1]=z;
      edge[y-1][x-1]=z;
    }
    dp[a-1][(1<<n)-1]=0;
    dfs(a-1,(1<<n)-1);
    double ans=INF+100;
    int ansj;
    for(int j=0;j<(1<<n);j++){
      if(ans>dp[b-1][j]) ansj=j;
      ans=min(ans,dp[b-1][j]);
    }
    //cout<<"ansl"<<ansj<<endl;
    if(ans<INF){
      printf("%f\n",ans);
    }else{
      cout<<"Impossible"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  ll n, m;
  cin >> n >> m;
  ll n2 = 2*n;
  if(n2==m) cout << n << endl;
  else if(n2<m){
    m = m-n2;
    m /= 4;
    cout << m+n << endl;
  }
  else{
    cout << m/2 << endl;
  }
}


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

    long double pi=3.1416,x;

    x=2*pi*r;
    
    cout<<setprecision(20)<<fixed;
    cout<<x<<endl;









    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <time.h>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
using namespace std;
inline int lowb(int x) {
	return x & -x;
}
int n, m, a[100005], b[100005] /*, p[], ans */;
struct EDGE {
	int to, dis;
};
long long ans= 1;
int main() {
	cin >> n;
	for(int i= 1; i <= n; i++) {
		cin >> a[i];
		if((a[i] != 0 && i == 1) || (a[i] == 0 && i != 1)) {
			cout << 0 << endl;
			return 0;
		}
	}
	sort(a + 1, a + n + 1);
	b[0]= 1;
	for(int i= 1; i <= n; i++) {
		ans= ans * b[a[i]] % 998244353, ++b[a[i] + 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		int[] a = new int [n];
		boolean[] done = new boolean [n];
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(str[i]) - 1;
		}
		int cnt = 0;
		for(int i = 0; i < n; i++){
			if(!done[i]){
				done[i] = true;
				int j = a[i];
				if(i==a[j]){
					done[j] = true;
					cnt++;
				}
			}
		}
		sb.append(cnt);
		System.out.println(sb);
	}
}

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

int main()
{
    string s;
    cin >> s;
    int counter = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i == 3)
            s[i] = '8';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <string.h>
#include <algorithm>
#include<cstdlib>
typedef long long ll;
using namespace std;

int main()
{
    string a;
    int count = 0;
    cin >> a;
    for(int i = 0; i < 4; i++)
    {
        if(a[i] == '2'){
            count++;
        }
    }
    cout << count << endl;
}

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

void Main() {
    // input
    string S;
    cin >> S;

    int count = 0;

    if (S == "RSR") {
        count = 1;
        cout << count << endl;
        return;
    }

    for (int i = 0; i < 3; i++) {
        if (S[i] == 'R') {
            while (S[i] == 'R') {
                count++;
                i++;
            }
        }
    }





    // output
    cout << count << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N,M,K;
  cin >> N >> M >> K;
  vector<long long> A(N);
  vector<long long> B(M);
  vector<long long> C(N+1,0);
  vector<long long> D(M+1,0);
  for(int a = 0;a < N;a++){
    cin >> A[a];
    if(a == 0)C[1] = A[0];
    if(a != 0)C[a+1] = C[a] + A[a];
  }
  for(int a = 0;a < M;a++){
    cin >> B[a];
    if(a == 0)D[1] = B[0];
    if(a != 0)D[a+1] = D[a] + B[a];
  }
  long long result = 0;
  long long n = 0;
  for(int a = N;a >= 0;a--){
     for(int b = n;b <= M&&C[a] + D[b] <= K;b++){
         if(result < a + b){
         result = a + b;
         }
       n = b;
     }
    
    
  }
  cout << result << endl;
  
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  while(1){
    ll n,x,ans=0;
    cin >> n >> x;
    if(n == 0 && x == 0)break;
    for (int i = 1; i <= n; i++) {
      for (int l = i+1; l <= n; l++) {
        for (int j = l+1; j <= n; j++) {
          if(i+l+j == x){
            ans++;
          }  
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3104
# -*- coding: utf-8 -*-

import itertools

# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

#list = []
#for i in range(N+1):
#    list.append(i)

#print(list)

#print(range(N+1))

ans=0

i=K
while(i<=N+1):
    #print("i:"+str(i))
    #comb=combinationListRecursive(list, i)
    #comb = list(itertools.combinations(range(N+1), i))
    #print(comb)
    #tmp=[]
    #min=0
    #max=0
    #j=0
    #while(j<=i-1):
        #min = min+j
        #max = max+(N-j)
        #j=j+1
    max=((N-i+1+N)*i)/2
    min=((0+i-1)*i)/2
    #print("max:"+str(max))
    #print("min:"+str(min))
    #print("diff:"+str(max-min+1))
    ans=ans+(max-min)+1

    i=i+1


print(int(ans)%1000000007)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

int mul(int a, int b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}

void solve() {
  int n, k, ans = 1, K; cin >> n >> k;
  K = k;
  vector <int> p, neg, z;
  vector <pii> v;
  for(int i = 0; i < n; i++) {
    int x, s; cin >> x;
    if(x > 0) {
      p.pb(x);
      s = 1;
    }
    if(x < 0) {
      neg.pb(abs(x));
      s = -1;
    }
    if(x == 0) {
      z.pb(x);
      s = 1;
    }
    v.pb({abs(x), s});
  }
  sort(all(p)); sort(all(neg)); sort(all(z)); sort(all(v));
  int i = sz(p)-1, j = sz(neg)-1;

  if(k%2) {
    if(!p.empty()) {
      k--; ans = mul(ans, p[i]);
      i--;
    }
  }

  while(k && (i > 0 || j > 0)) {
     int a = -INF, b = -INF;
     if(i >= 1) {
       a = p[i] * p[i-1];
     }
     if(j >= 1) {
       b = neg[j] * neg[j-1];
     }
     if(a > b) {
       ans = mul(ans, a);
       k-=2; i-=2;
     }
     else {
       ans = mul(ans, b);
       k-=2; j-=2;
     }
  }
  if(k) {
    if(!z.empty()) {
      ans = 0;
    } else {
      ans = 1;
      for(int l = 0; l < K; l++) {
         ans = mul(ans, v[l].ss * v[l].ff);
      }
    }
  }
  cout << ans << '\n';
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
     solve();
  }


Measured memory_bytes: 9512
import random
import time
import copy
start=time.time()
d=int(input())
c=list(map(int, input().split()))
s=[]
solution=[]
last=[0]*26
sco=0
for i in range(d):
  s.append(list(map(int, input().split())))
for day in range(1,d+1):
  man=[]
  for i in range(26):
    man.append(s[day-1][i]+last[i]*c[i])
  con=man.index(max(man))
  sco+=s[day-1][con]
  last[con]=day
  for (i,j) in zip(last,c):
    sco-=i*j
  solution.append(con)
while time.time()-start<1.9:
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(10)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,c):
      sc-=i*j
  if sc>sco:
    solution=copy.deepcopy(sol)
    sco=sc
for i in solution:
  print(i+1)


Measured memory_bytes: 9964
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

int main() {
    string in;
    cin >> in;
    unordered_map<char, int> cop;
    for (int i = 0; i < 4; ++i) {
        ++cop[in[i]];
    }
    if (cop.size() != 2) {
        cout<<"No"<<endl;
        return 0;
    }
    for (auto p : cop) {
        if (p.second != 2) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
};


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

int main(){
  int counter = 0;
  int max = 0;
  string N;
  cin >> N;
  max = N.size();
  //cout << max << endl;
  vector<int> plus(N.size());
  for(int i = 0; i < max; i++){
    if(N.at(i) == '1') counter += 1;
    if(N.at(i) == '2') counter += 2;
    if(N.at(i) == '3') counter += 3;
    if(N.at(i) == '4') counter += 4;
    if(N.at(i) == '5') counter += 5;
    if(N.at(i) == '6') counter += 6;
    if(N.at(i) == '7') counter += 7;
    if(N.at(i) == '8') counter += 8;
    if(N.at(i) == '9') counter += 9;
  }
  //cout << counter << endl;
  if(counter % 9 > 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 4380
package main

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

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

type Stack struct {
	stack []int
}

func (stack *Stack) push(val int) {
	stack.stack = append(stack.stack, val)
}

func (stack *Stack) pop() int {
	if len(stack.stack) == 0 {
		return -1
	}

	val := stack.stack[len(stack.stack)-1]
	stack.stack = stack.stack[0 : len(stack.stack)-1]
	return val
}

func (stack *Stack) empty() bool {
	if len(stack.stack) == 0 {
		return true
	}
	return false
}

type Stack2 struct {
	stack []Tuple
}

type Tuple struct {
	index int
	area  int
}

func (stack *Stack2) push(val Tuple) {
	stack.stack = append(stack.stack, val)
}

func (stack *Stack2) pop() Tuple {
	if len(stack.stack) == 0 {
		return Tuple{-1, 0}
	}

	val := stack.stack[len(stack.stack)-1]
	stack.stack = stack.stack[0 : len(stack.stack)-1]
	return val
}

func (stack *Stack2) top() Tuple {
	if len(stack.stack) == 0 {
		return Tuple{-1, 0}
	}

	val := stack.stack[len(stack.stack)-1]
	return val
}

func (stack *Stack2) empty() bool {
	if len(stack.stack) == 0 {
		return true
	}
	return false
}

func main() {
	line := nextLine()

	s1 := Stack{}
	s2 := Stack2{}
	total := 0 // 面積の総和
	for i, r := range line {
		rr := string(r)

		switch rr {
		case "\\":
			s1.push(i) // indexをStackに追加
		case "/":
			b := s1.pop()
			if b == -1 {
				continue
			}

			area := i - b
			total += area

			if !s2.empty() {

				if s2.top().index < b {
					s2.push(Tuple{b, area})
				} else {
					t2 := s2.pop()
					new_area := area

					for t2.index > b {
						new_area += t2.area
						t2 = s2.pop()
					}
					s2.push(t2)
					s2.push(Tuple{b, new_area})
				}
			} else {
				s2.push(Tuple{b, area})
			}
		default:
			// no op
		}
	}

	fmt.Println(total)

	out := make([]string, 0)
	if len(s2.stack) == 0 {
		fmt.Println(0)
		return
	}
	for _, a := range s2.stack {
		if a.area == 0 {
			continue
		}
		out = append(out, strconv.Itoa(a.area))
	}
	fmt.Printf("%d %s\n", len(out), strings.Join(out, " "))
}



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

div_num = 0
for n in range(105, N+1, 2):
  div_c = 0
  for t in range(1, n+1):
    if n % t == 0:
      div_c += 1
  if div_c == 8 :
    div_num += 1

print(div_num)

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

int main(){
  // 入力
  long int N;
  cin >> N;

  long int result=0;
  for (long int i=1; i<=N; i++) {
    if(i%3!=0 && i%5!=0 ) {
      result+=i;
    }
  }

  cout << result << endl;
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 30; j++)
		{
			if (4 * i + 7 * j == n)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ld pi = (acos(-1));


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ll n,k; cin >> n >> k;
  ll ans=0;
  for(ll i=k; i<=n+1;++i){
    ll first = i*(i-1)/2;
    ll last =(n*2-i+1)*i /2;
    ll add = last-first+1;
    ans=(ans+add)%mod;    
  }
  cout << ans << endl; 
}

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
  int fib[45], n, i;
  
  scanf( "%d" , &n );
  
  fib[0] = fib[1] = 1;
  for ( i=2; i<=n; i++ ) fib[i] = fib[i-2] + fib[i-1];
  
  printf( "%d\n" , fib[n] );
  
  return 0;
}



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

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  	
  	bool ans = true;
  	sort(a.begin(), a.end());
  	rep(i, n){
		if(a[i] == a[i+1]){
        	ans = false;
          	break;
        }
    }
  
  	if(ans) cout << "YES" << endl;
  	else cout << "NO" << endl;
}

Measured memory_bytes: 3948
# 参考URL https://note.nkmk.me/python-union-find/
class UnionFind():
    # parents
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # find(x)
    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # union(x, y)
    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # size(x)
    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # same(x, y)
    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # members(x)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    # roots()
    # すべての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # group_count()
    # グループの数を返す
    def group_count(self):
        return len(self.roots())

    # all_group_members
    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    # __str__()
    # print()での表示用
    # ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

n, k, l = map(int, input().split())

road = UnionFind(n)
rail = UnionFind(n)
for _ in range(k):
    p, q = map(int, input().split())
    road.union(p-1, q-1)
for _ in range(l):
    r, s = map(int, input().split())
    rail.union(r-1, s-1)

dic = {}
l = []
for i in range(n):
    tup = (road.find(i), rail.find(i))
    l.append(tup)
    if tup in dic:
        dic[tup] += 1
    else:
        dic[tup] = 1

ans = []
for i in l:
    ans.append(dic[i])

print(' '.join(map(str, ans)))

Measured memory_bytes: 113244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

const int N = 100001;

int color[N];
bool vis[N][11];

vector<int> edges[N];

struct Query
{
	int v, d, c;
} queries[N];

void f(int v, int d, int c)
{
	if (!color[v]) {
		color[v] = c;
	}
	if (d > 0) {
		if (!vis[v][d - 1]) {
			vis[v][d - 1] = true;
			f(v, d - 1, c);
		}
		for (int i = 0; i < edges[v].size(); ++i) {
			if (!vis[edges[v][i]][d - 1]) {
				vis[edges[v][i]][d - 1] = true;
				f(edges[v][i], d - 1, c);
			}
		}
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		scanf("%d%d%d", &queries[i].v, &queries[i].d, &queries[i].c);
	}
	for (int i = q - 1; i >= 0; --i) {
		if (!vis[queries[i].v][queries[i].d]) {
			f(queries[i].v, queries[i].d, queries[i].c);
		}
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d\n", color[i]);
	}
	return 0;
}



Measured memory_bytes: 9080
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String ans[] = { "Yes", "No" };
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		sc.close();
		int an = ((a == b) ? (a != c) ? 0 : 1 : (a == c) ? 0 : (b == c) ? 0 : 1);
		System.out.println(ans[an]);
	}
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
#define ll long long

int main(){
  ll A, B;
  cin >> A >> B;
  while(B>0){
    ll C = A%B; A=B; B=C;
  }

  ll p=2, ans=1;
  while(p*p<=A){
    ll c=0;
    while(A%p==0){
      A/=p;
      c=1;
    }
    if (c>0) ++ans;
    ++p;
  }
  if (A>1) ++ans;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pub push_back


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;








typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;

vector<ll> fact;
vector<ll> fact2;
void finit(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll comb(ll a, ll b);


void finit(int n){
	fact.resize(n + 5);
	fact2.resize(n + 5);
	fact[0] = fact2[0] = 1;
	for (int i = 1; i <= n; i++){
		fact[i] = (fact[i - 1] * i) % MOD;
		fact2[i] = exp(fact[i], MOD - 2, MOD);
	}
}
ll exp(ll taban, ll us, ll md) {
	ll carpan = taban % md;
	if (carpan == 0) return 0;
	ll temp = us;
	ll ans = 1;
	while (temp){
		if (temp % 2) ans = (ans*carpan) % md;
		temp /= 2;
		carpan = (carpan*carpan) % md;
	}
	return ans;
}

ll ebob(ll a, ll b){
	if (!a)return b;
	return ebob(b%a, a);
}

ll ekok(ll x, ll y){
	return (x*y) / ebob(x, y);
}

ll comb(ll x, ll y){
	if (x < y) return 0;
	return fact[x] * ((fact2[x - y] * fact2[y]) % MOD) % MOD;
}
















ll n, k;
ll res;
ll t = 1, x, y, p, q;
signed main(){
	IOS;
	//cin >> t;
	while (t--){
		cin >> n;
		string s;
		vi vec;
		while (n > 0){
			if (n % 26 == 0){
				vec.push_back(26);
				n -= 26;
			}
			else{
				vec.pub(n % 26);
				//cout << n % 26 << endl;;
				
			}
			n /= 26;
			
			
		}
		ll size = vec.size();
		while (!vec.empty()){
			
			s.pub(vec.back() + 'a' -1  );
			vec.pop_back();
		}
		cout << s;

		
	}


	getchar(); getchar();

	return 0;

}

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

int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  long long ans = (n / (a+b)) * a;
  if(n % (a+b) > a)
    ans+=a;
  else
    ans+=n % (a+b);
  cout << ans << endl;
}

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

const int N = 1e5+7, K = 61;
long long v[N], d[N], p[N][K], ans[N];

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

    int n;
    cin>>n;

    for (int i=1; i<=n; i++) cin>>v[i];
    for (int i=1; i<n; i++) {
        d[i] = v[i+1]-v[i];
        p[i][0] = i;
    }

    int m;
    long long k;
    cin>>m>>k;

    for (int i=1; i<=m; i++) {
        int x;
        cin>>x;
        swap(p[x-1][0], p[x][0]);
    }

    for (int i=1; i<K; i++)
        for (int j=1; j<n; j++)
            p[j][i] = p[p[j][i-1]][i-1];

    vector<long long> ans;
    ans.push_back(v[1]);
    for (int i=1; i<n; i++) {
        int cur = i;
        for (int i=K-1; i>=0; i--)
            if (k & (1LL<<i))
                cur = p[cur][i];
        ans.push_back(ans.back()+d[cur]);
    }
    assert(ans.back() == v[n]);
    for (long long x: ans)    cout<<x<<"\n";
}


Measured memory_bytes: 51444
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  char b;
  cin >> b;
  if(b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else if(b == 'G') cout << 'C' << endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N,K;
  cin>>N>>K;
  if((N+1)/2>=K){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
  return 0;
}

Measured memory_bytes: 3592
rows,column = gets.chomp.split(" ").map(&:to_i)
boxes = []
rows.times do |row|
  columns = gets.chomp.split("").map(&:to_s)
  boxes << columns
end
boxes.each_with_index do |row,y|
  row.each_with_index do |point,x|
    if point != "#"
      count = 0
      check_list = [[x-1,y-1],[x,y-1],[x+1,y-1],[x-1,y],[x+1,y],[x-1,y+1],[x,y+1],[x+1,y+1]]
      check_list.each do |check|
        if (check[1] >= 0 && check[1] < rows)&&(check[0] >= 0 && check[0] < column)
          if boxes[check[1]][check[0]] == "#"
            count += 1
          end
        end
      end
      boxes[y][x] = count
    end
  end
end

boxes.each do |row|
  ans = ""
  row.each do |point|
    ans += point.to_s
  end
  puts ans
end



Measured memory_bytes: 2172
use std::io::*;
use std::str::FromStr;
use std::cmp::max;

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();

    let mut ruil: Vec<usize> = vec![0; n+1];
    let mut ruir: Vec<usize> = vec![0; n+1];
    ruil[0] = a[0];
    ruir[n] = a[n-1];
    for i in 0..n-1 {
        ruil[i+1] = gcd(ruil[i], a[i+1]);
        ruir[n-i-1] = gcd(ruir[n-i], a[n-i-2]);
    }

    let mut ans = 0;
    for i in 0..n {
        if i == 0 {
            ans = max(ans, ruir[2]);
        } else if i == n-1 {
            ans = max(ans, ruil[n-2]);
        } else {
            ans = max(ans, gcd(ruil[i-1], ruir[i+2]));
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

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

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 998244353
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 4005;
int N;
string S;
int sumR[MAX_N];
int sumB[MAX_N];

int dp[MAX_N][MAX_N];

signed main()
{
  cin >> S; N = S.size()*2;
  REP(n,S.size()) {
    sumR[n+1] = sumR[n];
    sumB[n+1] = sumB[n];
    if(S[n]=='0') {
      sumR[n+1]+=2;
    } else if(S[n]=='1') {
      sumR[n+1]++;
      sumB[n+1]++;
    } else {
      sumB[n+1]+=2;
    }
  }

  dp[0][0] = 1;

  REP(n,N) {
    REP(red,n+1) {
      if(dp[n][red] == 0) {
        continue;
      }

      if(red<sumR[min((LL)S.size(),n+1)]) {
        dp[n+1][red+1] += dp[n][red];
        dp[n+1][red+1] %= MOD;
      }

      int blue = n-red;
      if(blue<sumB[min((LL)S.size(),n+1)]) {
        dp[n+1][red] += dp[n][red];
        dp[n+1][red] %= MOD;
      }
    }
  }

  cout << dp[N][sumR[S.size()]] << endl;

  return 0;
}

Measured memory_bytes: 123520
Q, H, S, D = map(int, input().split())
N = int(input())

N = N*4

price = [Q,H,S,D]
quas = [1, 2, 4, 8]

che = [(Q*8, 0), (H*4, 1), (S*2, 2), (D, 3)]
che.sort()

ans = 0
for (hoge, ind) in che:
	qua = quas[ind]
	now = price[ind]

	ans += (N // qua) * now
	N %= qua

print(ans)
	


Measured memory_bytes: 38384
#include <stdio.h>
int main(void){
    int sx,sy,tx,ty;
    scanf("%d",&sx);
    scanf("%d",&sy);
    scanf("%d",&tx);
    scanf("%d",&ty);
    for(int i=sx;i<tx;i++)
        putchar('R');
    for(int i=sy;i<ty;i++)
        putchar('U');
    for(int i=tx;i>sx;i--)
        putchar('L');
    for(int i=ty;i>sy;i--)
        putchar('D');
    putchar('D');
    for(int i=sx;i<tx+1;i++)
        putchar('R');
    for(int i=sy-1;i<ty;i++)
        putchar('U');
    putchar('L');
    putchar('U');
    for(int i=tx;i>sx-1;i--)
        putchar('L');
    for(int i=ty+1;i>sy;i--)
        putchar('D');
    putchar('R');
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long count = 0;
  vector<long long> a(n);
  for (long long i=0; i<n; i++) {
    cin >> a[i];
  }
  for (long long i=1; i<n; i++) {
    if (a[i-1]>a[i]) {
      count += a[i-1]-a[i];
      a[i] = a[i-1];
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 4316
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   ll n, k; cin>>n>>k;
   vector<ll> LI(n);

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

   sort(all(LI));

   ll hi = 1e18, lo = -1e18;

   ll val_mid = 0;

   while(lo != hi){
       ll cnt = 0;
       val_mid = lo + (hi-lo)/2;
       for(int i = 0; i < n-1; i++){
           ll llo = 0, hhi = n-1-i, mmid = 0;
           while(hhi != llo){
               mmid = (hhi + llo)/2;
               if(LI[i]*(LI[i] >= 0 ? LI[i+1+mmid] : LI[n-1-mmid]) < val_mid)
                    llo = mmid + 1;
                else hhi = mmid;
           }
           cnt += llo;
           }
           if(cnt < k) lo = val_mid + 1;
           else hi = val_mid;
       }

       cout<<lo-1<<"\n";
}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

int main(){
	ll n,k; cin >> n >> k;
	vector<double>p(n,1); rep(i,n)p[i] /= n;
	ll q = min(n,k-1)
	rep(i,q){
		ll r = i+1;
		while(r < k){
			r *= 2;
			p[i] /= 2;
		}
	}
	double ans = 0;
	rep(i,n)ans += p[i];
	cout << fixed << setprecision(12);
	cout << ans << endl;
}

Measured memory_bytes: 1024
l,r = map(int,input().split())
if r-l > 2017:
  print(0)
else:
  mod_min = 2019
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      mod = (i*j)%2019
      if mod <= mod_min:
        mod_min = mod
      else:
        pass
  print(mod_min) 

  

  
  


    

Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

void permutationConv(vector<LL> &b,vector<LL> &f){
    vector<int> tmp(b.size());
    REP(i,b.size()) tmp[i]=b[f[i]];
    REP(i,b.size()) b[i]=tmp[i];
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    LL k;
    cin >> n;
    vector<LL> x(n), dx(n-1),r(n-1),r2(n-1);
    vector<vector<LL>> to(62,vector<LL>(n-1));
    REP(i,n) cin >> x[i];
    REP(i,n-1) {
        dx[i]=x[i+1]-x[i];
        r[i]=i;
    }
    cin >> m>>k;
    vector<LL> jmp(m);
    REP(i,m){
        cin >> jmp[i];
    }
    REP(i,m) swap(r[jmp[i]-2],r[jmp[i]-1]);
    REP(i,n-1) to[0][i]=r[i];
    //REP(j,n-1)DBG(to[0][j])
    FOR(i,1,61){
        REP(j,n-1) to[i][j]=j;
        REP(j,2) permutationConv(to[i],to[i-1]);
        //cerr << " "<<i << endl;
        //REP(j,n-1)DBG(to[i][j])
    }
    REP(i,n-1) r[i]=i;
    for(LL i=k,j=0; i>0; i/=2,++j){
        if(i%2==1){
            permutationConv(r,to[j]);
        }
    //REP(i,n-1)DBG(r[i])
    }
    //REP(i,n-1)r2[r[i]]=dx[i];
    //REP(i,n-1)DBG(r2[i])
    REP(i,n-1)x[i+1]=x[i]+dx[r[i]];

    cout << fixed << setprecision(10);
    REP(i,n)cout << (double)x[i] <<endl;

    return 0;
}


Measured memory_bytes: 55280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc090_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int sum = 0;
            for (int i = a; i <= b; i++)
            {
                string str = i.ToString();
                if (str[0] == str[4] && str[1] == str[3])
                {
                    sum++;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 30056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int memo = 1; 
  for (int i = 0; i < N - 1; i++) {
    if (A.at(i) == A.at(i + 1)) {
      memo++;
    }
    else {
      if (memo < A.at(i)) {
        ans += memo;
        memo = 1;
      }
      else {
        ans += abs(A.at(i) - memo);
        memo = 1;
      }
    }
  }
  if (memo < A.at(N - 1)) {
    ans += memo;
  }
  else {
    ans += abs(A.at(N - 1) - memo);
  }
  cout << ans << endl;
}

    

Measured memory_bytes: 3756
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
using namespace std;

void trace(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i];
	}
	cout << "\n";
}

void insertionSort(int a[], int n) {
	trace(a, n);
	int v, j;
	for (int i = 1; i < n; i++) {
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		trace(a, n);
	}
}

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

	insertionSort(a, n);
}


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

char byte_minus(char ch, int num)
{
  if ( 97 <= ch && ch <= 122 )
  {
    if ( ch - 97 >= num )
    {
      return ch - num;
    }
    else
    {
      return byte_minus('Z', num - (ch - 96) );
    }
  }
  else
  {
    if ( ch - 65 >= num )
    {
      return ch - num;
    }
    else
    {
      return byte_minus('z', num - (ch - 64) );
    }
  }
}

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if ( n == 0 ) break;
    int* keys = new int[n];
    for (int i = 0; i < n; i++)
    {
      cin >> keys[i];
    }
    string cipher;
    //getline(cin, cipher);
    cin >> cipher;
    for (int i = 0, size = cipher.length(); i < size; i++)
    {
      int key_index = i % n;
      char result = byte_minus(cipher[i], keys[key_index]);
      cout << result;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1208