akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
using namespace std;
signed main(){
	int a,b,c[10],d[10],ans=INT_MAX;
	cin>>a>>b;
	f(i,a) cin>>c[i]>>d[i];
	f(i,pow(2,a)){
		int x=b,y=0,z=i;
		bool vz[10]={true,true,true,true,true,true,true,true,true,true};
		f(j,a){
			if(z%2){
				x-=(c[j]*(j+1)*100+d[j]);
				y+=c[j];
				vz[j]=false;
			}
			z/=2;
		}
		int vx=a-1;
		int vy=c[vx]-1;
		while(x>0&&vx>=0){
			if(vz[vx]&&vy){
				x-=vx*100+100;
				y++;
				vy--;
			}
			else{
				vx--;
				if(vx>=0) vy=c[vx]-1;
			}
		}
		if(x<=0) ans=min(ans,y);
	}
	cout<<ans<<endl;
	return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

int counter(int x){
	if(x == 0)
		return 0;
	return counter(x >> 1) + (x & 1);
}
 
int main(void){
	
	int N;
	
	int A[18], x[18][18], y[18][18];
	
	cin >> N;
	
	rep(i, N){
		cin >> A[i];
		rep(j, A[i])
			cin >> x[i][j] >> y[i][j];
	}
	
	int ans = 0;
	
	for(int bits = 1; bits < (1 << N); bits++){
		bool check = true;
		rep(i, N){
			if(!(bits & (1 << i)))
				continue;
			rep(j, A[i])
				if(((bits >> (x[i][j] - 1)) & 1) ^ y[i][j])
					check = false;
		}
		if(check)
			ans = max(ans, counter(bits));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
c=[]
t=[]
f=[]
for v in range(n-1):
    cn, tn, fn = map(int,input().split())
    c.append(cn)
    t.append(tn)
    f.append(fn)

for q in range(n):
    time=0
    for p in range(q,n-1):
        if time>t[p]:
            while time%f[p]>0:
                time+=1
        else:
            time=t[p]
        time+=c[p]
    print(time)

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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"

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

    // cout<<fixed<<setprecision(15);

    ll n;
    cin>>n;

    ll a[n];

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

    sort(a,a+n);

    if(n % 2)
    {
        cout<<0<<endl;
    }
    else
    {
         cout<<a[n/2] - a[n/2 - 1]<<endl;
    }

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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 (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    vector<ll> dp(n);
    dp[0]=1000;
    FOR(i,1,n){
        dp[i]=dp[i-1];
        FOR(j,0,i){
            chmax(dp[i],dp[j]+dp[j]/a[j]*(a[i]-a[j]));
        }
    }
    cout << dp[n-1] << endl;
}

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

int ruijyo (int x, int a) {
  int ans = 1;
  if (a == 0) {
    return 1;
  }
  else {
    for (int i = 0; i < a; i++) {
      ans *= x;
    }
  return ans;
  }
}


int main() {
  int a, b;
  cin >> a >> b;
  string str;
  if (a < b) {
    int sum = 0;
    for (int i=0; i<b; i++) {
      sum += ruijyo(10, i) * a;
    }
    cout << sum << endl;
  }   
  else {
    int sum = 0;
    for (int i=0; i<a; i++) {
      sum += ruijyo(10, i) * b;
    }
    cout << sum << endl;
  }
}
      

 
  
      
      

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	/** 大きい値 */
	private static final int INF = Integer.MAX_VALUE >> 1;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt();
			int[] l = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			System.out.println(dfs(0, 0, 0, 0, n, a, b, c, l));
		}
	}

	/**
	 * 目的を達成するための最小の必要なMP
	 * 
	 * @param current 現在何番目の竹を処理しているか
	 * @param d       長さaを作るための竹の現在の長さ
	 * @param e       長さbを作るための竹の現在の長さ
	 * @param f       長さcを作るための竹の現在の長さ
	 * @param n       竹の数
	 * @param a
	 * @param b
	 * @param c
	 * @param l       竹の長さの配列
	 * @return 目的を達成するための最小の必要なMP
	 */
	private static int dfs(int current, int d, int e, int f, final int n, final int a, final int b, final int c,
			final int[] l) {
		if (current == n) {
			if (min(d, e, f) > 0) {
				return Math.abs(d - a) + Math.abs(e - b) + Math.abs(f - c) - 30;
			} else {
				return INF;
			}
		}
		// 現在の竹を処理しない
		int ret0 = dfs(current + 1, d, e, f, n, a, b, c, l);
		// 現在の竹をdに接続する
		int ret1 = dfs(current + 1, d + l[current], e, f, n, a, b, c, l) + 10;
		// 現在の竹をeに接続する
		int ret2 = dfs(current + 1, d, e + l[current], f, n, a, b, c, l) + 10;
		// 現在の竹をfに接続する
		int ret3 = dfs(current + 1, d, e, f + l[current], n, a, b, c, l) + 10;
		return min(ret0, ret1, ret2, ret3);
	}

	/**
	 * @param x 配列
	 * @return 配列の最小値
	 */
	private static int min(int... x) {
		return Arrays.stream(x).min().getAsInt();
	}
}


Measured memory_bytes: 61676
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

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

#define fs first
#define sc second

int N;
string s;
map<P, ll> cnt;

int main(){
    cin >> N;
    cin >> s;

    for(int i = 0; i < (1 << N); i++){
        string red, blue;
        for(int j = 0; j < N; j++){
            if((i >> j) % 2 == 0){
                red += s[j];
            }
            else{
                blue += s[j];
            }
        }
        if(cnt.find(P(red, blue)) == cnt.end()){
            cnt[P(red, blue)] = 1;
        }
        else{
            cnt[P(red, blue)]++;
        }
    }

    ll res = 0;
    string latter_s;
    for(int i = 2*N-1; i >= N; i--){
        latter_s += s[i];
    }

    for(int i = 0; i < (1 << N); i++){
        string red, blue;
        for(int j = 0; j < N; j++){
            if((i >> j) % 2 == 1){
                red += latter_s[j];
            }
            else{
                blue += latter_s[j];
            }
        }
        if(cnt.find(P(red, blue)) == cnt.end()){
            continue;
        }
        else{
            res += cnt[P(red, blue)];
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 46080
#include <stdio.h>
#include <algorithm>
using namespace std;

int mid(int a, int b, int c) {
  if (a <= b && b <= c) {
    return b;
  } else if (b <= a && a <= c) {
    return a;
  } else {
    return c;
  }
}

int main() {
  int a1, a2, a3;
  scanf("%d %d %d", &a1, &a2, &a3);

  int b1 = min(a1, min(a2, a3));
  int b2 = mid(a1, a2, a3);
  int b3 = max(a1, max(a2, a3));
  printf("%d\n", (b3-b2) + (b2-b1)); 
}



Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

n,a,b=map(int,input().split())


if a==b:
    print(0)
    exit()

if abs(a-b)%2==0:
    print(int(abs(a-b))//2)
    exit()
else:
    if a==1:
        print(int(abs(b-1)//2+1))
    elif b==n:
        print(int(abs(n-(a+1))//2+1))
    else:
        go0=(a-1)+(b-a-1)//2+1
        goN=(n-b)+(b-a-1)//2+1
        print(min(go0,goN))

Measured memory_bytes: 38384
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())

a = 0
for x in range(N+1): 
    for y in range(N-x+1):
        if (10000*x + 5000*y + 1000*(N-x-y)) == Y:
            print(str(x)+" "+str(y)+" "+str(N-x-y))
            a = 1
            break
        if a == 1:
            break
    if a == 1:
        break

if a != 1:
    print("-1 -1 -1")

Measured memory_bytes: 3064
import numpy as np

n,m = map(int,input().split())
l = []
for _ in range(m):
    a = list(map(int,input().split()))
    l.append(a)

memo = np.zeros((n,2))
memo[0][1] = 1

for i in range(n):
    memo[i][0] = 1

tmp1 = 0
tmp2 = 0

for j in range(m):
    tmp1 = l[j][0]-1
    tmp2 = l[j][1]-1
    memo[tmp1][0] -= 1
    memo[tmp2][0] += 1
    
    if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:
        memo[tmp2][1] = 1
    
    if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:
        memo[tmp1][1] = 0

ans = 0
for k in range(n):
    ans += memo[k][1]

print(int(ans))

Measured memory_bytes: 37828
check (a,b) =
  let v = '0' /= head b
      a' = if a == [] then 0 else read a :: Int
      b' = if b == [] then 0 else read b :: Int
      x' = (b'+a') `mod` 2
      y' = (b'-a') `mod` 2
      x  = (b'+a') `div` 2
      y  = (b'-a') `div` 2
  in
    v && (x'==0) && (y'==0) && (x >= 0) && (y >= 0)

ans s =
  let l = length s
      c = map (\i-> splitAt i s) [0 .. l-1]
      b = filter check c
      a = length b
  in
--    (c,b,a)
    a

main = do
  l <- getLine
  let o = ans l
  print o



Measured memory_bytes: 3832
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 2018-2-18 20:59:12
# Powered by Visual Studio Code
#

n = gets.to_i
a = gets.to_i

if a >= 500
  puts "Yes"
elsif n%500 <= a
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn d(mut a: u64) -> u64 {
    let mut count = 0;
    while a > 0 {
        a /= 10;
        count += 1;
    }
    count
}


fn solve(n: u64) -> u64{
    let mut min = d(n);
    let end = (n as f64).sqrt() as u64;
    for i in 2..end+1 {
        if n % i != 0 {
            continue;
        }
        let cand = d(n / i);
        if cand < min {
            min = cand;
        }
    }
    min
}



fn main() {
    input! {
        n: u64,
    };
    println!("{}", solve(n));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
// clang-format off
#define FOR(i, n) for (int i=0; i<(int)n; ++i)
#define RFOR(i, n) for (int i=n-1; i>=0; --i)
#define FORR(x,arr) for(auto& x:arr)
#define OUTV(x) FOR(j,x.size()) cerr<<x[j]<<(x.size()-j-1?' ':'\n');
#define OUTM(x) FOR(i,x.size()) {OUTV(x[i])}
#define DEBUG(x) cerr<<"DEBUG: "<<#x<<" = "<<x<<endl;
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
int ign;
using namespace std;
typedef signed long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
// clang-format on

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  // std::random_device rd;
  //  std::mt19937 ran(rd());

  vpii v(5);
  FOR(i, 5) {
    cin >> v[i].second;
    v[i].first = (10 - v[i].second % 10) % 10;
  }
  sort(v.begin(), v.end());

  int res = 0;
  FOR(i, 5) {
    res += v[i].second;

    if (i < 4) res += v[i].first;
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
n = gets.to_i

h = []
ans = []

n.times do |i|
  a,b = gets.split
  b = b.to_i
  h << [a,b,i+1]
end

h.sort_by! do |a,b,c|
  [a,-b]
end

h.each do |a,b,c|
  ans << c
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int h, w;
  cin >> h >> w;

  vector<string> v;
  for (int i = 0; i < h; i++)
  {
    string s;
    cin >> s;

    v.push_back(s);
    v.push_back(s);
  }

  for (int i = 0; i < 2 * h; i++)
  {
    cout << v[i] << endl;
  }
}

Measured memory_bytes: 256
sz = int(1e5)
isprime = [True for _ in range(sz + 1)]

for i in range(sz + 1):
    if i <= 1:
        isprime[i] = False
    elif isprime[i]:
        j = 2 * i
        while j <= sz:
            isprime[j] = False
            j += i

cnt = [0 for _ in range(sz + 1)]
for i in range(3, sz + 1):
    if i % 2 == 1 and isprime[i] and isprime[(i + 1) // 2]:
        cnt[i] = cnt[i - 1] + 1
    else:
        cnt[i] = cnt[i - 1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(cnt[r] - cnt[l - 1])

Measured memory_bytes: 5144
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#include<set>
#include<cctype>
#include<iomanip>
using namespace std;

struct p{
int h;
int w;
int n;
bool flag=false;
};
int main(){
ios::sync_with_stdio(false);
/***
#ifdef ONLINE_JUDGE
#else
    freopen("1.txt", "r", stdin);
#endif
***/
int a,b,c,x,y;
cin>>a>>b>>c>>x>>y;
int commont_part=(x<y?x:y);
int sum=0;
if(a+b>2*c) sum+=2*c*commont_part;
else        sum+=commont_part*(a+b);
if((x-commont_part)*a+(y-commont_part)*b<2*c*(x-commont_part+y-commont_part))
{
    sum+=(x-commont_part)*a+(y-commont_part)*b;

}
else{
    sum+=2*c*(x-commont_part+y-commont_part);
}
cout<<sum;


 return 0;
}


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

using namespace std;

using ll = long long;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int n;
vector<int> b(41, 0), sum(41, 0);
int ret = 0;

void dfs(int cur, ll ban, const vector<vector<int>> &g, const vector<ll> &con, int ss, ll visit)
{
    if (cur == n)
        return;
    if (ss + sum[cur + 1] <= ret)
        return;
    // cout << bitset<64>(visit) << " " << ss << endl;
    ret = max(ret, ss);
    dfs(cur + 1, ban, g, con, ss, visit);
    if ((ban >> (cur + 1)) & 1)
        return;
    dfs(cur + 1, ban | con[cur + 1], g, con, ss + b[cur + 1], visit | (1LL << (cur + 1)));
}

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

    while (cin >> n, n)
    {
        ret = 0;
        vector<string> a(n);
        vector<vector<string>> d(n);
        map<string, int> mp;
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            mp[a[i]] = i;
            cin >> b[i];
            int c;
            cin >> c;
            for (int j = 0; j < c; j++)
            {
                string s;
                cin >> s;
                d[i].push_back(s);
            }
        }
        sum[n - 1] = b[n - 1];
        for (int i = n - 2; i >= 0; i--)
            sum[i] = sum[i + 1] + b[i];
        // printv(sum);
        vector<vector<int>> g(n);
        vector<ll> con(n, 0); // con[i] := i に隣接する頂点
        for (int i = 0; i < n; i++)
        {
            for (const auto &s : d[i])
            {
                int idx = mp[s];
                g[i].push_back(idx);
                con[i] |= (1LL << idx);
            }
        }
        dfs(0, con[0], g, con, b[0], 1);
        cout << ret << endl;
    }
}



Measured memory_bytes: 3300
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    string s;
    vector<int> idx;
    int ans[maxn]={0};
    
    cin >> s;
    
    rep(i,s.size()-1){
        if(s[i]=='R'&&s[i+1]=='L'){
            for(int l=i;l>=0;l--){
                if(s[l]=='R'){
                    if((i-l)%2==1){
                        ans[i+1]++;
                    }else{
                        ans[i]++;
                    }
                }
                else {
                    break;
                    
                }
            }
                
            for(int r=i+1;r<s.size();r++){
                if(s[r]=='L'){
                    if((r-(i+1))%2==1){
                        ans[i]++;
                    }else{
                        ans[i+1]++;
                    }
                }else{
                    break;
                }
            }
        }
    }
    
    rep(i,s.size()){
        cout << ans[i];
        if(i<s.size()-1)cout <<' ';
        else cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    s=Counter(input()).most_common()
    t=Counter(input()).most_common()
    n=len(s)
    print("Yes" if all(s[i][1]==t[i][1] for i in range(n)) else "No")
resolve()

Measured memory_bytes: 42460
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

ll g[200][200];
ll d[200][200];

int main() {
	IOS();
	int n;
	string s;
	cin >> n >> s;
	if(n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2)){
		dump("Yes");
	}else {
		dump("No");
	}
}

Measured memory_bytes: 256
def main():
    N = int(input())
    heights = list(map(int, input().split()))

    """
    for j>i, j-i = Ai + Aj
    i + Ai = j -Aj
    """

    L = [0] * N
    R = [0] * N

    count = 0
    for i, height in enumerate(heights):
        right = i + height
        left = i - height

        if right < N:
            R[right] += 1

        if left > 0:
            L[left] += 1
            count += R[left]

    print(count)


if __name__ == "__main__":
    main()


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

int main() {
  int N;
  scanf("%d",&N);
  vector<int64_t> L(N+1);
  L.at(0) =2;
  L.at(1) =1;
  for(int i =2; i<N+1;i++){
    L.at(i)=L.at(i-2)+L.at(i-1);
  }
  cout<<L.at(N)<<endl;
}


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

int main(void)
{
	char s[201],p[101],t[101];
	scanf("%s%s",s,p);
	strcpy(t,s);
	strcat(s,t);
	if(strstr(s,p)==NULL)puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 2084
# -*- coding: utf-8 -*-


def main():
    h, w = map(int, input().split())
    board = [list(input()) for _ in range(h)]
    dx = [0, 0, -1, 1]
    dy = [-1, 1, 0, 0]

    for i in range(h):
        for k in range(w):
            if board[i][k] == '#':
                count = 0

                for m in range(4):
                    x = i + dx[m]
                    y = k + dy[m]

                    if 0 <= x < h and 0 <= y < w and board[x][y] == '#':
                        count += 1

                if count == 0:
                    print('No')
                    exit()

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  int ans = n / 2;
  if (n % 2 == 1) ans ++;
  cout << ans << endl;
  return 0;
}

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

typedef pair<int,int> P;

int w, h, k, ans=2;
set<P> exist;
set<P> visited[2];

void bfs(vector<P> s, int idx){
  
  queue<P> q;
  
  for(int i=0;i<s.size();i++){
    q.push(s[i]);
    visited[idx].insert(s[i]);
  }
  
  while(!q.empty()){
    
    P node=q.front(); q.pop();
    int x=node.first, y=node.second;
    
    if(idx==0){
      if(x==w-1||y==0) ans=min(ans, 0);
      if(x==w-2||y==1) ans=min(ans, 1);
    }
    
    if(idx==1){
      if(x==0||y==h-1) ans=min(ans, 0);
      if(x==1||y==h-2) ans=min(ans, 1);
    }
    
    for(int i=-1;i<=1;i++){
      for(int j=-1;j<=1;j++){
	
	if(i==0&&j==0) continue;
	
	int nx=x+i, ny=y+j;
      
	if(nx<0||ny<0||w<=nx||h<=ny) continue;
      
	if(exist.count(P(nx,ny))==0) continue;
	if(visited[idx].count(P(nx,ny))==1) continue;
      
	q.push(P(nx,ny));
	visited[idx].insert(P(nx,ny));
      }
    }
    
    if(idx==1){
      
      for(int i=-1;i<=1;i++){
	for(int j=-1;j<=1;j++){
	  
	  if(i==0&&j==0) continue;
	  
	  int nx=x+i, ny=y+j;
	  if(nx<0||ny<0||w<=nx||h<=ny) continue;
	  
	  for(int k=-1;k<=1;k++){
	    for(int l=-1;l<=1;l++){

	      if(k==0&&l==0) continue;
	      
	      if(!(i+k==-2||i+k==2||j+l==-2||j+l==2)) continue;
	      
	      int nnx=nx+k, nny=ny+l;
	  
	      if(nnx<0||nny<0||w<=nnx||h<=nny) continue;
	  
	      if(abs(x-nnx)+abs(y-nny)<=1) continue;
	  
	      if(visited[0].count(P(nnx,nny))==1) ans=min(ans, 1);
	      
	    }
	  }
	  
	}
	
      }
	
    }
  }
  
}

int main(){
  
  cin>>w>>h>>k;
  
  int x, y;
  vector<P> s1, s2;
    
  for(int i=0;i<k;i++){
    scanf("%d %d", &x, &y);
    if(x==0||y==h-1) s1.push_back(P(x,y));
    if(x==w-1||y==0) s2.push_back(P(x,y));
    exist.insert(P(x,y));
  }
  
  bfs(s1, 0);
  
  bfs(s2, 1);
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 17268
n = int(input())
*b, = map(int, input().split())
a = [1001001001]*n
a[:-1] = [min(ai, bi) for ai, bi in zip(a, b)]
a[1:] = [min(ai1, bi) for ai1, bi in zip(a[1:], b)]
print(sum(a))

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

int main(){
    int64_t n; cin >> n;
    if(n%2 == 1) cout << 0 << endl;
    else{
        int64_t ans = 0;
        n /= 2;
        while(n >= 5){
            n /= 5;
            ans += n;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 2e9
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;

ll n, m, q;
vector<ll> a, b, c, d;
ll ans = 0;

void dfs(vector<ll> seq)
{
  if (seq.size() == n + 1)
  {
    ll score = 0;
    REP(i, q)
    {
      if (seq[b[i]] - seq[a[i]] == c[i])
        score += d[i];
    }
    ans = max(ans, score);
    return;
  }

  seq.push_back(seq.back());
  while (seq.back() <= m)
  {
    dfs(seq);
    seq.back()++;
  }
}

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

  a = b = c = d = vector<ll>(q);
  REP(i, q)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  dfs(vector<ll>{1});

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  int pm,pe,pj,n;
  while(cin>>n){
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> pm >> pe >> pj;
      if(pm==100||pe==100||pj==100){
	cout << 'A' << endl;
	continue;
      }
      else if((pm+pe)/2>=90){
	cout << 'A' << endl;
	continue;
      }
      else if((pm+pe+pj)/3>=80){
	cout << 'A' << endl;
	continue;
      }
      else if((pm+pe+pj)/3>=70){
	cout << 'B' << endl;
	continue;
      }
      else if((pm+pe+pj)/3>=50&&pm>=80||pe>=80){
	cout << 'B' << endl;
	continue;
      }
      else cout << 'C' << endl;
    }
  }
  return 0;
}

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

int main () {
  int N, ans;
  cin >> N;
  ans = 0;
  for (int i = 0; i < N; i++) {
    int gs, ge;
    cin >> gs >> ge;
    ans += ge - gs + 1;
  }
  
  cout << ans << endl;
}

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

using namespace std;

int n, m, q, ma=-1;
vector<int> a, b, c, d;
//vector< vector< vector<int> > > bod;

void dfs(int dep, int usd, vector<int> v) {
	if (dep == n) {
		int tmp = 0;
		//for (int i = 0;i < v.size();i++) cout << v[i] << " ";
		//cout << endl;
		//ma++;

		for (int i = 0;i < q;i++) {
			if (v[b[i]-1] - v[a[i]-1] == c[i]) {
				//cout << "#";
				tmp += d[i];
				//cout << v[b[i]] << " " << v[a[i]] << " " << c[i] << " " << d[i] << endl;
			}
			//cout << b[i] << " " << a[i] << endl;
			//cout << v[b[i]] << " " << v[a[i]] << " " << c[i] << " " << d[i] << endl;
		}
		ma = max(ma, tmp);
		return;
	}

	for (int i = 0;i <m - usd;i++) {
		v[dep] = i+v[dep-1];
		dfs(dep + 1, usd + i, v);
	}

}

int main(){
	vector<int> v;

	cin>> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	v.resize(n, 0);

	/*bod.resize(n + 1);
	for (int i = 0;i < n + 2;i++) {
		bod[i].resize(n + 1);
		for (int j = 0;j < n + 2;j++) {
			bod[i][j].resize(n + 1);
		}
	}*/
	for(int i=0;i<q;i++) cin>> a[i] >> b[i] >> c[i] >> d[i];

	dfs(1, 0, v);

	cout<< ma << endl;
}


Measured memory_bytes: 3508
use std::collections::HashMap;

macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = scan!(usize);
    let vs = scan!(i64;;);
    let mut m = HashMap::new();
    for n in vs.iter() {
        let v = m.entry(n).or_insert(0);
        *v += 1;
    }

    let mut nums = vec![];
    for (&k, &v) in m.iter() {
        if v >= 4 {
            nums.push(k);
            nums.push(k);
        } else if v >= 2 {
            nums.push(k);
        }
    }
    nums.sort();
    if nums.len() < 2 {
        println!("0")
    } else {
        println!("{}", nums[nums.len() - 1] * nums[nums.len() - 2])
    }
}


Measured memory_bytes: 12540
#include <iostream>
#include <vector>
using namespace std;
int main() {
	vector<int> a(200001), b(200001);
	int N;
	cin >> N;

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

	if (N % 2 == 0) {
		//�����̂Ƃ�
		int harf = N / 2;
		int key = harf;
		int anum = 0;
		for (int i = 0; i < harf; i++)
		{
			b[key] = a[anum++];
			b[key-((i + 1) * 2 - 1)] = a[anum++];
			key++;
		}
	}
	else {
		//��̂Ƃ�
		int key = N / 2;
		int anum = 0;
		b[key] = a[anum++];
		key++;
		for (int i = 1; i <= N/2; i++)
		{
			b[key] = a[anum++];
			b[key - (i * 2)] = a[anum++];
			key++;
		}
	}

	for (int i = 0; i < N; i++)
	{
		cout << b[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200)cout << s << endl;
    else puts("red");
}


Measured memory_bytes: 3616
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)
const long long inf = 1LL << 62;

const int maxn = 200000 + 10;
int a[maxn];
long long Abs(long long x) {
    if (x < 0) return -x;
    return x;
}

int main(int argc, char **argv) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    long long tot = 0;
    for (int i = 1; i <= n; i++) tot += a[i];

    long long cur = 0;
    long long ans = inf;
    for (int i = 1; i < n; i++) {
        cur += a[i];
        ans = min(ans, Abs(2 * cur - tot));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();

        long a = sc.nextLong();
        boolean over = false;
        for (int i = 1; i < n; i++) {
            long m = sc.nextLong();
            if (m == 0) {
                System.out.println(0);
                return;
            }

            if (Math.log10(a) + Math.log10(m) > 18) {
                over = true;
            }
            a *= m;
        }
        if (over || a > 1000000000000000000L) {
            System.out.println(-1);
            return;
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 59940
#include <cstdio>

#define ABS(v) ((v) < 0 ? -(v) : (v))

int main(void)
{
    int N, X, t;
    bool has[105] = {0, };
    scanf("%d %d", &X, &N);
    while(N--) {
        scanf("%d", &t);
        has[t] = true;
    }
    
    int sml, big;
    for(sml = X; sml >= 0; sml--)
        if(!has[sml]) break;
    for(big = X; big < 105; big++)
        if(!has[big]) break;
    
    if(ABS(X - sml) <= ABS(X - big)) printf("%d", sml);
    else printf("%d", big);
}

Measured memory_bytes: 1708
// MatrixMultiplication.c
//
// n×mの行列 Aと m×lの行列 Bを入力し、それらの積である n×lの行列 Cを
// 出力するプログラムを作成してください。
// 行列 Cの各要素 cij は次の式で得られます：
//   c ij = k-1Σm aik bkj
// ここで、A、B、Cの各要素をそれぞれ aij、bij、cij とします。
// 【入力】
// １行目に n、m、l が空白区切りで与えられます。
// 続く行に n×m の行列 A と m×l の行列 B が与えられます。
// 【出力】
// n×l の行列 C の要素 cij を出力してください。
// 各行の隣り合う要素を１つの空白で区切ってください。
// 【制限】
// ・1≤n,m,l≤100
// ・0≤aij,bij≤10000
// 【例】
// 入力：
// 3 2 3
// 1 2
// 0 3
// 4 5
// 1 2 1
// 0 3 2
// 出力：
// 1 8 5
// 0 9 6
// 4 23 14
#include<stdio.h>

int main( void) {
  int n, m, l;
  long long int A[100][100], B[100][100], C[100][100]={};

  // 入力データの処理
  scanf( "%d %d %d", &n, &m ,&l);

  for ( int i = 0; i < n; i++) {
    for ( int j = 0; j < m; j++) {
      scanf( "%lld", &A[i][j]);
    }
  }
  for ( int j = 0; j < m; j++) {
    for ( int k = 0; k < l; k++) {
      scanf( "%lld", &B[j][k]);
    }
  }

  // 新しい行列Cの計算
  for ( int i = 0; i < n; i++) {
    for ( int k = 0; k < l; k++) {
      for ( int j = 0; j < m; j++) {
	C[i][k] += A[i][j] * B[j][k];
      }
    }
  }

  // 行列Cの出力
  for ( int i = 0; i < n; i++) {
    for ( int k = 0; k < l; k++) {
      printf( "%lld", C[i][k]);
      if ( k < l - 1) printf( " ");
    }
    printf( "\n");
  }

  return 0;
}



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

int n, m, a[100005], c[100005];

int lowbit(int x)
{
	return x & (-x);
}

void updata(int i, int k)
{
	while (i <= n){
		c[i] += k;
		i += lowbit(i);
	}
}

int getsum(int i)
{
	int res = 0;
	while(i > 0){
		res += c[i];
		i -= lowbit(i);
	}
	return res;
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		updata(i, a[i] - a[i - 1]);
	}
	while (m--){
		int ch, x, y, k;
		scanf("%d%d", &ch, &x);
		if (!ch){
			scanf("%d%d", &y, &k);
			updata(x, k);
			updata(y + 1, -k);
		}else{
			printf("%d\n", getsum(x));
		}
	}
	return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> x(n), y(n);
	for (int i=0; i<n; i++)
		cin>>x[i]>>y[i];
	vector<int> p(n);
	for (int i=0; i<n; i++)
		p[i]=i;
	double ret=0, ct=0;
	do {
		double cur=0;
		for (int i=1; i<n; i++) {
			double dx=x[p[i]]-x[p[i-1]], dy=y[p[i]]-y[p[i-1]];
			cur+=sqrt(dx*dx+dy*dy);
		}
		ret+=cur; ct++;
	} while(next_permutation(p.begin(),p.end()));
	cout<<setprecision(10)<<fixed<<ret/ct<<"\n";
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
                                
int n, W, w[N], c[N];
ll dp[2][N];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> W;
   for (int i = 1; i <= n; i ++) cin >> w[i] >> c[i];
   for (int i = 0; i <= 1; i ++)
      for (int j = 0; j <= W; j ++)
         dp[i][j] = -inf;
   dp[0][0] = 0;
   for (int i = 1; i <= n; i ++) {
      bool ch = (i & 1);
      for (int j = 0; j <= W; j ++) {
         dp[ch][j] = dp[(ch ^ 1)][j];
         if (j >= w[i]) 
            dp[ch][j] = max (dp[ch][j], dp[(ch ^ 1)][j - w[i]] + c[i]);
      }
   }
   cout << *max_element (dp[(n & 1)], dp[(n & 1)] + W + 1);
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

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

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

	int n, k; cin >> n >> k;
	bitset<18> b;
	int max = 1 << n;
	for (int i = 0; i < max; i++) {
		b = i;
		if (b.count() == k) {
			cout << i << ":";
			for (int j = 0; j < n; j++) {
				if (b.test(j))
					cout << " " << j;
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3172
using System;
using System.Collections;
using System.Linq;

class prog
{
    public static void Main(string[] args)
    {
        string[] in1 = Console.ReadLine().Split(' ');
        int H = int.Parse(in1[0]);
        int W = int.Parse(in1[1]);

        for(int h = 0;h < H; h++)
        {
            var input = Console.ReadLine();
            Console.WriteLine(input);
            Console.WriteLine(input);
        }
    }
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2) && S.at(2) == S.at(3)){
    cout << "No" << endl;
  }
     
  else if(S.at(0) == S.at(1) && S.at(2) == S.at(3) || S.at(0) == S.at(2) && S.at(1) == S.at(3) || S.at(0) == S.at(3) && S.at(2) == S.at(1)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

int main(){
    double x1, x2;
    double y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%08f\n", sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  queue<char> s[3];
  int f = 0;

  REP(i, 3) {
    string str;
    cin >> str;
    REP(j, str.size()) {
      s[i].push(str[j]);
    }
  }

  while (true){
    char c = s[f].front();
    s[f].pop();
    f = c - 'a';
    if (s[f].empty()){
      printf("%c\n", f + 'A');
      break;
    }
  }

  return (0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(10) << w*h/2 << endl;
  if(x == w/2 && y == h/2){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N;
    intmax_t ans = 0;

    scanf("%jd", &N);

    ans = N / 2;

    if (N % 2) {
        ans++;
    }

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

    return 0;
}


Measured memory_bytes: 128
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

ans = 0

def measure(originX,originY):
    dist = []
    for X,Y in XY:
        dist.append(abs(X-originX)+abs(Y-originY))
    return max(dist)-min(dist)

originX = 0
originY = 0
ans = max(ans,measure(originX,originY))

originX = 10**9
originY = 0
ans = max(ans,measure(originX,originY))

originX = 0
originY = 10**9
ans = max(ans,measure(originX,originY))

originX = 10**9
originY = 10**9
ans = max(ans,measure(originX,originY))

print(ans)

Measured memory_bytes: 123244
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    string n;
    cin >> n;
    if(n[0] == n[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  int S = 0;
  for (int i = 0; i < N; i++){
    S ^= a[i];
  }
  for (int i = 0; i < N; i++){
    cout << (S ^ a[i]);
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 3924
import numpy as np
def main():
    n = int(input())
    h = list(map(int, input().split()))
    nh = np.zeros([n], dtype=int)
    nh[1] = abs(h[0]-h[1])
    for i in range(2,n):
        one = nh[i-1] + abs(h[i-1]-h[i])
        two = nh[i-2] + abs(h[i-2]-h[i])
        if two <= one:
            nh[i] = two
        else:
            nh[i] = one
    
    print(nh[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 22732
s = input()
if len(s) == 1:
  print(0)
else:
  left = 0
  right = len(s)-1
  ans = 0
  while left <= right:
    if s[left] == s[right]:
      left += 1
      right -= 1
    elif s[left] == 'x':
      ans += 1
      left += 1
    elif s[right] == 'x':
      ans += 1
      right -= 1
    else:
      ans = -1
      break
  print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
int main(void)
{
	int x1=1,x[10000],i;
	for(i=0;x1 != 0;i++)
	{
		scanf("%d" , &x1);
		x[i] = x1;
	}
	
	for(i=0;x[i] != 0;i++)
	{
		printf("Case %d: %d\n",i+1,x[i]);
	}
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a,b;
	double c,d;
	scanf("%d %d",&a,&b);
	printf("%d\n",a/b);
	printf("%d\n",a%b);
	c=a;
	d=b;
	printf("%.8lf\n",c/d);
	return 0;
}

Measured memory_bytes: 2732
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
main(){
    string s;
    int t[26]={};
    cin>>s;
    int p=-1,flag=0;
    if(s.size()==26){
        for(int i=24;i>=0;i--){
            for(int j=i;j<=25;j++){
                if(s[i]<s[j]){
                    p=i;
                    flag=1;
                    break;
                }
            }
            if(flag) break;
        }
        if(p==-1){
            cout<<-1; return 0;
        }
        char x='z';
        rep2(i,p+1,25){
            if(s[i]>s[p]&&s[i]<x)
            x=s[i];
        }
        s.erase(s.begin()+(p+1),s.end());
        s[p]=x;
        cout<<s;
        return 0;
    }
    rep(i,s.size()){
        rep(j,26){
            if(s[i]==alphabet[j])
            t[j]++;
        }
    }
    int i=0;
    while(t[i]){
        i++;
    }
    s.push_back(alphabet[i]);
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[n];
    int M = 0;
    for (int i = 0; i < n; i ++) {
        int b; cin >> b;
        a[i] = b;
        M ^= b;
    }
    
    for (int i = 0; i < n; i ++) {
        cout << (a[i]^M)<< " ";
    }
    cout << endl;
    return 0;
}


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

int main(){
	int A,B;
	cin >> A >> B;
	if(A==B)
	cout << "Draw" << endl;
	else if(A==1)
	cout << "Alice" << endl;
	else if(B==1)
	cout << "Bob" << endl;
	else if(A>B)
	cout << "Alice" << endl;
	else if(B>A)
	cout << "Bob" << endl;
	
}

Measured memory_bytes: 256
using System;

namespace ABC128
{
    class C
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int[] k = new int[M];
            int[,] s = new int[M, 20];

            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ');
                k[i] = int.Parse(input[0]);

                for (int j = 1; j <= k[i]; j++)
                {
                    s[i, j] = int.Parse(input[j]);
                }
            }

            input = Console.ReadLine().Split(' ');
            int[] p = new int[M];
            for (int i = 0; i < M; i++)
            {
                p[i] = int.Parse(input[i]);
            }

            int[] a = new int[N];
            CalcSw(N, a, M, k, s, p);

            Console.WriteLine(count);

        }

        static int count = 0;
        static void CalcSw(int N, int[] a, int M, int[] k, int[,] s, int[] p)
        {
            if (N == 0)
            {
                int c = 0;
                for (int i = 0; i < M; i++)
                {
                    c = 0;
                    for (int j = 1; j <= k[i]; j++)
                    {
                        if (a[s[i, j] - 1] == 1) { c++; }
                    }
                    if ((c % 2) != p[i]) { return; }
                }
                count++;
                return;
            }

            N--;
            a[N] = 0;
            CalcSw(N, a, M, k, s, p);
            a[N] = 1;
            CalcSw(N, a, M, k, s, p);
        }
    }
}


Measured memory_bytes: 13140