akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader fs = new FastReader();

        int snuke = fs.nextInt();
        int snack = fs.nextInt();
        HashMap<Integer,Integer> owners = new HashMap<>();

        for(int i=1; i<=snack; i++){
            int di = fs.nextInt();
            for (int j = 1; j <= di; j++) {
                owners.put(fs.nextInt(),0);
            }
        }
        System.out.println((snuke-owners.keySet().size()));
    }

    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: 26632
#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;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

ll dp[200001][3];
void solve(long long N, std::vector<long long> A){
  ll ans=0;
  if(N%2==0){
    dp[0][1]=A[0];
    dp[1][0]=A[1];
    dp[2][1]=A[0]+A[2];
    FOR(i,3,N){
      dp[i][1]=dp[i-2][1]+A[i];
      dp[i][0]=max(dp[i-2][0],dp[i-3][1])+A[i];
    }
    ans=max(dp[N-1][0],dp[N-2][1]);
  }else{
    dp[0][2]=A[0];
    dp[1][1]=A[1];
    dp[2][0]=A[2];
    dp[2][2]=A[2]+A[0];
    dp[3][1]=max(A[0],A[1])+A[3];
    FOR(i,4,N){
      dp[i][2]=dp[i-2][2]+A[i];
      dp[i][1]=max(dp[i-2][1],dp[i-3][2])+A[i];
      dp[i][0]=max(dp[i-4][2],max(dp[i-3][1],dp[i-2][0]))+A[i];
    }
    ans=max(dp[N-3][2],max(dp[N-2][1],dp[N-1][0]));

  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 9616
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <set>
#define MAX_N 100005

using namespace std;

int n,ans=0;
set<int> st;
multiset<int> mst;

int main()
{
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		st.insert(x);
		mst.insert(x);
	}
	for(set<int>::iterator it=st.begin();it!=st.end();it++)
	{
		int now=mst.count(*it);
		if(now>=(*it)) ans+=now-(*it);
		else ans+=now;
	}
	printf("%d\n",ans);
}


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

namespace ABC105.Task02
{
    internal class Task02
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            if (Solve(n))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool Solve(int n)
        {
            for (var i = 0; i <= n / 7; i++)
            {
                var rest = n - (7 * i);
                if (rest % 4 == 0)
                {
                    return true;
                }
            }
            return false;
        }
    }
}


Measured memory_bytes: 13140
tile=input()

# R→Lのindexを取得する
NOW_CHAR="R"
split_index=[0]

for i,s in enumerate(tile):
    if s!=NOW_CHAR:
        if NOW_CHAR=="L":
            split_index.append(i)
        NOW_CHAR=s
split_index.append(len(tile))

#タイルを分割して解きやすくする
parse_tile=[]

for i in range(len(split_index)-1):
    parse_tile.append(tile[split_index[i]:split_index[i+1]])

#Rの位置
result=[]
for part in parse_tile:
    origin_index = part.index("RL") 

    odd_num=0
    eve_num=0
    temp_result = []

    for i,_ in enumerate(part):
        temp_result.append("0")
        if (i-origin_index)%2==0:
            eve_num+=1
        else:
            odd_num+=1
    temp_result[origin_index] = str(eve_num)
    temp_result[origin_index+1]=str(odd_num)
    result+=temp_result
print(" ".join(result))

Measured memory_bytes: 15224
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        ArrayList<int[]> list = new ArrayList<>();
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            int[] a = {i, A[i]};
            list.add(a);
        }
        long[][] dp = new long[N+1][N+1];
        long max = 0L;
        Collections.sort(
            list, 
            new Comparator<int[]>() {
                @Override
                public int compare(int[] obj1, int[] obj2) {
                    return obj2[1] - obj1[1];
                }
            }
        );

        for(int x = 0; x < N; x++){
            for(int y = 0; y < N; y++){
                if(x+y<N) {
                    int[] dpm = list.get(x+y);
                    if (y+1<=N) dp[x][y+1] = Math.max(dp[x][y+1], dp[x][y] + (long)dpm[1]*Math.abs(dpm[0]-(N-y-1)));
                    if (x+1<=N) dp[x+1][y] = Math.max(dp[x+1][y], dp[x][y] + (long)dpm[1]*Math.abs(dpm[0]-x));
                }
            }
        }
        for (int i=0;i<N+1;i++) {
			max = Math.max(max, dp[i][N-i]);
		}

        System.out.println(max);
    }
} 

Measured memory_bytes: 84932
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
//const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1001001001001;

int main(){
    int k;cin>>k;
    
    if(k%2==0 || k%5==0){
        cout<<-1<<endl;
        return 0;
    }
    
    int ans = 1;
    int mod = 7%k;
    
    while(mod%k){//0でない
        mod *= 10;
        mod += 7;
        mod %= k;
        ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int main() {
    string s, t, ans = "Yes";
    cin >> s >> t;
    map<char, int> sm, tm;
    rep(i, s.size()) sm[s[i]]++;
    rep(i, t.size()) tm[t[i]]++;

    vector<int> sv, tv;
    for(auto x: sm) sv.push_back(x.second);
    for(auto x: tm) tv.push_back(x.second);
    sort(sv.begin(), sv.end());
    sort(tv.begin(), tv.end());

    if (sv.size() != tv.size()) ans = "No";
    rep(i, min(sv.size(), tv.size())) {
        if (sv[i] != tv[i]) ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N, M, Q;
ll a[55], b[55], c[55], d[55];

ll dfs(ll *x, ll n) {
  ll i;
  
  if(n==N) {
    ll t=0;
    for(i=0; i<Q; i++) if(x[b[i]]-x[a[i]]==c[i]) t+=d[i];
    return t;
  }
  
  ll res=0;
  for(i=(n==0) ? 1:x[n-1]; i<=M; i++) {;
    x[n]=i;
    chmax(res, dfs(x, n+1));
  }
  
  return res;
}

int main(void) {
  ll i, j, k;
  
  cin >> N >> M >> Q;
  for(i=0; i<Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  
  ll x[11];
  pt(dfs(x, 0));
}
 
 


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

int main(){
  int n; cin>>n;
  int dp[100010];
  for(int i=0; i<=100010; ++i)dp[i]=10000000;

  set<int> reg;
  reg.insert(1);
  int m=6;
  while(m<=100000){
    reg.insert(m);
    m*=6;
  }
  m=9;
  while(m<=100000){
    reg.insert(m);
    m*=9;
  }

  dp[0]=0;
  for(int i=1; i<=n; ++i){
    for(int x:reg){
      if(i-x>=0)dp[i]=min(dp[i], dp[i-x]+1);
    }
  }

  cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
#include <iomanip>  
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s == "SUN")cout << 7 << endl;
	else if (s == "MON")cout << 6 << endl;
	else if (s == "TUE")cout << 5 << endl;
	else if (s == "WED")cout << 4 << endl;
	else if (s == "THU")cout << 3 << endl;
	else if (s == "FRI")cout << 2 << endl;
	else if (s == "SAT")cout << 1 << endl;

}

Measured memory_bytes: 256
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
int fac[N], inv[N];

int fpow(int a, int b) {
  int ans = 1;
  for(; b > 0; a = 1ll * a * a % MOD, b >>= 1) {
    if(b & 1) {
      ans = 1ll * ans * a % MOD;
    }
  }
  return ans;
}

void init() {
  fac[0] = 1;
  for(int i = 1; i < N; i++) {
    fac[i] = 1ll * fac[i - 1] * i % MOD;
  }
  inv[N - 1] = fpow(fac[N - 1], MOD - 2);
  for(int i = N - 2; i >= 0; i--) {
    inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
  }
}

const int INV2 = fpow(2, MOD - 2);

int f(int n) {
  return 1ll * n * (n + 1) % MOD * INV2 % MOD;
}

void Main() {
  init();
  int n, m, k; cin >> n >> m >> k;
  int ans = 1ll * fac[n * m - 2] * inv[k - 2] % MOD * inv[n * m - k] % MOD;
  int c = 0;
  for(int i = 0; i < m; i++) {
    c += 1ll * f(i) * n % MOD * n % MOD;
    if(c >= MOD) c -= MOD;
  }
  for(int i = 0; i < n; i++) {
    c += 1ll * f(i) * m % MOD * m % MOD;
    if(c >= MOD) c -= MOD;
  }
  ans = 1ll * ans * c % MOD;
  cout << ans << "\n";
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>

using namespace std;
/**
2^60 = 1152921504606846976
 */
long long xor_sum4(int n, long long a[]) {
  long long divider = 1000000007;
  vector<bitset<60>> ba;
  long long ans = 0;
  for(int i=0;i<n;i++) {
    bitset<60> b = a[i];
    ba.push_back(b);
    // cout << b << endl;
  }
  for(int i=0;i<60;i++) {
    long long count_zero = 0;
    long long count_one = 0;
    for(int j=0;j<ba.size();j++) {
      bitset<60> b = ba[j];
      if (b[i] == 0)
	count_zero++;
      else
	count_one++;
    }
    // cout << i << " -> one: " << count_one << ", zero: " << count_zero << endl;
    /*
    long long adder = (count_one * count_zero) * pow(2, i);
    adder = adder % divider;
    ans += adder;
    */
    ans += (((count_one * count_zero) % divider) * ((1LL << i) % divider)) % divider;
    ans = ans % divider;
    // cout << ans << endl;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  long long a[n];
  for(int i =0;i<n;i++) {
    cin >> a[i];
  }
  auto ans = xor_sum4(n, a);
  cout << ans;
}

Measured memory_bytes: 8816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

int MAXN = 55, MAXM = 11;
const int R = 0, L = 1;
const int E = 0, N = 1, W = 2, S = 3;

const int rxx[4] = {1, 0, -1, 0}, rxy[4] = {0, -1, 0, 1}, ryx[4] = {0, 1, 0, -1}, ryy[4] = {1, 0, -1, 0};

int main()
{
    int m0, v0[2][MAXM];
    int m, v[2][MAXM];
    int x[MAXN], y[MAXN];

    int n;
    while(cin >> n && n)
    {
        cin >> m0;
        REP(m0) cin >> x[i] >> y[i];
        REP(m0 - 1) { x[i + 1] -= x[0]; y[i + 1] -= y[0]; }
        x[0] = y[0] = 0;

        int vec;
        if(x[1] - x[0] > 0) vec = E;
        if(y[1] - y[0] > 0) vec = N;
        if(x[1] - x[0] < 0) vec = W;
        if(y[1] - y[0] < 0) vec = S;
        for(int i = 0;i < m0;i++) 
        {
            v0[0][i] = rxx[vec] * x[i] + ryx[vec] * y[i];   
            v0[1][i] = rxy[vec] * x[i] + ryy[vec] * y[i];
        }

        rep(setnum, n )
        {
            cin >> m;
            REP(m) cin >> x[i] >> y[i];
            if(m != m0) continue;

            REP(m - 1){ x[i + 1] -= x[0]; y[i + 1] -= y[0];}
            x[0] = y[0] = 0;
            if(x[1] > 0) vec = E;
            if(y[1] > 0) vec = N;
            if(x[1] < 0) vec = W;
            if(y[1] < 0) vec = S;
            for(int i = 0;i < m;i++) 
            {
                v[0][i] = rxx[vec] * x[i] + ryx[vec] * y[i];   
                v[1][i] = rxy[vec] * x[i] + ryy[vec] * y[i];
            }
            int f = 1;
            REP(m0)if(v0[0][i] != v[0][i] || v0[1][i] != v[1][i]) { f = 0; break;}
            if(f) { cout << setnum + 1 << endl; continue;}
            reverse(&x[0], &x[m]); reverse(&y[0], &y[m]);

            REP(m - 1){ x[i + 1] -= x[0]; y[i + 1] -= y[0];}
            x[0] = y[0] = 0;
            if(x[1] > 0) vec = E;
            if(y[1] > 0) vec = N;
            if(x[1] < 0) vec = W;
            if(y[1] < 0) vec = S;
            for(int i = 0;i < m;i++) 
            {
                v[0][i] = rxx[vec] * x[i] + ryx[vec] * y[i];   
                v[1][i] = rxy[vec] * x[i] + ryy[vec] * y[i];
            }
            f = 1;
            REP(m0)if(v0[0][i] != v[0][i] || v0[1][i] != v[1][i]) { f = 0; break;}
            if(f) { cout << setnum + 1 << endl; continue;}

        }
        cout << "+++++" << endl;
    }

    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void)
{
	char n[100];
	int no;
	
	scanf("%s",n);
	
	if(n[0]>n[1]){
		no=1;
	}else if(n[0]==n[1]){
		if(n[2]<=n[1]){
			no=1;
		}else{
			no=2;
		}
	}else{
		no=2;
	}
	
	switch(no){
		case 1:
			printf("%c%c%c\n",n[0],n[0],n[0]);
			break;
		case 2:
			printf("%c%c%c\n",n[0]+1,n[0]+1,n[0]+1);
			break;
	}
	
	return 0;
}
		

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

char strchange(char c);

int main() {
	string str;
	getline(cin, str);

	transform(str.begin(), str.end(), str.begin(), ::strchange);
	cout << str << endl;
}

char strchange(char c) {
	if (0x40 < c && c < 0x5B)
		return c + 0x20;
	else if (0x60 < c && c < 0x7B)
		return c - 0x20;
	else
		return c;
}


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

namespace debug
{

    class ProgramD
    {
        static void Main(string[] args)
        {
            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long m = long.Parse(s[1]);
            long k = long.Parse(s[2]);
            long MOD = 998244353;

            //下準備
            nCk com = new nCk();
            com.fac = new long[n + 1];
            com.inv = new long[n + 1];
            com.finv = new long[n + 1];
            com.mod = MOD;
            com.max = n + 1;

            //メモ作成
            com.com_init();

            long ans = 0;

            for(long i = 0; i <= k;i++)
            {
                if (i == 0)
                {
                    ans += modpow(m - 1, n - 1, MOD);
                    ans %= MOD;
                    continue;
                }

                ans += (com.com(n - 1, i) * modpow(m - 1, n - i - 1, MOD)) % MOD;
                ans %= MOD;

            }

            ans *= m;
            ans %= MOD;

            Console.WriteLine(ans);
                
        }

        //繰り返し二乗法で求める
        static long modpow(long a, long n, long MOD)
        {
            if (n == 0)
                return 1;
            if (n % 2 == 0)
            {
                long temp = modpow(a, n / 2, MOD);
                return temp * temp % MOD;
            }

            return a * modpow(a, n - 1, MOD) % MOD;
        }
    }

    class nCk
    {
        public long mod;
        public long max;
        public long[] fac;
        public long[] inv;
        public long[] finv;


        //メモ作成(前準備)
        public void com_init()
        {
            fac[0] = 1;
            fac[1] = 1;
            finv[0] = 1;
            finv[1] = 1;
            inv[1] = 1;
            for (long i = 2; i < max; i++)
            {
                fac[i] = i * fac[i - 1] % mod;
                inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }

        //二項計算
        public long com(long n, long k)
        {
            if (n < 0 || k < 0)
                return 0;
            if (n < k)
                return 0;
            return fac[n] * (finv[n - k] * finv[k] % mod) % mod;
        }

    }
}


Measured memory_bytes: 32376
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [u64;n],
    }

    p.sort();

    let ans = &p[0..k].iter().sum::<u64>();

    println!("{}", ans);
}


Measured memory_bytes: 2164
N,M=list(map(int,input().split()))

s=dict()
for i in range(N):
    a=list(map(int,input().split()))
    for i in range(1,len(a)):
        if(a[i] not in s):
            s.update({a[i]:1})
        else:
            s[a[i]]+=1
ans=0
for i in range(1,len(s)+1):
    try:
        if(s[i]==N):
            ans+=1
    except:
        pass
if(N==1):
    print(a[0])
else:
    print(ans)

Measured memory_bytes: 3188
INF = 1000000000+7

x,y = map(int, input().split())
a = 2*x-y
b = -x + 2*y
if a%3!=0 or b%3!=0:
    print(0)
    exit()

n = a//3
m = b//3
nm = n+m

def cmb(n,r):
    if r > n:
        return 0
    if n - r < r:
         r = n - r
    if r > n:
        return 0
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if n<0 or m<0:
    print(0)
    exit()
ans = cmb(nm,n)
print(ans%INF)


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
// #define INF 1e9
const ll INF = 1LL << 60;

int n;
vector<int> r, c;
ll dp[105][105];

ll solve(){
  REP(i, n+1){
    dp[i][i+1] = 0;
  }
  FOR(w, 2, n+1){
    REP(left, n){
      int right = left + w;
      if(right > n) break;
      FOR(i, left+1, right){
        dp[left][right] = min(dp[left][right], dp[left][i]+dp[i][right] + r[left] * c[right-1]*r[i]);
      }
    }
  }
  return dp[0][n];
}

int main(){
  cin >> n;
  r.resize(n), c.resize(n);
  REP(i, n){
    cin >> r[i] >> c[i];
  }
  REP(i, n+3){
    REP(j, n+3){
      dp[i][j] = INF;
    }
  }
  cout << solve() << endl;
  return 0;
}



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

int main() {
    lint x;
    cin >> x;
    lint ans = 0;
    ans += (x / 500) * 1000;
    x -= (x / 500) * 500;
    ans += (x / 5) * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>b){
    cout<<"a > b\n";
  }else if(a<b){
    cout<<"a < b\n";
  }else{
    cout<<"a == b\n";
  }
  return 0;
} 



Measured memory_bytes: 3080
a = gets.split.map(&:to_i)
b = 300000 
c = 200000
d = 100000
if a[0] == 1 && a[1] == 1
  puts b + b + 400000
elsif    a[0] == 1 && a[1] == 2
  puts b + c
elsif     a[0] == 1 && a[1] == 3
  puts b + d
elsif   a[0] == 1 
  puts b
elsif   a[0] == 2 && a[1] == 1
  puts b + c
elsif   a[0] == 3 && a[1] == 1
  puts b + d
elsif   a[1] == 1  
  puts b
elsif     a[0] == 2 && a[1] == 2
  puts c + c
elsif     a[0] == 2 && a[1] == 3
  puts c + d
elsif     a[0] == 2 
  puts c
elsif     a[0] == 3 && a[1] == 2
  puts c + d
  elsif   a[1] == 2
  puts c
elsif     a[0] == 3 && a[1] == 3
  puts d + d
elsif     a[0] == 3 
  puts d
  elsif   a[1] == 3
  puts d
else
  puts 0
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();

    	if(X>=1200) {
    		System.out.println("ARC");
    	}else {
    		System.out.println("ABC");
    	}
    }
}


Measured memory_bytes: 23892
n, m = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
div = make_divisors(m)
for i in div[::-1]:
    if i <= m / n:
        print(i)
        break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    if(s[k-1]=='A'){s[k-1] = 'a';}
    if(s[k-1]=='B'){s[k-1] = 'b';}
    if(s[k-1]=='C'){s[k-1] = 'c';}

    cout << s << endl;
    return 0;
}


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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

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

  ll N, M;
  cin >> N >> M;

  vector<pair<ll, ll>> requests(M);
  FOR(i, 0, M) { cin >> requests[i].first >> requests[i].second; }

  // firstは降順、secondは昇順
  sort(requests.begin(), requests.end(),
       [](pair<ll, ll> const& l, pair<ll, ll> const& r) {
         if (l.first > r.first) return true;
         if (l.first == r.first && l.second < r.second) return true;
         return false;
       });

#if 0
  cout << endl;
  for (auto b : requests) {
    cout << b.first << " " << b.second << endl;
  }
  cout << endl;
#endif

  ll cnt = 0;

  while (requests.size() > 0) {
    // requests[0].firstとrequests[0].first+1の間の橋を破壊
    ll t = requests[0].first;
    auto result = remove_if(requests.begin(), requests.end(),
                            [=](pair<ll, ll> r) { return t < r.second; });
    // remove_ifでは実際に削除はされていなく、最終的にeraseする必要がある
    requests.erase(result, requests.end());

    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, M = map(int, input().split())
ans = 0
if N >= 2:
    ans += combinations_count(N, 2)
if M >= 2:
    ans += combinations_count(M, 2)
print(ans)


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

int main() {
  int H,N;
  cin >> H >> N;
  vector<int> A(N);
  rep(i,N) cin >> A.at(i);
  int sum = 0;
  rep(i,N) sum += A.at(i);
  if (sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int N, min = 1000;
  cin >> N;

  for ( int i = 0; i <N; i++ ) {
    int x, j = 0;
    cin >> x;

    while ( x % 2 == 0 ) {
      j++;
      x /= 2;
    }

    if ( j < min ) min = j;
  }

  cout << min << endl;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
# 届く時間を1の位で切り上げたとき、届く時間の和
Menu = [A,B,C,D,E]
L1=[0]
L2=[]
time_max=0
extra=[]
"""
解答1
"""
for i in Menu:
    if i%10==0:
        L1.append(i)
    else:
        L2.append(i + 10 - int(i%10))
        extra.append(i%10)

if len(L2)>0:        
	tmp = 10 - min(extra)
	time_max=sum(L1)+sum(L2)
	print(time_max-tmp)
else: #全部10で割れる場合
  print(sum(L1))

Measured memory_bytes: 3064
'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const N = Number(input.shift());
  const params = input.map(p => p.split(' ').map(v => parseInt(v, 10)));

  const A = params[0];
  const B = params[1];
  const C = params[2];
  
  let ans = 0;

  ans += B[A[0] - 1];

  A.reduce((a, b) => {
    ans += B[b - 1];
    if (b - a === 1) ans += C[a - 1];
    return b;
  });
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());

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

ll top(ll r,ll g){
ll cnt=0;
while(g<=r){
    g=g<<1;
    cnt++;
}
return cnt;

}
int main()
{
ll n,k;
cin>>n>>k;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
string y="Yes",nn="No";
for(ll i=k;i<n;i++){
    if(a[i]>a[i-k])
        cout<<y<<endl;
    else
        cout<<nn<<endl;
}
    return 0;
}


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

int main() {

	int a, b;

	cin >> a >> b;

	int d, r;
	double f;

	d = a / b;
	r = a % b;
	f = 1.0 * a / b;

	cout << fixed;
	cout << setprecision(6) << d << " " << r << " " << f << endl;

	return 0;
}


Measured memory_bytes: 3268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static Integer ct;
	private static Integer len;

	public static void main(String[] args) throws IOException {
		proconScan proScan = new proconScan();
		proScan.scan();

		ct = 0;
		len = proScan.backLine().length();
		Character flag=' ';
		changeOthello(new StringBuilder(proScan.backLine()), 0);
		System.out.println(ct);
		proScan.proconEnd();
	}

	public static StringBuilder changeOthello(StringBuilder board, Integer first){
		Character buf = null;
		Character buf2 = null;
		StringBuilder buf3 = new StringBuilder();
		int i,j;
		for(i=first; i<len; i++){
			if( i==first ) buf=board.charAt(i);
			else if(board.charAt(i)!=buf){
				ct++;
				buf2=board.charAt(i);
				for(j=first;j<i;j++){
					buf3.append(buf2);
				}
				board.replace(first, i, buf3.toString());
				break;
			}
		}
		if(i<len){
			changeOthello(board, i);
		}
		return board;
	}

}

class proconScan {
	private BufferedReader br;
	private String inLine;
	private String[] inString;
	private Integer idx;
	private String splitChar;

	public proconScan() {
		br = new BufferedReader(new InputStreamReader(System.in));
		idx = 0;
		splitChar = " ";
	}

	public proconScan(String split) {
		br = new BufferedReader(new InputStreamReader(System.in));
		idx = 0;
		splitChar = split;
	}

	public void proconEnd() throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		br.close();
	}

	public String scan() throws IOException {
		idx = 0;
		inLine = br.readLine();
		inString = inLine.split(splitChar, 0);
		return inLine;
	}

	public Integer scanInteger1() throws IOException {
		scan();
		return Integer.parseInt(inString[0]);
	}

	public String backLine() {
		return inLine;
	}

	public String nextString() {
		return inString[idx++];
	}

	public String[] getString() {
		return inString;
	}

	public Integer nextInteger() {
		Integer num;
		try {
			num = Integer.parseInt(inString[idx++]);
		} catch (NumberFormatException e) {
			num = null;// TODO: handle exception
		}
		return num;
	}

	public Integer[] getInteger() {
		Integer[] num = new Integer[this.getLen()];

		for (int i = 0; i < this.getLen(); i++) {
			num[i] = Integer.parseInt(inString[i]);
		}

		return num;
	}

	public Float nextFloat() {
		Float num;
		try {
			num = Float.parseFloat(inString[idx++]);
		} catch (NumberFormatException e) {
			num = null;// TODO: handle exception
		}
		return num;
	}

	public Float[] getFloat() {
		Float[] num = new Float[this.getLen()];

		for (int i = 0; i < this.getLen(); i++) {
			num[i] = Float.parseFloat(inString[i]);
		}

		return num;
	}

	public Integer getLen() {
		return inString.length;
	}

	public int[] getInt() {
		int[] num = new int[this.getLen()];

		for (int i = 0; i < this.getLen(); i++) {
			num[i] = Integer.parseInt(inString[i]);
		}

		return num;
	}

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll dp[114][10];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, k;
	cin>>h>>w>>k;
	dp[0][0]=1;
	REP(i, h){
		REP(j, 1<<(w-1)){
			int a[10];
			REP(p, w-1){
				a[p]=0;
			}
			REP(p, w-1){
				if(j>>p&1){
					a[p]=1;
				}
			}
			bool ok=true;
			REP(p, w-2){
				if(a[p]==1 && a[p+1]){
					ok=false;
					break;
				}
			}
			if(!ok){
				continue;
			}
			REP(p, w){
				if(p+1<w && a[p]==1){
					dp[i+1][p]=(dp[i+1][p]+dp[i][p+1])%MOD;
				}
				else if(p-1>=0 && a[p-1]==1){
					dp[i+1][p]=(dp[i+1][p]+dp[i][p-1])%MOD;
				}
				else{
					dp[i+1][p]=(dp[i+1][p]+dp[i][p])%MOD;
				}
			}
		}
	}
	cout<<dp[h][k-1]<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

#define ll long long

int main(void){
    int n, ans = 0;
    cin >> n;
    vector<int> d(n);

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

    for(int i = 0;i < n;++i){
        for(int j = i+1;j < n;++j){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int cnt = 0;

void print(int A[], int N) {
    cout << A[0];
    for (int i=1; i < N; i++) {
        cout << " " << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N, int g) {
    int v;
    int j;
    for (int i=g; i < N; i++) {
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j + g] = v;
    }
    return;
}


void shellSort(int A[], int N) {
    cnt = 0;
    vector<int> G;
    int h = 1;
    while (h <= N) {
        G.push_back(h);
        h = 3 * h + 1;
    }

    for (int i=G.size()-1; i >=0; i--) {
        insertionSort(A, N, G[i]);
    }
    cout << G.size() << endl;
    for (int i=G.size()-1; i >=0; i--) {
        cout << G[i];
        if (i > 0) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    for (int i=0; i < N; i++) {
        cout << A[i] << endl;
    }
}

int main(){
    int n;
    int A[1000010];

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


Measured memory_bytes: 7012
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    a, b = MII()
    if a%2==0 or b%2==0: print('Even')
    else: print('Odd')

if __name__ == '__main__':
    main()


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

int main() {
    int n;
    cin >> n;
    int ttl =0;
    for(int i=1; i<=n; i++){
        int x =i, cnt=0;     
        while (x>0)
        {
            x/=10;
            cnt++;
        }
        if(cnt%2!=0) ttl++;
    }
    cout << ttl << endl;
    return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int ans=1,x;
cin>>x;
bool r=0;
for(int i=2;i<=x;i++){
int y=i;
int k=y;
 for(int j=1;j<=100;j++)
 {
  if(y>x)
   break;
  else{
   y*=k;
   if(y<=x)
   ans=max(ans,y);
  }
 }
}
cout<<ans;
system("pause");
return 0;
}

Measured memory_bytes: 504
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def commonDivisors(x1, x2):
    cf = []
    for i in range(2, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


def solve():
    N, M = [int(x) for x in input().split()]
    S = input()
    T = input()
    # cdivs = commonDivisors(N, M)
    # ans_flag = True
    # print(cdivs)
    # for c in cdivs:
    #     if S[c - 1] != T[c - 1]:
    #         ans_flag = False
    # if ans_flag:
    #     print(lcm([N, M]))
    # else:
    #     print(-1)
    # N_divs = make_divisors(N)
    # M_divs = make_divisors(M)
    L = lcm([N, M])
    ic, jc = 0, 0
    i, j = ic * L // N + 1, jc * L // M + 1
    ans = L
    while ic < N and jc < M:
        # print(i, j, ic, jc, S[ic], S[jc])
        if i == j:
            if S[ic] != T[jc]:
                ans = '-1'
                break
            ic += 1
            jc += 1
            i = ic * L // N + 1
            j = jc * L // M + 1
        elif i < j:
            ic += 1
            i = ic * L // N + 1
        elif i > j:
            jc += 1
            j = jc * L // M + 1
    print(ans)
    # print(N_divs, M_divs)
    # return
    # ans_flag = True
    # for d in divs:
    #     if S[d] != T[d]:
    #         ans_flag = False
    # if ans_flag:
    #     print(lcm([N, M]))
    # else:
    #     print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 74124
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int d;
    cin >> d;
    if (d == 25) {
        cout << "Christmas" << endl;
    } else if (d == 24) {
        cout << "Christmas Eve" << endl;
    } else if (d == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,ca;
queue<int> que;
signed main(){
    cin>>n>>m;
    if(m%2==1||n*2>m||n*4<m){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
}


Measured memory_bytes: 10504
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] C, S, F;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        C = new int[N - 1];
        S = new int[N - 1];
        F = new int[N - 1];
        for(int i = 0; i < N - 1; i++)
        {
            C[i] = cin.nextInt();
            S[i] = cin.nextInt();
            F[i] = cin.nextInt();
        }
    }
    static void solve()
    {
        input();
        int[] ans = new int[N];

        for(int i = 0; i < N -1; i++)
        {
            int t = 0;
            for(int j = i; j < N - 1; j++)
            {
                if (S[j] >= t)
                    t = S[j] + C[j];
                else
                    t = (t + F[j] - 1) / F[j] * F[j] + C[j];
            }
            ans[i] = t;
        }
        WriteLine(String.Join("\n", ans));
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
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 / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int s; cin >> s;
    vector<int> v(1000000);
    v[s] = 1;
    bool flag = true;
    int cnt = 1;
    while(flag){
        if(s % 2 == 0){
            s = s / 2;
            v[s]++;
        }else{
            s = 3 * s + 1;
            v[s]++;
        }
        cnt++;
        if(v[s] == 2) break;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4096
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[3];
		A[0] = sc.nextInt();
		A[1] = sc.nextInt();
		A[2] = sc.nextInt();
		int K = sc.nextInt();
		Arrays.parallelSort(A);
		System.out.println(A[0]+A[1]+(int)(A[2]*Math.pow(2, K)));
	}
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    bool C = false;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == 'C' && !C) {
            C = true;
        } else if (S[i] == 'F' && C) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    scan.close();

    String fS = S.substring(0, (S.length()-1)/2);
    String bS = S.substring((S.length()+1)/2, S.length());

    if(kai(S) && kai(fS) && kai(bS)) {
      System.out.println("Yes");
    }
    else {
      System.out.println("No");
    }
  }

  public static boolean kai(String s) {
    StringBuffer sb = new StringBuffer(s);
    String rs = sb.reverse().toString();
    if(s.equals(rs)) {
      return true;
    }
    else {
      return false;
    }
  }
}

Measured memory_bytes: 23124
#pragma comment(linker, "/STACK:512000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
#ifdef AIM
#include <sys/resource.h>
#endif
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
  string s = FILENAME;
//    assert(!s.empty());
  freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/cryptozoology/output.txt", "w", stdout);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
  cout.sync_with_stdio(0);
  cin.tie(0);
#endif

#ifdef AIM
  const rlim_t kStackSize = 256 * 1024 * 1024;
  struct rlimit rl;
  int result;

  result = getrlimit(RLIMIT_STACK, &rl);
  if (result == 0)
  {
    if (rl.rlim_cur < kStackSize)
    {
      rl.rlim_cur = kStackSize;
      result = setrlimit(RLIMIT_STACK, &rl);
      if (result != 0)
      {
        fprintf(stderr, "setrlimit returned result = %d\n", result);
      }
    }
  }
#endif

  precalc();
  cout.precision(10);
  cout << fixed;
  cin >> t;
  int testNum = 1;
  while (t--) {
      //cout << "Case #" << testNum++ << ": ";
      solve(true);
  }
  cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cout.flush();
  auto end = clock();

  usleep(10000);
  print_stats(end - start);
  usleep(10000);
#endif

    return 0;
}

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
    sort(all(a));
    a.erase(unique(all(a)), a.end());
}

template<typename T>
void relax_min(T& cur, T val) {
    cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
    cur = max(cur, val);
}

void precalc() {
}

#define int li
//const int mod = 1000000007;

void solve(__attribute__((unused)) bool read) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) {
    cin >> x;
  }
  string s;
  cin >> s;
  reverse(all(a));
  reverse(all(s));
  vector<int> basis;
  vector<int> first_bit;
  for (int i = 0; i < n; ++i) {
    int mask = a[i];
    for (int j = 0; j < basis.size(); ++j) {
      if (mask & (1LL << first_bit[j])) {
        mask ^= basis[j];
      }
    }
    if (mask != 0 && s[i] == '1') {
      cout << "1\n";
      return;
    }
    if (mask != 0) {
      basis.push_back(mask);
      first_bit.push_back(63 - __builtin_clzll(mask));
    }
  }
  cout << "0\n";
}

Measured memory_bytes: 3652