akhauriyash/Code-Regression huggingface dataset:
use std::io::Read;
use std::cmp::{min, max};

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();

    if h % 3 == 0 || w % 3 == 0 {
        return "0".to_string();
    }

    let result = min(calc(h, w), calc(w, h));
    result.to_string()
}

fn calc(h: usize, w: usize) -> usize {
    let mut result = std::usize::MAX;
    for h1 in 1..h {
        let s1 = h1 * w;

        let s2 = (h - h1) * (w / 2);
        let s3 = h * w - s1 - s2;
        let smax = max(s1, max(s2, s3));
        let smin = min(s1, min(s2, s3));
        result = min(result, smax - smin);

        let s2 = ((h - h1) / 2) * w;
        let s3 = h * w - s1 - s2;
        let smax = max(s1, max(s2, s3));
        let smin = min(s1, min(s2, s3));
        result = min(result, smax - smin);
    }
    result
}


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

using ll = long long;

constexpr ll MOD = 1000000007;

int N;
vector<int> A(10001);

ll modpow(ll n, ll k) {
    if(k == 0) return 1;
    if(k % 2 == 0) {
        ll tmp = modpow(n, k/2);
        return (tmp * tmp) % MOD;
    }
    return (n * modpow(n, k - 1)) % MOD;
}

void solve(){
    map<int, int> pf;
    for(int i = 1; i <= N; ++i){
        int a = A[i];
        for(int j = 2; j * j <= a; ++j){
            if(a % j == 0) {
                int k = 0;
                while(a % j == 0) { a /= j; k++; }
                pf[j] = max(pf[j], k);
            }
        }
        if(a > 1) pf[a] = max(pf[a], 1);
    }

    ll lcm = 1;
    for(auto itr = pf.begin(); itr != pf.end(); ++itr){
        lcm *= modpow(itr->first, itr->second);
        lcm %= MOD;
    }

    ll ans = 0;
    for(int i = 1; i <= N; ++i){
        ans += (lcm * modpow(A[i], MOD - 2)) % MOD;
        ans %= MOD;
    }
    cout << ans;
}
int main(){
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 768
/*
author: madhav_1999 aka orthodoxparadox
3 May 2020 at 5:29 PM
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define dbl long double
#define int ll
#define ll long long
#define pii pair<int, int>
#define len(x) (int) x.size()
#define rev(a) reverse(all(a))
#define oiint ostream_iterator<int>(cout, " ") 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
#define inf 2e18
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef MADHAV
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
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...);}
#else
#define dbg(...) 42
#endif
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(int i=0;i<(int)v.size();++i) x<<v[i]<<" ";return x;} 
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;} 
template <typename X> ostream& operator << (ostream& x,const multiset<X>& v){for(auto it:v) x<<it<<" ";return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct pair_hash {inline std::size_t operator()(const std::pair<int, int> & v) const {return v.first*31+v.second;}};
const int MOD = 1e9 + 7;

int takemod(int a, int mod = MOD){a%=mod;if(a<0)a+=mod;return a;}

int fast_exp(int base, int expo, int mod = MOD) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}

int modinv(int a, int mod = MOD){return takemod(fast_exp(takemod(a, mod), mod-2, mod), mod);}


void solve()
{
	string s;
	cin >> s;
	cout << (s == "ABC" ? "ARC" : "ABC");
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#ifdef MADHAV
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	clock_t t1, t2;
	t1 = clock();

	int tt = 1;
	// cin >> tt;
	while(tt--)
	{
		solve();
	}
	#ifdef MADHAV
	t2 = clock(); cout << "\n\ntime taken: " << (t2-t1)/(dbl)CLOCKS_PER_SEC;
	#endif
	return 0;
}

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

int const N = 100*1000 + 16;
int const M = 1000*1000*1000 + 7;

int n;
ll a[64];
ll b[64];

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

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

  sort(a, a+n);
  ll sum = 0;

  for(int k = 0; k < 100000; ++k) {
    ll z = 0;
    for(int i = 0; i < n; ++i) {
      if(a[i] < n)
        continue;
      auto x = a[i] - n;
      b[i] = x/n;
      z += b[i];
    }

    for(int i = 0; i < n; ++i)
      a[i] = a[i] - n * b[i] + (z - b[i]);
    sum += z;
  }


  multiset<ll, greater<ll>> s;
  for(int i = 0; i < n; ++i) {
    auto x = a[i];
    s.insert(x);
  }

  ll d = 0;
  while(*s.begin()+d >= n) {
    auto x = *s.begin();
    s.erase(s.begin());
    s.insert(x-(n+1));
    ++d;
    ++sum;
  }

  cout << sum;
}

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

int main() {
	int n;
	cin>>n;
	vector<int> ans(3);
	for(int i=0;i<n;i++){
	    vector<int> temp(3);
	    for(int j=0;j<3;j++){
	        cin>>temp[j];
	    }
	    vector<int> ans_temp(3,-1);
	    for(int p=0;p<3;p++){
	        for(int q=0;q<3;q++){
	            if(p!=q){
	                ans_temp[q]=max(ans_temp[q],ans[p]+temp[q]);
	            }
	        }
	    }
	   // for(int x=0;x<3;x++){
	   //     cout<<ans_temp[x]<<" ";
	   // }
	   // cout<<"\n";
	    ans=ans_temp;
	}
	cout<<max({ans[0],ans[1],ans[2]});
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main() {

string s,t; cin>>s>>t;
  int ans=t.size(); int jj=s.size()-t.size();  int jjj=t.size();
  rep( i, jj+1 ) { int c=0;
  rep( j, jjj ) {
    
   if( s.at(i+j)!=t.at(j) )c++;
 
  }  if(c<ans){ans=c;} 
  }  

  cout<<ans<<endl;
}


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

int main(){
  int N; cin >> N;
  vector<int> X(N); rep(i, N) cin >> X[i];
  const int INF = 1e9 + 10;
  long long ans = INF;

  rep(a, 101) {
    long long tot = 0;
    rep(i, N) tot += abs(X[i] - a) * abs(X[i] - a);
    ans = min(ans, tot);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
def Amount(i, j, k):
    return 500*i + 100*j + 50*k

#A=500, B=100, C=50
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if(X==Amount(i,j,k)):
                count = count + 1
print(count)


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

using namespace std; 
int main()
{
	int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	
	for(int i=0;i<n-1;i++)
	{
		if(v[i]==v[i+1])
		{
			if(i==0)
				v[i]--;	
			
			else if(v[i]-1>=v[i-1])
				v[i]--;
				
		}
		
		else if(v[i]>v[i+1])	
		{
			if(v[i]-1>=v[i+1])
				v[i]--;
			else
			{
				cout<<"No"<<endl;
				return 0;	
			}
				
			
		}
			
		
		if(i>0&&v[i-1]>v[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
		
	}
	cout<<"Yes"<<endl;

	return 0;		
}




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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    REP(i,h-b){
        REP(j, w-a)
            cout << 0 ;
        REP(j, a){
            cout << 1;
        }
        cout << "\n";
    }
    REP(i, b)
    {
        REP(j, w-a)
        cout << 1 ;
        REP(j, a){
            cout << 0;
        }
        cout << "\n";
    }


    return 0;
}

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

n, m, x = map(int, input().split())
a = list(map(int, input().split()))
first_n, last_n = 0, 0
for i in range(m):
    if x < a[i]:
        last_n += 1
    else:
        first_n += 1
print(min(first_n, last_n))

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

int Partition(int *,int *,char *,int,int);
void QSort(int *,int *,char *,int,int);

int main()
{
  int i,n,s=0;
  int A[200000],B[200000];
  char ch,C[100000];
  
//Define the number of inputs
  scanf("%d%c",&n,&ch);
//Enter each value and text
  for(i=0;i<n;i++){
    scanf("%c%c%d%c",&C[i],&ch,&A[i],&ch);
    B[i]=i;
  }

  QSort(A,B,C,0,n-1);
//Check Stable or not
  for(i=0;i<n;i++){
    if(B[i]>B[i+1] && A[i]==A[i+1]){
      s=1;
      break;
    }
  }
//Print result
  if(s==0)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",C[i],A[i]);
  }
  return 0;
}

//First check
void QSort(int *A,int *B,char *C,int p,int r)
{
  int q;
  if(p<r){
    q=Partition(A,B,C,p,r);
    QSort(A,B,C,p,q-1);
    QSort(A,B,C,q+1,r);
  } 
}

//Quick Sort
int Partition(int *A,int *B,char *C,int p,int r)
{
  int x,i,j,temp;
  char ch;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
      temp=B[i];
      B[i]=B[j];
      B[j]=temp;
      ch=C[i];
      C[i]=C[j];
      C[j]=ch;
    }
    
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp; 
  temp=B[i+1];
  B[i+1]=B[r];
  B[r]=temp;
  ch=C[i+1];
  C[i+1]=C[r];
  C[r]=ch;
  return i+1;
}  


Measured memory_bytes: 2600
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

dicts = {i:0 for i in range(1, n)}
for i in range(m):
    dicts[a[i]] += 1

a, b = 0, 0

for i in range(1,n):
    if i < x:
        a += dicts[i]
    if i > x:
        b += dicts[i]

print(min(a, b))



Measured memory_bytes: 3060
#include <iostream>

using namespace std;

long long x(long long n) {
    if (n <= 0LL) {
        return 0;
    }
    long long ans[] = {n, 1LL, n + 1, 0LL};
    return ans[n % 4];
}

int main() {
    long long a, b;
    cin >> a >> b;
    cout << (x(b) ^ x(a - 1)) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N, D, X = sc.nextInt
    println(Array.fill(N)((D - 1) / sc.nextInt + 1).sum + X)
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25672
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<string>
#include<vector>
#include<math.h>
#include<time.h>
#include<utility>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
//#include<conio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int k;
long long ans=1;
char s[2][55];
vector<int> ve;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	cin>>s[0]>>s[1];
	for(int i=0;i<n;i+=k){
		if(s[0][i]==s[1][i]){
			k=1;
		}else{
			k=2;
		}
		ve.push_back(k);
	}
	ans*=(ve[0]==1)?3:6;
	for(int i=1;i<ve.size();i++){
		if(ve[i-1]==1){
			if(ve[i]==1) ans*=2;
			else ans*=2;
		}else{
			if(ve[i]==1) ans*=1;
			else ans*=3;
		}
	}
	cout<<ans%1000000007<<endl;
	return 0;
}


Measured memory_bytes: 256
count = 0
n, k = map(int, input().split())
for b in range(k+1, n+1):
    p = n // b
    r = n % b
    count += (p * max(0,b - k) + max(0,r - k + 1))
    if k == 0:
        count -= 1
print(count)


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

int main()
{
  int M, N;
  int64 w[200001] = {}, t[200002] = {};
  int c[15], b[15];
  int dp[1 << 15] = {};
  
  scanf("%d %d", &M, &N);
  for(int i = 1; i <= M; i++) {
    scanf("%lld %lld", &w[i], &t[i]);
    w[i] += w[i - 1];
    t[i] += t[i - 1];
  }
  for(int i = 0; i < N; i++) {
    scanf("%d %d", &c[i], &b[i]);
  }
  for(int i = 0; i < 1 << N; i++) {
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) continue;
      int weightHigh = upper_bound(w + dp[i], w + M + 1, w[dp[i]] + c[j]) - w - 1;
      int widthHigh  = upper_bound(t + dp[i], t + M + 1, t[dp[i]] + b[j]) - t - 1;
      dp[i|(1 << j)] = max(dp[i|(1 << j)], min(weightHigh, widthHigh));
    }
  }
  printf("%d\n", dp[(1 << N) - 1]);
}

Measured memory_bytes: 4452
//cod2017_qualA_a.cpp
//Sat Oct 20 22:33:34 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;

	if (s.size()>=4 && 
		s[0] == 'Y' && 
		s[1] == 'A' && 
		s[2] == 'K' && 
		s[3] == 'I'){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9+7;

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

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}


class Mll
{
    public:
    ll x;

    Mll() : x(0){}
    Mll(ll x=0) : x((x%MOD+MOD)%MOD){}

    Mll operator-() const
    {
        return Mll(-x);
    }

    Mll& operator+=(const Mll& A)
    {
        if((x += A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator-=(const Mll& A)
    {
        if((x += MOD - A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator*=(const Mll& A)
    {
        (x *= A.x) %= MOD;
        return *this;
    }
    
    Mll operator+(const Mll& A)
    {
        Mll res(*this);
        return res+=A;
    }
    Mll operator-(const Mll& A)
    {
        Mll res(*this);
        return res-=A;
    }
    Mll operator*(const Mll& A)
    {
        Mll res(*this);
        return res*=A;
    }
    
    bool operator==(const Mll& A)
    {
        Mll res(*this);
        return (res.x == A.x);
    }

    bool operator<(const Mll& A)
    {
        Mll res(*this);
        return (res.x < A.x);
    }

    bool operator>(const Mll& A)
    {
        Mll res(*this);
        return (res.x > A.x);
    }

    Mll pow(ll t) const // t乗
    {
        if(t==0) return 1;
        Mll A = pow(t>>1);
        A *= A;
        if(t&1) A *= *this;
        return A;
    }

    // for prime mod
    Mll inv() const
    {
        return pow(MOD-2);
    }
    Mll& operator/=(const Mll& A)
    {
        return (*this) *= A.inv();
    }
    Mll operator/(const Mll& A) const
    {
        Mll res(*this);
        return res/=A;
    }

    friend ostream& operator<<(ostream& os, const Mll& M)
    {
        os << M.x;
        return os;
    }
};

vector<Mll> ALLIN_MLL(ll N)
{
    vector<ll> numbers_ll(N);
    ALLIN1_NUMBER(numbers_ll);

    vector<Mll> numbers_Mll;
    for(ll i=0;i<N;i++)
    {
        Mll add(numbers_ll[i]);
        numbers_Mll.push_back(add);
    }

    return numbers_Mll;
}

ll ceil(ll dividend, ll divisor)
{
    return (dividend + divisor - 1) / divisor;
}

class UnionFind
{
    public:
    vector<ll> par;

    UnionFind(ll n) : par(n,-1){}

    ll root(ll x)
    {
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }

    void unite(ll x, ll y)
    {
        x = root(x); y = root(y);
        if(x==y) return;
        if(par[x] > par[y]) swap(x,y);
        par[x] += par[y];
        par[y] = x;
    }

    ll size(ll i)
    {
        return -par[root(i)];
    }
};


static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}



int main()
{
    string S;
    cin >> S;

    if(S[0]==S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue<int, vector<int>, greater<int> > q;
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
#define ld long double
#define ull unsigned long long
#define db double
#define ll long long
const db eps=1e-7;
//const db pi=acos(-1);
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (ll i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e5+7;

ll t,n,m,fl=0;

int main(){
    scanf("%lld",&n);
    m=100,t=1;
    while(m<n){
        m+=t;
        fl++;
        t=m/100;
    }
    printf("%lld\n",fl);

    return 0;
}

Measured memory_bytes: 3232
import java.util.Random;
import java.util.Scanner;

public class Main {
    static int d = 365;
    static int[] c = new int[26];
    static int[][] s = new int[d][26];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        sc.nextInt();
        for (int i=0;i<26;i++){
            c[i]=sc.nextInt();
        }
        for (int i=0;i<d;i++){
            for (int j=0;j<26;j++){
                s[i][j]=sc.nextInt();
            }
        }
        int[] contest = new int[d];
        int count = 100000;
        for (int i=0;i<d;i++)contest[i]=random.nextInt(26);
        for (int i=0;i<count;i++){
            int[] instance = contest.clone();
            int times = random.nextInt(12)+12;
            int[] choose = new int[times];
            for (int j=0;j<times;j++)choose[j]=random.nextInt(d);
            for (int j=0;j<times;j++)instance[choose[j]]=random.nextInt(26);
            if (function(contest)<function(instance))contest=instance;
        }
        for (int i=0;i<d;i++)System.out.println(contest[i]+1);
    }
    static long function(int[] contest){
        long satisfaction = 0;
        int[] interval = new int[26];
        for (int i=0;i<d;i++){
            satisfaction+=s[i][contest[i]];
            for (int j=0;j<26;j++)interval[j]++;
            interval[contest[i]]=0;
            for (int j=0;j<26;j++)satisfaction-=c[j]*interval[j];
        }
        return  satisfaction;
    }
}


Measured memory_bytes: 57548
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  double v;
  while(cin >> v){
    double t = v / 9.8;
    double y = 4.9 * t * t;
    ll n = (y + 5.0) / 5;
    if(5 * n - 5 < y)n++;
    cout << n << endl;
  }
	return 0;
}



Measured memory_bytes: 3032
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    string S;
    cin >> S;

    rep(i, S.size()){
        cout << 'x';
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s,t;
	cin>>s;
	t="AKIHABARA";
	for(int i=0;i<t.size();i++){
		if(s.size()>9){
			cout << "NO";
			return 0;
		}
		if(s[i]!=t[i]){
			s.insert(s.begin()+i,'A');
			i--;
		}
	}
	cout << "YES";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  
  sort(a.begin(), a.end());
  int cnt = 1;
  rep(i,2){
    if(a[i]!=a[i+1]) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
if a + b <= 2 * c:
  print(a * x + b * y)
elif max(a, b) <= 2 * c:
  m = min(x, y)
  print(2 * c * m + a * (x - m) + b * (y - m))
elif a <= 2 * c:
  print(2 * c * y + a * max(0, x - y))
elif b <= 2 * c:
  print(2 * c * x + b * max(0, y - x))
else:
  print(2 * c * max(x, y))


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

int main()
{
  int A,B,C ;
  cin>>A>>B>>C ;
  int sum=A+B+C ;
  int max=((A>B?A:B)>C?(A>B?A:B):C) ;
  
  int min=(sum%3==0?sum/3:sum/3+1) ;
  if(sum%2==0&&min%2!=0) min++ ;
  else if(sum%2!=0&&min%2==0) min++ ;
  if(min<max) min=max ;
  if(sum%2==0&&min%2!=0) min++ ;
  else if(sum%2!=0&&min%2==0) min++ ;
  
  cout<<(3*min-sum)/2<<endl ;
    
  return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  char data[102];
  int i, a, b;

  while(1){
    scanf("%s", data);
    if(data[0]=='0') break;
    a=b=0;

    for(i=1;;i++){
      if(data[i]=='\0') break;
      if(data[i]=='A') a++;
      else if(data[i]=='B') b++;
    }

    if(a>b) a++;
    else if(b>a) b++;

    printf("%d %d\n", a, b);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int i= 1;
do {
int x = i;
if(x%3==0)System.out.print(" "+i );
else{
while(true) {
    if (x % 10 == 3){
        System.out.print(" "+i);
        break;
    }
    x /= 10;
    if(x!=0)continue;
    else break;
}
}
} while (++i <= n);
System.out.println();
}
}


Measured memory_bytes: 28428
#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<iterator>

using namespace std;

int a[100010]={};
int sorted[100010]={};
int main(){
  int n;
  cin >> n;
  for(int i = 0; i< n;i++){
    cin >> a[i];
    sorted[i] = a[i];
  }

  sort(sorted,sorted+n);

  vector<int> hoge,fuga;
  for(int i=1;i<n;i+=2){
    hoge.push_back(a[i]);
    fuga.push_back(sorted[i]);
  }
  sort(hoge.begin(),hoge.end());
  sort(fuga.begin(),fuga.end());
  vector<int> mul;
  set_intersection(hoge.begin(),hoge.end(),fuga.begin(),fuga.end(),back_inserter(mul));
  cout << hoge.size()-mul.size() <<endl;
}


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

int main()
{
	string s;
	cin >> s;

	int a = s[0] - '0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] - '0';

	if (a + b + c + d == 7)
	{
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	}
	else if (a + b + c - d == 7)
	{
		cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	}
	else if (a + b - c + d == 7)
	{
		cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	}
	else if (a - b + c + d == 7)
	{
		cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	}
	else if (a - b - c + d == 7)
	{
		cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	}
	else if (a + b - c - d == 7)
	{
		cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	}
	else if (a - b + c - d == 7)
	{
		cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	}
	else if (a - b - c - d == 7)
	{
		cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
	}

	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    vi d(n);
    rep(i, 0, n) { cin >> d[i]; }

    sort(all(d));
    cout << d[n / 2] - d[n / 2 - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
N,M,Q=map(int, input().split())

L=[[0]*N for _ in range(N)]
for i in range(M):
    l,r=map(int, input().split())
    L[l-1][r-1]+=1

for i in range(N):
    for j in range(N):
        if i==0 and j==0:
            continue
        elif i==0:
            L[i][j]+=L[i][j-1]
        elif j==0:
            L[i][j]+=L[i-1][j]
        else:
            L[i][j]+=L[i-1][j]+L[i][j-1]-L[i-1][j-1]


#print(L)
for i in range(Q):
    p,q=map(int, input().split())
    p-=1
    q-=1
    if p==0:
        print(L[q][q])
    else:
        print(L[q][q]-L[p-1][q]-L[q][p-1]+L[p-1][p-1])

Measured memory_bytes: 74296
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    int amin;
    int amax;
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        if (!i) {
            amin = ai;
            amax = ai;
        }
        amin = min(amin, ai);
        amax = max(amax, ai);
    }

    cout << amax - amin << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,l,r,mid;
char s[10],t;
int main(){
    scanf("%d",&n);
	puts("0");
	fflush(stdout);
	scanf("%s",s);
	r=n,t=s[0];
    if(s[0]=='V') return 0;
    while(1){
        mid=(l+r)>>1;
        printf("%d\n",mid);
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='V') return 0;
        if(s[0]==t){
        	if(mid&1) r=mid;
        	else l=mid;
		}
		else{
			if(mid&1) l=mid;
			else r=mid;
		}
    }
    return 0;
}

Measured memory_bytes: 852
package main

import (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"runtime/debug"
	"strings"
)

func main() {
	b, _ := ioutil.ReadAll(os.Stdin)
	if len(b) == 0 {
		test()
	} else {
		solve(bytes.NewReader(b), os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n, m int
	fmt.Fscanln(r, &n, &m)
	cntByX := make(map[int]int)
	cntByMod := make(map[int]int)
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(r, &x)
		cntByX[x]++
		cntByMod[x%m]++
	}
	pairN := 0

	for mod := 0; mod <= m/2; mod++ {
		cnt := cntByMod[mod]
		if mod == 0 || (m%2 == 0 && mod == m/2) {
			pairN += cnt / 2
			cntByMod[mod] %= 2
			continue
		}
		that := m - mod
		assert(mod < that)
		if cnt > cntByMod[that] {
			cnt = cntByMod[that]
		}
		pairN += cnt
		cntByMod[mod] -= cnt
		cntByMod[that] -= cnt
	}

	for x, cnt := range cntByX {
		if cnt > 1 && cntByMod[x%m] > 1 {
			if cnt > cntByMod[x%m] {
				cnt = cntByMod[x%m]
			}
			pairN += cnt / 2
			cntByMod[x%m] -= cnt
			cntByMod[x%m] += cnt % 2
		}
	}

	fmt.Fprintln(w, pairN)
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `
7 5
3 1 4 1 5 9 2
`,
			want: `3`,
		},
		{
			in: `
15 10
1 5 6 10 11 11 11 20 21 25 25 26 99 99 99
`,
			want: `6`,
		},
		{
			in: `
3 10
8 8 8
`,
			want: `1`,
		},
		{
			in: `
20 10
1 5 6 10 11 11 11 11 11 11 31 31 20 21 25 25 26 99 99 99
`,
			want: `8`,
		},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(chomp(tt.in)), buf)
		if got, want := chomp(buf.String()), chomp(tt.want); got != want {
			fmt.Printf("%d: got %v, want %v\n", i, got, want)
		}
	}
}

func chomp(s string) string {
	return strings.Trim(s, "\n")
}

func assert(b bool) {
	if !b {
		debug.PrintStack()
		log.Fatal("err!")
	}
}


Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
// 区間加算、区間最小クエリ
template <typename F,typename T>
struct DST{
  T identity;
  F merge;
  int size;
  vector<T> dat,delay;
  
  DST(F f,T id):merge(f),identity(id){}

  void eval(int k,int l,int r){
    if(delay[k] != 0){
      dat[k] += delay[k];
      if(k<size-1){
	delay[2*k+1] += delay[k];
	delay[2*k+2] += delay[k];	
      }
      delay[k]=0;
    }
  }

  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
    delay.resize(size*2-1,0);    
  }

  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }

  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  void update(int a,int b,T x,int k,int l,int r){
    eval(k,l,r);

    if(r<=a||b<=l) return ;
    if(a<=l&&r<=b){
      delay[k] += x;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  T query(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(r<=a||b<=l) return identity;

    if(a<=l&&r<=b) return dat[k];
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }

  void all_eval(){
    rep(i,2*size-1){
      eval(i,0,0);
    }
  }

  T get(int k){ return dat[size-1+k];}
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
    cout << "************************\n";
    index = 0;
    num = 1;
    while(index<size){
      rep(i,num){
	cout << delay[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
    cout << "************************\n";      
  }


  
};
int main()
{
  int n,q;cin >> n >> q;
  vector<ll> c(q),s(q),t(q),x(q);
  rep(i,q){
    cin >> c[i];
    if(c[i]==0) cin >> s[i] >> t[i] >> x[i];
    else cin >> s[i] >> t[i];
  }
  
  auto f = [&](ll a,ll b){ return min(a,b);};
  ll id = (1LL<<60);
  DST<decltype(f),ll> dst(f,id);
  dst.init(n);
  vector<ll> vec(n,0);
  dst.build(vec);
  rep(i,q){
    if(c[i]==0) dst.update(s[i],t[i]+1,x[i],0,0,dst.size);
    else cout << dst.query(s[i],t[i]+1,0,0,dst.size) << "\n";
    //    dst.show();
  }
  
  return 0;
}



Measured memory_bytes: 11596
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c=map(int,readline().split())

    count=0
    li=[a,b,c]
    li.sort()

    count+=li[2]-li[1]
    li[0]+=li[2]-li[1]
    li[1]+=li[2]-li[1]

    count+=(li[2]-li[0])//2
    li[0]+=((li[2]-li[0])//2)*2

    if li[0]==li[2]:
        print(count)
    else:
        print(count+2)
        
if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll N = 2e5+9;
// const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod =163577857;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif     
    ll T= 1;
    // cin >> T;
    while(T--){
        ll n;cin>>n;
        ll p[n];
        for(int i = 0;i<n;i++){
            cin>>p[i];
        }
        ll b[n],a[n];
        for(int i = 0;i<n;i++){
            b[p[i]-1] = i+1;
            a[p[i]-1] = i+1;
        }
        for(int i = 1;i<n;i++){
            a[i]+=a[i-1];
        }
        for(int i = n-2;i>=0;i--){
            b[i]+=b[i+1];
        }
        for(int i = 0;i<n;i++){
            cout<<a[i]<<" ";
        }
        cout<<'\n';
        for(int i = 0;i<n;i++){
            cout<<b[i]<<" ";
        }
        cout<<'\n';


    }
   
}   

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; ll A, B; cin >> N >> A >> B;
  vector<ll> X(N); cin >> X;
  ll ans = 0;
  rep(i, N - 1) {
    auto diff = (X[i + 1] - X[i]) * A;
    ans += diff < B ? diff : B;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, m, k;
    cin >> n >> m >> k;

    vector<ll> a(n), b(m), suma(n + 1, 0), sumb(m + 1, 0);

    for (auto &&i : a)
    {
        cin >> i;
    }

    for (int i = 0; i < n; i++)
    {
        suma[i + 1] = suma[i] + a[i];
    }

    for (auto &&i : b)
    {
        cin >> i;
    }

    for (int i = 0; i < m; i++)
    {
        sumb[i + 1] = sumb[i] + b[i];
    }

    ll ans = 0;

    for (int i = 0; i <= n; i++)
    {
        if (k - suma[i] < 0)
        {
            continue;
        }

        auto it = upper_bound(sumb.begin(), sumb.end(), k - suma[i]);

        ans = max(ans, ll(it - sumb.begin() + i - 1));
    }

    cout << ans << endl;
}


Measured memory_bytes: 9596
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll X;
	while(cin>>X) {
		vector<bool> dp(X+1);
		dp[0]=true;
		REP(i, dp.size()) if(dp[i]) {
			RANGE(v, 100, 106) {
				ll nv = i+v;
				if(nv<dp.size()) dp[nv]=true;
			}
		}
		ll ans = dp[X];
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
//intのオーバーフローに気をつけろ,AGCはだいたいlongにしておけ
//毎回余りを求めることでオーバーフローしなくなる
//nextLineよりnextだ
//charは''で囲うんだぞ
//読み込みは先に全部やっておけ
//for文を回す回数に気をつけろ
	//for文は10^3の三重はTLE,10^5の二重はTLE,10^9のforはTLE
//貪欲は使えるか？？試した？？

import java.util.Scanner;

public class Main {

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

		    String s = sc.next();
		    if(s.length() == 2) {
		    	System.out.println(s);
		    }else {
		    	System.out.println(s.substring(2, 3)+s.substring(1,2)+s.substring(0,1));
		    }
		    
		    
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

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

	    return a;
	}
}


Measured memory_bytes: 23124
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);

		
		
		BigDecimal a = sqrt(new BigDecimal(sc.nextInt()),50);
		BigDecimal b = sqrt(new BigDecimal(sc.nextInt()),50);
		BigDecimal c = sqrt(new BigDecimal(sc.nextInt()),50);

		
		if (a.add(b).compareTo(c)==-1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

      	sc.close();
    }
		
	   public static BigDecimal sqrt(BigDecimal a, int scale){

        BigDecimal x = new BigDecimal(Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
        if(scale < 17){
             x = x.setScale(scale, BigDecimal.ROUND_HALF_EVEN);
             return x;
        }

        BigDecimal b2 = new BigDecimal(2);
        for(int tempScale = 16; tempScale < scale; tempScale *= 2){
            x = x.subtract(
                    x.multiply(x).subtract(a).divide(
                    x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
        }
        return x;
    }

}

Measured memory_bytes: 23764
N = int(input())
L = map(int, input().split())
L = sorted(L)
ans = 0
for li, l in enumerate(L):
    for mi, m in enumerate(L[li+1:]):
        for ni, n in enumerate(L[li+mi+2:]):
            if l + m <= n or l == m or m == n:
                continue
            ans += 1
print(ans)


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



int main(){
  int N;
  cin >>N;
  int a,b,c;
  while( cin >> a >> b >>c){
    if((a*a==b*b + c*c || b*b == a*a + c*c )|| c*c == a*a + b*b) cout <<"YES" << endl;
      else  cout <<"NO" << endl;
  }
}



Measured memory_bytes: 3012
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;

int s[100010];

int main(){
    string c;cin>>c;
    int N=c.size(),st=0,cn=0;
    rep(i,0,N){
        if(c.at(i)=='R'){
            cn++;
            st=1;
        }
        else if(st==1&&c.at(i)=='L'){
            st=0;
            s[i-1]=cn;
            cn=0;
        }
    }
    
    for(int i=N-1;i>=0;i--){
        if(c.at(i)=='L'){
            cn++;
            st=1;
        }
        else if(st==1&&c.at(i)=='R'){
            st=0;
            s[i+1]=cn;
            cn=0;
        }
    }
    int i=0;
    while(i<N){
        if(s[i]!=0&&abs(s[i]-s[i+1])%2==0){
            s[i]=(s[i]+s[i+1])/2;
            s[i+1]=s[i];
            i++;
        }
        else if(s[i]!=0&&abs(s[i]-s[i+1])%2==1){
            if((s[i]>s[i+1]&&s[i]%2==1)||(s[i]<s[i+1]&&s[i+1]%2==0)){
                s[i]=(s[i]+s[i+1])/2+1;
                s[i+1]=s[i]-1;
                i++;
            }
            else if((s[i]>s[i+1]&&s[i]%2==0)||(s[i]<s[i+1]&&s[i+1]%2==1)){
                s[i]=(s[i]+s[i+1])/2;
                s[i+1]=s[i]+1;
                i++;
            }
        }
        i++;
    }
    rep(i,0,N){
        if(i!=0)cout<<" ";
        cout<<s[i];
    }
    cout<<endl;
}






Measured memory_bytes: 1024
import kotlin.math.max
import kotlin.math.min


fun main(args: Array<String>) {

    val k = readLine()!!.toLong()

    var sum = 0L
    (1..k).forEach { a ->
        (1..k).forEach { b ->
            (1..k).forEach { c ->
                sum += gcd(gcd(a, b), c)
            }
        }
    }

    println(sum)
}

private val map = mapOf<Pair<Long, Long>, Long>()
private fun gcd(m: Long, n: Long): Long {
    val key = min(m, n) to max(m, n)
    return map.getOrElse(key, {
        when {
            m < n -> gcd(n, m)
            n == 0L -> m
            else -> gcd(n, m % n)
        }
    })
}

Measured memory_bytes: 54024
#include<iostream>
#include<algorithm>
#include<set>
#define N 11

const int infty = 1<<28;

using namespace std;

int main(){
  while(true){    
    int w[N][N];
    set<int> town;
    int n;

    cin >> n;
    if( n == 0 ) break;
    fill(&w[0][0],&w[N-1][N],infty);

    for(int i = 0; i < n; ++i){
      int a,b,c;
      cin >> a >> b >> c;
      town.insert(a);town.insert(b);
      w[a][b] = w[b][a] = c;
    }

    for(int k = 0; k < N; ++k){
      for(int i = 0; i < N; ++i){
	for(int j = 0; j < N; ++j){
	  w[i][j] = min( w[i][j], w[i][k] + w[k][j] );
	}
      }
    }
    
    int min_cost= infty;
    int answer_town;

    for(int i = 0; i < N; ++i){
      if( town.find(i) == town.end() ) continue;
      int cost = 0;
      for(int j = 0; j < N; ++j){
	if( i == j ) continue;
	if( town.find(j) == town.end() ) continue;
	cost += w[i][j];
      }
      if( min_cost > cost ){
	min_cost = cost;
	answer_town = i;
      }
    }

    cout << answer_town << ' ' << min_cost << endl;
  }
  return 0;
}

Measured memory_bytes: 0
from collections import deque
h,w,k = map(int,input().split())
a,b,c,d = map(int,input().split())
a -= 1
b -= 1
c -= 1
d -= 1
maze = [input() for _ in range(h)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
depth = [[float("inf") for _ in range(w)] for _ in range(h)]
dq = deque([(b,a)])
depth[a][b] = 0
while dq:
    x,y = dq.popleft()
    if x == d and y == c:
        break
    for i in range(4):
        nx,ny,K = x,y,k
        while K:
            K -= 1
            nx += dx[i]
            ny += dy[i]
            if 0<=nx<=w-1 and 0<=ny<=h-1 and maze[ny][nx] != "@" and depth[ny][nx] > depth[y][x]:
                if depth[ny][nx] == depth[y][x]+1:
                    continue
                depth[ny][nx] = depth[y][x] +1
                dq.append((nx,ny))
            else:
                break
print(depth[c][d] if depth[c][d] != float("inf") else -1)

Measured memory_bytes: 55104
#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>

#define N 64

using namespace std;

int main(void) {
	while(1) {
		int man[N] = {0};
		int bowl, now = 0;
		int n, p;
		bool endflag;
		scanf("%d %d", &n, &p);
		if(n == 0 && p == 0) break;
		bowl = p;
		while(1) {
			if(bowl != 0) {
				man[now]++;
				bowl--;
			} else {
				bowl = man[now];
				man[now] = 0;
			}

			if(bowl == 0) {
				endflag = true;
				for(int i = 0; i < n; i++) {
					if(i != now && man[i] != 0) {
						endflag = false;
						break;
					}
				}
				if(endflag) break;
			}
			now = (now + 1) % n;
		}

		printf("%d\n", now);
	}
	return 0;
}

Measured memory_bytes: 1188
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        a[i] -= a[i]
    else:
        a[i] -= x
        x = 0
if x > 0:
    print(a.count(0)-1)
else:
    print(a.count(0))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 998244353;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int l; cin >> l;
	long double x = 1.0L * l / 3.0L;
	cout << fixed << setprecision(15) << x*x*x;
}

Measured memory_bytes: 256