akhauriyash/Code-Regression huggingface dataset:
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	LL n, a, b, c, d, e;
	
	cin >> n >> a >> b >> c >> d >> e;
	cout << (n-1) / min({a, b, c, d, e}) + 5;
	
	
	
	
	
	
	
	
	
	
	
	
	
    
	return 0;
}


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

namespace debug
{
    public static partial class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine().ToLong();
            var ais = Console.ReadLine().ToLongArray();

            var s = ais.Sum();
            var xis = new long[n];

            var sum = 0L;
            for (var i = 1; i < n; i += 2)
            {
                sum += ais[i];
            }

            xis[0] = s - 2 * sum;
            for (var i = 1; i < n; i++)
            {
                xis[i] = 2 * ais[i - 1] - xis[i - 1];
            }

            Console.WriteLine(xis.JoinToStr(" "));
        }
    }

    public static partial class Program
    {
        //テンプレここから
        private static long GCD(long aaa, long bbb) => bbb == 0 ? aaa : GCD(bbb, aaa % bbb);
        private static long LCM(long aaa, long bbb) => aaa * bbb / GCD(aaa, bbb);
        private static long ToLong(this double ddd) => (long) ddd;
        private static long ToLong(this string str) => long.Parse(str);
        private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
        private static long[] ToLongArray(this string str, char opr = ' ') => str.Split(opr).ToLong();
        private static long Diff(long aaa, long bbb) => Math.Abs(Math.Max(aaa, bbb) - Math.Min(aaa, bbb));
        private static long Sign(this long iii) => Math.Sign(iii);
        private static bool IsEven(this long iii) => iii % 2 == 0;
        private static bool IsEven(this int iii) => iii % 2 == 0;

        private static readonly int[] _Dx =
        {
            0, -1, 0, 1
        };

        private static readonly int[] _Dy =
        {
            -1, 0, 1, 0
        };

        public const int MOD = 1000000007;
        public const string UPPER_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const string LOWER_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
        private static long ToLong(this char ccc) => ccc.ToString().ToLong();
        private static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
        private static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

        private static string JoinToStr(this IEnumerable<long> array, string sep = "") =>
            array.Select(xxx => xxx.ToString()).Join(sep);

        public static string JoinToStr(this IEnumerable<int> array, string sep = "") =>
            array.Select(xxx => xxx.ToString()).Join(sep);

        //テンプレここまで
    }
}


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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int a[maxn], pre[maxn];
int n;

struct Tree{
  vector<int> f;
  int len;
  Tree(int n = 0) : len(n), f(n+1, 0) {}
  void Update(int i, int x){
    for (; i <= len; i += i & (-i))
      f[i] += x;
  }
  int Get(int i){
    int ret = 0;
    for (; i > 0; i -= i & (-i))
      ret += f[i];
    return ret;
  }
};

ll k;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  cin >> n; k = 1ll * (n + 1) * n / 4;

  for (int i = 1; i <= n; ++i){
    cin >> a[i];
  }
  Tree T(n+10);

  int l = *min_element(a + 1, a + n + 1), r = *max_element(a + 1, a + n + 1);
  while (l <= r){
    int mid = (l + r) >> 1;
    ll ret = 0;

    int lb = 0;
    pre[0] = 0;
    for (int i = 1; i <= n; ++i){
      if (a[i] >= mid) pre[i] = pre[i-1] + 1;
      else pre[i] = pre[i-1] - 1;
      lb = min(lb, pre[i]);
    }

    for (int i = 0; i <= n; ++i){
      pre[i] = pre[i] - lb + 1;

    }

    T.Update(pre[0], 1);
    for (int i = 1; i <= n; ++i){
      int t = T.Get(pre[i]);

      T.Update(pre[i], 1);
      ret = ret + t;
    }

    for (int i = 0; i <= n; ++i){
      T.Update(pre[i], -1);
    }

    if (ret >= k) l = mid + 1;
    else r = mid - 1;
  }
  cout << l - 1;
}




Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
int main(){
    int k,t,a[100];
    scanf("%d%d",&k,&t);
    for(int i=0;i<t;i++)scanf("%d",&a[i]);
    std::sort(a,a+t);
    int sum=0;
    for(int i=0;i<=t-2;i++)sum+=a[i];
    printf("%d",std::max(0,a[t-1]-sum-1));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string a,b,c;
  cin >> a >> b >> c;
  char A, B, C;
  A = a[0] - 32;
  B = b[0] - 32;
  C = c[0] - 32;
  cout << A << B << C << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int main() {
//cout << fixed << setprecision(10);
ll ca=0;
ll n;
cin>>n;
ll t[n]={};
ll a[n]={};
for(int i=0; i<n; i++){
cin>>t[i];
a[i]=t[i];}
ll rui=0;
if(t[0]>=0){
ca+=t[0]+1;
rui=-1;}
else{ rui=t[0];}
for(ll i=1; i<n; i++){
if(rui<0){
if(rui+t[i]>0){
rui+=t[i];
continue;}
else{
ca+=1-(rui+t[i]);
rui=1;}}
else{
if(rui+t[i]<0){
rui+=t[i];
continue;}
else{
ca+=rui+t[i]+1;
rui=-1;}}
}
ll cb=0;

if(a[0]<=0){
cb+=-a[0]+1;
rui=1;}
else{ rui=a[0];}
for(ll i=1; i<n; i++){
if(rui<0){
if(rui+a[i]>0){
rui+=a[i];
continue;}
else{
cb+=1-(rui+a[i]);
rui=1;}}
else{
if(rui+a[i]<0){
rui+=a[i];
continue;}
else{
cb+=rui+a[i]+1;
rui=-1;}}
}
ll ans=min(ca,cb);
cout<<ans<<endl;}


Measured memory_bytes: 5080
#!/usr/bin/python3
# -*- coding: utf-8 -*-
MOD = 1000000007


S = str(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]

# init
if S[0]=="?":
  for j in range(10):
    dp[0][j] = 1
else:
  dp[0][int(S[0])] = 1

# dp
for i in range(1,len(S)):
  if S[i]=="?":
    ks = list(range(10))
  else:
    ks = [int(S[i])]
  for j in range(13):
    for k in ks:
      dp[i][(j*10+k)%13] = (dp[i][(j*10+k)%13]+dp[i-1][j]) % MOD
print(dp[len(S)-1][5])

Measured memory_bytes: 65500
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

int main() {
    int K, S;
    cin >> K >> S;
    int cnt = 0;
    rep(x, K+1) {
        rep(y, K+1) {
            int z = S-(x+y);
            if(0<=z && z<=K) cnt++;
        }
    }
    print(cnt);

    return 0;
}

Measured memory_bytes: 3484
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;
double res,k,n;

void check(double a,double m,double x){
	if(a == 0){
		if(x-k < 1){
			x = 1;
			res += (1/pow(m,n)) * x;
		}
		else res += (1/pow(m,n)) * (x-k);
	}
	else{
		for(int i = 1;i <= m;i++){
			check(a-1,m,x+i);
		}
	}
}

int main(){
	double m;
	while(1){
		res = 0;
		cin >> n >> m >> k;
		if(n == 0)break;
		check(n,m,0);
		printf("%.10f\n",res);
	}
	return 0;
}

Measured memory_bytes: 3280
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,Q=MI()
    A=LI()
    if N%2==1:#長さが奇数なら0を足しておく
        A+=[0]
        N+=1
    A.sort()
    
    """
    連続する区間or交互
    """
    
    S=[0]*(N+1)
    S2=[0]*(N+1)#偶数のみ
    
    for i in range(N):
        S[i+1]=S[i]+A[i]
        
    for i in range(0,N-1):
        S2[i+2]=S2[i]+A[i]
        
    # print(S)
    # print(S2)
        
    def calc(P):
        # 先手が上からP枚，後手がその後のP枚をとり，残りを交互に取った時の先手のscore
        fi=S[-1]-S[-P-1]
        fi+=S2[-2*P]
        return fi
    
    def ch(X,P):
        #xが指定され，先手が上からP枚以上取れるか
        maxa=A[-P-1]#後手が取るmax
        mina=A[-2*P+1]#後手がP-1ターン目までに取る取るmin(後手がPターン目に取るものはなんでも良い)
        diff=A[-P]-X
        
        # print(X,P,mina,maxa,diff)
        if diff<0:
            return False
        if X-diff<=mina and maxa<=X+diff:
            return True
        return False
        
    
    for _ in range(Q):
        x=I()
        
        #先手が上から何枚以上取れるか
        ng=N//2 +1
        ok=1#先手が最大値をとる
        while ng-ok>1:
            med=(ok+ng)//2
            if ch(x,med):
                ok=med
            else:
                ng=med
                
        # print(ok)
        print(calc(ok))
            

main()


Measured memory_bytes: 83476
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++) cin >> l[i];
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if((upper_bound(l.begin(),l.end(),abs(l[n-i-1]-l[n-j-1]))-l.begin())<n-j-1){
        ans+= n-(upper_bound(l.begin(),l.end(),abs(l[n-i-1]-l[n-j-1]))-l.begin())-j-1;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h> 
#include<string> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<char> vc;

typedef map<long long,long long> mpi;
#define llu unsigned long long 
#define vbi vector<bool> 
#define mod 1000000007
#define all(v) (v).begin(), (v).end()
#define alr(x) x.rbegin(),x.rend()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define ms(x,v) memset(x,v, sizeof(x))
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define print_vec(v) for(ll i=0;i<(int)v.size();i++) cout<<v[i]<<" ";
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
const int N = 2e5 + 5;
using pi = pair<ll, ll>;
ll i,j,k;
void solve(){
   ll k,n; cin>>k>>n;
   ll sum=(k*500);
   if(sum>=n) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
  

return ;
}
signed main(){
   
    //CASET
    solve () ;
  
 
 
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// toll-gates.rs --- Toll Gates
// author: Seong Yong-ju <sei40kr@gmail.com>

#[allow(unused_macros)]
macro_rules! get {
  ($t:ty) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.trim().parse::<$t>().unwrap()
    }
  };
  ($($t:ty),*) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      let mut iter = line.split_whitespace();
      (
        $(iter.next().unwrap().parse::<$t>().unwrap(),)*
      )
    }
  };
  ($t:ty; $n:expr) => {
    (0..$n).map(|_|
                get!($t)
    ).collect::<Vec<_>>()
  };
  ($($t:ty),*; $n:expr) => {
    (0..$n).map(|_|
                get!($($t),*)
    ).collect::<Vec<_>>()
  };
  ($t:ty ;;) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.split_whitespace()
        .map(|t| t.parse::<$t>().unwrap())
        .collect::<Vec<_>>()
    }
  };
  ($t:ty ;; $n:expr) => {
    (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
  };
}

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Failed to parse token")
}

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn main() {
    let (_n, m, x) = get!(usize, usize, usize);
    let ys = (0..m).map(|mut _i| read::<usize>()).collect::<Vec<_>>();

    let ans =
        {
            let (m1, m2) = ys.into_iter().fold((0, 0), |(m1, m2), y| {
                if y < x {
                    (m1 + 1, m2)
                } else {
                    (m1, m2 + 1)
                }
            });

            min(m1, m2)
        };

    with_bufwriter(|mut out| writeln!(out, "{}", ans).unwrap());
}


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

bool f(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;
    for(int i=2;i<n;i++) {
      if(n%i==0){
        return false;
      }
  }
  return true;
}
int main(){
  int n;
  cin >> n;
  n--;
  while(true){
    n++;
    if(f(n)){cout << n <<endl; return 0;}
  } 
}

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

using namespace std;

long long n,m,k,l,i,j,a,b,mod=1000000007,fact[3005],dp[3005][3005];
string s;

/*
long long pow(int a,int b){
    long long ret=0;
    for(int j=b;j>0;j/=2){
        if(j%2==1) ret=(ret+a)%mod;
        a=(a*a)%mod;
    }
    return ret;
}

long long gay(int a,int b){
    return a*pow(b,mod-2);
}

long long countC(int a,int b){
    return gay(fact(a),(fact(b)*fact(a-b))%mod);
}
*/
main(){

cin>>n>>s;
/*
for(i=1;i<n-1;i++)
    if(s[i]==s[i-1]) w[i]=i;

for(i=1;i<n;i++)
    if(w[i]==0) w[i]=w[i-1];


fact[1]=1;
for(i=2;i<=n;i++){
    fac[i]=(fact[i-1]*i)%mod;
}*/

dp[1][1]=1;

for(i=2;i<=n;i++){
    if(s[i-2]=='<')
        for(j=1;j<=i;j++)
            dp[i][j]=dp[i-1][j-1];
    else
        for(j=1;j<=i;j++)
            dp[i][j]=(dp[i-1][i-1]-dp[i-1][j-1]+mod)%mod;
    for(j=1;j<=i;j++){
        dp[i][j]+=dp[i][j-1];
        dp[i][j]%=mod;
    }
    cout<<endl;
}

cout<<dp[n][n];

}


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

int main(){
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3628
h, w, k=map(int, raw_input().split())
a=["#"*(w+2)]+["#"+raw_input()+"#" for i in range(h)]+["#"*(w+2)]
q=[]
first=0
dis=[[0]*(w+2) for i in range(h+2)]
for i in range(h+2):
	for j in range(w+2):
		if a[i][j]=="S":
			q.append((i, j))
			dis[i][j]=1
while first<len(q):
	cur_x, cur_y=q[first]
	first+=1
	for next_x, next_y in ((cur_x+1, cur_y), (cur_x-1, cur_y), (cur_x, cur_y+1), (cur_x, cur_y-1)):
		if a[next_x][next_y]=="." and not dis[next_x][next_y]:
			q.append((next_x, next_y))
			dis[next_x][next_y]=dis[cur_x][cur_y]+1
result=h*w
for i in range(h+2):
	for j in range(w+2):
		if 0<dis[i][j]<=k+1:
			dis_exit=min(i-1, j-1, h-i, w-j)
			cnt=(dis_exit+k-1)/k
			result=min(result, 1+cnt)
print result

Measured memory_bytes: 81284
#include<stdio.h>
int main()
{
    int a,p,t;
    scanf("%d%d",&a,&p);
    if(a*3+p<2)
    {
        printf("0");
    }
    else
    {
    t=(a*3+p)/2;
    printf("%d",t);
    }
    return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    set<int> sp;
    for(int i=0;i<s.size();i++)
    	if(s[i]=='0')
    		sp.insert(i);

    int from = n;
    vector<int> ans;
    while(from>0){
    	int tp = *sp.lower_bound(from-m);
    	if(tp==from){
    		cout<<-1;
    		return 0;
    	}
    	ans.pb(from-tp);
    	from = tp;
    }
    for(int i = ans.size()-1;i>=0;--i)
    	cout<<ans[i]<<" ";

    return 0;
}

Measured memory_bytes: 6216
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = int(input())
t = sum(s)
s = sorted(s)
a = [-1]*n
for i in range(n):
    if s[i] % 10 != 0:
        a[i] = i
if t%10 == 0:
    sw = 1
    for i in range(n):
        if a[i] != -1:
            t -= s[a[i]]
            sw = 0
            break
    if sw == 1:
        t = 0
print(t)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int dsum(ll x)
{
	int ret = 0;
	while (x) { ret += x % 10; x /= 10; }
	return ret;
}
int main()
{
	vector<pair<ll, double>> aa;
	for (ll x = 1; x <= 100000000LL; x++)
	{
		break;
		double v = (double)(x) / (double)(dsum(x));
		while (aa.size() && aa.back().second > v) aa.pop_back();
		aa.push_back(make_pair(x, v));
	}
	ll pow10[17];
	pow10[0] = 1;
	for (int i = 1; i <= 15; i++) pow10[i] = pow10[i - 1] * 10;
	for (int nd = 1; nd <= 15; nd++)
	{
		if (nd <= 6)
		{
			for (ll x = pow10[nd - 1]; x < pow10[nd]; x++)
			{
				double v = (double)(x) / (double)(dsum(x));
				while (aa.size() && aa.back().second > v) aa.pop_back();
				aa.push_back(make_pair(x, v));
			}
		}
		else
		{
			for (ll pr = pow10[5]; pr < pow10[6]; pr++)
			{
				ll x = pr * pow10[nd - 6] + pow10[nd - 6] - 1;
				double v = (double)(x) / (double)(dsum(x));
				while (aa.size() && aa.back().second > v) aa.pop_back();
				aa.push_back(make_pair(x, v));
			}
		}
	}
	int k;
	scanf("%d", &k);
	for (int i = 0; i < k; i++)
		printf("%lld\n", aa[i].first);
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>

using namespace std;

struct Lamp {
    int k;
    int p;
    vector<int> s;
};

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<Lamp> lamp(M);
    for(int i=0; i<M; i++) {
        int k;
        cin >> k;
        lamp[i].k = k;
        for(int j=0; j<k; j++) {
            int s;
            cin >> s;
            lamp[i].s.push_back(--s);
        }
    }
    for(int i=0; i<M; i++) {
        int p;
        cin >> p;
        lamp[i].p = p;
    }

    int ans = 0;
    for(int bit=0; bit<(1<<N); bit++) {
        bool ok = true;
        for(int i=0; i<M; i++) {
            int cnt = 0;
            for(int j=0; j<lamp[i].k; j++) {
                if((bit>>lamp[i].s[j]) & 1) {
                    cnt++;
                }
            }
            if(cnt%2 != lamp[i].p) {
                ok = false;
            }
        }
        if(ok) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
A,B,M = map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]
#print(xyc)

tmp_min = min(a)+min(b)

for i in range(len(xyc)):
	tmp = a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2]
	if tmp<tmp_min:
		tmp_min=tmp
print(tmp_min)

Measured memory_bytes: 38440
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        vi v(n+1);
        int ans = 0;
        rep(i, n+1) cin >> v[i];
        for(int i=0; i < n+1; i++){
            bool isP = true;
            vi vv;
            for(int j=0; j < n+1; j++){
                if(i != j) vv.pb(v[j]);
            }
            int m = vv[1] - vv[0];
            for(int j=2; j < vv.size(); j++){
                if(vv[j]-vv[j-1] != m){isP = false; break;}
            }
            if(isP){cout << v[i] << endl; break;}
        }
    }

}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

#define ALL(a)  (a).begin(),(a).end()

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    ll a, b;
    ll ans = 0;

    cin >> a >> b;

    (a - 2 * b > 0) ? (cout << a - 2 * b << endl) : (cout << 0 << endl);

    // cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 998244353;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
constexpr int MAX = 300001;
lint fact[MAX], finv[MAX], inv[MAX];
void cominit() {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
lint ncr(lint n, lint r, lint mod) {
  if(n < 0 || r < 0 || n-r < 0) return 0;
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, A, B, K;
  cin >> N >> A >> B >> K;
  cominit();
  lint ans = 0;
  REP(i, N+1) {
    lint p = i;
    if(K-p*A < 0 || (K-p*A)%B != 0) continue;
    lint q = (K-p*A) / B;
    if(q < 0 || q > N) continue;
    ans = (ans + ncr(N, p, MOD) * ncr(N, q, MOD) % MOD) % MOD;
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N;
	vector<pii> v;

	cin >> N;
	rep(i,N){
		int A, B;
		cin >> A >> B;
		v.emplace_back(B, A);
	}
	sort(all(v));

	bool ans = true;
	ll sum = 0;
	for(auto t: v){
		sum += t.Y;
		if(sum > t.X) ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}

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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#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...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

int m;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m;
    cout<<(m>=30?"Yes\n":"No\n");
}

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

int main(){
	int n;
	while(cin>>n){
		int a[150],flag=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			if(a[i]%2==0){
				if(a[i]%3!=0&&a[i]%5!=0)
					flag=1;
			}
		}
		if(flag)
			cout<<"DENIED"<<endl;
		else
			cout<<"APPROVED"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        if(A >= 13){
            System.out.println(B);
        }
        else if(6 <= A && A <= 12){
            System.out.println(B/2);
        }
        else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include<atcoder/string>

using namespace std;
using ll = long long;


int main()
{
	string s; cin >> s; int n = s.size();
	auto sa = atcoder::suffix_array(s);
	auto lcp= atcoder::lcp_array(s, sa);

	ll ans = n - sa[0];
	for(int i = 0; i < n - 1; i++) {
		ans += (n - sa[i + 1]) - lcp[i];
	}
	cout << ans << endl;

}

Measured memory_bytes: 15580
S = gets
t = ''
S.each_char do |s|
    if t == 'erase'
        if s == 'r'
            t = ''
        else
            t = s
        end
        next
    end
    if t == 'dream'
        if s == 'e'
            t << s
        else
            t = s
        end
        next
    end
    if t == 'dreame'
        if s == 'r'
            # そのままもう一文字
            t << s
        else
            t = 'e' + s
        end
        next
    end
    if t == 'dreamer'
        if s == 'a'
            t = 'era'
        else
            t = s
        end
        next
    end
    t << s
    if t.size > 7
        puts 'NO'
        exit
    end
end
t.strip!
ary = ['dream', 'dreamer', 'erase', 'eraser']
puts t == '' || ary.include?(t) ? 'YES' : 'NO'

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=3000+10;
inline ll quick_pow(ll base,ll n,ll mod) {
	ll ans=1;
	while(n) {
		if(n&1ll)
			ans=ans*base%mod;
		base=base*base%mod;
		n>>=1;
	}
	return ans;
}
ll c[maxn][maxn];
ll g[maxn][maxn];
int main() {
	ll n,mod;
	scanf("%lld%lld",&n,&mod);
	for(int i=1; i<=n; i++) {  //求组合数
		c[i][0]=1;
		c[i][i]=1;
		for(int j=1; j<i; j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for(int i=0; i<=n; i++) {   //求g[i][j]
		g[i][0]=1;
		for(int j=1; j<=i; j++)
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1)%mod)%mod;
	}
	ll ans=0;
	for(int i=0; i<=n; i++) {            //直接套公式
		ll k=c[n][i];
		if(i&1)
			k=(mod-k)%mod;
		ll kind=quick_pow(2,n-i,mod);
		ll x=quick_pow(2,n-i,mod-1);     //注意这里的模数
		x=quick_pow(2,x,mod);
		ll cnt=0,y=1;
		for(int j=0; j<=i; j++) {
			cnt=(cnt+(g[i][j]*y%mod))%mod;
			y=kind*y%mod;
		}
		ans=(ans+(k*cnt%mod*x%mod))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 139904
#include <iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <algorithm>
#include <cstring>
#include<queue>
#include <stack>
#include<map>
#include<vector>
using namespace std;

struct aera{
    int start;
    int end;
};

bool cmp(aera a ,aera b){
    if(a.end != b.end)	return a.end < b.end;
    else	return a.start > b.start;
}

int main()
{
    aera a1[100005];
    int n;
    cin>>n;
    
        for(int i = 0;i<n;i++){
            int x,y;
            cin>>x>>y;
            a1[i].start=x-y;
            a1[i].end=x+y;
        }
        sort(a1,a1+n,cmp);
        int i, count = 1;
        int lastend = a1[0].end;
        for( i = 0;i < n ;i++){
            if(lastend <= a1[i].start){
                count++;
                lastend = a1[i].end;
            }
        }
        printf("%d\n",count);
    
    
    return 0;
}







Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f

int main(){
    int n;
    cin >> n;
    int v[n];
    for(int i = 0; i < n ; ++i) cin >> v[i];
    vector<int> dp(n+1, oo);
    dp[0] = 0;
    for(int i = 1; i < n ; ++i){
        for(int x : {i-1, i-2}){
            if(x < 0) continue;
            dp[i] = min(dp[i], dp[x]+abs(v[i]-v[x]));
        }
    }
    printf("%d\n", dp[n-1]);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )

int N;
int A[100001];

int main() {
    cin >> N;
    A[0] = 0;
    REP(i, 1, N) {
        int m = i;
        A[i] += m/100000;
        m %= 100000;
        A[i] += m/10000;
        m %= 10000;
        A[i] += m/1000;
        m %= 1000;
        A[i] += m/100;
        m %= 100;
        A[i] += m/10;
        m %= 10;
        A[i] += m;
    }
    int v = 999999999;
    rep(i, 1, N) {
        v = min(v, A[i] + A[N-i]);
    }
    cout << v << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int i, j;
	int n;
	int a[20], v[20];
	int max = 0;
	int hozon_s;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %d", &a[i], &v[i]);
		if (max < v[i]){
			max = v[i];
			hozon_s = a[i];
		}
		if (max == v[i] && a[i] < hozon_s){
			hozon_s = a[i];
		}
	}
	
	printf("%d %d\n", hozon_s, max);
	
	return (0);
}	

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200005];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll n, k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<int> road;
    int i=1, d, len = 0, t = 0, x;
    vector<int> vis(n+1, 0);
    while(1) {
        if(!vis[i]) {
            road.push_back(i);
            vis[i] = ++t;
            i = a[i];
        }
        else if(vis[i]) {
            len = t - vis[i] + 1;
            x = vis[i];
            road.push_back(i);
            d = i; break;
        }
    }
    //for(auto i:road) cout<<i<<endl;
    //cout<<len<<endl;
    if(k<x-1) {
        cout<<road[k]<<endl;
        return 0;
    }
    k -= x - 1;
    k = k % len;
    cout<<road[x-1+k]<<endl;
	return 0;
}


Measured memory_bytes: 5848
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,fma")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 1<<20;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod;
ll n, x, f[maxn], seen[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> x >> mod;
	f[1] = x;
	int p = 2;
	ll sm = x;
	seen[x] = 1;
	while(true) {
		if(p > n) {
			cout << sm << '\n';
			return 0;
		}
		f[p] = f[p-1]*1ll*f[p-1]%mod;
		if(seen[f[p]]) break;
		sm += f[p];
		seen[f[p]] = p;
		p++;
	}
	int ST = seen[f[p]];
	int LEN = p - ST;
	//cout << ST << " " << LEN << " " << n%LEN << endl;
	n -= p-1;
	ll ans = sm;
	ll ful = 0;
	for(int i = ST; i < p; i++) {
		ful += f[i];
	}
	ans += ful*1ll*(n/LEN);
	n %= LEN;
	for(int i = 0; i < n; i++)
		ans += f[ST+i];
	cout << ans << '\n';
}


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

int main(){
    int n;
    cin >> n;
    int L[n];
    rep(i,n){
        cin >> L[i];
    }
    int sum = 0, maxv = L[0];
    rep(i,n) sum += L[i];
    rep(i,n) maxv = max(maxv,L[i]);
    if(maxv < sum - maxv){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
main(){
  int i=0,c=0;
  string s;
  while(cin>>s){
    if(c++)cout<<endl;
    string t[8];
    r(ii,5){
      r(j,8){
        if(j==2)t[j]+='=';
        else t[j]+='*';
      }
    }
    for(i=0;i<5-s.size();i++)
      t[1][i]=t[3][i]=' ';
    for(;i<5;i++){
      int p=s[i-(5-s.size())]-'0';
      if(p==0)t[1][i]=t[3][i]=' ';
      if(p==1)t[1][i]=t[4][i]=' ';
      if(p==2)t[1][i]=t[5][i]=' ';
      if(p==3)t[1][i]=t[6][i]=' ';
      if(p==4)t[1][i]=t[7][i]=' ';
      if(p==5)t[0][i]=t[3][i]=' ';
      if(p==6)t[0][i]=t[4][i]=' ';
      if(p==7)t[0][i]=t[5][i]=' ';
      if(p==8)t[0][i]=t[6][i]=' ';
      if(p==9)t[0][i]=t[7][i]=' ';
    }
    r(ii,8)cout<<t[ii]<<endl;
  }
}

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

int main(){
   int n, m = 0;
   int a[101];
   vector<int> ans;

   for(int i=1 ; i <= 100 ; i++){
       a[i] = 0;
   }
   while( cin >> n ){
       a[n]++;
   }
   for(int i=1 ; i <= 100 ; i++){
       m = max( a[i] , m );
   }
   for(int i=1 ; i <= 100 ; i++){
       if( m == a[i] ) ans.push_back(i);
   }
   for(int i=0 ; i < ans.size() ; i++ ){
       cout << ans[i] << endl;
   }
}

Measured memory_bytes: 1216
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int N = ri();
        int[] AAray = ria();
        Array.Resize(ref AAray, AAray.Length + 1);
        AAray[AAray.Length - 1] = 0;

        BigInteger money = 1000;
        BigInteger stock = 0;
        for (int i = 0; i < AAray.Length - 1; i++)
        {
            if(stock == 0) {
                if(AAray[i + 1] > AAray[i]) {
                    // 株を持っていなくて明日のほうが高いなら全買い
                    stock = money / AAray[i];
                    money %= AAray[i];
                }
            } else {
                if(AAray[i + 1] < AAray[i] || i == AAray.Length - 2) {
                    // 株を持っていて次が下がるか、今回で最後なら全売り
                    money += stock * AAray[i];
                    stock = 0;
                }
            }
        }

		Console.WriteLine(money);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 27708
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  cin >> s;
  ll n=s.size();

  ll e=0,o=0;
  
  if(n%2==0){
    for(int i=0;i<n/2;i++){
      e+=s[2*i]-'0';
      o+=s[2*i+1]-'0';
    }
    cout << n/2-max(e,o)+min(e,o) << endl;
  }
  else{
    for(int i=0;i<n/2;i++){
      e+=s[2*i]-'0';
      o+=s[2*i+1]-'0';
    }
    e+=s[n-1]-'0';
    if(e>o)cout << n/2+1-e+o << endl;
    else cout << n/2-o+e << endl;
  }
  



}

Measured memory_bytes: 3744
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int s=sc.nextInt();
		int[]a=new int [1000000];
		int Answer=0;
		a[0]=s;
		loop:for(int i=1;i<a.length;i++) {
			if(a[i-1]%2==0) {
				a[i]=a[i-1]/2;
			}
			else if(a[i-1]%2!=0) {
				a[i]=a[i-1]*3+1;
			}
			for(int j=0;j<i;j++) {
				if(a[i]==a[j]) {
					Answer=i;
					break loop;
				}
				
			}
		
		}
		System.out.println(Answer+1);
	
		sc.close();
	}

}

Measured memory_bytes: 27220
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        string n;
        int k;
        cin >> n >> k;

        function<ll(int, int, bool)> rec = [&](int i, int j, bool f) {
                static auto dp = make_v(n.length() + 1, k + 1, 2, -1LL);

                if (i == n.length()) {
                        return static_cast<ll>(j == k);
                }

                if (dp[i][j][f] != -1) {
                        return dp[i][j][f];
                }

                int m = f ? n[i] - '0' : 9;
                ll ret = 0LL;

                REP(d, m + 1) {
                        if (d != 0) {
                                if (j >= k) continue;
                                ret += rec(i + 1, j + 1, f && d == m);
                        } else {
                                ret += rec(i + 1, j, f && d == m);
                        }
                }

                return dp[i][j][f] = ret;
        };

        cout << rec(0, 0, true) << endl;

        return 0;
}


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

struct Data{
	string name;
	int max;
};

int main(){
	Data data[11] = {
		"light fly", 48,
		"fly", 51,
		"bantam", 54,
		"feather", 57,
		"light", 60,
		"light welter", 64,
		"welter", 69,
		"light middle", 75,
		"middle", 81,
		"light heavy", 91,
		"heavy", -1,
	};
	string test = "test";
	double input;
	while (cin >> input){
		int i;
		for (i = 0; i < 10; i++){
			if (input <= data[i].max) break;
		}
		cout << data[i].name << '\n';
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll mpow(ll x, ll n){
  ll res=1;
  ll base=x;
  while(n>0){
    if(n&1)
      res=res*base%MOD;

    base = base*base%MOD;
    n/=2;
  }

  return res;
}


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

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

  ll ans=0;
  vll memo(k+1);
  for(ll i=k; i>=1; i--){
    ll cnt=mpow(k/i,n);
    for(ll j=i*2; j<=k; j+=i)
      cnt=(cnt-memo[j]+MOD)%MOD;

    memo[i]=cnt;
    ans=(ans+cnt*i)%MOD;
  }

  cout<<ans<<endl;

}



Measured memory_bytes: 3988
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [i for i in range(1, N+1)]

for idx, i in enumerate(itertools.permutations(N_list)):
    # print(i)
    if list(i) == P:
        p = idx
    if list(i) == Q:
        q = idx

print(abs(p-q))

Measured memory_bytes: 42608
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string X;
    
    cin>>X;
    
    if(X.at(0)==X.at(1) || X.at(1)==X.at(2) || X.at(2)==X.at(3)){
        cout<<"Bad"<<endl;
    }else{
        cout<<"Good\n";
    }
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

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

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int res = 0;

    for (int r = 0; r * R <= N; r++) {
        for (int b = 0; r * R + b * B <= N; b++) {
            int n = r * R + b * B;
            if ((N - n) % G == 0) {
                res++;
            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256