akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int A,B,temp=1,ans=0;
    cin>>A>>B;

    while(temp<B){
        ans++;
        temp+=A-1;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 10
int main(){
    int s,w;
    scanf("%d %d",&s,&w);
    if(s>w){
        printf("safe");
    }else{
        printf("unsafe");
    }
    return 0;
}

Measured memory_bytes: 1732
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }
        
        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let n: i32 = read_as_vec()[0];

    let mut ans = 1;
    for _ in 0..3{
        ans *= n;
    }


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


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;



int main() {

  int n;cin >> n;
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;


  ll ans=0;
  FOR(i,0,n){

      if(s1[i]==s2[i] && s1[i]==s3[i]){
          continue;
      }
      else if(s1[i]==s2[i] || s1[i]==s3[i] || s2[i] == s3[i]){
          ans++;
      }
      else{
          ans += 2;
      }
  }

  cout << ans;

}

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

int main()
{
    string s;
    cin >> s;
    int price = 700;
    if(s.at(0) == 'o') price += 100;
     if(s.at(1) == 'o') price += 100;
      if(s.at(2) == 'o') price += 100;
      cout << price << endl;
      return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))
max_a = 10**9
min_a = 0

while max_a-min_a>1:
    count = K
    mean_a = (max_a+min_a)//2
    
    for i in range(N):
        if a[i]<=mean_a: continue
        count -= a[i]//mean_a
    if count >= 0:
        max_a = mean_a
    else:
        min_a = mean_a

print(max_a)

Measured memory_bytes: 30896
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define 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 (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
int a[3];


class UnionFind {
public:
    vector<int> rank, parent;

    UnionFind() {}

    UnionFind(int size) {
        rank.resize(size, 0);
        parent.resize(size, 0);
        for (int i = 0; i < size; ++i) {
            makeSet(i);
        }
    }

    void makeSet(int x) {
        parent[x] = x;
        rank[x] = 0;
    }

    void link(int x, int y) {
        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    int findSet(int x) {
        if (parent[x] != x) {
            parent[x] = findSet(parent[x]);
        }
        return parent[x];
    }
};

int p[100000];
int x[100000];
int y[100000];

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind *uf = new UnionFind(n);
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, m) {
        cin >> x[i] >> y[i];
        uf->unite(x[i] - 1, y[i] - 1);
    }
    int ans = 0;
    rep(i, n) {
        if (uf->same(p[i] - 1, i)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int A,B;
	cin >> A >> B;
	cat mod =1000000007;

	vector< vector<cat> > C(B+1,vector<cat>(B+1,0));
	for(int i =0; i <= B; i++) {
		C[i][0] =1;
		for(int j =1; j <= i; j++) {
			C[i][j] =C[i-1][j]+C[i-1][j-1];
			if(C[i][j] >= mod) C[i][j] -=mod;
		}
	}
	vector< vector<cat> > Cs(B+1,vector<cat>(B+2,0));
	for(int i =0; i <= B; i++)
		for(int j =0; j <= B; j++) Cs[i][j+1] =(Cs[i][j]+C[i][j])%mod;

	cat ans =A+1;
	for(int y =1; y < B; y++) for(int k =0; k <= A; k++) {
		int mxz =B-y, miz =max(1,k+2*(B-y)-A);
		if(miz > mxz) continue;
		cat s =(Cs[B-y-1][mxz]-Cs[B-y-1][miz-1])%mod;
		cat akt =((C[B-1][y-1]*(k+1))%mod*s)%mod;
		ans =(ans+akt)%mod;
	}
	ans %=mod;
	if(ans < 0) ans +=mod;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll A,B,C;



int main(){
  cin>>A>>B>>C;

  if(A+B>=C) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

#define MAX 200003
#define MOD 1000000007

vector<int> parent;

int find(int x){
  int y=parent.at(x);
  if(y!=x){
    y=find(y);
  }
  return parent.at(x)=y;
}

void unite(int a,int b){
  int x=find(a);
  int y=find(b);
  if(x!=y){
    parent.at(x)=y;
  }
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> X(M),Y(M),Z(M);
  for(int i=0;i<M;i++){
    cin>>X.at(i)>>Y.at(i)>>Z.at(i);
    X.at(i)--;
    Y.at(i)--;
  }

  parent.resize(N);
  for(int i=0;i<N;i++){
    parent.at(i)=i;
  }

  int ans=0;
  for(int i=0;i<M;i++){
    unite(X.at(i),Y.at(i));
  }

  vector<int> count(N,0);
  for(int i=0;i<N;i++){
    count.at(find(i))=1;
  }
  for(int i=0;i<N;i++){
    ans+=count.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3200
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n ,p;
    string s;
    cin >> n >> p >> s;
    if(10%p == 0){
        long long ans = 0;
        for(int r = 0; r < n; r++){
            if((s[r]-'0') % p == 0){
                ans += r + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> d(n+1);
    int ten = 1;
    for(int i = n-1; i >= 0; i--){
        int a = (s[i] - '0') * ten % p;
        d[i] = (d[i+1]+a) % p;
        ten *= 10;
        ten %= p;
    }
    vector<int> cnt(p);
    long long ans = 0;
    for(int i = n; i >= 0; i--){
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1404
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(void){
  int N, K;
  cin >> N >> K;
  if(K == 1){
    cout << 0 << endl;
  }else{
    cout << N - K << endl;
  }
}


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

const int MAX=200;
vector<int> T[MAX],state(MAX),d(MAX,-1);
int N;
queue<int> Q;

void BFS(){
    Q.push(0);
    d[0]=0;
    state[0]=1;
    while(Q.size()){
        int a=Q.front();
        for(int i=0;i<T[a].size();i++){
            if(state[T[a][i]]==0){
            Q.push(T[a][i]);
            state[T[a][i]]=1;
            d[T[a][i]]=d[a]+1;
        }
        }
        Q.pop();
    }
    for(int i=0;i<N;i++){
        cout<<i+1<<" "<<d[i]<<endl;
    }
}

int main(){

    cin>>N;
    
    for(int i=0;i<N;i++){
        state[i]=0;
    }
    for(int i=0;i<N;i++){
        int x,y;cin>>x>>y;
        x--;
    for(int j=0;j<y;j++){
        int a;cin>>a;
        a--;;
        T[x].push_back(a);
    }
    }
    BFS();
}



Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		
		if(x == 0) {
			System.out.println(1);
		} else if(x == 1) {
			System.out.println(0);
		}
		
	}
}




Measured memory_bytes: 35616
#include <algorithm>
#include <bits/stdc++.h>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define INF 1LL << 40;
#define ll long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
template <class T> inline void chmax(T &a, T b) { a < b ? a = b : a; };
template <class T> inline void chmin(T &a, T b) { a > b ? a = b : a; };
#define MOD 1000000007;
ll dp1[100010];
ll dp2[100010];
int main() {
    memset(dp1, 0, 100010);
    memset(dp2, 0, 100010);
    dp2[0] = 1;
    string l;
    cin >> l;
    int n = l.size();
    rep(i, n) {
        if(l[i] == '0') {
            dp2[i + 1] += dp2[i];
        } else {
            dp1[i + 1] += dp2[i];
            dp2[i + 1] += dp2[i] * 2;
        }
        dp1[i + 1] += dp1[i] * 3;
        dp1[i + 1] %= MOD;
        dp2[i + 1] %= MOD;
    };
    ll ans = (dp1[n] + dp2[n]) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 2048
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = int.Parse(ReadLine());
            //var s = Console.ReadLine().Split(' ')
            //var s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var ans = 1000 - (s % 1000);
            if (ans == 1000)
            {
                ans = 0;
            }

            WriteLine(ans);
            Out.Flush();
        }



    }

    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }


}

Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAXN = 1E5+2;
const int MOD = 1E9+7;
const int C[3]={3, 6, 6};

vector<int> g[MAXN];
int ans=1LL;
int n;

void impossible(){
	cout << "0";
	exit(0);
}

signed main(){
	cin >> n;
	for(int i=1; i<= n; ++i){
		int x; cin >> x;
		g[x].push_back(i);
	}
	if(g[0].size() > 3 || g[0].size() < 1) impossible();
	for(int i=1; i< n; ++i){
		if(g[i].size() > g[i-1].size()) impossible();
		for(int j=0; j< g[i].size(); ++j){
			int u = upper_bound(g[i-1].begin(), g[i-1].end(), g[i][j]) - g[i-1].begin();
			if(u <=  j) impossible();
			else ans = (ans*(u-j))%MOD;
		}
	}
	ans = (ans*C[g[0].size()-1])%MOD;
	cout << ans;
}

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

int n, m, x, cost, ans = 2e9;
vector<vector<int>> detail;
vector<int> algo;

int checkAlgo(int x, vector<int> algo){
	for(int i=1; i<algo.size(); i++){
		if(algo[i] < x){
			return -1;
		}
	}
	return algo[0];
}

int calculate(int k, vector<vector<int>> detail, int n, int m, int x){
	bitset<12> temp(k);
	vector<int> ans(m+1, 0);
	for(int i=0; i<n; i++){
		if(temp[i]){
			for(int j=0; j<m+1; j++){
				ans[j] += detail[i][j];
			}
		}
	}
	return checkAlgo(x, ans);
}

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

	for(int i=0; i<n; i++){
		cin >> cost;
		algo.push_back(cost);
		for(int j=0, a; j<m; j++){
			cin >> a;
			algo.push_back(a);
		}
		detail.push_back(algo);
		algo.clear();
	}

	for(int i=0, temp; i< 1<<n; i++){
		temp = calculate(i, detail, n, m, x);
		if(temp != -1){
			ans = min(ans, temp);
		}
	}

	ans = ans==2e9? -1: ans;
	cout << ans << endl;
}

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

using namespace std;
int main()
{
  int n;
cin >> n;
  
  vector<int> v;
  for(int i=0; i<n; i++)
  {
    int x;
    cin >> x;
    v.push_back(x);
  }
  
  int cnt=0;
  for(int i=0; i<n-2; i++)
  {
    if( v[i] < v[i+1] && v[i+1] < v[i+2]) cnt++;
    else if(  v[i+2] < v[i+1] && v[i+1] < v[i]) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

const int mod = 1e9+7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> ng(n,false);
  rep(i,m) {
    int a;
    cin >> a;
    ng[a] = true;
  }
  vector<int> dp(n+1);
  dp[0] = 1;
  for(int i = 1; i <= n; i++) {
    if(ng[i]) continue;
    dp[i] += dp[i-1];
    if(i > 1) dp[i] += dp[i-2];
    dp[i] %= mod;
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];
void dfs(int start,int to,int index){
	if(to-start+1<=1) return;
	for(int i=start;i<to;i++)
		for(int j=i+1;j<=to;j++) {res[i][j]=index;
		}
	int mid=(start+to)>>1;
	dfs(start,mid,index+1),dfs(mid+1,to,index+1);
}
int main(){
	cin>>n;
	dfs(1,n,1);
 
	for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
	cout<<res[i][j]<<" ";
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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 (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S; cin >> S;

    if(S.size() == 3){
        reverse(S.begin(), S.end());
    }
    cout << S << endl;
}


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

int main(){
    //入力
    string s;

    cin >> s;
    
    int i_s,i_e;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A'){
            i_s=i;
            break;
        }
    }
    for(int i=s.size()-1;i>-1;i--){
        if(s.at(i)=='Z'){
            i_e=i;
            break;
        }
    }

    cout << i_e-i_s+1 <<endl;
    
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
int r, g, b, n, ans;
int main(){
	scanf("%d%d%d%d", &r, &g, &b, &n);
	for(Rint i = 0;i <= n / r;i ++)	
		for(Rint j = 0;j <= (n - i * r) / g;j ++)
			if((n - r * i - g * j) % b == 0) ++ ans;
	printf("%d", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;cin>>a>>b>>c;
  ll as=(c-a-b);
  if(as>0 && 4*a*b<as*as){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

int q , w , e , z ;


int main()
{
	speed;

    int n , m , x ;
    cin >> n >> m >> x ;
    int a[m];
    for(int i = 0 ; i < m ; i ++ ){
        cin >> a[i] ;
    }
    for(int i = x ; i <= n ; i ++ ){
        for(int j = 0 ; j < m ; j ++ ){
            if( i == a[j] ){
                z++;
            }
        }
    }
    for(int i = x ; i > -1 ; i -- ){
        for(int j = 0 ; j < m ; j ++ ){
            if(i == a[j]){
                q++;
            }
        }
    }
    cout<<min(q,z);

	time;
}


Measured memory_bytes: 256
N = int(input())

word = [input() for i in range(N)]
#word = []
#for i in range(N):
#    word.append(input())

for i in range(1, N):
    if word[i][0] != word[i - 1][-1] or word.count(word[i]) != 1:
        print('No')
        exit()

print('Yes')



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N, M, tmp, result = 0;
  cin >> N;
  vector<string> s(N), u;
  bool can;
  REP(i, N) {
    can = true;
    cin >> s[i];
    REP(j, u.size()) {
      if (s[i] == u[j]) {
        can = false;
        break;
      }
    }
    if (can) {
      u.push_back(s[i]);
    }
  }
  cin >> M;
  vector<string> t(M);
  REP(i, M) {
    cin >> t[i];
  }
  REP(i, u.size()) {
    tmp = 0;
    REP(j, N) {
      if (u[i] == s[j]) {
        tmp++;
      }
    }
    REP(j, M) {
      if (u[i] == t[j]) {
        tmp--;
      }
    }
    if (tmp > result) {
      result = tmp;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
for i in range(n):
    r,t = map(int,input().split())
    a.append([t,r])
a.sort(reverse = True)
d = {}
cd = []
dp = 0
x = 0

for i in range(m):
    z,c = a[i]
    dp += z
    if c in d:
        cd.append(z)
    else:
        d[c] = z
        x += 1
cd.sort(reverse = True)
ans = dp + x**2
c = ans

for i in range(m,n):
    if len(cd) == 0:
        break
    z,v = a[i]
    if v in d:
        continue
    d[v] = z
    x += 1
    c = c - cd.pop()+z+2*x-1
    if c > ans:
        ans = c
print(ans)

Measured memory_bytes: 65112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -=b;
		if (c <= 0) {
			cout << "Yes";
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No";
			break;
		}
	}
	return 0;
}










Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int count = 0;
int main() {
  int i,n;
  int *S;
  scanf("%d",&n);
  if(n>500000) exit(8);
  S = (int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
      if(S[i]<0 || S[i]>1000000000) exit(8);
    }
  mergeSort(S,0,n);
  for(i=0;i<n-1;i++)
    {
      printf("%d ",S[i]);
    }
  printf("%d\n%d\n",S[i],count);
  return 0;
}
void merge(int *A,int left,int mid,int right){
  int n1=mid - left;
  int n2=right - mid;
  int i,j,k;
  int L[n1+1];
  int R[n2+1];

  for(i=0;i<n1;i++)
    {
      L[i] = A[left+i];
    }
  for(i=0;i<n2;i++)
    {
      R[i] = A[mid+i];
    }
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  i=0;
  j=0;
  for(k = left;k<right;k++)
    {
      count++;
      if(L[i]<=R[j])
	{
	  A[k] = L[i];
	  i++;
	}
      else
	{
	  A[k] = R[j];
	  j++;
	}
    }
}

void mergeSort(int *A,int left,int right){
  int mid,i;
 
  if(left+1<right)
    {
      mid = (left + right)/2;
      mergeSort(A,left,mid);      
      mergeSort(A,mid,right);
      merge(A,left,mid,right);
    }
}
      



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
#define INF 1000000
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<int, int> P;

struct edge{ int u, v; lli cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
	vector< vector<lli> > distance_matrix;
};


template <typename T>
vector<int> argsort(const vector<T> &v) {

  // initialize original index locations
  vector<int> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](int i1, int i2) {return v[i1] < v[i2];});

  return idx;
}

template<typename T>
void displayVector(vector<T> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}

int count_comb(int a, int b, int c){
  if(a!=b && b!=c){ return 6; }
  else if( a==b && b==c){ return 1; }
  else{ return 3; }
}

string sub(string str, int start, int end){
  // require : start < end
  return str.substr(start, end-start+1);
}

struct C{ int a; int b; };

int main(){
  lli x; cin >> x; x -= 400;
  cout << 8 - x/200  << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int n, x[10000][10000], dp[10000][10000], maxn = -1000000000;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= i; k++) {
				for (int l = 1; l <= j; l++) {
					dp[i][j] += x[k][l];
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = i; k <= n; k++) {
				for (int l = j; l <= n; l++) {
					maxn = max(maxn, dp[i - 1][j - 1] + dp[k][l] - dp[i - 1][l] - dp[k][j - 1]);
				}
			}
		}
	}
	cout << maxn << endl;
}

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

int main(){
    int n,a,p;
    while(cin>>n,n){
        vector<int>v;
        for(int i=0;i<n;i++){
            cin>>a;
            v.push_back(a);
        }
        if(n==1){
            cout<<v[0]<<endl;
            continue;
        }
        p=v[0];
        bool o=true;
        int i;
        for(i=1;i<n-1;i++){
            if(v[i]-p>1){
                cout<<p<<" ";
                o=true;
            }else{
                if(o){
                    cout<<p<<"-";
                    o=false;
                }
            }
            p=v[i];
        }
        if(v[i]-p>1){
            cout<<p<<" ";
            o=true;
        }else{
            if(o){
                cout<<p<<"-";
                o=false;
            }
        }
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 1220
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = array[0];
            var K = array[1];
            var Q = array[2];

            var pointArray = Enumerable.Repeat(K - Q, N).ToArray();
            for (int j = 0; j < Q; j++)
            {
                var i = int.Parse(Console.ReadLine());
                pointArray[i-1] += 1;
            }

            var maxPoint = pointArray.Max();
            for (int i = 0; i < N; i++)
            {
                if (pointArray[i] > 0)
                    Console.WriteLine("Yes");
                else
                    Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 18908
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,m,ans,cnt[maxn],tmp;
bool vis[maxn];
int x;
char s[10];
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	for (int i=1;i<=m;i++) {
		read(x); scanf("%s",s+1);
		if (s[1]=='A') {
			if (vis[x]) continue;
			vis[x]=1; ans+=cnt[x];
			tmp++;
		} else {
			if (vis[x]) continue;
			cnt[x]++;
		}
	}
	printf("%d %d\n",tmp,ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

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

int A, B, C, X;

int main() {
    cin >> A;
  	cin >> B;
    cin >> C;
    cin >> X;
    int count = 0;
    for (int i = 0; i <= A; i++) {
      for (int j = 0; j <= B; j++) {
        for (int k = 0; k <= C; k++) {
          int sum = (500*i) + (100*j) + (50*k);
          if (X == sum) count++;
        }
      }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = sum([abs(i) for i in x])
for i in range(N - K + 1):
    t = min(abs(x[i])+abs(x[i+K-1]-x[i]), abs(x[i+K-1])+abs(x[i+K-1]-x[i]))
    if t < ans:
        ans = t
print(ans)

Measured memory_bytes: 14224
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

def calc(A, B, N):
    M = N
    if len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 1:
        i = [i for i, (a, b) in enumerate(zip(A, B)) if a < b][0]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            if D < 0:
                continue

            D += k * B[i]
            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 2:
        i, j = [i for i, (a, b) in enumerate(zip(A, B)) if a < b]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            l, D = divmod(D, A[j])

            D += k * B[i]
            D += l * B[j]

            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 3:
        for g in range(N // A[0] + 1):
            for s in range(N // A[1] + 1):
                D = N - g * A[0] - s * A[1]

                if D < 0:
                    break

                q, r = divmod(D, A[2])

                D += g * B[0]
                D += s * B[1]

                r += g * B[0]
                r += s * B[1]
                r += q * B[2]

                M = max(M, D, r)
    return M

print(calc(B, A, calc(A, B, N)))


Measured memory_bytes: 40176
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn;
+(void)printf:(NSString*)format, ...;
@end

@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
    NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
    NSMutableString *result = [NSMutableString string];
    NSData *data = [handle availableData];
    while ([data length] > 0) {
        [result appendString:[[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]];
        data = [handle availableData];
    }
    return result;
}
+(void)printf:(NSString*)format, ...
{
    va_list arguments;
    va_start(arguments, format);
    NSString *string = [[[NSString alloc] initWithFormat: format arguments: arguments] autorelease];
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[string dataUsingEncoding: NSUTF8StringEncoding]];
    va_end(arguments);
}
@end

int main() {
    @autoreleasepool {
        NSString *input = [StdIO stringFromStdIn];
        NSArray *numbers = [input componentsSeparatedByString:@" "];
        NSInteger a = [[numbers objectAtIndex: 0] integerValue];
        NSInteger b = [[numbers objectAtIndex: 1] integerValue];
        [StdIO printf: (a*b % 2 == 0) ? @"Even": @"Odd"];
    }
    return 0;
}


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

long long N, C, K;
long long T[100005];

int main(){
	cin >> N >> C >> K;
	for(long long i = 0; i < N; i++){
		cin >> T[i];
	}
	sort(T, T + N);

	long long cur = 0;
	long long ans = 0;
	while(cur < N){
		long long time = T[cur];
		long long limit = time + K;
		long long num = 0;
		long long next;
		for(long long i = cur; i < N && num < C && T[i] <= limit; i++){
			num++;
			next = i;
		}
		ans++;
		cur = next + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

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

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

int main()
{
    int a,b;
  cin >> a >> b;
    if (a > 0 && a < 10 && b > 0 && b < 10) {
        cout << a * b << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,a=0,c=0,d,i,j,b[30]={};
  char s;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf(" %c",&s);
      b[s-'a']++;
    }
  }
  for(i=0;i<26;i++){
    if(b[i]%4==0)continue;
    if(b[i]%4==2)a+=2;
    if(b[i]%2){
      if(b[i]%4==3)a+=2;
      c++;
    }
  }
  //printf("%d %d\n",(n%2)*(m%2),c);
  //printf("%d %d\n",n/2*2*(m%2)+m/2*2*(n%2),a);
  d=n/2*2*(m%2)+m/2*2*(n%2);//printf("%d %d\n",d,a);
  if(c-((n%2)*(m%2)))printf("No\n");
  else if(d<a)printf("No\n");
  else{
    if(d%4==a%4)printf("Yes\n");
    else printf("No\n");
  }
  //else printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
<?php

    $S = str_split(trim(fgets(STDIN)));
    
    for($i=0;$i<count($S);$i++){
        if(($i+1)%2!=0){
            if($S[$i]=="R" || $S[$i]=="U" ||$S[$i]=="D"){
                
            }else{
                echo "No";
                exit;
            }
        }else{
            if($S[$i]=="L" || $S[$i]=="U" ||$S[$i]=="D"){
                
            }else{
                echo "No";
                exit;
            }
        }
    }
    echo "Yes";
?>

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

char c;
int n,m;

char dt[10002];
char *ch=dt+1;

void sit_left(char c)
{
	for(int i=0; i<n; i++)
	if(ch[i]=='#')
	{
		ch[i]=c;
		return;
	}
}

void typeA()
{
	sit_left('A');
}

void typeB()
{
	for(int i=n-1; i>=0; i--)
	if(ch[i]=='#')
	{
		if(ch[i+1]!='A'&&ch[i-1]!='A')
		{
			ch[i]='B';
			return;
		}
	}

	sit_left('B');
}

void typeC()
{
	for(int i=0; i<n; i++)
	if(ch[i]!='#')
	{
		if(ch[i+1]=='#')
		{
			ch[i+1]='C';
			return;
		}
		if(ch[i-1]=='#')
		{
			ch[i-1]='C';
			return;
		}
	}
}

void typeD()
{
	int dl=99999,dr=99999;
	int dist[10000];
	for(int i=0; i<n; i++)
	{
		dist[i] = 99999;
	}
	for(int i=0; i<n; i++)
	{
		dl++; dr++;

		if(ch[  i  ]!='#') { dl=0; }
		if(ch[n-i-1]!='#') { dr=0; }

		dist[  i  ] = min(dist[  i  ],dl);
		dist[n-i-1] = min(dist[n-i-1],dr);
	}
	dl=0;dr=0;
	for(int i=0; i<n; i++)
	{
		if(dist[i]>dr) { dl=i; dr=dist[i]; }	
	}
	ch[dl] = 'D';
}

int main()
{
	while(cin >> n >> m, (n||m))
	{
		for(int i=0; i<n; i++)
		{
			ch[i] = '#';
		}
		ch[-1] = ch[n] = 'X';

		//first
		cin >> c;
		switch(c)
		{
			case 'A': ch[  0]=c; break;
			case 'B': ch[n-1]=c; break;
			case 'C': ch[n/2]=c; break;
			case 'D': ch[  0]=c; break;
		}
		
		while(--m)
		{
			cin >> c;
			switch(c)
			{
				case 'A': typeA(); break;
				case 'B': typeB(); break;
				case 'C': typeC(); break;
				case 'D': typeD(); break;
			}
		}

		for(int i=0; i<n; i++)
		{
			cout << ch[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(int argc, const char** argv) {
    char c;
    cin>>c;
    if('A'<=c && c<= 'Z'){
        cout<<'A';
    }else if('a'<=c && c<='z'){
        cout<<'a';
    }
    return 0;
}

Measured memory_bytes: 3636
#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;

int a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
   // cin>>t;
    while(t--){
        int x,y;

        cin>>x>>y;

        int mi=min(x,y);
        int ma=max(x,y);

        while(ma--){
            printf("%d",mi);
        }

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




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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();
int main(){
    process();
    return 0;
}

void process(){
    ULL N,X,M;
    ULL data;
    ULL *sum;
    ULL count;
    LL *use;
    ULL f;
    ULL i;
    ULL loop_start,loop_end;
    ULL mod,loops;
    ULL mod_sum,loop_sum;
    cin >> N >> X >> M;
    sum = new ULL[M+1];
    use = new LL[M];
    for(i=0;i<M;i++){
        use[i] = -1;
    }
    data = X;
    sum[0] = 0;
    sum[1] = X;
    use[X] = 1;
    loop_start = 1;
    loop_end = N;
    for(i=1;i<= M && i < N;i++){
        data = (data * data) % M;
        sum[i+1] = sum[i] + data;
        if( use[data] != -1){
            loop_start = use[data];
            loop_end = i;
            break;
        }
        use[data] = i+1;
        
    }
    //cout << sum[6] << endl;
    f = loop_end - loop_start + 1;
    loops = (N - loop_start + 1) / f;
    mod = (N - loop_start + 1) % f;
    loop_sum = sum[loop_end] - sum[loop_start-1];
    mod_sum = sum[loop_start + mod-1] - sum[loop_start-1];
    cout << sum[loop_start-1] + loop_sum * loops  + mod_sum << endl;
/*    cout << "check" << endl;
    cout << loop_start << ":" << loop_end << endl;
    cout << f << endl;
    cout << loops << endl;
    cout << mod << endl;
    cout << sum[loop_start] << ":" << sum[loop_start-1] << endl;
    cout << sum[loop_end] - sum[loop_start] << endl;
    cout << N << ":" << loop_start-1 + f * loops + mod << endl; */
    return;
}


Measured memory_bytes: 4792
#include <iostream>
int main(){
    using namespace std;
    int a,b,c,i,ans;
    ans = 0;
    cin >> a >> b >> c;
    for(i=a;i<=b;i++){
        if(c%i==0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

int main()
{
    int h,w,n,max,min,ans;
    while(cin>>h>>w>>n){
        max=(h>w?h:w);
        min=h+w-max;
        ans=n/max;
        if(ans*max < n) ans++;
        if(ans<=min){
            cout<<ans<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>    /*入出力*/
#include <stdlib.h>   /*標準ライブラリ*/
#include <string.h>   /*文字列*/
#include <math.h>     /*計算*/
#include <assert.h>   /*確認*/
#include <ctype.h>    /*文字操作*/
#include <stdbool.h>  /*bool型*/
#include <limits.h>   /*限界*/
//---------------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//---------------------------------------------------
//bottom up 型のDP
//https://atcoder.jp/contests/dp/tasks/dp_b

LL min(LL a, LL b){
  if(a>b)return b;
  else return a;
}

int main(void)
{
  LL N;
  LL K;
  LL q = 0;
  LL ans = 0;
  LL H[100000];
  LL DP[100000]={0};

  //入力
  scanf("%lld %lld", &N, &K);
  for (LL i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }

  //DPの初期化
  DP[0] = 0;

  //処理部
  for (LL i = 1; i < N; i++) {
    //作業用変数qを初期化
    q = 1000000000;

    //i-j番目からi番目に飛ぶときの最小値を考える
    for (LL j = 1; j <= K && !(i-j < 0); j++) {
      q = min(q , DP[i-j] + ABS(H[i-j]-H[i]));
    }

    //DPの値を更新
    DP[i] = q;
  }

  //出力
  ans = DP[N-1];
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1664
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, k = read_h()
    print(k * (k - 1)**(n - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 10007;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9000000000000000000;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int sa[100100], ta[100100];

int main() {
	string s, t;
	cin >> s >> t;
	s = " " + s;
	t = " " + t;
	for (int i = 1; i <= s.size(); i++) {
		sa[i] = sa[i - 1];
		if (s[i] == 'A')sa[i]++;
		else sa[i] += 2;
	}
	for (int i = 1; i <= t.size(); i++) {
		ta[i] = ta[i - 1];
		if (t[i] == 'A')ta[i]++;
		else ta[i] += 2;
	}
	int q;
	cin >> q;
	int a, b, c, d;
	for (int i = 0; i < q; i++) {
		cin >> a >> b >> c >> d;
		//cout << sa[a - 1] << " " << sa[b] << " " << ta[c - 1] << " " << ta[d] << endl;
		if (((sa[b] - sa[a - 1]) % 3 == (ta[d] - ta[c - 1]) % 3)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	//system("pause");
}

Measured memory_bytes: 1636