akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string a,b;
  cin>>a>>b;
  int s=a.size();
  int t=b.size();
  if(s>t) cout<<"GREATER"<<endl;
  else if(s<t) cout<<"LESS"<<endl;
  else{
    string u="EQUAL";
    rep(i,0,s){
      if(a[i]>b[i]){
        u="GREATER";
        break;
      }
      else if(a[i]<b[i]){
        u="LESS";
        break;
      }
    }
    cout<<u<<endl;
  }
}

Measured memory_bytes: 256
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [[Double]] -> [Double]
solve [x, y] = iter 0 0 0 0 x y where
    iter m1 m2 m3 mi [] [] = m1:m2**(1/2):m3**(1/3):mi:[]
    iter m1 m2 m3 mi (x:xs) (y:ys) = iter (m1+d) (m2+d^2) (m3+d^3) (if mi < d then d else mi) xs ys
        where d = abs (x-y)  
readLine:: IO [Double]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Double]]
readLines 0 = return []
readLines n = readLine >>= (\a -> fmap (a:) (readLines (pred n)))
            
main :: IO() 
main = do
    n <- readLn::IO Int
    l <- readLines 2
    mapM_ print (solve l)



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

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        string a = to_string(i);
        if(a.length()&1)cnt++;
    }
    
    cout << cnt << "\n";
    
    
    return 0;
}


Measured memory_bytes: 256
a = [int(i) for i in input().split()]
if a[0]<=8 and a[1]<=8:
  print('Yay!')
elif a[0] > 8 or a[0] > 8:
    print(':(')
elif a[0]+a[1] == 16 and a[0]>7 or a[1] > 7:  
  print(':(')

Measured memory_bytes: 3060
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
n, hlist = gets_n_and_i_list

hlist.reverse!

0.upto(n-2) do |i|
  ch = hlist[i]
  nh = hlist[i+1]
  if ch < nh
    hlist[i+1] -= 1
  end
end

if hlist == hlist.sort.reverse
  puts "Yes"
else
  puts "No"
end

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

using lint = long long;

#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto &&i : n)

inline bool inside(int y, int x, int h, int w) { return 0 <= y && y < h && 0 <= x && x < w; }
const int dy[] = {0, 1, 0, -1}, dx[] = {1, 0, -1, 0};
struct PRE { PRE() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);} } _PRE;
// }}}

int n, m;
vector<int> p, a, b, c;
lint imos[101010];

int main() {
  cin >> n >> m;
  p = vector<int>(m);
  a = b = c = vector<int>(n);
  rep(i, m) cin >> p[i], p[i]--;
  rep(i, n - 1) cin >> a[i] >> b[i] >> c[i];

  rep(i, m - 1) {
    imos[min(p[i], p[i + 1])]++;
    imos[max(p[i], p[i + 1])]--;
  }
  rep(i, n - 1) imos[i + 1] += imos[i];

  lint res = 0;
  rep(i, n - 1) res += min(a[i] * imos[i], b[i] * imos[i] + c[i]);
  cout << res << endl;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
  int n; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  vector<int> furui(1000001, 0);
  for(int x : a){
    if(furui[x] != 0){
      furui[x] = 2;
      continue;
    }
    for(int i=x; i<=1000000; i=i+x){
	    furui[i]++;
    }
  }
  int ans = 0;
  for(int x : a){
    if(furui[x]==1) ans++;
  }
  //rep(i,90) cout << furui[i] << " ";
  cout << ans << endl;
}


Measured memory_bytes: 7932
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

def intersect1d(a, b, c, d):
    return a <= d and b >= c

def intersect(xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2):
    return intersect1d(xa1, xa2, xb1, xb2) and intersect1d(ya1, ya2, yb1, yb2)

def main():
    for line in sys.stdin:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.split())
        print("YES" if intersect(xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2) else "NO")

if __name__ == "__main__": main()

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

long long int n,m,c[20],a[20][20],x,ans,p,i,j,k,s,t;
bool tr,vis[20];

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m>>x;ans=1e16;
	for (i=1;i<n+1;i++)
	{
		cin>>c[i];
		for (j=1;j<m+1;j++) cin>>a[i][j];
	}
	p=1;
	for (i=1;i<n+1;i++) p=p*2;p--;
	for (t=0;t<p+1;t++)
	{
		k=t;tr=true;
		for (i=1;i<n+1;i++)
		{
			if (k%2==1) vis[i]=true;else vis[i]=false;
			k=k/2;
		}
		for (i=1;i<m+1;i++)
		{
			s=0;for (j=1;j<n+1;j++) if (vis[j]) s=s+a[j][i];
			if (s<x) tr=false;
		}
		if (tr)
		{
			s=0;
			for (i=1;i<n+1;i++) if (vis[i]) s=s+c[i];
			ans=min(ans,s);
		}
	}
	if (ans==1e16) cout<<-1;else cout<<ans;
}


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

int main() {
  int n;
  cin>>n;
  if(n<10)
    cout<<n<<endl;
  else if(n<100)
    cout<<"9"<<endl;
  else if(n<1000)
    cout<<n-90<<endl;
  else if(n<10000)
    cout<<"909"<<endl;
  else if(n<100000)
    cout<<n-9090<<endl;
  else
    cout<<"90909"<<endl;
}


Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
    s: String,
    }

    let mut s = String::from(s);
    let patterns = ["eraser", "erase", "dreamer", "dream"];
    let s = patterns.iter().fold(s, |s, x| s.replace(x, ""));
    println!("{}", if s.is_empty() { "YES" } else { "NO "});
}

Measured memory_bytes: 4352
<?php
fscanf(STDIN, '%s', $s);

$n = strlen($s);
$ans = 0;
$pcnt = 0;
$i = 0;
while ($i<$n) {
    $v = $s[$i];
    $nv = ($s[$i] == '>') ? '<' : '>';
    $pv = $nv;
    $ni = strpos($s, $nv, $i);
    if (empty($ni)) $ni = $n;

    $cnt = $ni - $i;

    if ($v == '>' && $pv == '<') {
        $ans += factorial(max($cnt, $pcnt)) + factorial(min($cnt-1, $pcnt-1));
    }
    if ($ni == $n && $v == '<') {
        $ans += factorial($cnt);
    }

    // echo $v.'*'.$cnt.PHP_EOL;

    $i = $ni;
    $pcnt = $cnt;
}
echo $ans.PHP_EOL;

function factorial ($n) {
    return ($n + 1) * $n / 2;
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
int n,v;
int main(){
	scanf("%d%d",&n,&v);
	for (int i=0;i<=n;i++)
		for (int j=0;j+i<=n;j++)
			if (i*10000+j*5000+(n-i-j)*1000==v)
				return printf("%d %d %d",i,j,n-i-j),0;
	puts("-1 -1 -1"); 
} 

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


int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ans;
  ans = 60 * (h2 - h1) + (m2 - m1) - k;
  cout << ans<< endl;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    map<char, int> A;
    map<char, int> B;
    set<char> a;
    set<char> b;
    for(int i = 0; i < S.length(); i++){
        if(A.count(S[i]))A[S[i]]++;
        else A[S[i]] = 1;
        a.insert(S[i]);
    }
    for(int i = 0; i < T.length(); i++){
        if(B.count(T[i]))B[T[i]]++;
        else B[T[i]] = 1;
        b.insert(T[i]);
    }
    
    vector<int> Acnt, Bcnt;
    for(auto s : a){
        Acnt.push_back(A[s]);
    }
    for(auto s : b){
        Bcnt.push_back(B[s]);
    }
    
    sort(Acnt.begin(), Acnt.end());
    sort(Bcnt.begin(), Bcnt.end());
    
    bool jdg = true;
    int Na = A.size(), Nb = B.size();
    if(Na == Nb){
        for(int i = 0; i < Na; i++){
            if(Acnt[i] != Bcnt[i])jdg = false;
        }
    }else{
        jdg = false;
    }
    
    cout << ((jdg) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 776
/***
* When I wrote this
* only God & I understood
* what I was doing
* Now, God only knows
/***/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
#define rep(i,a,n) for (int i=a;i<=n;i++)/*i为循环变量，a为初始值，n为界限值，递增*/
#define per(i,a,n) for (int i=a;i>=n;i--)/*i为循环变量， a为初始值，n为界限值，递减*/
const int mod = 1e9 + 7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//fixed<< setprecision(2)
void slove()
{

}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s;
    while (cin >> s)
    {
        if (s[0] == s[1] && s[1] == s[2] && s[0] == 'R')cout << "3\n";
        else if ((s[0] != s[1] && s[1] == s[2] && s[1] == 'R') || (s[0] == s[1] && s[1] != s[2] && s[1] == 'R'))cout << "2\n";
        else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')cout << "1\n";
        else cout << "0\n";

    }
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5e5+7;
int n,m,fa[N],cnt=0;
int a[N],b[N],c[N],d[N];
inline int read() {
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]); }
inline void unionn(int x,int y) {fa[find(x)]=find(y); }
map<int,int> p;
signed main() {
    n=read();
    for (int i=1;i<=n;i++) {
        a[i]=c[i]=read();
        a[n+1]^=a[i];
    }
    c[n+1]=a[n+1];

    for (int i=1;i<=n;i++) {
        b[i]=d[i]=read();
        b[n+1]^=b[i];
    }
    d[n+1]=b[n+1];

    sort(c+1,c+n+2); sort(d+1,d+n+2);
    bool flag=false;
    for (int i=1;i<=n+1;i++) {
        if (c[i]!=d[i]) {
            flag=true;
            break;
        }
    }

    if (flag) {printf("-1\n"); return 0;}
    int ans=0;
    for (int i=1;i<=n+1;i++) {
        if (a[i]!=b[i] || i==n+1) {
            if (i<=n) ans++;
            if (!p[a[i]]) p[a[i]]=++cnt;
            if (!p[b[i]]) p[b[i]]=++cnt;
        }
    }
    if (ans==0) {
        printf("0\n");
        return 0;
    }
    for (int i=1;i<=cnt;i++) fa[i]=i;
    for (int i=1;i<=n;i++) {
        if (a[i]!=b[i]) {
            unionn(p[a[i]],p[b[i]]);
        }
    }
    for (int i=1;i<=cnt;i++) {
        if (fa[i]==i) ans++;
    }
    printf("%d\n",ans-1);
    return 0;
}

Measured memory_bytes: 24576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i=0,g[]=new int[10000];
		double w[]=new double[10000],h[]=new double[10000],bmi[]=new double[10000];
		while(sc.hasNext()){
			String str[]=sc.next().split(",");
			g[i]=Integer.parseInt(str[0]);
			w[i]=Double.parseDouble(str[1]);
			h[i]=Double.parseDouble(str[2]);
			bmi[i]=w[i]/(h[i]*h[i]);
			i++;
		}
			for(int j=0;j<i;j++){
				if(bmi[j]>=25)
					System.out.println(g[j]);
			}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<sstream>
using namespace std;

// Aは自分のクッキーの枚数
// Bは相手のクッキーの枚数
void cookie(int& A, int& B) {
	int give = A / 2;
	if (A % 2 == 1) A--;
	A -= give;
	B += give;
}

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	
	if (K % 2 == 1) { // Kが奇数なら
		for (int i = 0; i < K / 2; i++) {
			cookie(A, B);
			cookie(B, A);
		}
		cookie(A, B); // 最後にもう一回
	}
	else {
		for (int i = 0; i < K / 2; i++) {
			cookie(A, B);
			cookie(B, A);
		}
	}

	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

ll f(ll n){
	if (n % 2LL == 0LL){
		return n / 2LL;
	}else{
		return 3LL * n + 1LL;
	} // end if
	return -1LL;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll s; cin >> s;
	set<ll> same; same.clear();
	ll m = 2LL;
	ll n = s;
	same.insert(s);
	for (;;){
		ll curr = f(n);
//		cerr << "m: " << m << " curr: " << curr << endl;
		if(!same.count(curr)){
			same.insert(curr);
			++m;
		}else{
			break;
		} // end if
		n = curr;
	} // end for

	cout << m << endl;

	return 0;
}

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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll a, b, c;

int main() {
    cin >> a >> b >> c;

    ll d = c - a - b;
    if (d < 1) {
        cout << "No" << endl;
        return 0;
    }

    if (4 * a * b < d * d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

const int MAX_N=1<<17;
const ll I_MAX=(ll(1)<<31)-1;
int n,dat[2*MAX_N-1],q,com, x, y;
void init(int n_){
    n=1;
    while(n<n_) n*=2;
    rep(i,0,2*n-1) dat[i]=I_MAX;
}
void update(int k, int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}
int query(int a, int b, int k, int l, int r){
    if(r<=a||b<=l) return I_MAX;
    if(a<=l&&r<=b) return dat[k];
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>> n>>q;
    init(n);
    rep(i,0,q){
        cin>>com>>x>>y;
        if (com){
            cout<<query(x,y+1,0,0,n)<<"\n";
        }
        else{
            update(x,y);
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,nrlit,pw[1001];
string sol;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    pw[0]=1;
    for(ll i=1;i<=13;i++)
        pw[i]=pw[i-1]*26;
    nrlit=1;
    while(true)
    {
        if(n>pw[nrlit])
        {
            n-=pw[nrlit];
            nrlit++;
        }
        else
        {
            for(ll i=1;i<=nrlit;i++)
            {
                char c;
                for(char j='a';j<='z';j++)
                    if(pw[nrlit-i]*(j-'a')+1<=n)
                        c=j;
                sol.push_back(c);
                n-=pw[nrlit-i]*(c-'a');
            }
            cout<<sol;
            return 0;
        }
    }
    return 0;
}


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

typedef __int128 ll;

const int n = 2e5+10;
const ll sz = 34;

ll N;
ll A[n][40];
ll dp1[n][40];
ll dp2[n][40];

/*
void printDp1(){
  for(int i=0; i<N; i++){
    for(int j=0; j<sz; j++){
      cout << A[i][j] << ":" << dp1[i][j] << "  ";
    }
    cout << endl;
  }
  cout << endl;
}

void printDp2(){
  for(int i=N-1; i>=0; i--){
    for(int j=0; j<sz; j++){
      cout << A[i][j] << ":" << dp2[i][j] << "  ";
    }
    cout << endl;
  }
  cout << endl;
}
*/

int main(){
  long long tmp;
  cin >> tmp;
  N = tmp;
  for(int i=0; i<N; i++){
    cin >> tmp;
    A[i][0] = tmp;
    for(int j=1; j<sz; j++){
      A[i][j] = A[i][j-1] * (-2);
    }
  }

  for(int i=0; i<sz; i++){
    dp1[0][i] = i;
  }
  for(int i=1; i<N; i++){
    for(int j=0; j<sz; j++){
      dp1[i][j] = 1e15;
      for(int k=0; k<sz; k++){
        if(A[i-1][k] <= A[i][j]){
          dp1[i][j] = min(dp1[i][j], dp1[i-1][k] + j);
        }
      }
    }
    /*
    ll cur = A[i-1][sz-1], curC = dp1[i-1][sz-1];
    while(cur > A[i][sz-1]){
      cur *= 4;
      curC += 2*i;
    }
    dp1[i][sz-1] = min(dp1[i][sz-1], curC + sz - 1);
    */
    for(int j=3; j<sz; j+=2){
      dp1[i][j] = min(dp1[i][j], dp1[i][j-2] + 2*(i+1));
    }
  }
  //printDp1();

  for(int i=0; i<sz; i++){
    dp2[N-1][i] = i;
  }
  for(int i=N-2; i>=0; i--){
    for(int j=0; j<sz; j++){
      dp2[i][j] = 1e11;
      for(int k=0; k<sz; k++){
        if(A[i+1][k] >= A[i][j]){
          dp2[i][j] = min(dp2[i][j], dp2[i+1][k] + j);
        }
      }
    }
    for(int j=2; j<sz; j+=2){
      dp2[i][j] = min(dp2[i][j], dp2[i][j-2] + 2*(N-i));
    }
    /*
    ll cur = A[i+1][sz-2], curC = dp2[i+1][sz-2];
    while(cur < A[i][sz-2]){
      cur *= 4;
      curC += 2*(N-i-1);
    }
    dp2[i][sz-2] = min(dp2[i][sz-2], curC + sz - 2);
    */
  }
  //printDp2();

  ll best = 1e11;
  for(int i=0; i<N; i++){
    for(int j=0; j<sz; j++){
      best = min(best, dp1[i][j] + dp2[i][j] - j);
    }
  }

  tmp = best;
  cout << tmp << endl;

  return 0;
}


Measured memory_bytes: 375296
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int product = a * b;
    if (product % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
    
  }
}

Measured memory_bytes: 21844
main(){
  int m,d,s[]={0,31,60,91,121,152,182,213,244,274,305,335};
  char a[7][10]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
  while(1)
    {
      scanf("%d %d",&m,&d);
      if(m==0)
	break;
      d+=s[m-1];
      printf("%s\n",&a[(d%7==0)?6:(d%7-1)][0]);
    }
  return 0;
}

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


int main() {
    string a,b,c;
    int ca = 0, cb = 0, cc = 0;
    char cur = 'a'; 
    cin >> a >> b >> c;
    bool flag = true;
    while (flag) {
        switch (cur) {
            case 'a':
                if (ca < a.size()) {
                    cur = a[ca];
                    ca++;
                } else {
                    cout << "A";
                    flag = false;
                }
                break;
            case 'b':
                if (cb < b.size()) {
                    cur = b[cb];
                    cb++;
                } else {
                    cout << "B";
                    flag = false;
                }
                break;
            case 'c':
                if (cc < c.size()) {
                    cur = c[cc];
                    cc++;
                } else {
                    cout << "C";
                    flag = false;
                }
                break;
        } 
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	stack<int>S1;//存放'\'的位置
	stack<pair<int,int> >S2;
	char ch;
	int sum = 0;
	for(int i=0;cin>>ch;i++){
		if(ch == '\\')
			S1.push(i);
		else if(ch== '/' && S1.size()>0){
			int j = S1.top();//找出栈顶的'\'的位置 
			S1.pop();
			sum +=i - j;//加入总面积内
			int a = i - j;
			//栈内面积块的起始位置大则应该被放入起始位置小的以便形成更大大的面积块
			while(S2.size()>0&&S2.top().first>j){ 
				 a += S2.top().second;
				S2.pop();
			} 
			
			S2.push(make_pair(j,a));
		}
	}
	vector<int>ans;
	while(S2.size()>0){
		ans.push_back(S2.top().second);
		S2.pop();
	} 
	//位置反转 
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	cout<<ans.size();
	for(int i=0;i<ans.size();i++){
		cout<<" ";
		cout<<ans[i];
	} 
	cout<<endl;
	return 0;	
}


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  long long int X;
  cin >> X;
  vector<long long int> x(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x.at(i);
  }
  x.push_back(X);
  sort(x.begin(), x.end());
  vector<long long int> distance(N);
  for (int i = 1; i < N + 1; i++)
  {
    distance.at(i - 1) = x.at(i) - x.at(i - 1);
  }
  long long int ans = distance.at(0);
  for (int i = 1; i < N; i++)
  {
    ans = __gcd(distance.at(i), ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>

void numbering(int id, int *g, int num, std::vector<int> *a){
    int tmp;
    for(int i=0;i<a[id].size();i++){
        tmp = a[id][i];
        if(g[tmp])continue;
        g[tmp] = num;
        numbering(tmp, g, num, a);
    }
}

void grouping(std::vector<int> *a, int *g, int n){
    int num = 1;
    for(int i=0;i<n;i++){
        if(g[i])continue;
        g[i] = num;
        numbering(i,g,num,a);
        num++;
    }
}

int main(){
    int i, n, m, q, s, t;
    int *g;
    scanf("%d %d",&n,&m);
    g = (int *)malloc(sizeof(int)*n);
    memset(g, 0, sizeof(int)*n);
    std::vector<int> a[n];
    for(i=0;i<m;i++){
        scanf("%d %d",&s,&t);
        a[s].push_back(t);
        a[t].push_back(s);
    }
    scanf("%d",&q);
    grouping(a,g,n);
    for(i=0;i<q;i++){
        scanf("%d %d",&s,&t);
        if(g[s]==g[t])printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 13124
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<set>
#define DB double
DB x[3], y[3];
DB M, G[3];
DB s;
DB pow(DB n) { return n * n; }
int main() {
	for (int i = 0; i < 3; i++) {
		std::cin >> x[i] >> y[i];
	}
	for (int i = 0; i < 3; i++) {
		G[i] = std::hypot(x[i] - x[(i + 1) % 3],y[i] - y[(i + 1) % 3]);
		M = std::max(M, G[i]);
		s += G[i];
	}
	s /= 2;
	DB r = std::sqrt(s*(s - G[0])*(s - G[1])*(s - G[2]));
	r /= s;
	DB x = M * r;
	x /= (2 * r + M);
	std::cout <<std::fixed<<std::setprecision(12)<< x << std::endl;
	return 0;
}

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

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


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

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

	qsort(v,n,sizeof(int),up);
	
	double ans = v[0];

	for(int i = 0;i < n;i ++){
		ans = (ans+v[i])/2;
	}

	printf("%lf",ans);

	return 0;
	}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

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

    map<char, int> mp;

    rep (i, n) {
        string s;
        cin >> s;
        map<char, int> m;
        rep (j, s.size()) {
            if (i == 0) mp[s[j]]++;
            else {
                
                m[s[j]]++;
                
            }
        }
        if (i == 0) continue;
        for (char c = 'a'; c <= 'z'; c++) {
            mp[c] = min(mp[c], m[c]);
        }
    }

    vector<char> ans;

    for (char c = 'a'; c <= 'z'; c++) {
        //cout << c << " " << mp[c] << endl;
        rep (i, mp[c]) {
            ans.push_back(c);
        }
    }

    sort(ans.begin(), ans.end());

    rep (i, ans.size()) cout << ans[i];
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r, total;
  cin >> N;
  total = 0;
  
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    total += r - l + 1;
  }
  
  cout << total << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
    int n, ans = 1e9, i;
    vector <pair<int, int> > v, w;
    map <int, int> mp1, mp2;
    map <int, int>::iterator it;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        int x;

        scanf("%d", &x);

        if (i % 2 == 0) {
            mp1[x]++;
        } else {
            mp2[x]++;
        }
    }

    mp1[1e9] = 0;
    mp2[1e9] = 0;

    for (it = mp1.begin(); it != mp1.end(); it++) v.push_back(make_pair(it->second, it->first));
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    for (it = mp2.begin(); it != mp2.end(); it++) w.push_back(make_pair(it->second, it->first));
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());

    for (i = 0; i < 2; i++) {
        int p = 0;

        if (v[i].second == w[0].second) p = 1;

        ans = min(ans, n - (v[i].first + w[p].first));
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 6136
A = input()
B = input()
C = input()
D = input()
E = input()

AA = int(A)
BB = int(B)
CC = int(C)
DD = int(D)
EE = int(E)

a = A[-1]
b = B[-1]
c = C[-1]
d = D[-1]
e = E[-1]

aa = int(a)
bb = int(b)
cc = int(c)
dd = int(d)
ee = int(e)

data = [aa ,bb, cc, dd, ee]
def func(x):
    if(x==0): return False
    else: return True
    
filtered = filter(func, data)

if aa==bb==cc==dd==ee==0:
    kk =int(10)
else:
    kk = min (filtered)

n = int(0)

if aa == 0 :
    n = n+AA
else:
    n = n+AA+10-aa
if bb == 0 :
    n = n+BB
else:
    n = n+BB+10-bb
if cc == 0 :
    n = n+CC
else:
    n = n+CC+10-cc
if dd == 0 :
    n = n+DD
else:
    n = n+DD+10-dd
if ee == 0 :
    n = n+EE
else:
    n = n+EE+10-ee
print(n+kk-10)

Measured memory_bytes: 3064
s = input()

a1 = ["R","U","D"]
a2 = ["L","U","D"]

for i in range(len(s)):
	if i % 2 == 0:
		if a1.count(s[i]) == 0:
			print("No")
			exit()
	else:
		if a2.count(s[i]) == 0:
			print("No")
			exit()
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 500010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	VE a(n + 1);
	rep(i, n) {
		if (s[i] == '<') {
			chmax(a[i + 1], a[i] + 1);
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') {
			chmax(a[i], a[i + 1] + 1);
		}
	}
	int ans = 0;
	rep(i, n + 1) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
void solve();

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

//	int t;
	//cin >> t;
//	for(int i=1; i<=t; ++i){
		solve();
	
}
void solve()
{
   int k;
   cin>>k;
   string ans;
   int i;
   for(i=1;i<=k;i++)
   {
       ans+="ACL";
   }
   cout<<ans<<'\n';
   return;
}
	
	

Measured memory_bytes: 3652
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    long k, a, b;
    scan(k, a, b);

    long ans;

    if (k <= a) {
        ans = 1;
    }
    else if (a <= b) {
        ans = -1;
    }
    else {
        ans = 2L * ((k - b - 1) / (a - b)) + 1;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll xi, yi, hi;
    vector<array<ll,3>> X;
    for(int i=0;i<N;i++){
        cin >> xi >> yi >> hi;
        X.push_back(array<ll,3>{xi,yi,hi});
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            bool isBad = false;
            ll hCand = -1;
            for(int k=0; k<N; k++){
                if(X[k][2]==0) continue;
                hCand = X[k][2] + abs(i-X[k][0]) + abs(j-X[k][1]);
                break;
            }
            for(int k=0; k<N; k++){
                auto h = max((ll)0, hCand - abs(i-X[k][0]) - abs(j-X[k][1]));
                if(h!=X[k][2]){ isBad = true; break;}
            }
            if(isBad) continue;
            cout<<i<<" "<<j<<" "<<hCand<<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(s) freopen(s".in", "r", stdin), freopen(s."out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 500010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

char s[N] ;
int f[N], g[N], nxt[N] ;
int n, ans ;

void work(int *f) {
	nxt[1] = 0 ;
	for (int i = 2, j = 0; i <= n; i++) {
		while (j && s[i] != s[j + 1]) j = nxt[j] ;
		if (s[i] == s[j + 1]) j++ ;
		nxt[i] = j ;
	}
	rep(i, 1, n)
	if (i % (i - nxt[i]) > 0 || nxt[i] == 0) f[i] = true ;
}

signed main(){
    scanf("%s", s + 1) ; n = strlen(s + 1) ;
	work(f) ;
	reverse(s + 1, s + n + 1) ;
	work(g) ;
	if (f[n]) {
		printf("1\n1\n") ;
		return 0 ;
	}
	rep(i, 1, n) if (f[i] && g[n - i]) ans++ ;
	if (ans == 0) printf("%d\n1\n", n) ;
	else printf("2\n%d\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/



Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
    int d[10] = {};
    for (int i = 0; i < k; i++) {
        int D;
        cin >> D;
        d[D] = 1;
    }
    for (int num = n;; num++) {
        int tmp = num, f = 1;
        while (tmp) {
            if (d[tmp % 10]) f = 0;
            tmp /= 10;
        }
        if (f) {
            cout << num << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long d = sc.nextInt();
		long[] x=new long[n];
		long[] y=new long[n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextLong();
			y[i]=sc.nextLong();
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if(d*d>=(x[i]*x[i]+y[i]*y[i])){
				ans++;
			}
		}
		System.out.println(""+ans);

	}

}

Measured memory_bytes: 64036
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

bool good[1005];
int t[1005][1005];
int num[1005];
int n,m;

queue<int> q1;

void check(int a){
	if(num[a]==n-1)return;
	int b=t[a][num[a]];
	if(num[b]==n-1)return;
	if(t[b][num[b]]==a)good[b]=true,good[a]=true,q1.push(a);
	else good[a]=false;
}

int main(){
	int i,j,k;
	int a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<n-1;j++){
			cin>>t[i][j];
			t[i][j]--;
		}
	}
	for(i=0;i<n;i++){
		if(good[i])continue;
		a=t[i][0];
		check(i);
	}
	int p=0;
	for(i=0;!q1.empty();i++){
		int q=q1.size();
		while(q--){
			a=q1.front(),q1.pop();
			b=t[a][num[a]];
			num[b]++,num[a]++,p++;
			check(b),check(a);
		}
	}
	if(p!=n*(n-1)/2)i=-1;
	cout<<i<<endl;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3050;
ll n;
ll power(ll base,ll b,ll mod){
	ll ans=1;
	while(b){
		if(b&1)ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
ll s[N][N],c[N][N];
void second_stl(ll mod){
	s[0][0]=c[0][0]=1;
	for(int i=1;i<=n+1;++i){
		c[i][0]=1;
		for(int j=1;j<=i;++j)
			s[i][j]=s[i-1][j-1]+s[i-1][j]*j%mod,s[i][j]%=mod,c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
			//是否建立一个新集合 
	}
}
void solve(ll mod){
	ll ans=0;
	for(int i=0;i<=n;++i){
		ll sum=0,p1=power(2,power(2,n-i,mod-1),mod),p2=power(2,n-i,mod),p=1;	
		for(int j=0;j<=i;++j){
			ll tmp=s[i+1][j+1]*p1%mod*p%mod;
			sum=(sum+tmp)%mod;
			p=p*p2%mod;
		}
		if(i&1)ans=(ans-c[n][i]*sum%mod+mod)%mod;
		else ans=(ans+c[n][i]*sum%mod)%mod;
	}
	printf("%lld\n",(ans%mod+mod)%mod);
}
int main(){
//	freopen("s.in","r",stdin);
	ll mod;
	scanf("%lld%lld",&n,&mod);
	second_stl(mod); 
	solve(mod);
	return 0;
}

Measured memory_bytes: 96468
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>

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

using namespace std;

int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,c=0;
    cin>>n;
    string s;
    cin>>s;
    mc map1;
    for(auto x:s)map1[x]++;
    for(auto x:map1){
        if(x.second%2==0){c+=x.second;}
    }
    if(c==n){cout<<"Yes" <<"\n";}
    else{cout<<"No" <<"\n";}
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <iostream>
# define pb push_back
using namespace std;
int main()
{
  int t,a,b,ans=0;
  cin>>t;
  vector<int> v;
  vector<int> c;
  for(int i=0;i<t;i++)
  {
  cin>>a;
  v.pb(a);
  }
  for(int i=0;i<t;i++)
  {
  cin>>a;
  c.pb(a);
  }
  for(int i=0;i<t;i++)
  {
      a=v[i];
      b=c[i];
      if(a>b)
        ans+=(a-b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
s=sys.stdin.readlines()
q=int(s[0].split()[1])
f=lambda x,y:(x,int(y))
d=deque(f(*e.split())for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t)


Measured memory_bytes: 16296
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = 10**9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
    for i in range(n):
        diff_min = (a[i] % diff_min if a[i] % (diff_min) != 0 else diff_min)
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, sum;
int a[N];
int d[N];
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    sort(a, a + m);
    for (int i = 0; i < m - 1; ++i) {
        d[i] = a[i + 1] - a[i];
    }
    sort(d, d + m - 1, greater<int>());
    for (int i = n - 1; i < m - 1; ++i) {
        sum += d[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4424
YYMM=0
MMYY=0

S=input()
a=S[:2]
b=S[2:]

if int(a)<=12 and 0< int(a):
    MMYY =1
if int(b)<=12 and 0< int(b):
    YYMM =1

if MMYY==1 and YYMM==1:
    print("AMBIGUOUS")
elif MMYY==1 and YYMM==0:
    print("MMYY")
elif MMYY==0 and YYMM==1:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[1]-h[0])]
for i in range(2, n):
  dp.append(min(dp[-2]+abs(h[i]-h[i-2]), dp[-1]+abs(h[i]-h[i-1])))
print(dp[-1])

Measured memory_bytes: 20444
#include <cstdio>

int main(){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / b;
	printf("%d %d %.5lf", d, r, f);
	return 0;
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
    int[] numPatternCount = new int[19];
    int i, j, k, l;
    int size = 9;
    int sum;
    int c = 0;
    for (i = 0; i <= size; i++)
      for (j = 0; j <= size; j++)
        for (k = 0; k <= size; k++)
          for (l = 0; l <= size; l++) {
            sum = i + j + k + l;
            if (sum > 18)
              break;
            numPatternCount[i + j + k + l]++;
          }
    while ((readStr = reader.readLine()) != null) {
      int n = Integer.parseInt(readStr);
      System.out.println(
              n > 36 ? 0 :
                      numPatternCount[n > 18 ? numPatternCount.length - (n - numPatternCount.length) - 2 : n]
      );
    }
  }

}

Measured memory_bytes: 16876
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef short int si;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define st first
#define nd second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18

ll n;
int main() {
		ios::sync_with_stdio(false);
		cin>>n;
		ll s=0,nn=n;
		while(nn>0){
				s+=nn%10;
				nn/=10;
		}
		if(n%s==0)cout<<"Yes\n";
		else cout<<"No\n";



		return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  reverse(h.begin(), h.end());
  int ans = 0;
  int val = 0;
  for (int i = 1; i < n; i++) {
    if (h[i-1] <= h[i]) val++;
    else val = 0;
    ans = max(ans, val);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s_a = [0]*(n+1)
s_b = [0]*(m+1)
for i in range(1,n+1):
    s_a[i] = s_a[i-1] + a[i-1]
for i in range(1,m+1):
    s_b[i] = s_b[i-1] + b[i-1]
import bisect
Sa = bisect.bisect_right(s_a,k) -1
Sb = bisect.bisect_right(s_b,k) -1
ans = max(Sa,Sb)
for i in range(1,Sa+1):
    x = max(0, k - s_a[Sa-i+1])
    y = bisect.bisect_right(s_b,x)
    ans = max(ans,y+Sa-i)
print(ans)

Measured memory_bytes: 47528
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(x-r<0 || x+r>W || y-r<0 || y+r>H){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 26404
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main(){
	string s, t, bruh;
	int n, m;
	cin >> s >> t >> n >> m >> bruh;
	if (bruh == s){
		printf("%d %d\n", n - 1, m);
	}else{
		printf("%d %d\n", n, m - 1);
	}
}

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

const int N = 100010;
const int moder = 1e9 + 7;

int n, a[N];

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	int ans = 1, cnt = 0;
	for (int i = 0, j = 0; i < n; ++ i){
		while (j < n && 2 * j  - 2 * i + 1 <= a[j]){
			++ j;
			++ cnt;
		}
		if (j == n){
			break;
		}
		ans = 1ll * ans * (cnt + 1) % moder;
		-- cnt;
	}
	for (int i = 1; i <= cnt; ++ i){
		ans = 1ll * ans * i % moder;
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 640
#include<iostream>

#include<bits/stdc++.h>


using namespace std;

int main(){
  int H,A;
  
  cin>>H>>A;
  int cnt=0;
  while(1){
     if(H>0) {
         H=H-A;
         cnt++;
     }
     else break;
  }
   cout<<cnt;
}


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

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

  int res = sum;
  int sum2 = 0;
  for (int i = 0; i < N; i++) {
    sum2 += W[i];
    res = min(res, abs(sum2-(sum- sum2)));
  }
   cout << res << '\n';
 }


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 600010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,rt1,rt2;

int fa[maxn];

vector<int> G[maxn];

int f[maxn],Ans[maxn],S[maxn],top;

map<PII,int> mp;

int cur[maxn];

void Euler(int u){
	for(int &i=cur[u];i<G[u].size();i++){
		int v=G[u][i];
		if(!mp[MP(u,v)]){
			mp[MP(v,u)]=mp[MP(u,v)]=1;
			Euler(v);
		}
	}
	S[++top]=u;
}

void dfs(int u){
	f[u]=1;
	for(auto v:G[u])if(v!=fa[u])dfs(v),f[u]^=1;
}

void Work(){
	dfs(rt1);
	dfs(rt2);
	REP(i,1,n)if(f[i]!=f[i+n]){
		puts("IMPOSSIBLE");
		return;
	}
	puts("POSSIBLE");
	REP(i,1,n)if(f[i])G[i].PB(i+n),G[i+n].PB(i),Ans[i]=-1;
	G[0].PB(rt1);G[rt1].PB(0);
	G[0].PB(rt2);G[rt2].PB(0);
	Euler(0);
	REP(i,1,top-1)if(S[i+1]==S[i]+n)Ans[S[i]]=1;
	REP(i,1,n)printf("%d ",Ans[i]);puts("");
}

void Init(){
	read(n);
	REP(i,1,n){
		read(fa[i]);
		if(fa[i]==-1)rt1=i;
		else G[i].PB(fa[i]),G[fa[i]].PB(i);
	}
	REP(i,n+1,n*2){
		read(fa[i]);
		if(fa[i]==-1)rt2=i;
		else fa[i]+=n,G[i].PB(fa[i]),G[fa[i]].PB(i);
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 110456
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String,Integer> hash = new HashMap<>();
        int n =sc.nextInt();
        for (int i=0;i<n;i++){
            String s = sc.next();
            if (hash.containsKey(s)){
                hash.put(s,hash.get(s)+1);
            }else {
                hash.put(s,1);
            }
        }
        int max = Collections.max(hash.values());
        ArrayList<String> st  = new ArrayList<>();
        for (Map.Entry entry : hash.entrySet()){
            if ((int)entry.getValue()==max)st.add((String) entry.getKey());
        }
        Collections.sort(st);
        for (int i=0;i<st.size();i++)System.out.println(st.get(i));
    }
    static int factorial(int num){
        if (num==1||num==0)return 1;
        else return num*factorial(num-1);
    }
    static int arraySum(int[] array){
        int ans = 0;
        for (int value : array) ans += value;
        return ans;
    }
    static int combination(int a, int b){
        return factorial(a)/(factorial(b)*factorial(a-b));
    }
    static double log(double base,double antilogarithm){
        return Math.log(antilogarithm)/Math.log(base);
    }


}


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

int main(){
  int x,y;
  
  for(int i = 0; i < 3000; i++){
    cin >> x >> y;
    if(x == 0 && y == 0){
      break;
    }
    cout << min(x,y) << " " << max(x,y) << endl;
  }
  
  
  
  
  
     
  return 0;
}



Measured memory_bytes: 3048