akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc140/tasks/abc140_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

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, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (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:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

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

fn main() {
    input! {
        n: usize,
        b: [i32; n-1]
    };

    let mut a = vec![0; n];
    a[0] = b[0];
    a[n-1] = b[n-2];
    for i in 1..n-1 {
        a[i] = min(b[i-1], b[i]);
    }
    let mut sum = 0;
    for i in 0..n {
        sum += a[i];
    }
    println!("{}", sum);
}


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

int main() {
    int N;
    cin >> N;
    string W[N];
    for (int i = 0; i < N; ++i) cin >> W[i];

    bool rule = true;
    for (int i = 1; i < N; ++i) {
        if (W[i].front() != W[i - 1].back()) {
            rule = false;
            break;
        }
        for (int j = 0; j < i; ++j) {
            if (W[j] == W[i]) {
                rule = false;
                break;
            }
        }
        if (!rule) break;
    }

    if (rule) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
k, s = gets.chomp.split(" ").map(&:to_i)

# k, s = [2, 2]

res = 0
(0 .. k).each do |x|
  (0 .. k).each do |y|
    z = s - x - y
    if z >= 0 && z <= k
      res += 1
    end
  end
end

print("#{res}\n")

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e6+10;
ll r[maxn],g[maxn],w[maxn];
bool cmp(ll x,ll y)
{
    return x>y;
}
int main()
{
   ll x,y,a,b,c;
   cin>>x>>y>>a>>b>>c;
   for(int i=1;i<=a;i++) cin>>r[i];
   for(int i=1;i<=b;i++) cin>>g[i];
   for(int i=1;i<=c;i++) cin>>w[i];
   sort(r+1,r+a+1,cmp);
   sort(g+1,g+b+1,cmp);
   sort(w+1,w+c+1,cmp);
   priority_queue <ll,vector<ll>,greater<ll> >q;
   ll sum=0;
   for(int i=1;i<=x;i++) q.push(r[i]),sum+=r[i];
   for(int i=1;i<=y;i++) q.push(g[i]),sum+=g[i];
   for(int i=1;i<=c;i++)
   {    if(q.empty()) break;
       ll mi=q.top();
       if(w[i]>mi) {
           sum+=w[i];
           sum-=mi;
           q.pop();
       }
       else break;
   }
   cout<<sum<<endl;
   //system("pause");
   return 0;
}


Measured memory_bytes: 9332
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b, c;
  readf("%s %s %s\n", &a, &b, &c);

  if (b - a == c - b) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

char S[200020];

int main() {
	scanf("%s", S + 1);
	int cnt = 0;
	ll ans = 0;
	for(int i=1;S[i];i++) {
		if(S[i] == 'B') ++cnt;
		else ans += cnt;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n,m,a;
  cin >> n >> m;
  int ans = n;
  for(int i=0;i<m;i++){
    cin >> a;
    ans -= a;
  }
  ans = max(ans,-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3672
import math
n=int(input())
def koch(d,p1,p2):
	if d==0:
		return
	s=[0,0]
	t=[0,0]
	u=[0,0]
	s[0]=2/3*p1[0]+1/3*p2[0]
	s[1]=2/3*p1[1]+1/3*p2[1]
	t[0]=1/3*p1[0]+2/3*p2[0]
	t[1]=1/3*p1[1]+2/3*p2[1]
	u[0]=s[0]+(t[0]-s[0])*math.cos(math.pi/3)-(t[1]-s[1])*math.sin(math.pi/3)
	u[1]=s[1]+(t[0]-s[0])*math.sin(math.pi/3)+(t[1]-s[1])*math.cos(math.pi/3)
	koch(d-1,p1,s)
	print(*s)
	koch(d-1,s,u)
	print(*u)
	koch(d-1,u,t)
	print(*t)
	koch(d-1,t,p2)
print(0,0)
koch(n,[0,0],[100,0])
print(100,0)


Measured memory_bytes: 5784
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


bool vis[N];
int cnt[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
//    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        
        int pe=0,res=0;
        for(int i=1;i<=m;i++){
            int x;
            string s;
            cin>>x>>s;

            if(s=="AC"){
                if(!vis[x]){
                    res++;
                    pe+=cnt[x];
                }
                vis[x]=true;
            }
            else{
                if(!vis[x]){
                    cnt[x]++;
                }
            }
        }
        printf("%d %d\n", res,pe);

        //printf("Case %d: ",++te);
    }
    return 0;
}




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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  set<char> st;
  rep(i, n) {
    char ch;
    cin >> ch;
    st.insert(ch);
  }
  cout << (st.size() == 3 ? "Three" : "Four") << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      
      int n = sc.nextInt();
      double head_pro[] = new double[n+1];
      double tail_pro[] = new double[n+1];
      for(int i=1;i<=n;i++)
      {
          head_pro[i] = sc.nextDouble();
          tail_pro[i] = 1-head_pro[i]; 
      }
      double dp[][] = new double[n+1][n+1];
      dp[0][0] = 1;
      for(int i=1;i<=n;i++)
      {
          for(int j=0;j<=n;j++)
          {
              if(i<j)
                continue;
              if(j==0)
              {
                  dp[i][j]=dp[i-1][j]*tail_pro[i];
              }
              else
              {
                  dp[i][j]=(dp[i-1][j-1]*head_pro[i])+(dp[i-1][j]*tail_pro[i]);
              }
          }
      }
      double ans = 0;
      for(int i=n;i>n/2;i--)
      {
          ans+=dp[n][i];
      }
      w.println(ans);
      w.close();
    }
}

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

int main(){
    string s; 
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    if(s=="Cloudy") cout << "Rainy" << endl;
    if(s=="Rainy") cout << "Sunny" << endl;
    return 0;
}


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

int main()
{
int n,i,cnt=0;
cin >> n;
char a[n],b[n],c[n];
cin >> a;
cin >> b;
cin >> c;

for(i=0;i<n;i++){
if(a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i]){
cnt=cnt+2;
}else if(a[i]!=b[i] || a[i]!=c[i] || b[i]!=c[i]){
cnt=cnt+1;
}
}

cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
a=[]
for i in range(len(s)):
    if s[i]=='0':
        a.append('0')
    elif s[i]=='1':
        a.append('1')
    else:
        if len(a)!=0:
            trash=a.pop()
        else:
            pass
print(''.join(a))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
using namespace std;

int main(){
	int n, k, c, mx=0, l=-2020200;
	string s;
	cin >> n >> k >> c >> s;
	vector<int> v(n,0), v2(n,0);

	for (int i=0; i<n; i++){
		if (s[i]=='o' && l+c<i){
			mx++;
			v[i]=1;
			l=i;
		}
	}

	l = 2020200;
	for (int i=n-1; i>=0; i--){
		if (s[i]=='o' && l-c>i){
			v2[i]=1;
			l=i;
		}
	}

	if (mx<=k)
		for (int i=0; i<n; i++){
			if (v[i] && v2[i])
				cout << i+1 << endl;
		}
    return 0;
}

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

using namespace std;

int solve(
  const vector<int>& P,
  const vector<int>& C,
  int G,
  vector<int>& solved,
  int count
) {
  if (G <= 0) return count;

  int min = -1;
  for (int i = 0; i < P.size(); ++i) {
    int left = P[i] - solved[i];
    if (left <= 0) continue;

    int score = (i + 1) * 100;
    int n = G / score + (G % score ? 1 : 0);
    if (n > left) n = left;
    solved[i] += n;
    int scores = n * score;
    if (solved[i] == P[i]) scores += C[i];
    int result = solve(P, C, G - scores, solved, count + n);
    if (min < 0 or min > result) min = result;
    solved[i] -= n;
  }
  return min;
}

int main()
{
  int D, G;
  cin >> D >> G;
  vector<int> P(D), C(D);
  for (int d = 0; d < D; ++d) cin >> P[d] >> C[d];
  vector<int> solved(D);
  cout << solve(P, C, G, solved, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
H = gets.split.map(&:to_i)

dp = Array.new(N, Float::INFINITY)
dp[0] = 0

(N - 1).times do |i|
  if i == 0
    dp[1] = (H[i + 1] - H[i]).abs
  else
    dp[i + 1] = [(H[i + 1] - H[i]).abs + dp[i], (H[i + 1] - H[i - 1]).abs + dp[i - 1]].min
  end
end

puts dp[-1]

Measured memory_bytes: 11404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,l;
    cin>>n>>l;
    vector <string> s(n);
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
      cout<<s[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif


namespace Solver{
using namespace std;

struct Problem{
    int n,m;
    vector<vector<pair<int,LL>>> a;
    vector<int> vis;
    vector<LL> ans,tmp;
    Problem(int n, int m):n(n),m(m),a(n),vis(n),ans(n){};
    void dfs(int i,LL x=0){
        DBG(i)
        if(vis[i] and x!= ans[i])no();
        if(!vis[i]){
            vis[i]=1;
            ans[i]=x;
            tmp.push_back(x);
            for(auto && j:a[i]){
                dfs(j.first,x+j.second);
            }
        }
    }
    void solve(){
        for(int i=0; i<m; ++i){
            LL l,r,d;
            cin >> l >> r >> d;
            --l,--r;
            a[l].emplace_back(r,d);
            a[r].emplace_back(l,-d);
        }
        for(int i=0; i<n; ++i){
            if(!vis[i]){
                dfs(i);
                DBG(tmp)
                if(*max_element(tmp.begin(),tmp.end())-*min_element(tmp.begin(),tmp.end())>1e9)no();
                tmp.clear();
            }
        }
        cout << "Yes" << "\n";
    }
    void no(){cout << "No" <<"\n"; exit(0);}

};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0,m;
    std::cin >> n >> m;
    Solver::Problem p(n,m);
    p.solve();
    return 0;
}



Measured memory_bytes: 16764
x=gets.to_i
if x<600
  puts 8
elsif x<800
  puts 7
elsif x<1000
  puts 6
elsif x<1200
  puts 5
elsif x<1400
  puts 4
elsif x<1600
  puts 3
elsif x<1800
  puts 2
elsif x<2000
  puts 1
end


Measured memory_bytes: 14380
#include <iostream>

using namespace std;

int main(int argc, char const* argv[]) {
	long long int x, k, count;
	count = 0;

	cin >> k;
	cin >> x;

	count = k * 500;

	if (count >= x)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int H1,M1,H2,M2,K;

	scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);

	int H3 = H2 - H1;
	int M3 = M2 - M1;

	int sum = H3 * 60 + M3;
	printf("%d\n",sum - K);
	return 0;
}



Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstdio>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

   
    int n;
    cin >> n;

    char c;
    vector<bool> a(26,false);
    for(int i = 0;i < n;i++){
        cin >> c;
        a[c-'A']=true;
    }
    int count = 0;
    for(int i = 0;i < 26;i++){
        cin >> c;
        if(a[i] == true){
            count++;
        }
    }

    if(count == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
/* mamba mentality */
#include "bits/stdc++.h"
using namespace std;
typedef long double ld;
#define int long long
typedef pair<int,int> pii;
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(int i=k; i<=n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define endl '\n'
#define deb(x) cout<<#x<<" = "<<x<<endl
#define gcd __gcd
#define inf LLONG_MAX
#define minf LLONG_MIN 
const int mod = (int)(1e9+7);

int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
bool is_power_2(int n)  { return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}

int dx[]    =  { 1 ,  0,  -1,  0,  -1, -1, 1,  1};
int dy[]    =  { 0 ,  1,   0, -1,  -1,  1, 1, -1};
char dir[]  =  {'D','R','U','L'};

const int maxn =100005;

/* ------------------------------------------------------- */



void solve()
{
    int n,i,j,k,m;
    cin>>n;
    map<string ,int> mp;
    rep(i,n)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"];
}  
signed main()
{
    RAGE;
   
    int t=1;
    //  cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3688
#include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define SORT(v) (sort(v.begin(),v.end()))
using ll = long long;
using namespace std;

void solve();

int main() {

	solve();
	return 0;

}

void solve() {

	string s;
	string s1, s2;
	cin >> s;
	while (s.size()) {
		s.pop_back();
		s.pop_back();
		s1 = s.substr(0, sizeof(char)*(s.size() / 2));
		s2 = s.substr(sizeof(char)*(s.size() / 2), sizeof(char)*(s.size() / 2));
		if (s1 == s2) {
			cout << s1.size()*2 << endl;
			exit(0);
		}
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int MAXN=100;
int n,k;
int a[MAXN+10];
bool cmp(const int a,const int b){return a>b;}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	sort(a+1,a+1+n,cmp);
	int sum=0;
	for(int i=1;i<=k;++i)sum+=a[i];
	printf("%d",sum);
	return 0;
}

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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

ll dp[100001] = {};

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int tmp;
    cin >> tmp;
    dp[tmp] = -1;  // hole
  }

  dp[0] = 1;
  if (dp[1] == -1) {
    dp[1] = 0;
  } else {
    dp[1] = 1;
  }

  for (int ith = 2; ith < N + 1; ++ith) {
    if (dp[ith] == -1) {
      dp[ith] = 0;
      continue;
    }
    dp[ith] = dp[ith - 1] % MOD + dp[ith - 2] % MOD;
  }

  cout << dp[N] % MOD << endl;
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  int n = s.size();
  string t="";
  for(int i=s.size()-1;i>=0;i--) t+=s[i];
  
  bool flag1 = false,flag2 = false,flag3 = false;
  if(s==t) flag1 = true;

  string s_n1 = "";
  for(int i=0;i<(n-1)/2;i++) s_n1+=s[i];
  string s_n1r = "";
  for(int i=(n-1)/2-1;i>=0;i--) s_n1r+=s[i];
  if(s_n1 == s_n1r) flag2 = true;
  
  string s_n3 = "";
  for(int i=(n+3)/2-1;i<n;i++) s_n3+=s.at(i);
  string s_n3r = "";
  //for(int i=n-1;i>=(n+3)/2;i--) s_n3r+=s.at(i);
  for(int i=s_n3.size()-1;i>=0;i--) s_n3r+=s_n3[i];
  if(s_n3 == s_n3r) flag3 = true;
  
  if(flag1 && flag2 && flag3) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int N;
    
    cin >> N;
    
    for( int i = 1 ; i < 10 ; i++ ){
        for( int j = 1; j < 10; j++){
            if( i * j == N ){
                cout << "Yes";
                return 0;
            }
        }
    }
    
    cout << "No";
    
}


Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 *
 * AND WATCH OUT FOR OFF BY ONE!!!
 */

#include <bits/stdc++.h>
const bool unsyncedio=std::ios::sync_with_stdio(false);
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll (i)=0; (i)<(n); (i)++)

int main() {
int n;
    cin>>n;
    vector<vector<pair<int, int>>> tree(n+1);
    vector<int> color(n+1);
    fori(n) {
        int u, v, w;
        cin>>u>>v>>w;   
        tree[u].push_back({ v, w%2 });
        tree[v].push_back({ u, w%2 });
    }

    function<void(int, int, int)> dfs=[&](int node, int parent, int w) { 
        w%=2;
        color[node]=w;
        for(auto c : tree[node]) {
            if(c.first!=parent)
                dfs(c.first, node, w+c.second);
        }
    };

    dfs(1, -1, 0);
    for(int i=1; i<=n; i++)
        cout<<color[i]<<endl;
        

}



Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace  std;
int const N=1e5;

double fact(int n)
{
    long long ans=1;
    while(n--)
    {
        ans*=n;
        // n--;
    }
    return  ans;
}
int main() {
    vector <pair<double,double>> vec;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        double x,y;
        cin>>x>>y;
        vec.push_back(make_pair(x,y));

    }
    double sum=0;
    double cnt=0;
    sort(vec.begin(),vec.end());
    do
    {
        cnt++;
        for(int i=0;i<vec.size()-1;i++)
        {
            double x=(vec[i].first-vec[i+1].first)*(vec[i].first-vec[i+1].first);
            double y=(vec[i].second-vec[i+1].second)*(vec[i].second-vec[i+1].second);

            sum+=sqrt(x+y);


        }

    }
    while(next_permutation(vec.begin(),vec.end()));
    cout<<fixed<<setprecision(10)<<sum/cnt;
}

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

int main() {
    string s;
    int n, q;
    cin >> n >> q;
    cin >> s;
    vector<int> ac(s.size()+1);
    ac[0] = 0;
    for(int i = 0; i < s.size()+1; i++) {
        if(s[i]=='A'&&s[i+1]=='C') ac[i+1] = ac[i]+1;
        else ac[i+1] = ac[i];
    } 
    rep(i,q){
        int l, r;
        cin >> l >> r;
        r--; l--;
        cout << ac[r]-ac[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
# AtCoder Beginner Contest 086 A
# [URL]      https://atcoder.jp/contests/abc086/tasks/abc086_a
# [compiler] Version 0.5.0

#==================================================================================================#

function abc086_a()

	# STEP.01
	# get the number of the slice of cake
	a,b = Base.parse.( Base.split( Base.readline( Base.STDIN ) ) )

	# STEP.02
	# output the result
	if Base.iseven( a*b )
		Base.println( Base.STDOUT, "Even")
	else
		Base.println( Base.STDOUT, "Odd" )
	end

	# STEP.TRUE_END
	return Base.nothing

end

#==================================================================================================#

Main.abc086_a()


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

int main() {
	int p;
	bool submit[31];

	for (int i = 1;i <= 30;i++) {
		submit[i] = false;
	}
	for (int i = 0;i < 28;i++) {
		scanf("%d", &p);
		submit[p] = true;
	}

	for (int i = 1;i <= 30;i++) {
		if (!submit[i]) {
			printf("%d\n", i);
		}
	}

	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A, B;

    cin >> A >> B;
    cout << A*B << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(){
    int i,j;
    int A[100],N,num=0,min,v;
    
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    for(i=0;i<N;i++){
        min = i;
        for(j=i;j<N;j++){
            if(A[min] > A[j]){min = j;
                
            }
        }
        v = A[min];
        A[min] = A[i];
        A[i] = v;
        if(i != min) num++;
    }
    
    printf("%d",A[0]);
    for(i=1;i<N;i++) printf(" %d",A[i]);
    printf("\n");
    printf("%d\n",num);
    
    return 0;  
}


Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
while(1){
int n;
cin>>n;
if(n==0)break;
vector<string> s(n);
for(int i=0;i<n;i++){
	cin>>s[i];
}
int ans=0;
bool f=false;
int r=0,l=0;
for(int i=0;i<n;i++){
if(s[i]=="lu")l=1;
if(s[i]=="ru")r=1;
if(s[i]=="ld")l=0;
if(s[i]=="rd")r=0;
if(l==r){
	if(r==1&&!f){
		f=true;
		ans++;
	}
	if(r==0&&f){
		f=false;
		ans++;
	}

}

}
cout<<ans<<endl;
}

return 0;
}



Measured memory_bytes: 3140
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			long ans = 0;

			//for (int i = 0; i < n - 1; i++) {
			//	for (int j = i + 1; j < n; j++) {
			//		if (j - i == a[i] + a[j]) {
			//			System.Diagnostics.Debug.WriteLine($"{i + 1}:{a[i]} {j + 1}:{a[j]}");
			//			ans++;
			//		}
			//	}
			//}

			Dictionary<int, int> count1 = new Dictionary<int, int>();   // i + a[i]
			Dictionary<int, int> count2 = new Dictionary<int, int>();   // i - a[i]
			for (int i = 0; i < n; i++) {
				int sum = (i + 1) + a[i];
				if (!count1.ContainsKey(sum)) {
					count1.Add(sum, 0);
				}
				count1[sum]++;
				int diff = (i + 1) - a[i];
				if (!count2.ContainsKey(diff)) {
					count2.Add(diff, 0);
				}
				count2[diff]++;
				//System.Diagnostics.Debug.WriteLine($"{i + 1}:{a[i]} {sum} {diff}");
			}

			foreach (var item in count1) {
				long x = item.Value;
				if (count2.ContainsKey(item.Key)) {
					long y = count2[item.Key];
					ans += x * y;
					//System.Diagnostics.Debug.WriteLine($"{item.Key} {x}x{y}");
				}
			}

			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 58672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair(a, b)
#define F first
#define S second
#define Y second.first
#define X second.second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int w, h;
int s[32][32], dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1}, c[4], used[32][32][4];

int main(){
  while(scanf("%d%d", &w, &h) && w+h){
    rep(i, h) rep(j, w) scanf("%d", &s[i][j]);
    rep(i, 4) scanf("%d", c+i);

    memset(used, 0, sizeof(used));
    priority_queue<pipi, vector<pipi>, greater<pipi> >q; // cost, nesw, y, x
    q.push(MP(MP(0, 1), MP(0, 0)));
    while(!q.empty()){
      pipi now = q.top(); q.pop();
      if(used[now.Y][now.X][now.F.S]++) continue;
      //      printf("%d %d %d %d\n", now.F.F, now.F.S, now.Y, now.X);
      if(now.Y == h-1 && now.X == w- 1){
	printf("%d\n", now.F.F);
	break;
      }
      rep(i, 4){
	pipi next = now;
	if(i != s[now.Y][now.X]) next.F.F += c[i];
	next.F.S = (next.F.S+i)%4;
	next.Y += dy[next.F.S]; next.X += dx[next.F.S];
	if(next.Y < 0 || next.X < 0 || next.Y >= h || next.X >= w) continue;
	q.push(next);
      }
    }
  e:;
  }
  return 0;
}

Measured memory_bytes: 1348
fun main(args: Array<String>) {
    val s = readLine()!!
    val q = readLine()!!.toInt()
    val pre = StringBuilder()
    val post = StringBuilder()

    var isRev = false
    repeat(q) {
        val line = readLine()!!.split(' ')
        val t = line[0].toInt()
        if (t == 1) {
            isRev = !isRev
        } else {
            val f = line[1].toInt()
            val c = line[2][0]
            val isPre = (isRev && f == 2 || !isRev && f == 1)
            if (isPre) {
                pre.append(c)
            } else {
                post.append(c)
            }
        }
    }

    if (isRev) {
        println("${post.reversed()}${s.reversed()}${pre}")
    } else {
        println("${pre.reversed()}$s$post")
    }
}

Measured memory_bytes: 61200
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
	int N; cin >> N;
	if (N <= 2) {
		cout << 1 << endl;
		return 0;
	}

	int past; cin >> past;
	int *a = new int[N - 1];
	for (int i = 0; i < N - 1; i++) {
		int b; cin >> b;
		if (past < b) {
			a[i] = 1;
		}
		else if (past == b) {
			a[i] = 0;
		}
		else {
			a[i] = -1;
		}
		past = b;
	}

	int c = 1;
	int flag = 0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] == 0) { continue; }
		if (flag == 0) {
			flag = a[i];
		}
		else if (flag != a[i]) {
			c++;
			flag = 0;
		}
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 640
A,B,C=map(int,input().split())
if A == B == C:
	print((A % 2) - 1)
else:
	i = 0
	while (A % 2) == (B%2) == (C%2) == 0:
		A,B,C = (B//2) + (C//2), (C//2) + (A//2), (A//2) + (B//2)
		i += 1
	print(i)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"sort"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printans(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &b[i])
	}
	for i := 0; i < n; i++ {
		c[i] = i + 1
	}

	var l, r int
	for i := 1; nextPermutation(sort.IntSlice(c)); i++ {
		if reflect.DeepEqual(c, a) {
			l = i
		}
		if reflect.DeepEqual(c, b) {
			r = i
		}
	}
	if l < r {
		l, r = r, l
	}
	fmt.Fprintln(write, l-r)
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>

int main(void){
  std::string s, output;
  std::vector<char> v;
  std::cin >> s;
  
  for(const char* cptr = s.c_str(); *cptr != '\0'; cptr++){
    if(*cptr == '0' || *cptr == '1')
      v.push_back(*cptr);
    else if (*cptr == 'B' && !v.empty())
      v.pop_back();
  }

  for(auto iter = v.begin(); iter!=v.end(); iter++){
    std::cout << *iter;
  }
  std::cout << std::endl;
}

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

using namespace std;

int main() {
	int sideInfo[3];
	int total[4];

	memset(total, 0, sizeof(total));
	while (true) {
		cin >> sideInfo[0] >> sideInfo[1] >> sideInfo[2];
		sort(sideInfo, sideInfo + 3);
		if (sideInfo[0] + sideInfo[1] <= sideInfo[2]) {
			break;
		}
		++total[0];
		for (int i = 0; i < 3; ++i) {
			sideInfo[i] *= sideInfo[i];
		}
		if (sideInfo[0] + sideInfo[1] == sideInfo[2]) {
			++total[1];
		}else if (sideInfo[0] + sideInfo[1] > sideInfo[2]) {
			++total[2];
		}
		else {
			++total[3];
		}
	}
	cout << total[0];
	for (int i = 1; i < 4; ++i) {
		cout << " " << total[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
bool check(ll q)
{
    ll m=n/q-1;
    return m>q;
}
int main()
{
    scanf("%lld",&n);
    ll ans=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i)continue;
        if(check(i))ans+=n/i-1;
        if(n/i!=i&&check(n/i))ans+=i-1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
// AOJ Volume 0 Problem 0092

#include <stdio.h>
#include <string.h>

#define SIZE (1000)

int map[SIZE][SIZE];
int indexx[SIZE + 1][SIZE + 1][2];

int main(void)
{
	int n;
	char str[1001];
	int i, j;
	int max;
	int s;
	

    while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%s", str);
			for (j = 0; str[j] != '\0'; j++){
				if (str[j] == '*'){
					map[i][j] = 0;
				}
				else {
					map[i][j] = 1;
				}
			}
		}
		
		memset(indexx, 0, sizeof(indexx));
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				if (j == 0){
					indexx[i][j][0] = map[i][j];
					indexx[j][i][1] = map[j][i];
				}
				else {
					indexx[i][j][0] = (indexx[i][j - 1][0] + map[i][j]) * map[i][j];
					indexx[j][i][1] = (indexx[j - 1][i][1] + map[j][i]) * map[j][i];
				}
			}
		}
//		for (i = 0; i < n; i++){
//			for (j = 0; j < n; j++){
//				printf("(%2d:%2d)", index[i][j][0], index[i][j][1]);
//			}
//			printf("\n");
//		}
		max = 0;
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				if (indexx[i][j][0] != 0 && indexx[i][j][1] != 0){
					s = 2;
					while (indexx[i + s - 1][j + s - 1][0] >= s && indexx[i + s - 1][j + s - 1][1] >= s){
						s++;
					}
					s--;
					if (s > max){
//						printf("<%d, %d=%d>", j, i, s);
						max = s;
					}
				}
			}
		}
		
		printf("%d\n", max);
	}
	return (0);
}

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

int main(){
  int N,K;
  cin >> N >> K;
  int x,sum = 0;
  for(int i = 0;i < N;i++){
    cin >> x;
    if(K - x > 0){
    	if(x > K - x)
          sum += (K - x) * 2;
    	else
          sum += x * 2;
    }else{
        if(x > x - K)
          sum += (x - K) * 2;
    	else
          sum += x * 2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#include <stdio.h>
#include <string.h>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAXN = 10001; 


int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    LL n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    if(s[0] != t[0]) {
        cout << -1 << endl;
        return 0;
    }
    LL l = m*n/__gcd(n,m);
    
    map<LL, char> mp;
    char empty = mp['a'];
    LL ln = l/n;
    LL curLN = ln;
    FOR(i,1,n) {
        mp[curLN+1] = s[i];
        curLN += ln;
    }
    
    LL lm = l/m;
    LL curLM = lm;
    FOR(i,1,m) {
        char c = mp[curLM + 1];
        if (c != empty && c != t[i]) {
            cout << -1 << endl;
            return 0;
        }
        curLM += lm;
    }
    cout << l << endl;
    return 0; 
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
using Int = long long unsigned;
Int const INF = 1e10;
typedef vector<pair<Int,Int>> pvec;

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

    int n;Int sc; cin>>n>>sc; sc/=100;int a[n],b[n]; vector<int>p;
    for (int i = 0; i < n; i++)cin>>a[i]>>b[i];
    for (int i = 0; i < n; i++)b[i]/=100;
    for (int bit = 0; bit < (1<<n); bit++){
        Int gc=0;int ans=0;
        for (int i = 0; i < n; i++){
            if(bit&(1<<i)){
                gc+=(i+1)*a[i]+b[i];
                ans+=a[i];
            }
        }
        if(gc<sc){
            for (int i = n-1; i >= 0; i--){
                if(!(bit&(1<<i))){
                    if(sc-gc<=(a[i]-1)*(i+1)){
                        if(!((sc-gc)%(i+1))){
                            ans+=(sc-gc)/(i+1);gc+=sc-gc;break;
                        }else ans+=(sc-gc)/(i+1)+1;gc+=sc-gc;break;
                    }else break;
                }
            }
        }
        if(gc>=sc)p.push_back(ans);
    }
    cout<<*min_element(p.begin(),p.end())<<'\n';
}

Measured memory_bytes: 512
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- (`mod` 10) <$> getInt
    let ans | n == 3 = "bon"
            | n == 0 || n == 1 || n == 6 || n == 8 = "pon"
            | otherwise = "hon"
    putStrLn ans

Measured memory_bytes: 3752
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
#include <cctype>
#include <iostream>
#include <map>


#define rg register
#define ll long long
#define ull unsigned long long  
using namespace std;

inline int read(){
	rg int s=0,f=0;
	rg char ch=getchar();
	while (not isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while (isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	
	return f?-s:s;
}

map<int,bool> ma;

signed main(void){
	
	for(rg int i=1;i<=9;i++){
        for(rg int j=1;j<=9;j++){
            ma[i*j]=true;
        }
    }

    int n=read();
    if(ma[n]) printf("Yes");
    else printf("No");
	
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,P = inpl()
S = list(map(int,list(input())))

if 10%P==0:
    ans= 0
    for i,s in enumerate(S):
        if s%P == 0:
            ans += i+1
    print(ans)
else:
    tmpl = [s*pow(10,N-1-i,P)%P for i,s in enumerate(S)]
    xx = [tmpl[0]]
    for t in tmpl[1:]:
        xx.append((xx[-1]+t)%P)

    yy = [S[0]%P]
    for s in S[1:]:
        yy.append((yy[-1]*10+s)%P)

    nums = [0]*P
    nums[0] += 1
    ans = 0
    for i,y in enumerate(yy):
        tmp = y*pow(10,N-1-i,P)%P
        ans += nums[tmp]
        nums[xx[i]] += 1
    print(ans)


Measured memory_bytes: 30404
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s;
int k;
set <string> st;

int main() { 

  getline(cin, s);
  cin >> k;

  for (int i = 0; i < sz(s); i++) {
    for (int j = i; j < min(i + 5, sz(s)); j++) {
      string cur = s.substr(i, j - i + 1);
      st.insert(cur);
      if (sz(st) > k) {
        st.erase(*st.rbegin());
      }
    }
  }

  cout << *st.rbegin() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll multi_gcd = a[0];
    FOR(i, 1, n) multi_gcd = gcd(multi_gcd, a[i]);
    debug(multi_gcd);
    int max = *max_element(all(a));
    if (k % multi_gcd != 0 || k>max){
        puts("IMPOSSIBLE");
    } else {
        puts("POSSIBLE");
    }
}

Measured memory_bytes: 640
#-*-coding:utf-8-*-

def main():
    N = int(input())
    x_list = list(map(int, input().split()))
    x_list_sort = x_list[:]
    x_list_sort.sort()
    med1 = x_list_sort[(N//2)-1]
    med2 = x_list_sort[N//2]
    for i in x_list:
        if i <= med1:
            print(med2)
        elif i >= med2:
            print(med1)
            
if __name__ == '__main__':
    main()

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = b / a;
  ans = min(ans , c);
  cout << ans << endl;
}

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

int main(){
  int y,m,d;
  char c;
	scanf("%d%c%d%c%d",&y,&c,&m,&c,&d);
  
  /*printf("%d",y);
  printf("%d",m);
  printf("%d",d);*/
  
  if(y <= 2019 && m <= 4 && d <= 30) printf("Heisei");
  else printf("TBD");
  
  return 0;
  
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        string s = Console.ReadLine().PadLeft(101, '0');
        string t = Console.ReadLine().PadLeft(101, '0'); ;
        int cmp = s.CompareTo(t);
        Console.WriteLine(cmp == 0 ? "EQUAL" : (cmp < 0 ? "LESS" : "GREATER"));
    }
}

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

using namespace std;

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

typedef long long int lld;
typedef pair<int, int> pii;

const int maxv = 100005;
vector<lld> dp(maxv, 1e10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n, w;
	cin >> n >> w;

	vector<pair<lld, lld>> vec(n);

	dp[0] = 0;
	for (int i = 0; i < n ; i++) {
		cin >> vec[i].first >> vec[i].second;
	}

	for (int i = 0; i < n; i++) {
		for (int j = maxv - 1; j >= vec[i].second; j--) {
			dp[j] = min(dp[j], dp[j - vec[i].second] + vec[i].first);
		}
	}

	lld res = 0;
	for (int i = 0; i < maxv; i++) {
		if (dp[i] <= w)
			res = i;
	}

	cout << res << endl;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;
const double EPS=1e-12;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,A,B;cin>>N>>A>>B;
  cout<<min(N*A,B)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int mod=1e9+7;
bool prime(ll n)
{
    if(n==1)
        return false;
    if(n==2)
        return true;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
ll gcd(ll x,ll y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
ll fp(ll b,ll p)
{
    if(p==0)
        return 1;
    ll  z=fp(b,p/2);
    if(p%2==0)
        return (z*z)%mod;
    else
        return (((z*z)%mod)*(b%mod))%mod;
}
long long  Factorial(long long n)
{
    if(n > 1)
        return n * Factorial(n - 1);
    else
        return 1;
}
const int m=1e6+1;
ll fact[m],inv[m];
void fn()
{
    fact[0]=1,inv[0]=1;
    for(int i=1; i<=1e6; i++)
    {
        fact[i]=(i*fact[i-1])%mod;
        inv[i]=fp(fact[i],mod-2);
    }
}

long long  nCr(ll N, ll R)
{
    return (((fact[N]*inv[N-R])%mod)*inv[R])%mod;
}
vector<int>v;
void primeFactors(int n)
{
    while (n%2 == 0)
    {
        v.push_back(2);
        n = n/2;

    }

    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            v.push_back(i);
            n = n/i;
        }
    }
    if (n > 2)
        v.push_back(n);
}
long long  NCR(long long N, long long R)
{
    return (Factorial(N)) / ((Factorial(N-R)) * Factorial(R));
}
int main()
{
int r,c;
cin>>r>>c;
char arr[r][c];
int ans[r][c];
for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
        cin>>arr[i][j];
        ans[i][j]=0;
    }
}
ans[0][0]=1;
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
    if(arr[i][j]=='#'){ans[i][j]=0;continue;}
    if(i){
        ans[i][j]+=ans[i-1][j];
    }
    if(j){
      ans[i][j]+=ans[i][j-1];
    }
   ans[i][j]%=mod;
}
}
cout<<ans[r-1][c-1]<<endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  bool flag = false;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i*j == N){
        flag = true;
        //cout << "i = " << i << " j = " << j << endl;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256