akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <vector>
using namespace std;

static int face[6];

void roll(int dice[]){
    int new_face[6];
    for(int j = 0; j < 6; j++)
        new_face[j] = face[dice[j]];
    for(int k = 0; k < 6; k++)
        face[k] = new_face[k];
}

int main(void){
    
    string operations;
    for(int i = 0; i < 6; i++)
        cin >> face[i];
    cin >> operations;
    
    for(int i = 0; i < operations.size(); i++){
        char op = operations[i];
        
        if(op == 'N'){
            int dice[6] = {1,5,2,3,0,4};
            roll(dice);
        }
        else if(op == 'S'){
            int dice[6] = {4,0,2,3,5,1};
            roll(dice);
        }
        else if(op == 'E'){
            int dice[6] = {3,1,0,5,4,2};
            roll(dice);
        }
        else{
            int dice[6] = {2,1,5,0,4,3};
            roll(dice);
        }
    }
    
    cout << face[0] << endl;
    return 0;
}





Measured memory_bytes: 3212
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
	//this is a sample overloading function for sorting stl
	bool operator()(pii const &a, pii const &b)
	{
		if(a.F==b.F)
			return (a.S<b.S);
		return (a.F<b.F);
	}
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();
  
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k,x,y;
        cin>>n>>k>>x>>y;
        ll xMul=min(k,n);
        ll yMul=max(0LL,n-k);
        cout<<x*xMul+y*yMul<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int x[3];
  x[0]=a+b;
  x[1]=a-b;
  x[2]=a*b;
  sort(x,x+3);
  cout<<x[2];
  return 0;
}

Measured memory_bytes: 256
uses
	SysUtils,
	Classes;

procedure MainProc;
	var
		text : string;
		strlist : TStringList;
		x1, y1 : Integer;
		x2, y2 : Integer;
		x3, y3: Integer;
		x4, y4: Integer;
		edgeLenX: Integer;
		edgeLenY: Integer;
	begin
	ReadLn(text);
	strlist := TStringList.Create;
	try
		strlist.Delimiter := ' ';
		strlist.DelimitedText := text;
		x1 := StrToInt(strlist.Strings[0]);
		y1 := StrToInt(strlist.Strings[1]);
		x2 := StrToInt(strlist.Strings[2]);
		y2:= StrToInt(strlist.Strings[3]);
	finally
			FreeAndNil(strlist);
			end;
	edgeLenX := x1 - x2;
	edgeLenY := y1 - y2;
	
	x3 := x2 + edgeLenY;
	y3 := y2 - edgeLenX;
	x4 := x1 + edgeLenY;
	y4 := y1 - edgeLenX;
	text := IntTostr(x3) + ' ' + IntTostr(y3) + ' ' + IntTostr(x4) + ' ' + IntTostr(y4);
	WriteLn(text);
	end;

begin
MainProc;
end.

Measured memory_bytes: 256
using System;

namespace AtCoder.ABC100
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if (a <= 8 && b <= 8)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC100.A.Solve();
        }
    }
}


Measured memory_bytes: 13140
N = int(input())
S = input()
L = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
S = list(S)
ANS = []

for n in range(len(S)):
    new_n =(L.index(S[n]) + N)  % 26
    ANS.append(L[new_n])

print(''.join(ANS))

Measured memory_bytes: 3188
N = int(input())
A = list(map(int,input().split()))
abs_A = [abs(a) for a in A]
minus_count = 0
for e in A:
    if e <= 0:
        minus_count += 1
if minus_count % 2 == 0:
    print(sum(abs_A))
else:
    print(sum(abs_A)-2*(min(abs_A)))



Measured memory_bytes: 65184
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)
	ma := 1
	mi := 1000000000
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		ma = max(ma, a)
		mi = min(mi, a)
	}
	fmt.Println(abs(ma - mi))
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 082
	// https://atcoder.jp/contests/abc082/tasks
	final static int MOD = 10007;
	
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		double c = (a+b) / 2.0;
		
		if (c - (int)c == 0) {
			System.out.println((int)c);
		} else {
			System.out.println((int)c + 1);
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 20436
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#include <cmath>
#include <bitset>
#include <string>
#include <queue>

using namespace std;

#define int long long
const int MOD = 1000000007;

signed main() {
    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }

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

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

using namespace std;

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

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N;
	cin >> N;
	ll x;
	VLL A(N);
	for (int i = 0;i < N;i++) cin >> A[i];
	sort(all(A));
	for (int i = 1;i < N;i++){
		if (A[i] == A[i-1]) {
			cout << "NO" << endl;
			break;
		}
		if (i == N - 1) cout << "YES" << endl;
	}
}

Measured memory_bytes: 1792
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

for i in range(n):
    if i%2==1:
        s.appendleft(a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)


Measured memory_bytes: 25416
#include<stdio.h>
int main()
{
    int a1,a2,a3;

    scanf("%d %d %d",&a1,&a2,&a3);
    if(a1+a2+a3>=22){
        printf("bust\n");
    }
    else{
        printf("win\n");
    }
    return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char SLA = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class DLamp {
public:
    int H, W;
    vector<string> board;

    void solve(std::istream& in, std::ostream& out) {
        in >> H >> W; in.ignore();

        REP(i, H) {
            string str;
            getline(in, str);
            board.push_back(str);
        }

        auto hor = vector<vector<int>>(2001, vector<int>(2001, 0));
        auto ver = vector<vector<int>>(2001, vector<int>(2001, 0));

        REP(y, H) {
            int cnt = 0;
            int pre = -1;
            REP(now, W+1) {
                if (now == W || board[y][now] == '#') {
                    for (int i = pre + 1; i < now; ++i) {
                        hor[y][i] = cnt;
                    }
                    pre = now;
                    cnt = 0;
                    continue;
                }
                if (board[y][now] == '.') {
                    cnt++;
                    continue;
                }
            }
        }

        REP(x, W) {
            int cnt = 0;
            int pre = -1;
            REP(now, H+1) {
                if (now == H || board[now][x] == '#') {
                    for (int i = pre + 1; i < now; ++i) {
                        ver[i][x] = cnt;
                    }
                    pre = now;
                    cnt = 0;
                    continue;
                }
                if (board[now][x] == '.') {
                    cnt++;
                    continue;
                }
            }
        }

        int ans = 0;
        REP(y, H) REP(x, W) chmax(ans, hor[y][x] + ver[y][x] - 1);
        OUT(ans);
    }
};


int main() {
    DLamp solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 35712
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N),C(N),ans;
    int ANS=0;
    for(int i=0;i<N;i++){
        cin >> A.at(i);
        if(i>0){
            if(A.at(i-1)+1==A.at(i)) ans.push_back(A.at(i-1)-1);
        }
    }
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        ANS += x;
    }
    for(int i=0;i<N-1;i++) cin >> C.at(i);
    for(int i=0;i<ans.size();i++){
        ANS += C.at(ans.at(i));
    }
    cout << ANS << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
# r = list(map(int, input().split()))
total = 0
if n >= k:
    total += (1/n)*(n-k+1)
#print(total)

for i in range(min(n, k-1)):
    count = 0
    b = i+1
    while k > b:
        b *= 2
        count += 1
    #print(count)
    a = 1/(n*pow(2, count))
    total += a

print(total)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N;
    cin >> N;
    int ans = 0;
    int det = 1;
    rep1(i,N){
        if(i == det*10) det *= 100;
        if(i >= det) ans++;
    }
    pr(ans);
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  rep(i, n){
    if(s[i] == 'R') cnt++;
  }
  int num = cnt;
  for(int i = 0; i < num; i++) if(s[i] == 'R') cnt--;
  cout << cnt << endl;
}

Measured memory_bytes: 3716
import math
def prodR(s,a,c,N):
    R=[s]
    for i in range(1,N+1):
        R.append((a*R[i-1]+c)%256)
    return R[1:]

def entropy(R,I,N):
    O=[(I[i]+R[i])%256 for i in range(N)]
    L=[0]*256
    for i in O:
        L[i]+=1
    H=-sum(float(L[i])/N*math.log(float(L[i])/N,2) for i in range(256) if L[i]!=0)
    return H

while True:
    N=input()
    if N==0:break
    I=map(int,raw_input().split())
    maxInt=1e10
    for s in range(16):
        for a in range(16):
            for c in range(16):
                R=prodR(s,a,c,N)
                H=entropy(R,I,N)
                if maxInt>H:
                    maxInt=H
                    ans=s,a,c
    print "%d %d %d"%(ans[0],ans[1],ans[2])

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

int main(){
  long long n;
  cin >> n;
  vector<char> a(100004, true);
  a[0] = a[1] = false;
  for(long long i = 2; i <= 100003; ++i){
      if(a[i])
          for(long long j = i * i; j <= 100003; j += i) a[j] = false;
  }
  for(int i = n; i <= 100003; ++i)
      if(a[i]){
          cout << i;
          return 0;
      }
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> ba(m);
	rep(i, m) {
		int ai, bi;
		cin >> ai >> bi;
		ai--; bi--;
		ba[i] = { bi,ai };
	}
	sort(ba.begin(), ba.end());
	int now = -1;
	int ans = 0;
	rep(i, m) {
		if (ba[i].second > now) {
			now = ba[i].first-1;
			ans++;
		}
	}
	cout << ans << endl;
}


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

const int N=305;
char s[N][N];
int ans[N][N];

void assignAns(int u,int d,int l,int r,int ch){
    for(int i=u;i<=d;i++){
        for(int j=l;j<=r;j++) ans[i][j]=ch;
    }
}

void solve(){
    int h,w,k;
    scanf("%d%d%d",&h,&w,&k);
    int cur=0;
    for(int i=1;i<=h;i++){
        scanf("%s",s[i]+1);
    }
    for(int u=1,d=1;u<=h;u=d+1,d=u){
        while(d<=h){
            bool flag=1;
            for(int i=1;i<=w;i++) if(s[d][i]!='.') { flag=0; break; }
            if(flag){
                d++;
                continue;
            }
            break;
        }
        if(d==h+1){
            for(int i=u;i<=h;i++){
                for(int j=1;j<=w;j++) ans[i][j]=ans[i-1][j];
            }
            break;
        }
        int l=1;
        for(int i=1;i<=w;i++){
            if(s[d][i]=='#'){
                assignAns(u,d,l,i,++cur);
                l=i+1;
            }
        }
        for(int i=u;i<=d;i++){
            for(int j=l;j<=w;j++) ans[i][j]=ans[i][j-1];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(j>1) printf(" ");
            printf("%d",ans[i][j]);
        }
        printf("\n");
    }
}

int main(){

    solve();
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;

    Graph G(N);
    REP(i, N-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> c(N);
    REP(i, N) cin >> c[i];

    sort(c.rbegin(), c.rend());
    
    vector<ll> mark(N, -1);
    queue<ll> qu;
    qu.push(0);
    ll cnt = 0;
    while(!qu.empty()){
        auto q = qu.front();qu.pop();
        mark[q] = c[cnt];
        cnt++;
        for(auto next: G[q]){
            if(mark[next]<0) qu.push(next);
        }
    }

    ll res = 0;
    REP(i, N) res += c[i];
    res -= c[0];

    cout << res << endl;
    for(auto x: mark) cout << x << " ";
    cout << endl;
    
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    n = n%10;
    if ( n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ) {
        cout << "hon" << endl;
    } else if ( n == 0 || n == 1 || n == 6 || n == 8 ) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
// 29/07/19 // 7:10 PM //

#include <iostream>

using namespace std;

#define MAXN 110
#define MAXW 100010

int n, w;
int weight[MAXN], value[MAXN];

long long memo[MAXN][MAXW];

long long knapsack(){

    for(int i=1; i<=n; i++){
        for(int j=0; j<=w; j++){
            memo[i][j] = memo[i-1][j];

            if(j>=weight[i])
                memo[i][j] = max(memo[i][j], value[i] + memo[i-1][ j-weight[i] ]);
        }
    }

    return memo[n][w];
}


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> w;

    for(int i=1; i<=n; i++)
        cin >> weight[i] >> value[i];

    cout << knapsack() << "\n";

    return 0;
}



Measured memory_bytes: 79360
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# D - Line++

n, x, y = map(int, input().split())

ndist = [0] * n  # ndist[k] = 距離kの頂点対の個数
for p in range(1, n):
    for q in range(p + 1, n + 1):
        # p,q間の距離
        d = min(q - p, abs(x - p) + 1 + abs(y - q))
        ndist[d] += 1

for k in range(1, n):
    print(ndist[k])


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

ll exor(ll a){
    ll p=(a+1)/2;
    if((a+1)%2==0){
        return p%2;
    }else{
        return (p%2)^a;
    }
}

int main(){

    ll a,b;

    cin >> a >> b;

    cout << (exor(a-1)^exor(b)) << endl;

    return 0;
}

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int mod = 1e9 + 7;
const int MAX = 1e5 + 1;

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		ll x, moves, dist;
		cin >> x >> moves >> dist;
		x = abs(x);
		ll howMany = x / dist;
		if(moves >= howMany)
		{
			if(howMany == moves)
			{
				ll pos = x - (dist * moves);
				cout << pos;
			}
			else
			{
				//cout << "2\n";
				ll currPos = x - (howMany * dist);
				ll availMoves = moves - howMany;
				if(availMoves & 1) // if odd
				{
					ll aage = currPos - dist;
					aage = abs(aage);
					cout << min(aage, abs(currPos + dist));
				}
				else
				{
					ll aage = currPos - 2 * dist;
					aage = abs(aage);
					ll piche = abs(currPos - 2 * dist);
					cout << min(aage, min(currPos, piche));
				}
			}
		}
		else
		{
			ll pos = x - (dist * moves);
			cout << pos;
		}
	}
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
	using namespace std;
	int main() {
		int N, D1, D2;
		cin >> N >> D1 >> D2;
		vector<vector<int>> A(2*N, vector<int>(2*N));
		{
			int n = 2;
			int x = 1;
			for (;;) {
				if (D1 % n) {
					for (int i = 0; i < 2*N; ++ i) for (int j = 0; j < 2*N; ++ j) A[i][j] |= (i/x + j/x + 1) % 2;
					break;
				}
				n *= 2;
				if (D1 % n) {
					for (int i = 0; i < 2*N; ++ i) for (int j = 0; j < 2*N; ++ j) A[i][j] |= (i/x + 1) % 2;
					break;
				}
				n *= 2;
				x *= 2;
			}
		}
		{
			int n = 2;
			int x = 1;
			for (;;) {
				if (D2 % n) {
					for (int i = 0; i < 2*N; ++ i) for (int j = 0; j < 2*N; ++ j) A[i][j] |= (i/x + j/x + 1) % 2 * 2;
					break;
				}
				n *= 2;
				if (D2 % n) {
					for (int i = 0; i < 2*N; ++ i) for (int j = 0; j < 2*N; ++ j) A[i][j] |= (j/x + 1) % 2 * 2;
					break;
				}
				n *= 2;
				x *= 2;
			}
		}
		int cnt = 0;
		for (int i = 0; i < 2*N; ++ i) for (int j = 0; j < 2*N; ++ j) if (A[i][j] == 3) {
			cout << i << " " << j << endl;
			if (++cnt == N*N) return 0;
		}
	}


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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1] -= 'A' - 'a';
  cout << s << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	
    	int n = sc.nextInt();
    	int taro = 0, hanako = 0;
    	for(int i = 0; i < n; i++) {
    		String aml1 = sc.next(), aml2 = sc.next();
    		if(aml1.compareTo(aml2) > 0) {
    			taro+=3;
    		} else if(aml1.compareTo(aml2) < 0) {
    			hanako+=3;
    		} else {
    			taro++;
    			hanako++;
    		}
    	}
    	System.out.println(taro + " " + hanako);
    }
}

Measured memory_bytes: 29336
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def ans(self):
        print(len(set(self.par))-1)

n,m=map(int,input().split())
uf=UnionFind(n)

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a,b)
a=1
b=1
c=0
for i in range(3,n+1):
    if uf.same_check(1,i):
        a+=1
    elif uf.same_check(2,i):
        b+=1
    else:
        c+=1
if a>b:
    a+=c
else:
    b+=c
print(a*(a-1)//2+b*(b-1)//2-m)



Measured memory_bytes: 7856
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M,c;
    vector<int> A,B;
    cin >> N >> M;
    REP(i,N){
        cin >> c;
        A.push_back(c);
    }
    REP(i,M){
        cin >> c;
        B.push_back(c);
    }
    A.push_back(0);
    A.push_back(0);
    sort(A.begin(),A.end(),greater<>());
    sort(B.begin(),B.end(),greater<>());
    
    //REP(i,N){cout << A[i] << " ";}cout << endl;
    //REP(i,M){cout << B[i] << " ";}cout << endl;
    
    REP(i,N-1){if(A[i]==A[i+1])GOODBYE;}
    REP(i,M-1){if(B[i]==B[i+1])GOODBYE;}
    
    int Ans=1;
    int a=0,b=0;
    int now=0;
    for(int i=N*M;i>0;i--){
        if(A[a]==i && B[b]==i){
            a++;b++;
        }else if(A[a]==i && B[b]<i){
            Ans*=b;a++;
            Ans%=MOD;
        }else if(A[a]<i && B[b]==i){
            Ans*=a;b++;
            Ans%=MOD;
        }else if(A[a]<i && B[b]<i){
            Ans*=a*b-now;
            Ans%=MOD;
        }else{
            //cout << "うんこ" MM i << endl;
            GOODBYE;
        }
        //cout << i MM Ans << endl;
        now++;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val x = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Pair(it[0], it[1]) }
    val from1 = x.filter { it.first == 1 }.map { it.second }
    val toN = x.filter { it.second == n }.map { it.first }
    val ans = if ((from1.intersect(toN)).isNotEmpty()) "POSSIBLE" else "IMPOSSIBLE"
    println(ans)
}

Measured memory_bytes: 110580
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    int N;
    string S;
    cin >> N >> S;
    if(N%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    bool flag = true;
    for(int i = 0; i < N/2 && flag; i++){
        flag = (S[i] == S[N/2 + i]);
    }
    cout << (flag?"Yes":"No") << endl;

    return 0;
}


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

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





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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

ll tmax = 0;
ll tmin = 0;

int hoge(vector<ll> &A, ll t) {
    int ans = 0;
    rep(i,A.size()) {
        if (A[i]>t) {
            ans += A[i]/t;
        }
    }
    return ans;
}

int main(){
    int N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) {
        ll a;
        cin >> a;
        A[i] = a;
        tmax = max(tmax,a);
    }

    while(tmax-tmin>1) {
        ll mid = (tmax+tmin)/2;
        if (hoge(A,mid)<=K) {
            tmax = mid;
        }
        else {
            tmin = mid;
        }
    }
  cout << tmax << endl;

}


Measured memory_bytes: 4844
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solve()
{
int n;
cin>>n;
int rem=n%1000;
if(rem!=0)
cout<<1000-rem<<endl;
else
cout<<0<<endl;
}
int main()
{
     #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


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

#define ll long long int

using namespace std;

int main() {
    string s;
    cin >> s;
    for (auto c : s) {
        if (c >= 'a') {
            cout << 'a' << endl;;
        } else {
            cout << 'A' << endl;;
        }
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int  A, B, n=0;
  cin >> A >> B;
  for(;A<=B;A++)
    for(int i=0;i<2;i++){
      if((A/(long)powl(10,i))%10 != (A/(long)powl(10,4-i))%10)
        break;
      if(i)
        n++;
    }
  cout << n << endl;
}

Measured memory_bytes: 256
def int_to_string(n: int, radix: int = 10) -> str:
    """https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString"""

    if radix < 2 or radix > 36:
        raise ValueError("radix must be between 2 and 36")

    char = "0123456789abcdefghijklmnopqrstuvwxyz"
    negative = n < 0
    n = abs(n)
    digits = []

    while n:
        d = n % radix
        n //= radix
        digits.append(d)

    s = "".join([char[d] for d in reversed(digits)])

    if negative:
        return "-" + s

    return s


N, K = map(int, input().split())
print(len(int_to_string(N, K)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
 
#define endl "\n"
 
const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
 
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    string s;
    cin >> s;

    int sum = 0;
    for (char c : s) {
        sum += c - '0';
        sum %= 9;
    }
    cout << (sum == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3780
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n, t = list(map(int, input().split()))
cmin = float('inf')
able = False
for i in range(n):
    ci, ti = list(map(int, input().split()))
    if ti <= t:
        cmin = min(cmin, ci)
        able = True

if able:
    print(cmin)
else:
    print('TLE')


Measured memory_bytes: 3060
N, Y = gets.chomp.split(' ').map(&:to_i)

(0..N).reverse_each do |x|
  next if 10000 * x > Y
  (0..(N-x)).reverse_each do |y|
    next if 10000 * x + 5000 * y > Y
    if Y == 10000 * x + 5000 * y + 1000 * (N - x - y)
      puts "#{x} #{y} #{N - x - y}"
      exit
    end
  end
end
puts '-1 -1 -1'


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

int main(void) {
  int sum = 0;
  cin >> sum;

  int hour, minute, second;
  hour = sum / 3600;
  minute = (sum - hour*3600) / 60;
  second = (sum - hour*3600 - minute*60);

  cout << hour << ":" << minute << ":" << second << endl;
}


Measured memory_bytes: 3092
using System;
using System.IO;

class Solve {
    static void Main(string[] args) {
        var N = int.Parse(Console.ReadLine());
        var robos = new (int left, int right)[N];
        for (int i = 0; i < N; i++) {
            var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            robos[i] = (arr[0] - arr[1], arr[0] + arr[1]);
        }
        Array.Sort(robos);
        var answer = 0;
        var x = int.MaxValue;
        for (int i = N - 1; i >= 0; i--) {
            if (x < robos[i].right) continue;
            answer++;
            x = robos[i].left;
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}


Measured memory_bytes: 47040
import java.util.*

fun main(args: Array<String>){
    val scanner = Scanner(System.`in`)
    val (N, K) = scanner.nextLine().split(" ").map { it.toInt() }
    val hs = scanner.nextLine().split(" ").map { it.toInt() }
    val ans = hs.filter{ it >= K }.size
    println(ans)
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	LL n, d; cin >> n >> d;
	LL ans = 0;
	while (n>0)
	{
		n -= 2 * d + 1;
		ans++;
	}
	COUT(ans);
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll p=1e9+7;
ll inf=1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,w,h,y,r,k,d,q,m,t,a,b;
	ld x;
	cin>>x;
	ll n=1;
	ld ans;
	ld p=100.0;
	while(1)
	{
	    ld t2=1.01;
	    ans=p*t2;
	    p=floor(ans);
	    if(ans>=x)
	    break;
	    else
	    n++;
	}
	cout<<n;
	
	return 0;
	
	
}


Measured memory_bytes: 3744
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

N, A, B = tuple(map(int, input().strip().split()))

s  = 0

for n in range(1, N + 1):
    n1 = n % 10
    n2 = (n // 10) % 10
    n3 = (n // 100) % 10
    n4 = (n // 1000) % 10
    n5 = (n // 10000) % 10
    p = n1 + n2 + n3 + n4 + n5
    if A <= p <= B:
        s += n

print(s)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


Measured memory_bytes: 9080
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  ll r, s, p;std::cin >> r >> s >> p;
  string t; std::cin >> t;

  ll ans = 0;
  for(int i=0;i<k;i++){
    vvl dp = vv(1, 3, 0, ll);
    ll now = 1;
    for(int j=i;j<n;j+=k, now++){
      dp.push_back(vll{0, 0, 0});
      dp[now][0] = max(dp[now-1][1], dp[now-1][2]) + (t[j]=='s'?r:0);
      dp[now][1] = max(dp[now-1][0], dp[now-1][2]) + (t[j]=='p'?s:0);
      dp[now][2] = max(dp[now-1][1], dp[now-1][0]) + (t[j]=='r'?p:0);
    }
    ans += max({dp[now-1][0], dp[now-1][1], dp[now-1][2]});
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6836
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

const long long MOD = 1000000007;

int main(){
    long long N;
    cin >> N;
    long long a, b, c;
    a = 10;
    b = 9;
    c = 8;
    for(long long i = 1; i < N; i++){
        a = (a * 10) % MOD;
        b = (b * 9) % MOD;
        c = (c * 8) % MOD;
    }
    long long ans;
    ans = (a - (b * 2 - c)) % MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int fnc(int n){
    if(n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}

int vector_finder(std::vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main(){
    int s;
    cin >> s;
    vector<int> a(1);
    a[0] = s;
    int i = 0;

    while(1){
        if(vector_finder(a,fnc(a[i]))){
            goto out;
        }
        a.push_back(fnc(a[i]));
        i++;
    }
    out:
    cout << i + 2 << endl;
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int ans=1;
    for (int i=0; i<N; i++) {
        if (ans<=K) ans *= 2;
        else ans += K;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#
#
#料金表
#  A サイズ   B サイズ   C サイズ   D サイズ   E サイズ   F サイズ
#大きさ   60cm以内  80cm以内  100cm以内   120cm以内   140cm以内   160cm以内
#重さ  2kg以内   5kg以内   10kg以内  15kg以内  20kg以内  25kg以内
#料金  600円  800円  1000円   1200円   1400円   1600円
fee = {:A => 600,:B => 800,:C => 1000,:D=>1200,:E=>1400,:F=>1600}
loop do
  n = gets.to_i
  break if n==0
  sum=0
  n.times do
    x,y,h,w=gets.split.map(&:to_i)
    s = x+y+h
    if s<61 && w<3
      sum+= fee[:A]
    elsif s<81 && w<6
      sum+= fee[:B]
    elsif s<101 && w<11
      sum+= fee[:C]
    elsif s<121 && w < 16
      sum+=fee[:D]
    elsif s<141 && w < 21
      sum+=fee[:E]
    elsif s<161 && w < 26
      sum+=fee[:F]
    end
  end
  puts sum
end

#
#料金表
#  A サイズ   B サイズ   C サイズ   D サイズ   E サイズ   F サイズ
#大きさ   60cm以内  80cm以内  100cm以内   120cm以内   140cm以内   160cm以内
#重さ  2kg以内   5kg以内   10kg以内  15kg以内  20kg以内  25kg以内
#料金  600円  800円  1000円   1200円   1400円   1600円

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n, K; cin >> n >> K;
    ll ans = 0;
    REP(t, n-1) {
        ans += ans/(K-1)+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3180
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def main(n,k):
    z = n % k
    if z > k-z:
        return k-z
    else:
        return z
n,k = listint()
print(main(n,k))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 int n;
 string s;
 string solve(char begin,char end){
     string ret;
     char last=end,cur=begin;
     for (int i = 0; i < n; i++) {
         char next;
         if(last=='S'){
             if(cur=='S'){
                 if(s[i]=='o')next='S';
                 else next='W';
             }
             else{
                 if(s[i]=='o')next='W';
                 else next='S';
             }
         }
         else {
             if(cur=='S'){
                 if(s[i]=='o')next='W';
                 else next='S';
             }
             else {
                 if(s[i]=='o')next='S';
                 else next='W';
             }
         }
         last=cur;
         cur=next;
         ret+=next;
     }
     if(ret[ret.size()-1]!=begin || ret[ret.size()-2]!=end)return "";
     else {
         return ret.back()+ret.substr(0,ret.size()-1);
}
 }

 int main(void)
 {
     cin>>n;
     cin>>s;
     string ret;
     if((ret=solve('S','S'))!=""){
         cout<<ret<<endl;
     }
     else if((ret=solve('S','W'))!=""){
         cout<<ret<<endl;
     }
     else if((ret=solve('W','W'))!=""){
         cout<<ret<<endl;
     }
     else if((ret=solve('W','S'))!=""){
         cout<<ret<<endl;
     }
     else cout<<-1<<endl;
     return 0;
 }

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int A[3][3];
    string A_check[3][3];
    int N;
    int B[100] = {1000};
    
    A_check[0][0] = "NO";
    A_check[0][1] = "NO";
    A_check[0][2] = "NO";
    A_check[1][0] = "NO";
    A_check[1][1] = "NO";
    A_check[1][2] = "NO";
    A_check[2][0] = "NO";
    A_check[2][1] = "NO";
    A_check[2][2] = "NO";
    
    cin >> A[0][0] >> A[0][1] >> A[0][2];
    cin >> A[1][0] >> A[1][1] >> A[1][2];
    cin >> A[2][0] >> A[2][1] >> A[2][2];
    cin >> N;
    
    //Bingo table
    for(int i=0; i<N; i++)
    {
        cin >> B[i];
        
        for(int ii=0; ii<3; ii++)
        {
            for(int jj=0; jj<3; jj++)
            {
                 if(A[ii][jj] == B[i]) A_check[ii][jj] = "YES";
            }
        }
    }
    
    //debug
    // for(int ii=0; ii<3; ii++)
    // {
    //     cout << A_check[ii][0] << " " <<A_check[ii][1] << " " << A_check[ii][2] << endl;
    // }
    
    //タテチェック
    for(int jj=0; jj<3; jj++)
    {
        if( (A_check[0][jj] == "YES") && (A_check[1][jj] == "YES") && (A_check[2][jj] == "YES") )
        {
            cout << "Yes";
            return 0;
        }

    }
    
    //ヨコチェック
    for(int ii=0; ii<3; ii++)
    {
        if( (A_check[ii][0] == "YES") && (A_check[ii][1] == "YES") && (A_check[ii][2] == "YES") )
        {
            cout << "Yes";
            return 0;
        }

    }
    
    //斜めチェック
    if( (A_check[0][0] == "YES") && (A_check[1][1] == "YES") && (A_check[2][2] == "YES") )
    {
        cout << "Yes";
        return 0;
    }
    
    if( (A_check[0][2] == "YES") && (A_check[1][1] == "YES") && (A_check[2][0] == "YES") )
    {
        cout << "Yes";
        return 0;
    }

    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n,k = map(int,input().split())

A = np.array(input().split(),np.int)

F = np.array(input().split(),np.int)


A.sort()
F.sort()

F_ = F[::-1]

left = -1
right = (A * F_).sum()

while (right - left) > 1:
    s = (left + right) // 2
    r = np.maximum(0, A - s // F_).sum() <= k
    if r:
        right = s 
    else:
        left = s 

print(right)


Measured memory_bytes: 37204