akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static List<List<int>> l = new List<List<int>>();
        static void Main(string[] args)
        {
            var rr = ReadSplit();
            var l = rr[0].Long();
            var r = rr[1].Long();
            var ans = 10000000000;
            if (r - l >= 2019)
            {
                WriteRead(0);
                return;
            }
            else
            {
                for (int i = 0; i < r - l; i++)
                {
                    for (int j = i + 1; j <= r - l; j++)
                    {
                        ans = Math.Min(ans, (((l + i) % mod)* ((l + j) % mod)) % mod);
                    }
                }
                WriteRead(ans);
            }
        }

        private static long mod = 2019;
        
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 13268
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    l,r,d = map(int, input().split())
    ans = 0


    for i in range(l,r+1,1):
        if i%d == 0:
            ans += 1

    print(ans)

if __name__ == '__main__':
	main()


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

int main(){
    using namespace std;
    size_t n;
    cin >> n;
    vector<pair<size_t, bool>> pts(2 * n);
    for(size_t i = 0, a, b; i < 2 * n; ++i){
        cin >> a >> b;
        pts[a].first = b;
        pts[a].second = i < n;
    }
    set<size_t> st;
    size_t ans{0};
    for(const auto& i : pts)if(i.second)st.insert(~i.first);
    else if(!st.empty()){
        auto it = st.upper_bound(~i.first);
        if(it != st.end() && ++ans)st.erase(it);
    }
    cout << ans << endl;
}

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int black = 1 , white = 2;
int n;
vector <int> graph[ N ];
LL dp[ N ][ 5 ];

void add( LL &a , LL b ) {
        a += b;
        if( a > MOD ) a -= MOD;
}
LL mul( LL a , LL b ) {
        return (a*b)%MOD;
}
LL dfs( int s , int p , int col ) {
        if( dp[s][col] != -1 ) return dp[s][col];
        LL ret = 1;
        for( auto x : graph[s] ) {
                if( x != p ) {
                        LL sum = 0;
                        if( col == black ) {
                                add( sum , dfs( x , s , white ) );
                        }
                        else {
                               add( sum , dfs( x , s , white ) );
                               add( sum , dfs( x , s , black ) );
                        }
                        ret = mul( ret , sum );
                }
        }
        return dp[s][col] = ret%MOD;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        cin >> n;
        for( int i = 1; i <= n - 1; i++ ) {
                int u , v;
                cin >> u >> v;
                graph[u].push_back( v );
                graph[v].push_back( u );
        }
        memset( dp , -1 , sizeof( dp ) );
        for( int i = 1; i <= 2; i++ ) dfs( 1 , 0 , i ); /// 1 - bl , 2 = wh
        add( dp[1][1] , dp[1][2] );
        cout << dp[1][1] << endl;
        return 0;
}














Measured memory_bytes: 19328
def main():
    N = int(input())
    c = [x == 'R' for x in input().rstrip()]
    
    left = 0
    right = N - 1
    count = 0
    while left < right:
        while left < N and c[left] != False:
            left += 1
        while right >= 0 and c[right] != True:
            right -= 1
        if left < right:
            count += 1
            left += 1
            right -= 1
    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 11000
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int p;
  string s;
  cin>>s;
  cin>>p;
  
  bool flag = false;
  vector<int> q(p);
  vector<int> f(p, 0);
  vector<string> c(p, "0");
  
  rep(i, p){
    cin>>q[i];
    if(q[i] == 2){
      cin>>f[i]>>c[i];
    }
  }
  
  rep(i, p){
    if (q[i] == 1){
      //reverse(s.begin(), s.end());
      if(flag == false)  flag = true;
      else flag = false;
    }
  
    else if (q[i] == 2){
      if(f[i] == 1){
        if(flag == false) s.insert(0, c[i]);
        else  s.append(c[i]);
      }
    
      else if(f[i] == 2){
        if(flag == false)  s.append(c[i]);        
        else s.insert(0, c[i]);
      }
    }
    
  }
  
  if(flag == true) reverse(s.begin(), s.end());
  cout<<s<<endl;

  return 0;
}

Measured memory_bytes: 14208
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;


void solveCase() {
   int n, m;
   cin >> n >> m;
   vector <string> v(n);

   for(auto &e: v) {
      cin >> e;
   }

   bool ok = true;
   int hashcnt = 0;
   for(int i = 0; i < n; i++) {
      for(int j = 0; j < m; j++) {
         if(v[i][j] == '#') {
            hashcnt += 1;
            int cnt = 0;
            cnt += (i > 0) && v[i - 1][j] == '#';
            cnt += (j > 0) && v[i][j - 1] == '#';
            if(cnt == 0) {
               ok &= ((i == 0) && (j == 0)) || ((i + 1 == n) && (j + 1 == m));
            } else {
               ok &= (cnt == 1);
            }
         }
      }
   }
   ok &= (hashcnt + 1 == n + m);
   cout << (ok ? "Possible" : "Impossible") << endl;
}

 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,a[200010];

int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    if(n==1){
        std::cout << a[0] << std::endl;
        return 0;
    }
    if(n%2==0){
        for (int i = n; i >0; i-=2) {
            std::cout << a[i-1]<<" ";
        }
        for (int i = 1; i <= n-2; i+=2) {
            std::cout << a[i-1]<<" ";
        }
        std::cout << a[n-1 -1] << std::endl;
    }else{
        for (int i = n; i >0; i-=2) {
            std::cout << a[i-1]<<" ";
        }
        for (int i = 2; i <= n-2; i+=2) {
            std::cout << a[i-1]<<" ";
        }
        std::cout << a[n-1 -1] << std::endl;
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

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

ll eval(vector<vector<int>> s, vector<int> c, vector<int> t, int d) {
    ll ans = 0;
    vector<int> last(26,0);
    rep(i, d) {
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, 26) {
            ans -= c[j]*(i+1 - last[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(26,0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    ll ans = 0;

    rep(i, d) {
        cin >> t[i];
        // ans += eval(s,c,t,i);
        // cout << ans << endl;
        cout << eval(s, c, t, i+1) << endl;
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	if(A==B) cout<<"Draw"<<endl;
	else if(A==13 && B==1) cout<<"Bob"<<endl;
	else if(B==13 && A==1) cout<<"Alice"<<endl;
	else if(A>B) cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    string n;
    cin >> n;

    if(n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x1=0,i;
   string s1,s2;
   cin>>s1;
   cin>>s2;
   for(i=0; s1[i]!='\0'; i++)
   {
       if(s1[i]!=s2[i])
       {
           x1++;
       }
   }
   cout<<x1;
}


Measured memory_bytes: 3816
S=int(input())
N=list(map(int,input().split()))

count=0
ans=0
for i in range(S-1):
   if N[i]<N[i+1]:
     if ans<count:
      ans=count
      count=0
     else:
      count=0
   else:
     count=count+1

if ans<count:
   ans=count
       
print(ans)

Measured memory_bytes: 14224
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int h, w;
	cin>>h>>w;
	int c[26]={};
	for(int i=0; i<h; i++){
		string s;
		cin>>s;
		for(int j=0; j<w; j++){
			c[s[j]-'a']++;
		}
	}
	int odd=0;
	for(int i=0; i<26; i++){
		if(c[i]%2){
			odd++;
			c[i]--;
		}
	}
	if(odd>=2){
		cout<<"No"<<endl;
		return 0;
	}
	int r2=0;
	for(int i=0; i<26; i++){
		if(c[i]%4==2) r2++;
	}
	if(r2<=(w%2)*(h/2)+(h%2)*(w/2)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn.readLine
  val Array(a, b) = readLine().trim.split(" ").map(_.toInt)
  if (0 < a) {
    println("Positive")
  } else if (0 == a) {
    println("Zero")
  } else if (0 <= b) {
    println("Zero")
  } else {
    if ((b - a) % 2 == 0) {
      println("Negative")
    } else {
      println("Positive")
    }
  }

}


Measured memory_bytes: 21684
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << endl)

using namespace std;
using ll = unsigned long long;

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	
	vector<int> t;
	int dt = 0;
	int i, j;
	bool f = false;
	vector<int> sum;

	for(i = 0; i < N - 1; i++) {
		if(!f) {
			t.push_back(i);
			f = true;
		}
		if(S[i] != S[i + 1]) {
			f = false;
		}
	}
	
	if(!f) {
		t.push_back(i);
		f = true;
	}
	
	t.push_back(N);
	
	//for(auto e : t) OUT(e);
	
	if(t.size() == 1) {
		OUT(N);
		return 0;
	}
	
	int size = t.size();
	
	if(S[0] == '1') {
		for(i = 1; i < size; i += 2) {
			sum.push_back(t[min(i + 2 * K, size - 1)] - t[i - 1]);
		}
	}
	else {
		for(i = 0; i < size; i += 2) {
			sum.push_back(t[min(i + 2 * K, size - 1)] - t[max(i - 1, 0)]);
		}
	}
	
	sort(sum.begin(), sum.end());
	
	OUT(sum[sum.size() - 1]);
}


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

long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
	long long g = gcd(a, b);
	return a / g * b; //オーバーフローに注意
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    long long ans = A[0];
    for (int i = 1; i < N; i++) {
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const int MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");
    mt19937 mt(234793824);
    auto solve = [&mt](int _) {
        int a, b, c, d, e, f;
        cin >> a >> b >> c >> d >> e >> f;
        vector<int> can(10000);
        for (int i = 0; i <= 3000; ++i) {
            for (int j = 0; j <= 3000; ++j) {
                int x = i * c + d * j;
                if (x < can.size()) {
                    can[x] = 1;
                }
            }
        }
        ld best = -1;
        pair<int, int> res;
        for (int cnt_a = 0; cnt_a * a * 100 <= f; ++cnt_a) {
            int sum = cnt_a * a * 100;
            for (int cnt_b = 0; cnt_b * b * 100 + sum <= f; ++cnt_b) {
                int x = cnt_b * b * 100 + sum;
                if (!x){
                    continue;
                }
                for (int z = 0; z + x <= f; ++z) {
                    if (z * 100 <= e * x && can[z]) {
                        ld cc = (ld)z / (x + z);
                        if (cc > best) {
                            best = cc;
                            res = {x + z, z};
                        }
                    }
                }
            }
        }
        cout << res.first << " " << res.second << "\n";
    };


    fast_io();

    cout.precision(9);
    cout <<
         fixed;
    for (int i = 1;i <=1;++i)
        solve(1);


}


Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC148_c solver = new ABC148_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC148_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long A = in.nextLong();
            long B = in.nextLong();

            out.println(A * B / gcd(A, B));

        }

        private long gcd(long m, long n) {
            if (m < n) return gcd(n, m);
            if (n == 0) return m;
            return gcd(n, m % n);
        }

    }
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL dp(4*4*4, 0);
	dp[3*16 + 3*4 + 3] =1; 
	// AGC, GAC, ACG, AxGC, AGxC
	
	rep(i, n){
		VL np(4*4*4, 0);
		rep(x, 4) rep(y, 4) rep(z, 4) rep(d, 4){
			if(y==0 && z==1 && d==2) continue;
			if(y==1 && z==0 && d==2) continue;
			if(y==0 && z==2 && d==1) continue;
			if(x==0 && z==1 && d==2) continue;
			if(x==0 && y==1 && d==2) continue;
			(np[y*16 + z*4 + d] += dp[x*16 + y*4 + z])%=MD;
		}
		swap(dp, np);
	}
	ll ans =0;
	for(auto x: dp) (ans += x)%=MD;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
use proconio::input;

#[proconio::fastout]
pub fn main() {
    input! {
    a:[usize],
    bc:[(usize,usize)],
    }
    let mut acnt = vec![0; 100010];
    let mut s = 0;
    for aval in a {
        s += aval;
        acnt[aval] += 1;
    }
    for (b, c) in bc {
        let bcnt = acnt[b];
        s += c * bcnt;
        s -= b * bcnt;
        acnt[c] += bcnt;
        acnt[b] -= bcnt;
        println!("{}", s);
    }
}


Measured memory_bytes: 6764
import java.util.Arrays;

public class Main {
  private static void solve() {
    int h = ni();
    int n = ni();
    int[][] p = ntable(n, 2);

    int[][] dp = new int[n + 1][h + 1];
    for (int[] v : dp)
      Arrays.fill(v, Integer.MAX_VALUE / 2);
    dp[0][h] = 0;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= h; j++) {
        dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
      }
      for (int j = h; j >= 0; j--) {
        int t = Math.max(0, j - p[i][0]);
        dp[i + 1][t] = Math.min(dp[i + 1][t], dp[i + 1][j] + p[i][1]);
      }
    }
    System.out.println(dp[n][0]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 83020
n=int(input())
box=list(map(int,input().split()))
count=0
for i in range(n):
    j=box[i:].index(min(box[i:]))+i
    box[i],box[j]=box[j],box[i]
    if i!=j:
        count +=1
print(*box)
print(count)

"""n=int(input())
box=list(map(int,input().split()))
count=0
for i in range(n):
    mini=i
    for j in range(i,n):
        if box[j]<box[mini]:
            mini=j
    if box[i]>box[mini]:
        box[i],box[mini]=box[mini],box[i]
        count +=1
print(*box)
print(count)"""


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

long long gcd(long long a, long long b) {
    if (a == 0) return b;
    if (b == 0) return a;
    return gcd(b, a%b);
}

long long max_num(long long a, long long b) {
    if (a >= b) {
        return a;
    } else if (a < b)
    {
        return b;
    }
    
}

void solve(long long N, std::vector<long long> A){
    vector<long long> l_gcd(N);
    vector<long long> r_gcd(N);

    for (int i=0; i<N; i++) {
        if (i == 0) {
            l_gcd[i] = A[i];
        } else {
            l_gcd[i] = gcd(l_gcd[i-1], A[i]);
        }
    }
    for (int i = N-1; i>=0;i--) {
        if (i == N-1) {
            r_gcd[i] = A[i];
        } else {
            r_gcd[i] = gcd(r_gcd[i+1], A[i]);
        }
    }
    long long max = 0;
    for (int i=0; i<N; i++) {
        if (i == 0) {
            max = max_num(max, r_gcd[i+1]);
        }
        else if (i == N-1)
        {
            max = max_num(max, l_gcd[i-1]);
        }
        else
        {
            max = max_num(max, gcd(l_gcd[i-1], r_gcd[i+1]));
        }
    }
    cout << max << endl;
}


// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    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: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define inf 10000000000
#define f first
#define s second
#define pb push_back
ll dp[1000][1000];
ll dp1[1000][1000];
int main(){
	ll n, m, l;
	cin>>n>>m>>l;
	for(ll i=0;i<1000;i++){
		for(ll j=0;j<1000;j++){
			dp[i][j]=inf;
		}
		dp[i][i]=0;
	}
	for(ll i=0,a, b, c;i<m ; i++){
		cin>>a>>b>>c;--a;--b;
		dp[a][b]=dp[b][a]=c;
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
			}
		}
	}
	for(ll i=0;i<1000;i++){
		for(ll j=0;j<1000;j++){
			dp1[i][j]= dp[i][j]<=l?1:inf;
		}
		dp1[i][i]=0;
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				dp1[i][j]=min(dp1[i][k]+dp1[k][j],dp1[i][j]);
			}
		}
	}
	ll q;
	cin>> q;
	while(q--){
		ll s, t;
		cin>>s>>t;--s, --t;
		ll ans=dp1[s][t];
		if(ans>=inf)cout<<-1<<endl;
		else cout<<ans-1<<endl;
	}
}

Measured memory_bytes: 16128
import java.util.Scanner;

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

		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = 0;
		if (b + w < a) {
			ans = a - b - w;
		} else if (b < a) {
		} else if (b < a + w) {
		} else {
			ans = b - a - w;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
        String a=sc.next();
        String b=sc.next();
        String c=sc.next();
        if(a.charAt(a.length()-1)==b.charAt(0) &&b.charAt(b.length()-1)==c.charAt(0)){
            System.out.println("YES");
        }else System.out.println("NO");

	}
}


Measured memory_bytes: 24020
a, b = map(int, input().split())

def xor_zero2n(n):
    remainder4 = n%4
    ret = 0
    for i in range(remainder4+1):
        ret ^= n-i
    return ret

def xor_a2b(a,b):
    return xor_zero2n(a-1)^xor_zero2n(b)

print(xor_a2b(a,b))


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

int main(){
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
const int MYINF = 1e9+7;

#define NSIZE 10010
#define QSIZE 500

int S[NSIZE];
int n;

int cmp(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

int binsearch_h(int x, int left, int right) {
	int m;
	if (left == right) {
		return S[left] == x;
	} else if (left > right) {
		return 0;
	}
	m = (right + left)  / 2;
	if (x < S[m]) {
		return binsearch_h(x, left, m - 1);
	} else if (x > S[m]) {
		return binsearch_h(x, m + 1, right);
	} else {
		return 1;
	}
}

int binsearch(int x) {
	return binsearch_h(x, 0, n - 1);
}

int main(int argc, char **argv)
{
	int q, i, x, count;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	qsort(S, n, sizeof(int), cmp);

	scanf("%d", &q);
	count = 0;
	for (i = 0; i < q; i++) {
		scanf("%d", &x);
		count += binsearch(x);
	}
	printf("%d\n", count);

	return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    string s;
    cin >> n >> s;

    int ct =0;
    for(int i = 0; i < n -2 ; ++i)
    {
      string aux = "";
      aux = s.substr(i,3);
      if(aux == "ABC")
        ct++;
      aux = "";
    }
    cout << ct;
    


    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::{stdin, BufRead, Read};
use std::cmp;
use std::str::SplitWhitespace;
use std::vec;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf);
    buf.clear();
    stdin().read_line(&mut buf);
    let n_vec:Vec<u32> = buf.split_whitespace().map(|n|n.parse::<u32>().unwrap()).collect();

    println!("{}", f(&n_vec, 0));
}
fn f (n_vec: &[u32], max: u32)->u32{
    if n_vec.len() == 0{
        return 0
    }
    let n = n_vec[0];
    f(&n_vec[1..n_vec.len()], cmp::max(n, max)) + if n >= max {1} else {0}
}


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

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    vector<bool> prime(1000001, true);
    prime[0] = false;
    prime[1] = false;
    for (int p = 2; p * p < 1000001; p++) {
        if (!prime[p]) continue;
        for (int i = 2 * p; i < 1000001; i += p) {
            prime[i] = false;
        }
    }
    vector<ll> primes;
    rep(i, 1000001) {
        if (prime[i]) primes.push_back(i);
    }
    int n = primes.size();
    //cout << n << "\n";
    map<ll, ll> power;
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        ll B = A[i];
        map<ll, ll> p0;
        for (int i = 0; primes[i] * primes[i] <= B; i++) {
            ll x = primes[i];
            while (B % x == 0) {
                B /= x;
                p0[x]++;
            }
            power[x] = max(power[x], p0[x]);
        }
        if (B > 0) p0[B]++;
        power[B] = max(power[B], p0[B]);
    }
    ll gcd = 1, MOD = 1e9 + 7;
    rep(i, n) {
        rep(j, power[primes[i]]) {
            gcd = (gcd * primes[i]) % MOD;
        }
    }
    //cout << "gcd=" << gcd << "\n";
    ll ans = 0;
    rep(i, N) {
        ans = (ans + gcd * mod_pow(A[i], MOD - 2, MOD)) % MOD;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6004
n = int(input())
dict = {}
for i in range(n):
    s, p = input().split()
    if s not in dict:
        dict[s] = []
    dict[s].append((int(p), i + 1))

for s in sorted(dict.keys()):
    for (p, i) in reversed(sorted(dict[s])):
        print(i)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#define LEN 100005

using namespace std;

typedef struct process
{
  string name;
  int time;
};

class queue
{
private:

public:
  int head;
  int tail;
  process p[LEN];
  void enqueue(process x);
  process dequeue();
  bool isFull();
  bool isEmpty();
  void init();
};

void queue::enqueue(process x){
  p[tail] = x;
  tail = (tail + 1) % LEN;
}

process queue::dequeue(){
  process x = p[head];
  head = (head + 1) % LEN;
  return x;
}

bool queue::isFull(){
  return (head == (tail + 1) % LEN);
}

bool queue::isEmpty(){
  return (head == tail);
}

void queue::init(){
  head = 0;
  tail = 0;
}

int main(){
  int n, quantum, sum=0, c;
  process u;
  queue Q;
  cin >> n >> quantum;
  for(int i = 1; i <= n; i++){
    cin >> Q.p[i].name >> Q.p[i].time;
  }

  Q.head = 1;
  Q.tail = n + 1;

  while(Q.head != Q.tail){
    u = Q.dequeue();
    c = min(quantum, u.time);
    u.time -= c;
    sum += c;

    if(u.time > 0){
      Q.enqueue(u);
    }
    else{
      cout << u.name << " " << sum << endl;
    }
  }
    
  return 0;
}



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

int main()
{
	int N;
	cin >> N;
	vector<vector<ll>> a(N, vector<ll>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}
	vector<ll> cost(1 << N);
	for (int i = 1; i < (1 << N); i++) {
		for (int k = 0; k < N; k++) if (i & (1 << k)) {
			for (int l = k + 1; l < N; l++) if (i & (1 << l)) {
				cost[i] += a[k][l];
			}
		}
	}
	vector<ll> dp(1 << N);
	for (int i = 1; i < (1 << N); i++) {
		for (int j = i;; j = (j - 1) & i) {
			dp[i] = max(dp[i], dp[j] + cost[i - j]);
			if (j == 0) break;
		}
	}
	cout << dp.back() << endl;
	return 0;
}


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

int N, ans = 0;
vector<int> adj[100010];

int dfs(int u, int p) {
    int acnt = 0;
    int bcnt = 0;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        int t = dfs(v, u);
        if(t) acnt++;
        else bcnt++;
    }

    if(acnt == 0 && bcnt < 2) return 0;
    else {
        if(bcnt) ans += (bcnt - 1);
        return 1;
    }
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for(int i = 0; i < N; i++) if(adj[i].size() >= 3) {
        dfs(i, -1);
        printf("%d", ans);
        return 0;
    }

    printf("1");
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using ll = int_fast64_t;

int main(){
        ll q, t, x;
        scanf("%ld", &q);

        std::vector<ll> a(0);
        for(ll i=0; i<q; i++){
                scanf("%ld", &t);
                if(t==0){
                        scanf("%ld", &x);
                        a.push_back(x);
                }else if(t==1){
                        scanf("%ld", &x);
                        printf("%ld\n", a[x]);
                }else{
                        a.pop_back();
                }
        }
        return 0;
}


Measured memory_bytes: 4904
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: i64,
    k: i64,
  }
  let mut count = 0;
  let mut n = n;
  while n > 0 {
    n /= k;
    count += 1;
  }

  puts!("{}\n", count);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
using namespace std;

#define FOR(i, s, e) for (int i = (s); i < (e); i++)

int h, w, mp[10][10], wl[205][205];

int main()
{
    scanf("%d %d", &h, &w);
    FOR(i, 0, 10) FOR(j, 0, 10) scanf("%d", &mp[i][j]);
    FOR(i, 0, h) FOR(j, 0, w) scanf("%d", &wl[i][j]);

    //ワーシャル-フロイド法！
    FOR(k, 0, 10) FOR(i, 0, 10) FOR(j, 0, 10)
        mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
   
    int ans = 0;
    FOR(i, 0, h) FOR(j, 0, w) 
        if (wl[i][j] != -1 && wl[i][j] != 1) ans += mp[wl[i][j]][1];
    
    printf("%d\n", ans);
}

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

using ll = long long;
const int INF = 1e9 + 1;

int main() {

	ll a, b;
	cin >> a >> b;

	ll x = a * b;
	if (a < b)
		swap(a, b);

	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	cout << x / b << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, x;
  cin >> n >> k;
  x = 1;
  for(int i = 0; i < n; i++){
    if(x * 2 < x + k){
      x *= 2;
    }else{
      x += k;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  long double w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << w * h * 1.0 / 2 << " ";

  if (x * 2 == w && y * 2 == h) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            decimal iA = decimal.Parse(sS[0]);
            decimal iB = decimal.Parse(sS[1]);
            decimal iN = decimal.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<decimal> lstMin = new List<decimal>();
            lstMin.Add(iB - 1);
            lstMin.Add(iN);
            lstMin.Sort();
            decimal iMax = lstMin[0];
            decimal iOne = Math.Truncate(iA * iMax / iB) - iA * Math.Truncate(iMax / iB);
            //List<decimal> lstRet = new List<decimal>();
            //for (decimal i = 0; i <= iMax; i++)
            //{
            //    decimal iOne = Math.Truncate(iA * i / iB) - iA * Math.Truncate(i / iB);
            //    if (lstRet.Contains(iOne) && lstRet[lstRet.Count - 1] != iOne) { break; }
            //    lstRet.Add(iOne);
            //}
            //lstRet.Sort();
            //lstRet.Reverse();

            // 出力
            System.Console.WriteLine("{0}", iOne.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

    //input
    cin>>x;

    //calculation answer
    int s_count=0,t_count=0;
    for(int i=0;i<x.size();i++){
        if(x[i]=='S') s_count++;
        else if(x[i]=='T'){
            if(s_count!=0) s_count--;
            else t_count++;
        }
    }
    cout<<s_count+t_count<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    string s;
    cin>>s;
    int pr=0,pw=N-1;
    int ans=0;
    while(pr<pw){
        if(s.at(pr)=='R'){pr++;continue;}
        if(s.at(pw)=='W'){pw--;continue;}
        if(s.at(pr)=='W' && s.at(pw)=='R'){
            ans++;
            s.at(pr)='R';
            s.at(pw)='W';
        }
        //cout<<s<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int K; //1-32
    int num=0;

    cin >> K;

    //1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    if( K == 4 ||
        K == 6 ||
        K == 9 ||
        K == 10 ||
        K == 14 ||
        K == 21 ||
        K == 22 ||
        K == 25 ||
        K == 26)
    {
        num = 2;
    }
    else if(K == 8 ||
            K == 12 ||
            K == 18 ||
            K == 20 ||
            K == 27)
    {
        num = 5;
    }
    else if( K == 16 )
    {
        num = 14;
    }
    else if( K == 24 )
    {
        num = 15;
    }
    else if( K == 32 )
    {
        num = 51;
    }
    else if(K == 28 ||
            K == 30)
    {
        num = 4;
    }
    else
    {
        num = 1;
    }
    
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
a = list(input().split())
stack = []
for i in range(len(a)):
    n = len(stack)
    if a[i] == '+':
        if (n-2) <0:
            sys.exit("スタックアンダーフロー")
        tmp = int(stack.pop(n-1)) + int(stack.pop(n-2))
        stack.append(tmp)
        
    elif a[i] == '-':
        if (n-2) <0:
            sys.exit("スタックアンダーフロー")
        tmp_1 = int(stack.pop(n-1))
        tmp_2 = int(stack.pop(n-2))
        tmp = tmp_2 - tmp_1
        stack.append(tmp)
        
    elif a[i] == '*':
        if (n-2) <0:
            sys.exit("スタックアンダーフロー")
        tmp = int(stack.pop(n-1)) * int(stack.pop(n-2))
        stack.append(tmp)
        
    elif a[i] == '/':
        if (n-2) <0:
            sys.exit("スタックアンダーフロー")
        tmp_1 = int(stack.pop(n-1))
        tmp_2 = int(stack.pop(n-2))
        tmp = tmp_2 / tmp_1
        stack.append(tmp)
    else:
        stack.append(int(a[i]))
print(stack[0])


Measured memory_bytes: 5620
import java.util.HashMap;
import java.util.Scanner;

class Main {
	int n;
	HashMap<Integer,Integer> map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		n = sc.nextInt();
		map = new HashMap<Integer,Integer>();
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			if(map.containsKey(a)){
				map.replace(a, map.get(a)+1);
			} else {
				map.put(a, 1);
			}
			
		}
	}

	void solve() {
		int max = Integer.MIN_VALUE;
		for(int x=0;x<=1.0e+5+1;x++){
			max = Math.max(max, map.getOrDefault(x-1, 0) + map.getOrDefault(x,0) + map.getOrDefault(x+1,0));
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 64900
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
  int n,m;cin>>n>>m; int p[m], s[m];
  bool a[n]; int w[n]; fill(a, a+n, false); fill(w,w+n,0);
  for(int i=0;i<m;i++) {
    string ss;
    cin>>p[i]>>ss; p[i]--; s[i]=ss=="AC";
  }
  for(int i=0;i<m;i++) {
    //cout<<p[i]<<" "<<s[i]<<endl;
    if (s[i]) {
      a[p[i]]=true;
    } else if (!a[p[i]]) {
      w[p[i]]++;
    }
  }
  int sm1=0, sm2=0;
  for(int i=0;i<n;i++) {
    //cout<<a[i]<<" "<<w[i]<<endl;
    if (a[i]) sm1++, sm2+=w[i];
  }
  cout<<sm1<<" "<<sm2<<endl;
}


Measured memory_bytes: 1536
/*
g++ -std=c++14 -o2 -Wall ABC126B.cpp -o .\out\ABC126B.out
.\out\ABC126B.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  string ans = "";
  int fst = (s[0] - '0') * 10 + (s[1] - '0');
  int snd = (s[2] - '0') * 10 + (s[3] - '0');
  if (fst >= 1 && fst <= 12) {
    if (snd >= 1 && snd <= 12) {
      ans = "AMBIGUOUS";
    } else {
      ans = "MMYY";
    }
  } else if (snd >=1 && snd <= 12) {
    if (fst >= 1 && fst <= 12) {
      ans = "AMBIGUOUS";
    } else {
      ans = "YYMM";
    }
  } else {
    ans = "NA";
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>


using namespace std;

int main(){
    string S;
    cin >> S;
    string ans = "Yes";
   

    
    for(int i = 0;i < S.size(); i++){  
        if((i+1) % 2 == 1 && S.at(i) == 'L'){
            ans = "No";
            break;
         }

        if((i+1) % 2 == 0 && S.at(i) == 'R'){
            ans = "No";
            break;
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int countFiveHundred = x/500;
		int points = countFiveHundred*1000;
		x = x - (countFiveHundred*500);
		points += (x/5)*5;
		System.out.println(points);
	}
}

Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		list.add(1);
		list.add(3);
		list.add(5);
		list.add(7);
		list.add(8);
		list.add(10);
		list.add(12);
		List<Integer> list2 = new ArrayList<Integer>();
		list2.add(4);
		list2.add(6);
		list2.add(9);
		list2.add(11);
		List<Integer> list3 = new ArrayList<Integer>();
		list3.add(2);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (list.contains(x) && list.contains(y)) {
			System.out.println("Yes");
		} else if (list2.contains(x) && list2.contains(y)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

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

int main() {
    int A, B, C, D, L, R;
    cin >> A >> B >> C >> D;
    L = A + B;
    R = C + D;
    if (L >= R) {
        if (L == R) {
            cout << "Balanced" << endl;
        } else {
            cout << "Left" << endl;
        }
    } else {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;

void main()
{
  auto si = readln.split;
  auto st = SList!int();

  int a, b;
  foreach (s; si) {
    switch(s) {
    case "+":
      st.getOperands(a, b);
      st.insert(b + a);
      break;
    case "-":
      st.getOperands(a, b);
      st.insert(b - a);
      break;
    case "*":
      st.getOperands(a, b);
      st.insert(b * a);
      break;
    default:
      st.insert(s.to!int);
    }
  }

  writeln(st.front);
}

void getOperands(ref SList!int st, ref int a, ref int b)
{
  a = st.front; st.removeFront;
  b = st.front; st.removeFront;
}

Measured memory_bytes: 2500