akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, m;
    cin >> n >> m;
    vector<P> input(m);
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        input[i] = P(b, a);
    }
    sort(input.begin(), input.end());
    int ans = 0;
    int now = -1;
    for(int i = 0; i < m; ++i){
        int a = input[i].second, b = input[i].first;
        if(now >= a)    continue;
        ++ans;
        now = b - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
  		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int result = 1;
		while(n!=1){
			n=n/2;
			result=result*2;
		}
		System.out.println(result);
		
	}
}


Measured memory_bytes: 21844
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int64 MOD = 1000000007;

int64 dp[101010][13];

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

  string s; cin >> s;
  int n = s.size();
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '?') {
      for (int j = 0; j < 10; ++j) {
        for (int k = 0; k < 13; ++k) {
          dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
        }
      }
    } else {
      int num = s[i] - '0';
      for (int j = 0; j < 13; ++j) {
        dp[i + 1][(j * 10 + num) % 13] += dp[i][j];
      }
    }
    for (int j = 0; j < 13; ++j) {
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[n][5] << '\n';

  return 0;
}

Measured memory_bytes: 10704
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	if N >= 2 && M >= 2 {
		fmt.Println((N - 2) * (M - 2))
	} else if N == 1 && M >= 2 {
		fmt.Println(M - 2)
	} else if M == 1 && N >= 2 {
		fmt.Println(N - 2)
	} else {
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

	int a, b; cin >> a >> b;
	cout << (a + b) % 24 << endl;


	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a+b+c+9*max({a,b,c})<<endl;
      
}


Measured memory_bytes: 256
use std::io::BufRead;
fn main() {
    let stdin = std::io::stdin();
    let mut lines: Vec<Vec<i64>> = stdin
        .lock()
        .lines()
        .map(|l| {
            l.unwrap()
                .split_whitespace()
                .map(|w| w.parse().unwrap())
                .collect()
        })
        .collect();
    let (n, k, mut al, mut fl) = (lines[0][0], lines[0][1], lines.remove(1), lines.remove(1));
    if al.iter().sum::<i64>() <= k {
        println!("0");
        return;
    } else {
        al.sort();
        al.reverse();
        fl.sort();
        let mut list: Vec<_> = al.iter().zip(fl.iter()).collect();
        list.sort();
        list.reverse();
        let mut lp: i64 = 1;
        let mut rp: i64 = al.iter().max().unwrap() * fl.iter().max().unwrap();
        let mut mp: i64 = (lp + rp) / 2;
        while (lp != mp) || (mp != rp) {
            let cnt: i64 = list
                .iter()
                .filter(|&&(a, f)| (a * f) > mp)
                .map(|&(a, f)| a - (mp / f))
                .sum();
            // let mut cnt = 0;
            // for &(a, f) in &list {
            //     if (a * f) > mp {
            //         cnt += a - (mp / f);
            //     } else {
            //         break;
            //     }
            // }
            if k < cnt {
                lp = mp + 1;
            } else {
                rp = mp;
            }
            mp = (lp + rp) / 2;
        }
        println!("{}", mp);
    }
}


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

n, k = map(int, input().split())
a = list(map(int, input().split()))

cnt, town = 0, 1
l, s = [], set()
while True:
    town = a[town - 1]
    cnt += 1
    if cnt == k:
        print(town)
        exit()
    if town in s:
        loop_start = town
        break
    l.append(town)
    s.add(town)


loop_cnt = l.index(loop_start)
loop = l[loop_cnt:]
print(loop[(k - loop_cnt) % len(loop) - 1])



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

int main()
{
  int n;
  cin>>n;
  vector<int> e(n+1,0);
  char s;
  for(int i=1;i<=n;i++)
  {
    cin>>s;
    if(s=='E') e.at(i)=e.at(i-1)+1;
    else e.at(i)=e.at(i-1);
  }

  int cnt=1000000;
  for(int i=1;i<=n;i++)
  {
    int left=(i-1)-e.at(i-1);
    int right=e.at(n)-e.at(i);
    int turn=left+right;
    if(turn<cnt) cnt=turn;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(X) if(X)
int is_prime(long long int n) {
	long long int sqrt_n = sqrt(n);
	long long int i = 3;
	if(n == 2) return 1;
	if(n % 2 == 0) return 0;
	while(i <= sqrt_n) {
		if(n % i == 0) return 0;
		i += 2;
	}
	return 1;
}

long long int check(long long int n) {
	long long int sqrt_n = sqrt(n), min_move;
	bool flag = false;
	for(int i = 1; i <= sqrt_n; i++) {
		if(n % i == 0) {
			if(!flag) {
				min_move = (i - 1) + ((n / i) - 1);
				flag = true;
			} else min_move = min(min_move, (i - 1) + ((n / i) - 1));
		}
		
	}
	return min_move;
}
int main() {
	long long int n, min_move = LLONG_MAX;
	cin >> n;
	if(is_prime(n)) min_move = n - 1; 
	else min_move = check(n);
	cout << min_move << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    vector<int> st;
    rep(i, N) if (B[i] - A[i] >= B[(i + N - 1) % N] + B[(i + 1) % N]) {
        st.push_back(i);
    }

    ll ans = 0;
    while (!st.empty()) {
        int i = st.back();
        st.pop_back();
        ll c = (B[i] - A[i]) / (B[(i + N - 1) % N] + B[(i + 1) % N]);
        if (c > 0) {
            B[i] -= c * (B[(i + N - 1) % N] + B[(i + 1) % N]);
            ans += c;
            st.push_back((i + N - 1) % N);
            st.push_back((i + 1) % N);
        }
    }

    rep(i, N) if (A[i] != B[i]) ans = -1;
    write(ans);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  ll ans = 0;
  rep(i, n-1) {
    ans = ans + a[(i + 1) / 2];
  }

  cout << ans << endl;

  return 0;
}
/*
*/


Measured memory_bytes: 4012
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let _h: usize = s.next().unwrap().parse().unwrap();
	let _w: usize = s.next().unwrap().parse().unwrap();
	let m: usize = s.next().unwrap().parse().unwrap();
	let mut xs = vec![];
	let mut ys = vec![];
	let mut coord = vec![];
	for _ in 0..m {
		let y: u32 = s.next().unwrap().parse().unwrap();
		let x: u32 = s.next().unwrap().parse().unwrap();
		xs.push(x);
		ys.push(y);
		coord.push((y, x));
	}
	xs.sort();
	xs.dedup();
	ys.sort();
	ys.dedup();
	coord.sort();
	let mut horz = vec![0; ys.len()];
	let mut vert = vec![0; xs.len()];
	for (y, x) in coord.iter() {
		let i = ys.binary_search(y).unwrap();
		let j = xs.binary_search(x).unwrap();
		horz[i] += 1;
		vert[j] += 1;
	}
	let mut st = SegmentTree::construct(vert, 0, |a, b| std::cmp::max(a, b));
	let mut index = 0;
	let mut ans = 0;
	while index < coord.len() {
		let cur_y = coord[index].0;
		let mut fix = vec![];
		while index < coord.len() && coord[index].0 == cur_y {
			let x = coord[index].1;
			let j = xs.binary_search(&x).unwrap();
			st.set(j, st.get(j).unwrap().clone() - 1);
			fix.push(j);
			index += 1;
		}
		let r = horz[ys.binary_search(&cur_y).unwrap()] + st.fold(0, st.len());
		if ans < r {
			ans = r;
		}
		for i in fix {
			st.set(i, st.get(i).unwrap().clone() + 1);
		}
	}
	println!("{}", ans);
}

pub struct SegmentTree<T, F> {
	n: usize,
	data: Vec<T>,
	e: T,
	op: F,
}

impl<T, F> SegmentTree<T, F>
where
	T: Clone,
	F: Fn(T, T) -> T,
{
	pub fn construct(src: Vec<T>, e: T, op: F) -> Self {
		let mut data = vec![e.clone(); src.len()];
		data.extend(src);
		for i in (1..data.len() / 2).rev() {
			data[i] = op(data[i << 1].clone(), data[i << 1 | 1].clone());
		}
		Self {
			n: data.len() / 2,
			data,
			e,
			op,
		}
	}

	pub fn len(&self) -> usize {
		self.n
	}

	pub fn fold(&self, l: usize, r: usize) -> T {
		let mut s = self.e.clone();
		let mut t = self.e.clone();
		let mut l = l + self.n;
		let mut r = r + self.n;
		while l < r {
			if l & 1 != 0 {
				s = (self.op)(s, self.data[l].clone());
				l += 1;
			}
			if r & 1 != 0 {
				t = (self.op)(self.data[r - 1].clone(), t);
			}
			l >>= 1;
			r >>= 1;
		}
		(self.op)(s, t)
	}

	pub fn set(&mut self, i: usize, v: T) {
		let mut i = i + self.n;
		self.data[i] = v;
		while {
			i >>= 1;
			i > 0
		} {
			self.data[i] = (self.op)(self.data[i << 1].clone(), self.data[i << 1 | 1].clone());
		}
	}

	pub fn get(&self, i: usize) -> Option<&T> {
		if i < self.n {
			self.data.get(self.n + i)
		} else {
			None
		}
	}
}


Measured memory_bytes: 16076
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; i++)

int n, r;
int x1[10000],y1[10000],x2[10000],y2[10000];
int dp[2][10010];

int main(){
	while(scanf("%d%d", &n, &r),n||r){
		int ans = 0, ans2 = 0;
		rep(i,2) rep(j,10010) dp[i][j] = 0;
		rep(i,n){
			scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
			x1[i]++; y1[i]++;
		}
		for(int u = 1; u < 10010; u++){
			for(int v = 0; v < n; v++){
				if(y1[v] == u){
					dp[1][x1[v]]++;
					dp[1][x2[v]+1]--;
				}
				if(y2[v]+1 == u){
					dp[1][x1[v]]--;
					dp[1][x2[v]+1]++;
				}
			}
			for(int v = 1; v < 10010; v++) dp[1][v] += dp[1][v-1];
			for(int v = 0; v < 10010; v++) dp[1][v] += dp[0][v];
			for(int v = 0; v < 10010; v++) if(dp[1][v] > 0) ans++;
			if(r == 2){
				for(int v = 1; v < 10009; v++){
					if(dp[1][v] == 0) continue;
					ans2 += (dp[0][v] == 0)+(dp[1][v-1]==0)+(dp[1][v+1]==0);
				}
				for(int v = 0; v < 10010; v++){
					if(dp[0][v] == 0) continue;
					ans2 += (dp[1][v] == 0);
				}
			}
			for(int v = 0; v < 10010; v++){
				dp[0][v] = dp[1][v];
				dp[1][v] = 0;
			}
		}
		printf("%d\n", ans);
		if(r == 2) printf("%d\n", ans2);
	}
}

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e6 + 5;
const int mod = 1e9 + 7;

int modExpo(int a,int b,int c){
	if(b == 0) return 1;
	int answer = 1;
	while(b){
		if(b & 1) answer = ((answer % c) * (a % c)) % c;
		a = ((a % c) * (a % c)) % c;
		b /= 2; 
	}
	
	return answer;
}

int h,w,k;
char arr[6][6];

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		cin >> h >> w >> k;
		
		int val = 0;
		FOR(i,0,h){
			FOR(j,0,w){
				cin >> arr[i][j];
				if(arr[i][j] == '#') ++val;
			}
		}
		
		int ans = 0;
		for(int row = 0;row < (1 << h); ++row){
			bool vis[h][w];
			memset(vis,false,sizeof(vis));
			
			int cnt = 0;
			for(int i = 0; i < h; ++i){
				if(row & (1 << i)){
					for(int j = 0; j < w; ++j){
						vis[i][j] = true;
						if(arr[i][j] == '#') ++cnt;
					}
				}
			}
						
			for(int col = 0;col < (1 << w); ++col){
				int temp = cnt;
				for(int i = 0; i < w; ++i){
					if(col & (1 << i)){
						for(int j = 0; j < h; ++j){
							if(vis[j][i] == false){
								if(arr[j][i] == '#') ++temp;
							}
						}
					}
				}
				if((val - temp) == k) ++ans;
			}						
		}
		
		cout << ans;
	}	
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;



int main()
{

    ll n;
    cin>>n;
    ll ar[n+10];
    for(ll i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    ll ans=n;
    ll c=0;
    ll i=0;
    ll k=1;
    while(i<n)
    {
        if(ar[i]==k)
        {
            c++;
            k++;
        }
        i++;
    }
    if(!c)
        cout<<-1<<nn;
    else
        cout<<n-c<<nn;



}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 5168
#include<stdio.h>
int main()
{
	int h,w,k,temp;
	scanf("%d %d %d",&h,&w,&k);
	if(h > w) temp = h;
	else temp = w;
	int count = 1;
	for(int i = temp;i<k;i += temp)
	{
		count++;
	}
	printf("%d\n",count);
	return 0;
}

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


int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if( (a + b)> (c+ d)){
        cout << "Left" << endl;
    }else if ((a + b) ==(c+d)){
        cout << "Balanced" << endl;

    }else{
        cout << "Right" <<endl;
    }
}

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

int main() {
	// your code goes here
	int n,m,x,i;
	cin>>n>>m>>x;
	int a[m];
	int c[n+1]={0};
	for(i=0;i<m;i++)
	{
	    cin>>a[i];
	    c[a[i]]=1;
	}
	int p=0,q=0;
	for(i=x;i<n;i++)
	{
	    if(c[i]!=0)
	    p++;
	}
	for(i=x;i>0;i--)
	{
	    if(c[i]!=0)
	    q++;
	}
	cout<<min(p,q)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector <int> A(n,0);
    for (int i=0;i<n;i++) {cin>>A[i];}
    sort(A.begin(),A.end());
    int ats=0;
    for (int i=0;i<k;i++) {ats+=A[i];}
    cout<<ats<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int N=105;
const int M=1e7+10;
int dp[M][2];
int a[N],n,k;
int dfs(int k,int t)
{
	if(dp[k][t]>0) return dp[k][t];
	int ans=0,i;
	for(i=1;i<=n;i++)
		if(k>=a[i]) ans|=!dfs(k-a[i],!t);
	return dp[k][t]=ans;
}
int main()
{
	int i,j;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	if(dfs(k,0)==false) printf("Second\n");
	else printf("First\n");
	return 0;
}

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var n = ReadInt();
                if (n == 0) return;
                var c = Read().ToCharArray();
                var array = new int[n];

                var ba = 0;
                for (int i = 1; i <= 100; i++)
                {
                    if (c[i - 1] == 'M')
                    {
                        array[i % n]++;
                    }
                    else if (c[i - 1] == 'L')
                    {
                        //姫
                        array[i % n]++;
                        array[i % n] += ba;
                        ba = 0;
                    }
                    else
                    {
                        //坊主
                        array[i % n]++;
                        ba += array[i % n];
                        array[i % n] = 0;
                    }
                }
                var src = array.OrderBy(x => x);
                WriteLine(string.Join(" ", src) + " " + ba);
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 18268
N = int(input())
num = list(map(int, input().split(" ")))
oparation = 10 ** 8

for i in range(N):
    temp = 0
    while(1):
        if(num[i] % 2 or num[i] == 0):
            break
        else:
            num[i] /= 2
            temp += 1
    if(oparation > temp):
        oparation = temp
        
print(oparation)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll n,x;
ll dfs(ll a,ll b) {
	if(b%a==0) return 2*b-a;
	return b/a*a*2+dfs(b%a,a);
}
int main() {
	cin>>n>>x;
	cout<<dfs(x,n-x)+n;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;


int main(){
    int N, K; cin >> N >> K;
    vector<int> V;
    while(N >= K){
        V.push_back(N%K);
        N = N / K;
    }
    V.push_back(N);
    int ans = V.size();
    if(V[V.size()-1] == 0) ans -= 1;
    cout << ans << endl;
}

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

def main():
  s = input().strip()
  yy, mm = map(int, [s[:2], s[2:]])
  if 1 <= yy <= 12 and 1 <= mm <= 12:
    print('AMBIGUOUS')
  if not (1 <= yy <= 12) and 1 <= mm <= 12:
    print('YYMM')
  if 1 <= yy <= 12 and not (1 <= mm <= 12):
    print('MMYY')
  if not(1 <= yy <= 12) and not (1 <= mm <= 12):
    print('NA')

if __name__=='__main__':
  main()



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

int main() {
    int l, r, d;
    cin >> l >> r >> d;

    cout << r / d - (l - 1) / d << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int main(){
  string cmd;
  priority_queue<int> Q;
  while(cin >> cmd && cmd != "end"){
    if(cmd == "insert"){
      int k;
      cin >> k;
      Q.push(k);
    }else if(cmd == "extract"){
      int n = Q.top();
      Q.pop();
      cout << n << endl;
    }
  }
}

Measured memory_bytes: 7136
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>b)
    b+=360;
  double t=(a+b)/2.0;

  if(abs(a-t)>90-0.0001)
    t+=180;
  
  while(t>360-0.0001)
    t-=360;

  cout<<t<<endl;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
//have submited with my brother account becuase of forget to swap accounts
int ac=0,wa=0,re=0,tle=0,n;
scanf("%d",&n);
while(n--){
    string s;
    cin>>s;
    if(s=="AC"){
        ac++;
    }
    else if(s=="WA"){
        wa++;
    }
    else if(s=="TLE"){
        tle++;
    }
    else if(s=="RE"){
        re++;
    }
}
printf("AC x %d\n",ac);
printf("WA x %d\n",wa);
printf("TLE x %d\n",tle);
printf("RE x %d\n",re);

    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

long long P = 1000000007;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;

  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }

  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }

  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }

  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }

  long long mul(long long a, long long b) { return (a * b) % P; }

  long long add(long long a, long long b) { return (a + b) % P; }

  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

C cmb(1000000);

ll f(ll a, ll b) {
  return ((cmb.fac[a + b] * cmb.facInv[a]) % P * cmb.facInv[b]) % P;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    ll rest = n - k - (i - 1);
    ll rsep = i;
    ll best = k - i;
    ll bsep = i - 1;

    if (rest < 0 || best < 0) {
      cout << 0 << endl;
      continue;
    }
    ll r = f(rest, rsep);
    ll b = f(best, bsep);
    cout << (r * b) % P << endl;
  }
  return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, M;
	cin >> N >> M;
	cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}

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


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

vector<P>E[3000];
int d[3000];
int main() {
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	rep(i, m) {
		int a, b, l; scanf("%d%d%d", &a, &b, &l);
		a--; b--;
		E[a].push_back(P(l, b));
		E[b].push_back(P(l, a));
	}
	priority_queue<P, vector<P>, greater<P>>que;
	memset(d, 0x3f, sizeof(d));
	rep(i, k) {
		int s; scanf("%d", &s); s--;
		d[s] = 0;
		que.push(P(0, s));
	}
	while (!que.empty()) {
		P p = que.top(); que.pop();
		if (d[p.second] != p.first)continue;
		for (P u : E[p.second]) {
			if (d[u.second] > p.first + u.first) {
				d[u.second] = p.first + u.first;
				que.push(P(d[u.second], u.second));
			}
		}
	}
	double Max = 0;
	rep(i, n) {
		for (P u : E[i]) {
			double t = (u.first + abs(d[i] - d[u.second])) / 2.;
			Max = max(Max, min(d[i], d[u.second]) + t);
		}
	}
	printf("%d\n", (int)round(Max));
}

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

int main() {
    int N;
    cin >> N;
    
    if(N<10) cout<<N;
    else if(N<100) cout<<9;
    else if(N<1000) cout<<N-99+9;
    else if(N<10000) cout<<900+9;
    else if(N<100000) cout<<N-9999+900+9;
    else cout<<90000+900+9;
  cout<<endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::collections::*;

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

#[macro_export]
macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let N = read!(usize);
	let ps = read!([f64]);
	let mut dp = vec![0.0; N + 1];
	dp[0] = 1.0;
	for i in 0..N {
		for j in (1..N+1).rev() {
			dp[j] = dp[j] * (1.0 - ps[i]) + dp[j - 1] * ps[i];
		}
		dp[0] *= 1.0 - ps[i];
	}
	println!("{}", dp.into_iter().skip(N / 2 + 1).sum::<f64>());
}


Measured memory_bytes: 8572
#include<stdio.h>
  
int main(){
  int A,B,C;
  //1<= A,B,C <=9 から良い
  scanf("%d %d %d", &A, &B, &C);
  int count = 0;
  if(A==B) count++;
  if(B==C) count++;
  if(C==A) count++;
  if(count == 1){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


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

int main() {
	long long x;
	long long a, b;
	long long s[1000];

	cin >> x;

	for (long long i=0; i<1000; i++) {
		s[i] = i * i * i * i * i;
	}

	b = 0;
	for (a=0; a<1000; a++) {
		if (s[a] == x) {
			goto answer;
		} else if (s[a] < x) {
			for (b=0; b<1000; b++) {
				long long tmp = s[a] + s[b];
				if (tmp == x) {
					b = -b;
					goto answer;
				} else if (tmp > x) {
					break;
				}
			}
		} else {
			for (b=0; b<1000; b++) {
				long long tmp = s[a] - s[b];
				if (tmp == x) {
					goto answer;
				} else if (tmp < x) {
					break;
				}
			}
		}
	}

answer:
	cout << a << " " << b << endl;

	return 0;
}


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


int main() {
    int n,c=0;
	cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    for(int i=0; i<n; i++){
        c++;
        if(i==n-1){
            break;
        }
        if(s.at(i)==s.at(i+1)){
            c--;
        }
    }
    cout << c << endl;
}


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

int main() {
	long long n,m,i,j,k,ans=0,cur=1,res=0;
	cin >> n >> cur;
	j=0;
	for(i=1; i<n; i++){
		cin >> res;
		if(cur>=res){
			j++;
			ans=max(ans,j);
			
		}else{
			j=0;
		}
		cur=res;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
if((s[0] == 'A' && s[1] == 'A' && s[2] == 'A') || (s[0] == 'B' && s[1] == 'B' && s[2] == 'B'))
cout<<"No";
  else
    cout<<"Yes";
  
  return 0;
}

Measured memory_bytes: 256
//diverta2019_d.cpp
//Sat May 11 20:39:56 2019

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

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

	ll ans;
	for (ll i=1;i*i<n;i++){
		if (n%i==0 && n%((n-i)/i)){
			ans += (n-i)/i;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	cout << n*n*n << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, K;
  cin >> N >> K;
  if (N-N/2>=K) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int n;
void dfs(string s, char c){
    if(s.size() == n){
        cout << s << endl;
        return;
    }
    for(char i='a'; i<=c; ++i){
        string t = s;
        t += i;
        dfs(t, (i==c)?c+1:c);
    }
}

int main() {

    cin >> n;
    dfs("", 'a');

    return 0;
}

Measured memory_bytes: 1536
/*
title:

url:

わからなかったので解答を見た。
1次元の時から類推していけばとけたか...?
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007
#define int long long

typedef pair<int, int> p_i;

signed main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> sum[8];
    int x[8] = {1, -1, 1, 1, 1, -1, -1, -1};
    int y[8] = {1, 1, -1, 1, -1, 1, -1, -1};
    int z[8] = {1, 1, 1, -1, -1, -1, 1, -1};

    for (int i = 0; i < n; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        for (int j = 0; j < 8; j++)
        {
            sum[j].push(a * x[j] + b * y[j] + c * z[j]);
        }
    }

    int ans = -INF;
    for (int i = 0; i < 8; i++)
    {
        int tmp = 0;
        for (int j = 0; j < m; j++)
        {
            tmp += sum[i].top();
            sum[i].pop();
        }
        if (tmp > ans)
        {
            ans = tmp;
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    string s;cin>>s;
    int w;cin>>w;
    int x=0;

    while(x<s.size()){
        cout<<s[x];
        x+=w;
    }
    cout<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
int n,arr[101];
int cal(int a,int b){return (arr[a]+arr[b])*(abs(a-b));}
void Min(int &a,int b){a=min(a,b);}

int mem[3][101][101][101];
int dfs(int f,int num,int l,int r){
  if(l>r)return 0;
  if(l==r)return (arr[l]==l+1) ? INF:0;
  if(r-l==1)return (arr[l]==l+1||arr[r]==r+1)? cal(l,r):0;
  if(mem[f][num][l][r]!=-1)return mem[f][num][l][r];

  int res=INF;  
  for(int i=l+1;i<r;i++){
    if((f==0||f==1)&&arr[i]!=l+1){
      swap(arr[l],arr[i]);
      Min(res,cal(l,i)+dfs(0,0,l+1,i-1)+dfs(1,arr[i],i,r));
      swap(arr[l],arr[i]);
    }
    if((f==0||f==2)&&arr[i]!=r+1){
      swap(arr[i],arr[r]);
      Min(res,cal(i,r)+dfs(2,arr[i],l,i)+dfs(0,0,i+1,r-1));
      swap(arr[i],arr[r]);
    }
  }

  for(int i=l;i<r;i++){
    int a=(f==1)? dfs(f,num,l,i):dfs(0,0,l,i);
    int b=(f==2)? dfs(2,num,i+1,r):dfs(0,0,i+1,r);
    Min(res,a+b);
  }

  return mem[f][num][l][r]=res;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>arr[i];
  memset(mem,-1,sizeof(mem));
  cout<<dfs(0,0,0,n-1)<<endl;
}

Measured memory_bytes: 15184
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    while (true) {
		    String[] line = br.readLine().split(" ");

		    int n = Integer.parseInt(line[0]);
		    int x = Integer.parseInt(line[1]);

		    if (n == 0 && x == 0) break;

		    int resultCount = 0;
		    for (int i = 1; i <= n; i++) {
		    	for (int j = i + 1; j <= n; j++) {
		    		for (int k = j + 1; k <= n; k++) {

		    			if (i + j + k == x) {
		    				resultCount++;
		    			}
		    		}
		    	}
		    }
		    System.out.println(resultCount);
	    }
	}
}

Measured memory_bytes: 25084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	int n, p;	cin >> n >> p;
	ll odd = 0, even = 1;
	rep(i, n) {
		int a;	cin >> a;
		if (a & 1) {
			ll s = even + odd;
			even = odd = s;
		}
		else {
			odd <<= 1;	even <<= 1;
		}
	}
	cout << (p ? odd : even) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nk = in.readLineAsIntArray();
        int N = nk[0];
        int K = nk[1] - 1;
        String S = in.readLine();
        StringBuilder str = new StringBuilder();
        for(int i=0; i<S.length(); i++){
            if(i==K){
                str.append(Character.toLowerCase(S.charAt(i)));
            }else{
                str.append(S.charAt(i));
            }
        }
        System.out.println(str.toString());

    }



    static class CustomReader extends BufferedReader {

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

    }
}

Measured memory_bytes: 20180
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	vector<lli> v[26];

	string s;
	cin>>s;

	REP(i,0,s.size()){
		v[s.at(i)-'a'].push_back(i);
	}

	lli cnt=0;
	string t;
	cin>>t;
	REP(i,0,t.size()){
		if(DEBUG)cout<<cnt<<endl;
		lli now = t.at(i)-'a';
		auto index = lower_bound(v[now].begin(),v[now].end(),cnt%s.size());
		if(index!=v[now].end()){
			lli diff = cnt/s.size()*s.size();
			cnt = diff+(*index)+1;
			continue;
		}
		cnt = (cnt/s.size()+1)*s.size();
		index = lower_bound(v[now].begin(),v[now].end(),cnt%s.size());
		if(index!=v[now].end()){
			lli diff = cnt/s.size()*s.size();
			cnt = diff+(*index)+1;
			continue;
		}
		cout<<-1<<endl;
		return 0;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    ll N,x;
    cin>>N>>x;
    bool ok=true,o=true;
    if(x == 1 || x == 2*N-1)o = false;
    if(N<x){
        x=2*N-x;
        ok = false;
    }
    v ans(2*N);
    ll c = 1;
    rep(i,N-(x-1),N+(x-1)+1){
        ans[i] = c;
        c++;
    }
    rep(i,1,N-(x-1)){
        ans[i] = c;
        c++;
    }
    rep(i,N+(x-1)+1,2*N){
        ans[i] = c;
        c++;
    }
    if(o){
        cout<<"Yes"<<endl;
        rep(i,1,2*N){
            if(!ok)cout<<2*N-ans[i]<<endl;
            else cout<<ans[i]<<endl;
        }
    }
    else cout<<"No"<<endl;

    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    if (n & 1) {
        for (int i = 0; i < m; i++) {
            cout << i + 1 << ' ' << n - i << endl;
        }
    } else {
        for (int i = 0; i < m; i++) {
            if (i * 2 < (n - 2) / 2) cout << i + 1 << ' ' << n - i << endl;
            else cout << i + 1 << ' ' << n - i - 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3656