akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

// greatest common divisor and least common multiple
// gcd is calculated by Euclidean Algorithm
// lcm = m * n / gcd(m,n)
template <typename T = int>
T gcd(T a, T b) {
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template <typename T = int>
T lcm(T m, T n) {
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, m;
    cin >> n >> m;
    vector<lint> a(n);
    vector<lint> num2(40, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] /= 2;
        lint t   = 0;
        lint tmp = a[i];
        while (tmp % 2 == 0) {
            t++;
            tmp /= 2;
        }
        num2[t]++;
    }
    int diff2 = 0;
    for (int i = 0; i < 40; ++i) {
        if (num2[i] != 0)
            diff2++;
    }
    if (diff2 > 1) {
        cout << 0 << "\n";
        return 0;
    }
    lint g = a[0];
    for (int i = 0; i < n; ++i) {
        g = lcm(g, a[i]);
    }
    cout << (m / g + 1) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
struct UnionFind{
  vector<int> p;
  void init(int n){
    p.assign(n, -1);
  }
  int find(int a){
    return p[a] < 0 ? a : p[a] = find(p[a]);
  }
  bool merge(int a, int b){
    a = find(a);
    b = find(b);
    if(a==b) return 0;
    if(p[a]>p[b]) swap(a, b);
    p[a] += p[b];
    p[b] = a;
    return 1;
  }
} uf;
int n;
P<int, int> p[N];
V<P<int, int>> v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int x, y;
    cin >> x >> y;
    x--; y--;
    p[x] = mp(i, y);
  }
  uf.init(n);
  v.pb(mp(-1, IINF));
  FOR(i, 0, n){
    auto t = v.back();
    if(t.se > p[i].se){
      v.pb(p[i]);
      continue;
    }
    while(v.back().se < p[i].se){
      uf.merge(v.back().fi, p[i].fi);
      v.pop_back();
    }
    v.pb(t);
  }
  FOR(i, 0, n){
    cout << -uf.p[uf.find(i)] << endl;
  }
}

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

int main() {
    int N;
    cin>>N;
    map<int, int> primemap;
    vector<int> primearr;
    int tmp;
    for(int i=2;i<=N;++i){
        tmp = i;
        for(int j=2;tmp>1;++j){
            while(tmp%j==0){
                if(primemap[j]==0)primearr.push_back(j);
                tmp /= j;
                primemap[j]++;
            }
        }
    }
    int a=0, b=0, c=0, d=0, e=0, f=0, h=0;
    for(int i=0;i<primearr.size();++i){
        if(primemap[primearr[i]]>=74)a++;
        if(primemap[primearr[i]]>=24)b++;
        else if(primemap[primearr[i]]>=2)c++;
        if(primemap[primearr[i]]>=14)d++;
        else if(primemap[primearr[i]]>=4)e++;
        if(primemap[primearr[i]]>=4)f++;
        else if(primemap[primearr[i]]>=2)h++;
    }
    cout<<f*(f-1)/2 * h + f*(f-1)/2*(f-2) + a + b*c + d*e + d*(d-1) + b*(b-1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int L,A,B,C,D,AC,BD;
    cin>>L>>A>>B>>C>>D;
    if(A%C==0)AC=L-(A/C);
    else AC=L-(A/C+1);
    if(B%D==0)BD=L-(B/D);
    else BD=L-(B/D+1);
    if(AC<BD)cout<<AC<<endl;
    else cout<<BD<<endl;
}

Measured memory_bytes: 3096
#include<cstdio>

int main(){
	int n;
	scanf("%d", &n);
	int a[4][3][10];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				a[i][j][k] = 0;
			}
		}
	}

	int b,f,r,v;

	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		a[b-1][f-1][r-1] += v;
	}

	for(int i = 0; i < 4 ; i++){
		if(i){
			printf("####################\n");
		}
		for(int j = 0; j < 3; j++){
			printf(" %d %d %d %d %d %d %d %d %d %d\n", a[i][j][0], a[i][j][1], a[i][j][2], a[i][j][3], a[i][j][4], a[i][j][5], a[i][j][6], a[i][j][7], a[i][j][8], a[i][j][9]);
		}
	}
}

Measured memory_bytes: 1036
//Ace
#include<bits/stdc++.h>
using namespace std;
using in = long long;
using str = string;
using pi = pair<in,in>;
using vi = vector<in>;
#define F first
#define S second
#define pb push_back
#define rep(i,k,n) for (in i = k; i < n; ++i)
#define repr(i,k,n) for (in i = k; i >= n; --i)
#define sz(x) (in)x.size()
#define all(x) begin(x), end(x)
const int MOD = 1e9 + 7;
str s;
in n=0;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>s;

    rep(i,0,sz(s))n += (s[i]-'0');

    if(n%9==0)cout<<"Yes";
    else cout<<"No";

    return 0 ;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){   
    int n;
    cin >> n;
    if(n % 1000 == 0){
    	cout << 0;
    }
    else{
    	cout << 1000 - (n % 1000);
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define endl "\n"
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
using namespace std;

int main(int argc, char const *argv[])
{
	string s; cin >> s; int n = s.size()-1;
	if(s[n]=='2'||s[n]=='4'||s[n]=='5'||s[n]=='7'||s[n]=='9') cout << "hon";		
	if(s[n]=='0'||s[n]=='1'||s[n]=='6'||s[n]=='8') cout << "pon";
	if(s[n]=='3') cout << "bon";		
	return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = vs[0];
			int K = vs[1];

			double ans = 0;
			for (int i = 1; i <= N; i++) {
				int pt = i;
				if (pt < K) {
					int d = 1;
					while (pt < K) {
						pt *= 2;
						d *= 2;
					}
					ans += 1.0 / (d * N);
				} else {
					ans += 1.0 / N;
				}
			}
			Console.WriteLine(ans);
		}
	}
}


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  string s;
  cin >> s;
  int n = s.size();

  int res = 0;
  rep(i, n) rep(j, n - i + 1) {
    string sub = s.substr(i, j);
    bool isACGT = true;
    rep(k, sub.size()) {
      char c = sub[k];
      if (c != 'A' && c != 'C' && c != 'G' && c != 'T') {
        isACGT = false;
        break;
      }
    }
    if (isACGT) res = max(res, (int)sub.size());
  }

  cout << res << endl;
}

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a.begin(), a.end());
    int b = a[n / 2];

    long long ans = 0;
    for (int i = 0; i < n; i++) ans += abs(a[i] - b);
    cout << ans << endl;
}

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

int main(){
    int x,y;
    while(1){
        cin>>x>>y;
        if( x==0 && y==0 ) break;
        if(x<y){
            cout<<x<<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll LINF = numeric_limits<ll>::max() / 2;

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

    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<ll> sum(n+1,0);
    for(int i = 1;i <= n;i ++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    ll ans = LINF;
    int l = 1,r = 3;
    for(int i = 2; i <= n - 2; i++) {
        ll dif = sum[n];
        while(l < i) {
            ll d = abs(sum[i] - sum[l] * 2);
            if(d > dif) break;
            else dif = d;
            l++;
        }
        l--;

        dif = LINF;
        while(r < n) {
            ll d = abs(sum[n] + sum[i] - sum[r] * 2);
            if(d > dif) break;
            else dif = d;
            r++;
        }
        r--;

        ll up = max(max(max(sum[l],sum[i] - sum[l]),sum[r] - sum[i]),sum[n] - sum[r]);
        ll down = min(min(min(sum[l],sum[i] - sum[l]),sum[r] - sum[i]),sum[n] - sum[r]);
        ans = min(ans,up - down);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

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

fn main() {
  input! {
  h: i64,
  w: i64,
  ch: i64,
  cw: i64,
  dh: i64,
  dw: i64,
  mut maze: [Chars; h],
  }

  let xw = vec![1, -1, 0, 0];
  let xy = vec![0, 0, 1, -1];

  let mut depth = vec![vec![-1_i64; w as usize]; h as usize];
  let mut queue: VecDeque<(i64, i64)> = VecDeque::new();

  queue.push_back((cw - 1, ch - 1));
  maze[(ch - 1) as usize][(cw - 1) as usize] = 'x';
  depth[(ch - 1) as usize][(cw - 1) as usize] = 0;

  while let Some(v) = queue.pop_front() {
    for i in 0..4 {
      let nextx = v.0 - xw[i];
      let nexty = v.1 - xy[i];

      if nextx >= 0
        && nextx <= w - 1
        && nexty >= 0
        && nexty <= h - 1
        && maze[nexty as usize][nextx as usize] == '.'
        &&( depth[nexty as usize][nextx as usize] > depth[v.1 as usize][v.0 as usize]
          ||depth[nexty as usize][nextx as usize] == -1)
      {
        maze[nexty as usize][nextx as usize] = 'x';
        depth[nexty as usize][nextx as usize] = depth[v.1 as usize][v.0 as usize];
        queue.push_front((nextx, nexty));
      }
    }

    for movi in -2..3 {
      for movj in -2..3 {
        let nextx = v.0 - movi;
        let nexty = v.1 - movj;
        if nextx >= 0
          && nextx < w
          && nexty >= 0
          && nexty < h
          && maze[nexty as usize][nextx as usize] == '.'
          && (depth[nexty as usize][nextx as usize] > depth[v.1  as usize][v.0 as usize] + 1||
            depth[nexty as usize][nextx as usize] == -1 )
        {
          depth[nexty as usize][nextx as usize] = depth[v.1 as usize][v.0 as usize] +1;
          queue.push_back((nextx, nexty));
        }
      }
    }
  }

  println!("{}", depth[(dh - 1) as usize][(dw - 1) as usize]);
}


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

// 比較演算子を自動生成
#define CAT(a, b) a ## b
#define COMP_1(v1) return lhs.v1 < rhs.v1
#define COMP_2(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_1(__VA_ARGS__)
#define COMP_3(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_2(__VA_ARGS__)
#define COMP_4(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_3(__VA_ARGS__)
#define COMP_5(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_4(__VA_ARGS__)
#define LESS_THAN(n, ...) bool operator<(const A & rhs) const { auto& lhs = *this; CAT(COMP_, n)(__VA_ARGS__); }

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define FOR(i, s, n) for(ll i = (s); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()

// 10^x (by math)
#define TEN(x) ((ll)1e##x)

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;

void solution(istream& cin, ostream& cout) {
	ll n, k;
	cin >> n >> k;
	vl a(n);
	REP(i, n) {
		cin >> a[i]; a[i]--;
	}
	vl visited(n, -1);
	function<ll(ll, ll)> f = [&](ll cur, ll cnt) {
		if (visited[cur] != -1) {
			cnt = k - (k - cnt) % (cnt - visited[cur]);
		}
		visited[cur] = cnt;
		if (cnt == k) return cur;
		return f(a[cur], cnt + 1);
	};
	cout << (f(0, 0) + 1) << endl;
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	solution(cin, cout);
}


Measured memory_bytes: 14196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int N;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	int a[102] = {0};
	int b[102] = {0};
	long long ans = 0;

	cin >> N;
	for(int i=1; i<=N-1; i++){ cin >> b[i]; }

	a[1] = b[1];
	b[N] = b[N - 1];
	ans = a[1];
	for(int i=2; i<=N; i++){
		a[i] = min(b[i], b[i - 1]);
		ans += a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
const int MOD = 1e9+17;
LL a[MAXN],c[MAXN];
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    LL n;
    cin>>n;
    LL sum = 0;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    	sum+=a[i];
    }
    bool can = true;
    if(sum%(((1LL+n)*n)/2)!=0)  can = false;
    LL cnt = sum/(((1LL+n)*n)/2);
    for (int i = 0; i < n; ++i)
    {
    	if(i==0) c[i] = a[0]-a[n-1];
    	else c[i] = a[i]-a[i-1];
    }
    for (int i = 0; i < n; ++i)
    {
    	if(((c[i]-cnt)%n)!=0||(c[i]-cnt>0)) can = false;
    }
    if(can) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;        
}

Measured memory_bytes: 1792
def main():
    a, b, c = map(int, input().split())
    flag = False
    if (a == b and b != c) or (a != b and a == c) or (b == c and a != c):
        flag = True
    if flag: print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

	ll n,q; cin >> n >> q;

	vector<ll> a(n); rep(i,n) cin >> a[i];

	fenwick_tree<ll> fw(n);

	rep(i,n) fw.add(i,a[i]);

	rep(i, q) {
		ll t, u , v; cin >> t >> u >> v;
		if (t) cout << fw.sum(u,v) << endl;
		else fw.add(u,v);
	}
}



Measured memory_bytes: 12156
package main

import (
	"fmt"
  	"os"
  	"bufio"
  	"strconv"
)

func main(){
  var sc = bufio.NewScanner(os.Stdin)
  sc.Scan()
  N, _ := strconv.Atoi(string(sc.Text()))
  s := 0
  for i := 1 ; i <= N; i++{      
    s = i + s
  }
  fmt.Println(s)
}

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

int main()
{
    long N, P;
    cin >> N >> P;

    if (N == 1 || P == 1)
    {
        cout << P << endl;
        return 0;
    }

    long counter;
    long ans = 1;
    for (long i = 2; i * i <= P; i++)
    {
        counter = 0;
        while (P % i == 0)
        {
            counter++;
            P /= i;
        }
        if (counter >= N)
        {
            for (long j = 1; j * N <= counter; j++)
            {
                ans *= i;
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int d, n, s=1;
    cin >> d >> n;

    if(d == 0){
        if(n==100)
            cout << n+1 << endl;
        else
            cout << n << endl;
    }  
    else if(d == 1){
        if(n==100)
            cout << 100*(n+1) << endl;
        else
            cout << 100*n << endl;
    }
    else{
        if(n==100)
            cout << (n+1)*10000  << endl;
        else
            cout << n*10000 << endl;
    }
}


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


int main() {
 int N,M;
  cin >>N>>M;
  int c[M+1],dp[M+1][50100];
  rep(i,M){cin >>c[i+1];
  }
  
 	rep(j,50010){
      rep(i,M+1){dp[i][j]=INF;}
    }
  rep(i,M+1){dp[i][0]=0;}
  
  for(int i=1;i<=M;i++){
  	for(int j=1;j<=N;j++){
     if(j>=c[i]){dp[i][j]=min(dp[i-1][j],min(1+dp[i][j-c[i]],1+dp[i-1][j-c[i]]));}
     else{dp[i][j]=dp[i-1][j];}
    }
  }
  cout<<dp[M][N]<<endl;
  
  
}


Measured memory_bytes: 7196
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors
  end
end

datas = gets.split(" ").map{|nn|nn.to_i}
a = datas[0]
b = datas[1]
k = datas[2]

yakus = b.divisor_list.reverse
count = 0
yakus.each do|n|
  if a % n == 0
    count += 1
  end
  if count == k
    puts n.to_s
    count = -1000
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll n,m; cin>>n>>m;
    ll ac=0, wa=0;
    vector<ll> a(n, 0);
    rep(i,m){
        ll p; string s; cin>>p>>s;
        if(a[p-1]==-1) continue;
        if(s=="AC"){
            ac++;
            wa+=a[p-1];
            a[p-1]=-1;
        }else{
            a[p-1]++;
        }
    }
    cout<<ac<<' '<<wa<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String T = in.next();
            out.println(T.replace("?", "D"));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 36728
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> A(a), B(b);

    for (auto &&i : A) scanf("%d", &i);
    for (auto &&j : B) scanf("%d", &j);
    int ans = *min_element(A.begin(),A.end()) + *min_element(B.begin(),B.end());
    for (int i = 0; i < m; ++i) {
        int x, y, c; scanf("%d %d %d", &x, &y, &c);
        ans = min(ans, A[x-1]+B[y-1]-c);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

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

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}



int main() {
  int x, ans;
  for (int i = 1; i <= 5; i++) {
    cin >> x;
    if (x == 0) cout << i << endl;
  }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int n;	cin>>n;
	vector<pair<int,int>>odd(100000);
	vector<pair<int,int>>even(100000);
	set<int>kind;
	rep(i,0,n){
		int v;
		cin>>v;
		kind.insert(v);
		if(i%2==0){
			even[v].first++;
			even[v].second=v;
		}
		else{
			odd[v].first++;
			odd[v].second=v;
		}
	}
	sort(all(even));
	reverse(all(even));
	sort(all(odd));
	reverse(all(odd));
	int ans;
	if(kind.size()==1){
		ans=n/2;
	}
	else{
		ans=100000;
		if(odd[0].second!=even[0].second)	ans=min(ans,n-odd[0].first-even[0].first);
		if(odd[0].second!=even[1].second)	ans=min(ans,n-odd[0].first-even[1].first);
		if(odd[1].second!=even[0].second)	ans=min(ans,n-odd[1].first-even[0].first);
		if(odd[1].second!=even[1].second)	ans=min(ans,n-odd[1].first-even[1].first);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

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


void Main() {
    vector<bool> primes(100005, false);
    rep2(i, 1, 100005) {
        primes[i] = is_prime(i);
    }
    vector<bool> like(100005, false);
    rep2(i, 1, 100005) {
        if (i % 2 == 1 && primes[i] && primes[(i + 1) / 2]) {
            like[i] = true;
        }
    }
    vector<ll> acc(100005, 0);
    rep(i, 100004) {
        acc[i + 1] += acc[i] + like[i];
    }
    ll Q;
    cin >> Q;
    rep(i, Q) {
        ll l, r;
        cin >> l >> r;
        r++;
        cout << acc[r] - acc[l] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

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

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> mp1, mp2;
    repi(i, n, 0)
    {
        ll tmp;
        cin >> tmp;
        mp1[i + 1 + tmp]++;
        mp2[i + 1 - tmp]++;
    }
    ll ans = 0;
    repm(i, mp1)
    {
        // cout << i->second * mp2[i->first] << " ";
        ans += i->second * mp2[i->first];
    }
    // cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 37924
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

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

        boolean res = false;

        for (int i=1; i<=3;i++) {
            if ((a*b*i) % 2!=0) {
                res=true;
                break;
            }
        }

        out.println(res?"Yes":"No");
        out.flush();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define INF 999999999
using LL = long long;
using VI = vector<int>;

LL cnt;
int l;
int a[1000000];
int n;
VI g;

void insert(int a[],int n,int g){
  REP(i,g,n){
    int v = a[i];
    int j = i-g;
    while(j>=0&&a[j]>v){
      a[j+g]=a[j];
      j-=g;
      cnt++;
    }
    a[j+g] = v;
  }
}

void shell(int a[],int n){
  for(int h=1;;){
    if(h>n) break;
    g.push_back(h);
    h=3*h+1;
  }
  for(int i=g.size()-1;i>=0;i--){
    insert(a,n,g[i]);
  }
}

int main(){
  cin >> n;
  rep(i,n) scanf("%d",&a[i]);
  cnt = 0;
  shell(a,n);
  cout << g.size() << endl;
  for(int i=g.size()-1;i>=0;i--){
    printf("%d",g[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  rep(i,n) printf("%d\n",a[i]);
  return 0;
}



Measured memory_bytes: 7208
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int h,w,s;
int u[33][33];
P dp[32][32][33][33];
int area(int i, int j, int a, int b)
{
	return u[i+a][j+b]-u[i][j+b]-u[i+a][j]+u[i][j];
}
void exec()
{
	cin >> h >> w >> s;
	if(h==0&&w==0&&s==0)exit(0);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>u[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			u[i][j]+=u[i][j-1];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			u[i][j]+=u[i-1][j];
		}
	}
	memset(dp,0,sizeof(dp));
	int total=area(0,0,h,w);
	int bound=total-s;
	for(int a=1;a<=h;a++){
		for(int b=1;b<=w;b++){
			for(int i=0;i+a<=h;i++){
				for(int j=0;j+b<=w;j++){
					P v(0,0);
					int ar=area(i,j,a,b);
					if(ar>=bound){
						v=P(1,ar);
					}
					for(int p=1;p<a;p++){
						int f0=dp[i][j][p][b].first;
						int f1=dp[i+p][j][a-p][b].first;
						int s0=dp[i][j][p][b].second;
						int s1=dp[i+p][j][a-p][b].second;
						if(f0&&f1){
							v=max(v,P(f0+f1,min(s0,s1)));
						}
					}
					for(int q=1;q<b;q++){
						int f0=dp[i][j][a][q].first;
						int f1=dp[i][j+q][a][b-q].first;
						int s0=dp[i][j][a][q].second;
						int s1=dp[i][j+q][a][b-q].second;
						if(f0&&f1){
							v=max(v,P(f0+f1,min(s0,s1)));
						}
					}
					dp[i][j][a][b]=v;
				}
			}
		}
	}
	cout << dp[0][0][h][w].first << " " << dp[0][0][h][w].second-bound << endl;
}
int main() {
	while(1)exec();

}

Measured memory_bytes: 9888
fun main() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val ss = IntArray(n)

    repeat(k) {
        val d = readLine()!!.toInt()
        val a = readLine()!!.split(' ').map { it.toInt() - 1 }
        for (i in a) {
            ss[i]++
        }
    }

    println(ss.filter { it == 0 }.count())
}


Measured memory_bytes: 38828
a,b,c,d = gets.split(" ").map(&:to_f)

#高橋君のモンスターが体力0になるまでの攻撃回数
x = (a/d).ceil

#x回目の攻撃で青木君のモンスターが倒れているか判定
if c - b * x <= 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14304
object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val data = Iterator.continually {
    val x = scanner.nextInt
    val y = scanner.nextInt

    (x, y)
  }.takeWhile(t => !(t._1 == 0 && t._2 == 0)).toList

  val outputs = data.map {
    case (x, y) =>
      if(x < y) {
        s"$x $y"
      } else {
        s"$y $x"
      }
  }

  outputs.foreach(println)
}

Measured memory_bytes: 54336
s = input()
t = input()
m = len(s)
n = len(t)

dp = [[0 for i in range(m+1)] for i in range(n+1)]
for i in range(1, n+1):
  for j in range(1, m+1):
    if s[j-1] == t[i-1]:
      dp[i][j] = 1 + dp[i-1][j-1]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])

res = ""
i = n
j = m
while i > 0 and j > 0:
  if s[j-1] == t[i-1]:
    res = s[j-1] + res
    i -= 1
    j -= 1
  
  else:
    if dp[i-1][j] > dp[i][j-1]:
      i -= 1
    else:
      j -= 1

print(res)

Measured memory_bytes: 152900
// C - Prison
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,M; cin>>N>>M;
	int mini = 1000000, maxi = 0;
	for(int i=0; i<M; ++i){
		int l,r; cin>>l>>r;
		mini = min(mini, r);
		maxi = max(maxi, l);
	}
	cout<< (mini<maxi? 0: mini-maxi+1) <<endl;
}

Measured memory_bytes: 384
#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;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n;
  cin >> n;
  ll a=0, b=0, c=0, d=0;
  rep(i,n) {
    string s;
    cin >> s;
    if (s == "AC") a++;
    if (s == "WA") b++;
    if (s == "TLE") c++;
    if (s == "RE") d++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  return 0;
}


Measured memory_bytes: 3628
import re  # 正規表現, findall('正規表現', 文字列), search('正規表現', 文字列)
import sys # プログラム終了：sys.exit()
# sys.setrecursionlimit(10**6) # 再帰呼び出しの上限を上げる

def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
# 文字列のまま受け取りたいときはinput()

N = i_input()
A = l_input()

alice = 0
bob = 0

for i in range(N):
    biggest = max(A)
    if i % 2 == 0:
        alice += biggest
    else:
        bob += biggest
    A.remove(biggest)

print(alice - bob)


Measured memory_bytes: 3188
n,m=map(int,input().split())
l=[]
for i in range(n):
    x,y,z=map(int,input().split())
    l.append([x+y+z,x+y-z,x-y+z,-x+y+z,x-y-z,-x+y-z,-x-y+z,-x-y-z])

ans=0
from operator import itemgetter
for i in range(8):
    l.sort(key=itemgetter(i))
    l=l[::-1]
    p=0
    for j in range(m):
        p+=l[j][i]
    ans=max(ans,p)
print(ans)

Measured memory_bytes: 3432
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

  int N;
  cin >> N;

  set<int> s;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (s.find(a) != s.end()) {
      s.erase(a);
    } else {
      s.insert(a);
    }
  }

  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

namespace {
#define VERA(i,a,b) for(ll i=(a);i<(b);++i)
#define ANDY(i,a,b) for(ll i=(a);i>(b);--i)
#define SIZE(x) (ll)(x.size())

typedef long long ll;
typedef double dd;

string str;

bool Can(ll fst, ll snd, vector<ll> cnt) {
  if (--cnt[fst] < 0) return false;
  if (--cnt[snd] < 0) return false;
  ll a = fst, b = snd;
  VERA(i,2,SIZE(str)) {
    const auto nx = 3 - a - b;
    if (--cnt[nx] < 0) return false;
    tie(a,b) = make_pair(b,nx);
  }
  return true;
}

void Solve() {
  vector<ll> cnt(3,0);
  for(auto c : str)
    ++cnt[c-'a'];
  const auto N = SIZE(str);
  bool res=N==1;
  if (N > 1) {
    VERA(a,0,3) VERA(b,0,3) if (a!=b) res |= Can(a,b,cnt);
  }
  if (res) cout << "YES\n";
  else cout << "NO\n";
}

bool Input() {
  return bool(cin>>str);
}

}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  while (Input()) {
    Solve();
  }
  return 0;
}


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

int main() {
  string str;
  cin >> str;
  int A;
  A=0;
  if(str.at(0)=='R'){
    A++;
    if(str.at(1)=='R'){
      A++;
    if(str.at(2)=='R'){
      A++;
    }
    }
  }
  else{
    if(str.at(1)=='R'){
      A++;
    }
    if(str.at(2)=='R'){
      A++;
    }
  }
  cout <<A;
}


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

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

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

    int times = 0;
    bool flag = true;

    while(flag == true && times < k){
        vector<int> a_new(n+1);
        flag = false;
        times += 1;

        for(int i=0; i<n; i++){
            int l = max(0, i-a[i]);
            int r = min(n-1,i+a[i]);
            a_new[l] += 1;
            a_new[r+1] -= 1;
        }
        for(int i=0; i<n; i++){
            a_new[i+1] += a_new[i];
        }
        for(int i=0; i<n; i++){
            if(a_new[i] != a[i]) flag = true;
            //cout << a_new[i] << " ";
        }
        //cout << endl;
        a = a_new;
    }

    for(int i=0; i<n; i++){
        cout << a[i];
        if(i == n-1) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

vector<int> split(string s){
    vector<int> ret;
    s += ',';
    int x = -1;
    REP(i,s.size()){
	if(s[i] == ','){
	    ret.PB( stoi(s.substr(x+1,i-x-1)) );
	    x = i;
	}
    }
    return ret;
}

int main(){
    while(true){
	int n,m;
	int d[101][101];
	int dd[101];
	memset(d,-1,sizeof(d));
	memset(dd,-1,sizeof(dd));
	cin >> n;
	if(n == 0) break;
	cin >> m;
	vector< vector<int> > vec(n,vector<int>(0));
	REP(i,m){
	    string s;
	    cin >> s;
	    vector<int> sl = split(s);
	    vec[sl[0]].PB(sl[1]);
	    vec[sl[1]].PB(sl[0]);
	    d[sl[0]][sl[1]] = sl[2];
	    d[sl[1]][sl[0]] = sl[2];
	}
	int ans = 0;
	int count = 0;
	int t = 0;
	int v = 0;
	vector<bool> used(n,false);
	used[0] = true;
	priority_queue< pair<int,int>,vector< pair<int,int> >, greater< pair<int,int> > > q;
	REP(i,vec[0].size()){
	    q.push( pair<int,int>(d[0][vec[0][i]],vec[0][i]));
	}
	while(!q.empty()){
	    v = q.top().first;
	    t = q.top().second;
	    q.pop();
	    if(!used[t]){
		used[t] = true;
		dd[t] = v;
		ans += v/100 - 1;
		REP(i,vec[t].size()){
		    q.push( pair<int,int>(d[t][vec[t][i]],vec[t][i]));
		}
	    }else if(dd[t] > v){
	    }
	}
	REP(i,n){
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
// Dropping Ink (0026)
int main()
{
    vector<vector<int> > paper(10, vector<int>(10));
    int ret1 = 100;
    int ret2 = 0;
 
    int dx[] = {0, 0, 0, 1, -1, 1, 1, -1, -1, 0, 0, 2, -2}; 
    int dy[] = {0, 1, -1, 0, 0, 1, -1, 1, -1, 2, -2, 0, 0};

    for(;;){
       int x0, y0, size;
       char c;
       if(!(cin >> x0 >> c >> y0 >> c >> size))
            break;
        for(int i=0; i<4*size+1; ++i){
            int y = y0 + dy[i];
            int x = x0 + dx[i];
            if(y < 0 || y > 9 || x < 0 || x > 9)
                continue;
            if(paper[y][x] == 0)
                -- ret1;
            ++ paper[y][x];
            ret2 = max(ret2, paper[y][x]);
        }
    }
 
    cout << ret1 << endl << ret2 << endl;
}

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

int main() {
  int val[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

  int k;

  cin >> k;

  cout << val[k-1];



}

Measured memory_bytes: 3588
#include<iostream>
#include <stdio.h>
using namespace std;
 
int main(){
    char a;
	int i=0;
	while(cin>>a){
		if(a=='A'){cout<<"X";}else
	    if(a=='B'){cout<<"Y";}else
	    if(a=='C'){cout<<"Z";}else
		if(a=='D'){cout<<"A";}else
	    if(a=='E'){cout<<"B";}else
	    if(a=='F'){cout<<"C";}else
		if(a=='G'){cout<<"D";}else
	    if(a=='H'){cout<<"E";}else
	    if(a=='I'){cout<<"F";}else
		if(a=='J'){cout<<"G";}else
	    if(a=='K'){cout<<"H";}else
	    if(a=='L'){cout<<"I";}else
		if(a=='M'){cout<<"J";}else
	    if(a=='N'){cout<<"K";}else
	    if(a=='O'){cout<<"L";}else
	    if(a=='P'){cout<<"M";}else
	    if(a=='Q'){cout<<"N";}else
		if(a=='R'){cout<<"O";}else
	    if(a=='S'){cout<<"P";}else
	    if(a=='T'){cout<<"Q";}else
		if(a=='U'){cout<<"R";}else
	    if(a=='V'){cout<<"S";}else
	    if(a=='W'){cout<<"T";}else		
		if(a=='X'){cout<<"U";}else
	    if(a=='Y'){cout<<"V";}else
	    if(a=='Z'){cout<<"W";}}
	cout<<endl;
	return 0;}


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

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
using namespace std;
typedef long long ll;
vector<pair<ll, ll> > pack;
ll w,h;
char tb[310][310];
ll cost[310][310][310];
ll memo[310][310][310];

ll dp(ll i, ll x, ll y){
  if(x == 0 || y == 0) return 0;
  if(memo[i][x][y] != -1) return memo[i][x][y];
  return memo[i][x][y] = min(dp(i, x - 1, y), dp(i, x, y - 1)) + cost[i][x][y];
}

int main(){
  cin >> h >> w;
  REP(i, h){
    REP(j, w){
      cin >> tb[j][i];
    }
  }
  REP(i,310){
    REP(j,310){
      REP(k,310){
        cost[i][j][k] = 0;
        memo[i][j][k] = -1;
      }
    }
  }
  REP(i, w - 1){
    REP(j, h){
      ll tcost = 0;
      REP(k, h - j){
        if(tb[i][k] == tb[i+1][j + k]) tcost++;
      }
      //cout << tcost << "\n";
      cost[i][h-j][h] = tcost;
      REP(k, h){
        if(h - k - j <= 0){
          cost[i][0][h - k] = cost[i][0][h - k + 1];
          continue;
        }
        if(tb[i][h-k-j-1] == tb[i+1][h-1-k]) tcost--;
        cost[i][h - k - j - 1][h - k  - 1] = tcost;
      }
    }

    REP(j, h){
      ll tcost = 0;
      REP(k, h - j){
        if(tb[i][j + k] == tb[i+1][k]) tcost++;
      }
      //cout << tcost << "\n";
      cost[i][h][h-j] = tcost;
      REP(k, h){
        if(h - k - j <= 0){
          cost[i][h - k][0] = cost[i][h - k + 1][0];
          continue;
        }
        if(tb[i+1][h-k-j-1] == tb[i][h-1-k]) tcost--;
        cost[i][h - k  - 1][h - k - j - 1] = tcost;
      }
    }
  }
  ll sumcost = 0;
  REP(i, w-1){
    sumcost = sumcost + dp(i, h, h);
  }
  cout << sumcost << "\n";
    // RREP(j, 1, h + 1){
    //   RREP(k, 1, h + 1){
    //     cout << j << "," << k << ":" << cost[0][j][k] << " ";
    //   }
    // }

}


Measured memory_bytes: 465792
from copy import deepcopy
from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
a = 0
for y in product((0, 1), repeat=h):
    for x in product((0, 1), repeat=w):
        d = deepcopy(c)
        for row in range(h):
            if y[row] == 1:
                d[row] = ["r"] * w
        for col in range(w):
            if x[col] == 1:
                for row in range(h):
                    d[row][col] = "r"
        a += sum(row.count("#") for row in d) == k
print(a)

Measured memory_bytes: 9340
n,k = map(int,input().split())
li = list(map(int,input().split()))

if k == 1:
    print(min(abs(max(li)),abs(min(li))))
    exit()

time_li = []
for i in range(n-k+1):
    #print(li[i:i+k]) [-30, -10, 10]
    tmp_time_li = []
    mi = li[i]
    ma = li[i+k-1]
    if mi > 0 and ma >0:
        tmp_time_li.append(ma)
    elif mi < 0 and ma < 0:
        tmp_time_li.append(abs(mi))
    else:
        orikaeshi = min(abs(mi),abs(ma))*2+max(abs(mi),abs(ma))
        tmp_time_li.append(orikaeshi)
    time_li.append(tmp_time_li[0])
print(min(time_li))

Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n; cin >> n;
  map<char, int> mp;
  for(int i = 0; i < n; ++i){
    char c; cin >> c;
    ++mp[c];
  }
  string ans = "Three";
  if(mp.size()==4)ans = "Four";
  cout << ans << endl;
}



Measured memory_bytes: 256
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
s = input()
n, = gi()
ans = 0
mag = len(s) - 1
#corner cases:
if len(s) <= 7:
	s = int(s)
	for k in range(s + 1):
		if len(str(k)) - str(k).count("0") == n:
			ans += 1
	print(ans)
	exit()
while mag - n >= 0:
	a = 9
	b = 1
	c = 1
	if n > 2:
		c = 81 * ((mag - 1) * (mag - 2) // 2)
	elif n > 1:
		b = 9 * (mag - 1)
	ans += a * b * c
	#print(mag, a, b, c, ans)
	mag -= 1
mag = len(s)
a = int(s[0]) - 1
b, c = 1, 1
if n > 2:
	c = 81 * ((mag - 1) * (mag - 2) // 2)
elif n > 1:
	b = 9 * (mag - 1)
ans += a * b * c
a = b = c = 1
if n == 1:
	print(ans + 1)
	exit()
if n > 1:
	i = -1
	for k in range(1, len(s)):
		if s[k] != "0":
			i = k
			break;
	if i != -1:
		a = int(s[i]) - 1
		if n > 2:
			b = len(s) - i - 1
			b *= 9
		ans += a * b
		a = b = 1
		if n > 2:
			x = len(s) - i - 1
			a = 81 * (x * (x - 1)) // 2
		else:
			a = 9 * (len(s) - i - 1)
		ans += a
	if n > 2:
		a = b = c = 1
		j = -1
		for k in range(i + 1, len(s)):
			if s[k] != "0":
				j = k
				break;
		if j != -1:
			ans += 9 * (len(s) - j - 1) + int(s[j])
	else:
		ans += 1
print(ans)

Measured memory_bytes: 3192