akhauriyash/Code-Regression huggingface dataset:
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        String A=s.nextLine();
        String B=s.nextLine();
        String C=s.nextLine();
        Queue<Character> qA=new LinkedList<>();
        Queue<Character> qB=new LinkedList<>();
        Queue<Character> qC=new LinkedList<>();
        for(int i=0;i<A.length();i++){
            qA.add(A.charAt(i));
        }
        for(int i=0;i<B.length();i++){
            qB.add(B.charAt(i));
        }
        for(int i=0;i<C.length();i++){
            qC.add(C.charAt(i));
        }
        char curr_char='a';
        while(!qA.isEmpty() || !qB.isEmpty() || !qC.isEmpty()){
            if(curr_char=='a'){
                if(qA.isEmpty()){
                    System.out.println("A");
                    break;
                }

                curr_char=qA.remove();
            }
            if(curr_char=='b'){
                if(qB.isEmpty()){
                    System.out.println("B");
                    break;
                }

                curr_char=qB.remove();
            }
            if(curr_char=='c'){
                if(qC.isEmpty()){
                    System.out.println("C");
                    break;
                }
                curr_char=qC.remove();
            }
        }


    }
}


Measured memory_bytes: 21332
#include <stdio.h>

int main(void){

int tall[10];
int a,i,j,tmp;	
for (a=0; a<=9; a++){	
	do{
	scanf("%d",&tall[a]);
	} 
	while(tall[a]<0||tall[a]>10000);
}
	for(i=0; i<=9; ++i){
		for(j=i+1; j<=9; ++j){
			if(tall[i] < tall[j]){
				tmp=tall[i];
				tall[i]=tall[j];
				tall[j]=tmp;
			}
		}
	}
	printf("%d\n",tall[0]);
	printf("%d\n",tall[1]);
	printf("%d\n",tall[2]);				
return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main ()
{
	int i,n;
	while(scanf("%d",&n)!=EOF)
	{
		int a=0,b=0,t;
		for(i=0;i<n;i++)
		{
			scanf("%d",&t);
			if(t%2==0)
				a++;
			if(t%4==0)
				b++;
		}
		a=a-b;
		if((n-a)<=2*b&&a!=0)
			printf("Yes\n");
		else if((n-a-1)<=2*b&&a==0)
			printf("Yes\n");
		else
			printf("No\n");
	}
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}


int main(void){
 
  double w, h, x, y;
  cin>>w>>h>>x>>y;

  std::cout << std::setprecision(20) <<w*h/2.0<<" ";
  if(x==w/2.0 && y==h/2.0){
    cout<<"1"<<endl;
  }else{
    cout<<"0"<<endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::cout << std::count_if(S.begin(), S.end(), [](const char& S_i) { return S_i == '1'; }) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

const int MAX_V = 2100;
int V; //????????°
struct edge { int to, cap, cost, rev; };
vector<edge> G[MAX_V];
int dist[MAX_V]; //???????????¢
int prevv[MAX_V], preve[MAX_V];
void add_edge(int from, int to, int cap, int cost) { // from->to????????????cap,?????????cost???????????????
	G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
	G[to].push_back((edge){from, 0, -cost, (int)G[from].size() - 1});
}
// s??????t????????????f???????°??????¨???????±??????? ??????????????´??????-1
int min_cost_flow(int s, int t, int f) {
	int res = 0;
	while(f > 0) {
		fill(dist, dist + V, INF);
		dist[s] = 0;
		bool update = true;
		while(update) {
			update = false;
			for (int v = 0; v < V; ++v){
				if(dist[v] == INF)continue;
				for (int i = 0; i < G[v].size(); ++i){
					edge &e = G[v][i];
					if(e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
						dist[e.to] = dist[v] + e.cost;
						prevv[e.to] = v;
						preve[e.to] = i;
						update = true;
					}
				}
			}
		}
		if(dist[t] == INF) return -1;

		int d = f;
		for (int v = t; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d * dist[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

int main(void) {
	while(1) {
		int n; scanf("%d", &n);
		if(n == 0) break;
		int start = 2 * n, goal = 2 * n + 1;
		int l[1010], r[1010], w[1010];
		rep(i, n) scanf("%d %d %d", &l[i], &r[i], &w[i]);
		rep(i, MAX_V) G[i].clear();

	
		rep(i, n) add_edge(start, 2 * i, 1, 0);
		rep(i, n) add_edge(2 * i + 1, goal, 1, 0);
		rep(i, n) add_edge(2 * i, 2 * i + 1, 1, -w[i]);
		rep(i, n)rep(j, n){
			if(i == j) continue;
			if(r[i] < l[j]) add_edge(2 * i + 1, 2 * j, 1, 0);
		}
		// printf("k\n");
		V = 2 * n + 2;
	

		/*
		rep(i, 365) add_edge(i, i + 1, 2, 0);
		rep(i, n) add_edge(l[i] - 1, r[i], 1, -w[i]);
		V = 366;
		int re = min_cost_flow(0, 365, 2);
		printf("%d\n", -re);
		*/
		
		int ret = min_cost_flow(start, goal, 2);
		printf("%d\n", -ret);
		
	}
	return 0;
}

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

int main() {

  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  /*if((a[0] > a[1] && a[2] > a[0]) || (a[2] < a[0] && a[0] < a[1])) {
    cout << abs(a[2] - a[0]) + abs(a[0] - a[1]) << endl;
  }
  else if ((a[2] > a[1] && a[0] > a[2]) || (a[2] < a[1] && a[1] < a[0])) {
    cout << abs(a[2] - a[0]) + abs(a[2] - a[1]) << endl;
  }
  else 
    cout << abs(a[1] - a[0]) + abs(a[1] - a[2]) << endl;
    */
  vector<int> b;
  b.push_back(abs(a[2]-a[0])+abs(a[1]-a[0]));
  b.push_back(abs(a[1]-a[2])+abs(a[0]-a[2]));
  b.push_back(abs(a[1]-a[0])+abs(a[2]-a[1]));
  sort(b.begin(),b.end());

  cout << b[0] << endl;

  return 0;

}



Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let s = i::cmap(n);

    let native: usize = s
        .iter()
        .map(|s| {
            let mut a = false;
            let mut count: usize = 0;
            for c in s {
                if a && *c == 'B' {
                    count += 1;
                }
                a = *c == 'A'
            }
            count
        })
        .sum();
    let xa = s
        .iter()
        .filter(|s| s[0] != 'B' && s[s.len() - 1] == 'A')
        .count();
    let bx = s
        .iter()
        .filter(|s| s[0] == 'B' && s[s.len() - 1] != 'A')
        .count();
    let ba = s
        .iter()
        .filter(|s| s[0] == 'B' && s[s.len() - 1] == 'A')
        .count();
    println!(
        "{}",
        native
            + match (xa, bx) {
                (0, 0) =>
                    if ba > 0 {
                        ba - 1
                    } else {
                        0
                    },
                (a, b) => min(a + ba, b + ba),
            }
    );
    //dbg!(native, xa, bx, ba);
}

use i::cmap;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)
int main()
{
    int n=0;
    char a[4];
    cin >> a;
    REP(i,3)
    {
        if(a[i]=='1')
        {
            n++;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<int,int>
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,k,l,m,a,b,t,sum,sum1,flag;
    cin>>n;
    string s;
    sum=0,sum1=0,k=0,m=0;
    while(n--){
        cin>>s;

        if(s=="AC"){
            sum+=1;
        }
        if(s=="WA"){
            k+=1;
        }
        if(s=="TLE"){
            sum1+=1;
        }

        if(s=="RE"){
            m+=1;
        }
    }
    cout<<"AC x "<<sum<<endl;
    cout<<"WA x "<<k<<endl;
    cout<<"TLE x "<<sum1<<endl;

    cout<<"RE x "<<m<<endl;

}



Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2])  cout<<"Yes";
	else if(s[1]==s[2]&&s[2]==s[3])  cout<<"Yes";
	else  cout<<"No";
	return 0;
}

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

int main() {
 int H,W;
 cin >> H >> W;
  int cnt = 0;
  int a = H;
  int b = W;
  vector<vector<char>>data(H,vector<char>(W));
  for(int i=0;i<H;i++){
  for(int j=0;j<W;j++){
   cin >> data.at(i).at(j);                                                           
   }
  }
    for(int i=0;i<H;i++){
  for(int j=0;j<W;j++){
     if(data.at(i).at(j) == '.')
       cnt++;
     if(j == W-1){
     if(cnt == W){
       a--;
     for(int k=0;k<W;k++)
       data.at(i).at(k) = '+';
     }
     cnt = 0;  
     }
   }
  }
   for(int i=0;i<W;i++){
  for(int j=0;j<H;j++){
     if(data.at(j).at(i) == '.'||data.at(j).at(i) == '+')
       cnt++;
     if(j == H-1){
     if(cnt == H){
       b--;
     for(int k=0;k<H;k++)
       data.at(k).at(i) = '+';
     }
     cnt = 0;  
     }
   }
  }
  int c = 0,d = 0;
  for(int i=0;i<H;i++){
  for(int j=0;j<W;j++){
  if(data.at(i).at(j) != '+'){
    c++;
    if(c == b){
    cout << data.at(i).at(j) << endl;
    c = 0;
    }
    else
    cout << data.at(i).at(j);
  }
  }
  } 
}

Measured memory_bytes: 256
N,M = gets.chomp.split.map(&:to_i)

s = []
1.upto(M) do |m|
  s[m] = gets.chomp.split.map(&:to_i)
  s[m].shift
end

p = gets.chomp.split.map(&:to_i)

ans = 0
[0,1].repeated_permutation(N) do |arr|
  flag = false
  1.upto(M) do |m|
    sum = 0
    s[m].each do |ss|
      sum += arr[ss-1]
    end
    if sum % 2 != p[m-1]
      flag = true
      break
    end
  end
  next if flag
  ans += 1
end
p ans


Measured memory_bytes: 14384
<?php

$is_honban = 1;

if ($is_honban) {
  //----------------------------------------------------------------------------------
  // Input for honban
  //----------------------------------------------------------------------------------
  $sc = new Scanner();
  $n = $sc->nextInt();
  $a = array();
  for ($i = 0; $i < $n; $i++) {
    $a[] = $sc->nextInt();
  }


} else {
  //----------------------------------------------------------------------------------
  // Input for test
  //----------------------------------------------------------------------------------
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  $n = 3;
  $a = array('382253568','723152896','37802240','379425024','404894720','471526144');



}
//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

while (1) {
  for ($i = 0; $i < $n; $i++) {
    if ($a[$i] % 2 == 1) { break 2; }
    else { $a[$i] /= 2; }
  }
  $ans++;
}



//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
out::println($ans);



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;
  public function next() {
    if($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    ll N;
    cin >> N;
    vl A(N);

    for(ll i=0; i <N; i++){
        cin >> A.at(i);
    }
    ll odd = 0;
    for(ll i=0; i <N; i++){
        if(A.at(i)%2 == 1){
            odd++;
        }
    }

    if(odd % 2 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main() {
	long long n, k, m, temp;
	int cnt = 3;
	cin >> n >> k;
	m = n;
	if (m > 0){
		if (n > k) {
			n = n % k;
			m = min(m, n);
		}
		for (int i = 0; i < 2;++i) {
			n = abs(n - k);
			m = min(m, n);
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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

ll dp[1000+5][(1<<12)+5];
void solve(){
	int n,m;
    cin>>n>>m;
    rep(i,m+5){
        rep(j,(1<<n)+5)dp[i][j]=INF;//最小値なのでINFで初期化
    }
    dp[0][0]=0;
    vector<ll>a(m),b(m),st(m,0);
    rep(i,m){
        cin>>a[i]>>b[i];
        rep(j,b[i]){
            ll x;
            cin>>x;
            x--;//bit表記
            st[i]+=(1<<x);
        }
    }
    rep(i,m){
        for(int j=0;j<(1<<n);++j){
            chmin(dp[i+1][j],dp[i][j]);//i番目のカギを使わない場合
            chmin(dp[i+1][j|st[i]],dp[i][j]+a[i]);//使う場合
        }
    }
    cout<<(dp[m][(1<<n)-1]!=INF?dp[m][(1<<n)-1]:-1)<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 32512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h[100001];
ll dp[100001];
int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n] << endl;
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	bool findc = false;
	for(int i = 0;i < s.size();i++){
		if(s.at(i) == 'C' && findc == false){
			findc = true;
		}
		if(s.at(i) == 'F' && findc == true){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a);
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef double db;
const int N = 200+10;
const db EPS = 1e-9;
using namespace std;

void dbg() {cout << "\n";}
template<typename T, typename... A> void dbg(T a, A... x) {cout << a << ' '; dbg(x...);}
#define logs(x...) {cout << #x << " -> "; dbg(x);}

int n,a[N];

int main()
{
	scanf("%d",&n);
	rep(i,1,2*n) scanf("%d",&a[i]);
	sort(a+1,a+1+2*n);
	int ans = 0;
	for(int i = 1; i <= 2*n; i += 2) ans += a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// Example program
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main()
{
    int a; int b; int c; int d; int e; int f; int g; int h;
    cin>>a>>b>>c>>d>>e>>f>>g>>h;
   vector<int>v{a+b+c+d,e+f+g+h};
   sort(v.begin(),v.end());
   cout << v[1] << endl;
}

Measured memory_bytes: 3148
N,X = map(int,input().split())

def dp(n,x):
    if x == 0:
        return 0
    if n == 0:
        return 1
    if x <= 2**(n+1)-2:
        return dp(n-1,x-1)
    else:
        return 2**n+dp(n-1,x-2**(n+1)+1)

print(dp(N,X))

Measured memory_bytes: 38256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a[150],n,i,j,sum=0,x=0,b[150];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
        b[i]=sum;
    }
    for(i=0;i<n;i++)
    {
        b[i]=abs(2*b[i]-sum);
    }
    sort(b,b+n);
    printf("%d\n",b[0]);
    return 0;
}


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

const int N = 1e5 + 10;
ll x[N];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> x[i];
    ll ans = 1e18, tmp = 0;
    for (int i = k; i <= n; i++) {
        ll xl = x[i - k + 1], xr = x[i];
        if (xr <= 0) tmp = labs(xl);
        else if (xl >= 0) tmp = labs(xr);
        else tmp = xr - xl + min(labs(xl), labs(xr));
        ans = min(ans, tmp);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4396
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}
vector <int> v[29];


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
	string s;
	cin >> s;
	for (int i = 0; i < 26; i++) {
		v[i].pb(0);
	}
	for (int i = 0; i < s.size(); i ++) {
		v[s[i] - 'a'].pb(i + 1);
	}
	for (int i = 0; i < 26; i++) {
		v[i].pb((int)s.size() + 1);
	}             
	int mn = MOD;
    for (int i = 0; i < 26; i++) {
    	if (v[i].size() == 2) continue;
    	int res = 0;
    	for (int j = 0; j < v[i].size() - 1; j++) {
			res = max(res, v[i][j + 1] - v[i][j]);												    	
    	}
    	mn = min(mn, res);
    }
    cout << mn - 1<< endl;
    return 0;
}                

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll n; cin >> n;
  vector<ll> v(n,0);
  for(ll i=2; i<=n;i++){
    ll a; cin >> a;
    v[a-1]++;
  }
  for(auto e:v){
    cout << e << endl;
  }


  return 0;
}


Measured memory_bytes: 4840
from sys import stdin
from collections import defaultdict

N, K = [int(x) for x in stdin.readline().rstrip().split()]

S = stdin.readline().rstrip().split()
S2 = ''.join(S)

if K == 1:
    S3 = list(S2[0].lower())
else:
    S3 = list(S2[0])
for i in range(1,N):
  if i+1 == K:
    S3.append(S2[i].lower())
  else:
    S3.append(S2[i])

S4 = ''.join(S3)
print(S4)

Measured memory_bytes: 3316
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
using llint = long long int;
using lint = long int;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
	int x;
	cin >> x;
	cout << ((x == 3 || x == 5 || x == 7) ? "YES" : "NO");
	
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int a[maxn];
int b[maxn];

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

    const int N = 1e5;
    for (int i=0; i<=N; i++) {
	a[i]=1;
    }
    
    a[0]=a[1]=0;
    for (int i=2; i*i<=N; i++) {
	if (a[i]==1) {
	    for (int j=i*i; j<=N; j+=i) {
		a[j]=0;
	    }
	}
    }

    for (int i=2; i<=N; i++) {
	if (a[i]==1) {
	    if (a[(i+1)/2]==1) {
		b[i]=1;
	    }
	}
    }


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

    int q; cin>>q;
    while (q--) {
	int l,r; cin>>l>>r;
	cout<<b[r]-b[l-1]<<"\n";
    }

    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>a>>b;
  k=min(n+a,min(n+b,a+b));
  cout<<k;
  /*if(n<a) cout<<0;
  else cout<<10;*/
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3552
#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 << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    forn(i, 0, n) cin >> a[i] >> b[i];
    ll ans = 0;
    forn(bit, 0, 30) {
        if ((k & (1 << bit)) == 0) continue;
        ll cur = 0;
        forn(i, 0, n) {
            if (a[i] & (1 << bit)) continue;
            bool ok = true;
            forn(j, bit + 1, 30)
                if ((a[i] & (1 << j)) > (k & (1 << j))) {
                    ok = false;
                    break;
                }
            if (ok) cur += b[i];
        }
        setmax(ans, cur);
    }
    {
        ll cur = 0;
        forn(i, 0, n) {
            bool ok = true;
            forn(j, 0, 30)
                if ((a[i] & (1 << j)) > (k & (1 << j))) {
                    ok = false;
                    break;
                }
            if (ok) cur += b[i];
        }
        setmax(ans, cur);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,k;
   cin>> n >> k;
   int d[10000],a[10000],s[10000]={0};
   
   for (int i = 1;i <= k;i++){
       cin >> d[i];
       for (int j = 1;j <= d[i];j++){
           cin >> a[j];
           s[a[j]]++;
       }
   }

   long long cnt = 0;
   for (int i = 1;i <=n;i++){
       if(s[i]==0) {
           cnt++;
       }
   }
   cout << cnt << endl;
 
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
   string S;
   cin >> S;
   int len = (int)S.size();
   if(S[len-1] == '0' + 2 || S[len-1] == '0' + 4 || S[len-1] == '0' + 5 || S[len-1] == '0' + 7 || S[len-1] == '0' + 9){
       cout << "hon" << endl;
   }
   if(S[len-1] == '0' + 0 || S[len-1] == '0' + 1 || S[len-1] == '0' + 6 || S[len-1] == '0' + 8){
       cout << "pon" << endl;
   }
   if(S[len-1] == '0' + 3) cout << "bon" << endl;
   return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <set>

using namespace std;

int main() {
  int n;
  cin >> n;
  set<int> st;
  int a;
  while (cin >> a) {
    auto itr = st.find(a);
    if (itr == st.end())
      st.insert(a);
    else
      st.erase(itr);
  }
  cout << static_cast<int>(st.size()) << endl;
}


Measured memory_bytes: 8208
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> data(n, vector<int>(2));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(d>=pow(pow(data[i][0],2)+pow(data[i][1],2),0.5))
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 14496
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	if ((n&-n)==n) kill("No")
	cout<<"Yes\n";
	cout<<1<<' '<<2<<'\n';
	cout<<2<<' '<<3<<'\n';
	cout<<3<<' '<<1+n<<'\n';
	cout<<1+n<<' '<<2+n<<'\n';
	cout<<2+n<<' '<<3+n<<'\n';
	for (int i=5; i<=n; i+=2){
		cout<<"1 "<<i-1<<'\n';
		cout<<"1 "<<i<<'\n';
		cout<<i-1<<' '<<i+n<<'\n';
		cout<<i<<' '<<i-1+n<<'\n';
	}
	if (n%2==0){
		int lb=(n&-n);
		cout<<lb<<' '<<n+n<<'\n';
		cout<<(n^lb^1)<<' '<<n<<'\n';
		
	}
	
	return 0;
}


Measured memory_bytes: 2304
#include<cstdio>
#include<algorithm>

using namespace std;

long int ab(long int x){
    if (x < 0) return -x;
    else return x;
}

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

    long int a[n];
    for(int i = 0; i < n; i++){
        scanf("%ld", &a[i]);
        a[i] -= (long int)i;
    }

    // for(int i = 0; i < n; i++){
    //     printf("%ld ", a[i]);
    // }
    // puts("");

    sort(a, a + n);

    // for(int i = 0; i < n; i++){
    //     printf("%ld ", a[i]);
    // }
    // puts("");

    long int sm = 0;
    long int b = a[0];
    for(int i = 0; i < n; i++){
        sm += ab(a[i] - b);
    }

    long int ans = sm;
    long int cor = a[0];
    for(int i = 1; i < n; i++){
        long int dif;
        if (cor == a[i]) continue;
        else {
            dif = a[i] - cor;
            cor = a[i];
        }

        sm = sm + dif * i - dif * (n - i);
        if (ans > sm){
            ans = sm;
        }
        // printf("%ld %ld\n", dif, sm);
    }
    
    printf("%ld\n", ans);
    
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int N,K;
	cin>>N>>K;
	//勝つ確率
	 double ret;
	//解の方針
	//各さいころの目の値について何回表を出せばいいか探索する
	//各さいころの値についてn回表を出しつ続ける確率はx=1/N*(1/2)^tで求まる。
	for(int i=1;i<=N;i++)
	{
		 double pa=1.0/N;
		int now=i;
		while(now<K)
		{
			now*=2;
			pa/=2;
		}
		ret+=pa;
	}
	cout<<std::fixed<<std::setprecision(12)<<ret<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:print('Yes');exit()
print('No')


Measured memory_bytes: 62548
#include<stdio.h>
int main()

{
    int n,i,j=0;
    scanf("%d",&n);
    char s[123];


        scanf("%s",s);

    if(n%2==1)
        printf("No");

    else
    {


        for(i=0; i<n/2; i++)
        {
            if(s[i]==s[i+n/2])
               j++;

            //else
              //  printf("No");
        }

        if(j==n/2)
            printf("Yes\n");

        else
            printf("No\n");

    }

    return 0;

}


















Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll j;
    ll i;
    ll f =0;
    for( i=0;i<=25;i++)
    	{
    		for( j=0;j<=25;j++)
    		{
    			if(i*4+j*7 == n)
    			{
    				//cout<<"YES"<<endl;
    				f = 1;
    				break;
    			}
    		}
    	}
    	if(f==0)
    		cout<<"No"<<endl;
    	if(f == 1)
    		cout<<"Yes"<<endl;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        t: usize,
        x: usize,
    }
    let ans = t as f64 / x as f64;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
double bd[] = {48,51,54,57,60,64,69,75,81,91};
string cs[] = {"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
int main()
{
  double w;
  while(cin>>w){
    string str = cs[10];
    for(int i = 0;i < 10;i++){
      if(w <=bd[i]){
	str = cs[i];
	break;
      }
    }
    cout <<str<<endl;
  }
  return 0;
}

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

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<long> > arr1;
  arr1.resize(n);
  for(int i =0;i<n;i++){
    arr1[i].resize(m);
    for(int j=0;j<m;j++){
      cin >> arr1[i][j];
    }
  }

  vector<vector<long> > arr2;
  arr2.resize(m);
  for(int i =0;i<m;i++){
    arr2[i].resize(l);
    for(int j=0;j<l;j++){
      cin >> arr2[i][j];
    }
  }

  vector<vector<long> > arr3;
  arr3.resize(n);
  for(int i =0;i<n;i++){
    arr3[i].resize(l);
    for(int j=0;j<l;j++){
      for(int k=0;k<m;k++){
        arr3[i][j] += arr1[i][k]*arr2[k][j] ;
        }
      if (j != l-1)
      cout << arr3[i][j] << " ";
      else
      cout << arr3[i][j];
     }
    cout << "\n";
  }
  return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    char s[4];
    cin >> s;
    sort(s, s+4);
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vector<vector<pii>> A(N);
  vii C(N);
  rep(i,0,M){
    int X,Y,Z; cin>>X>>Y>>Z;
    A[X-1].pb(mp(Y-1,Z));
    C[Y-1].pb(X-1);
  }
  priority_queue<pii> Q;
  Q.push(mp(0,0));
  vi B(N);
  vector<bool> F(N);
  F[N-1]=1;
  queue<int> q;
  q.push(N-1);
  while(q.size()>0){
    int X=q.front();
    q.pop();
    rep(i,0,C[X].size()){
      int Y=C[X][i];
      if(!F[Y]){
        F[Y]=1;
        q.push(Y);
      }
    }
  }
  vi G(N,-INF);
  G[0]=0;
  while(Q.size()>0){
    int X=Q.top().second,Y=Q.top().first; Q.pop();
    if(G[X]>Y) continue;
    if(B[X]>N){
      cout<<"inf"<<endl;
      return 0;
    }
    rep(i,0,A[X].size()){
      int P=A[X][i].first,R=A[X][i].second+Y;
      if(F[P]&&G[P]<R){
        G[P]=R;
        Q.push(mp(R,P));
        B[P]++;
      }
    }
  }
  cout<<G[N-1]<<endl;
  }



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

int main() {
  ll x;cin>>x;
  int n=120;
  ll p[n];rep(i,n)p[i]=(ll)(i*i*i)*(ll)(i*i);
  //cout<<p[n-1]<<endl;
  
  ll y;
  rep(i,n) rep(j,n) {
    y = p[i] + p[j];
    if (y==x) {
      cout << i << " " << (j*-1);
      return 0;
    }
    if (i>j) {
      y = p[i]-p[j];
      if (y==x) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n),sum(n,0),ans(n,0);
  rep(i,n){
    cin >> t1;
    t1--;
    vec[i] = t1;
    sum[t1]++;
  }
  ll req = 0;
  rep(i,n){
    ans[i] = sum[i] * (sum[i]-1) / 2;
    req += ans[i];
  }
  rep(i,n){
    ll piv = vec[i];
    cout << req - ans[piv] + (sum[piv] - 1) * (sum[piv] - 2) / 2 << endl;
  }
}

Measured memory_bytes: 7936
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;

vector<int> v;

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

	v.resize(n);

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

	int res = 0;
	for (int i = 0; i < n - 1; i++)
	{
		for (int k = i + 1; k < n; k++)
		{
			res += v[i] * v[k];
		}
	}

	cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int f(int n) {
  int sum = 0;
  REP(i,100000) {
    sum += i;
    if (sum >= n) return i;
  }
  return -1;
}

void solve() {
  int N;
  cin >> N;
  const int m = f(N);
  vector<int> res;
  for (int i = m; i > 0; --i) {
    if (N >= i) {
      res.push_back(i);
      N -= i;
    }
  }
  sort(ALL(res));
  for (int i: res) cout << i << endl;
  return;
}


Measured memory_bytes: 384
// PCK2018 Yosen Q9 on line
// YAMADA Terushige 2018.9.30.

#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>

using namespace std;

int gcm(int a,int b){
  while(b!=0){
    int t=b;
    b=a%b;
    a=t;
  }
  return a;
}

struct point{
  int x,y;
  point(const int& px,const int& py):x(px),y(py) {};
};
  
pair <int,int> slope(point a,point b){
  int dx=a.x-b.x;
  int dy=a.y-b.y;
  if(dx<0){
    dx*=-1;
    dy*=-1;
  }
  int g=gcm(abs(dx),abs(dy));
  dx/=g;
  dy/=g;
  return make_pair(dx,dy);
}
	 
int main(){
  int N,K;
  cin >> N >> K;
  vector <point> p;
  for(int i=0;i<N;i++){
    int x,y;
    cin >> x >> y;
    p.push_back(point(x,y));
  }

  for(int i=0;i<N-1;i++){
    map < pair<int,int> ,int> sl;
    for(int j=i+1;j<N;j++){
      int num = ++sl[slope(p[i],p[j])];
      if(num >= K-1){
	cout << 1 << endl;
	return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 3308
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
vector<int>v[100001];
int main(){
    string A;
    cin>>A;
    LL sum[26]={0};
    LL ans=(LL)A.size()*(A.size()-1)/2;
    for(int i=0;i<A.size();i++){
        sum[A[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        ans-=sum[i]*(sum[i]-1)/2;
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 2948
n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 5] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
                dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])


Measured memory_bytes: 13976
#include <bits/stdc++.h>
using namespace std;
int r,c;//行数、列数
int n;//颜色总数
int x,y;//当前待着色点坐标
int ans[200][200];//答案记录表

int main()
{
    cin>>r>>c>>n;//分别输入行数、列数、颜色总数
    x=1,y=1;//初始坐标设置为（1，1）
    for(int i=1; i<=n; i++)
    {
        int cnt;//“当前颜色剩余着色块数”计数器
        cin>>cnt;
        while(cnt--)//对当前颜色一块一块着色
        {
            ans[x][y]=i;//着色
            if(y==c&&x%2==1)//如果该点在右边缘 且 在奇数行上
                y=c,x++;//下移一行，列数不变
            else if(y==1&&x%2==0)//如果该点在第一列上，且在偶数行上
                y=1,x++;//列数不变，下移一行
            else if(x&1)//如果在奇数行上
                y++;//右移一列
            else//否则左移一列
                y--;
        }
    }
    for(int i=1; i<=r; i++)
        for(int j=1; j<=c; j++)
            printf("%d%c",ans[i][j],j==c?'\n':' ');//在到达当前行最后一列前，每次空一格；到达后，换行；
    return 0;
}


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

N,M = list(map(int,input().split()))
H = list(map(int,input().split()))

# 展望台から行ける展望台の高さを格納しておく
from collections import defaultdict
d = defaultdict(int)
for i in range(M):
  A,B = list(map(int,input().split()))
  A -= 1
  B -= 1
  if d[A] < H[B]:
    d[A] = H[B]
  if d[B] < H[A]:
    d[B] = H[A]
cnt = 0
for idx,h in enumerate(H):
  if d[idx] == 0 or h > d[idx]:
    cnt += 1
else:
  print(cnt)


Measured memory_bytes: 25028