akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

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

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    string s;
    cin >> s;
    string ans = string();
    for(int i = 0; i  < s.length(); i++){
        if(i % 2 == 0) ans += s[i];
    }
    cout << ans << endl;
}


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

a = list(input())
b = list(input())
c = list(input())

turn = 'a'
while 1:
    if turn == 'a':
        if a:
            turn = a.pop(0)
        else:
            print('A')
            exit()
    elif turn == 'b':
        if b:
            turn = b.pop(0)
        else:
            print('B')
            exit()
    else:
        if c:
            turn = c.pop(0)
        else:
            print('C')
            exit()


Measured memory_bytes: 3060
import fractions
a,b = map(int,input().split())
ab_gcd = fractions.gcd(a,b)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
print(len(set(prime_factorize(ab_gcd)))+1)

Measured memory_bytes: 65004
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int Max = (100000000 + 5) * 2;
bool pre[Max];
int n, a[10005], maxn = 100;
long long ans = 0;
bool solve(int x) {
    if(x <= 3) {
        return x > 1;
    }
    if(x % 6 != 1 && x % 6 != 5) {
        return false;
    }
    int sq = ceil(sqrt(x));
    for (int i = 5; i <= sq; i += 6) {
        if(!(x % i) || !(x % (i + 2))) {
            return false;
        }
    }
    return true;
}
int main() {
    scanf("%d", &n);
    maxn = -1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        maxn = max(maxn, a[i]);
    }
    for (int i = 1; i <= n; i++) {
        if(solve(a[i]))
            ans++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2776
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 8)

 
def main():
    N = int(readline())
    A = [0] *(10**5+1)
    total = 0
    for a in map(int, readline().split()):
        total += a
        A[a] += 1
 
 
    Q = int(readline())
    for _ in range(Q):
        b, c = map(int, readline().split())
        total += A[b]*(c-b)
        print(total)
        A[c] += A[b]
        A[b] = 0
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 15816
#include <bitset>
#include <iostream>

using namespace std;

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

    bitset<3000> bit(1);
    int a;
    for (int i = 0; i < N; ++i) {
        cin >> a;
        bit |= (bit << a);
    }

    int Q;
    cin >> Q;
    
    int m;
    for (int q = 0; q < Q; ++q) {
        cin >> m;
        cout << (bit[m] ? "yes" : "no") << endl;
    }
    return 0;
}



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

typedef vector<int> vi;

long long sumA[200001];
long long sumB[200001];

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int count = 0;
  int a,b,k;
  cin >> a >> b >> k;
  for(int i = 1; i <= a; i++) {
    long long tmp;
    cin >> tmp;
    sumA[i] = sumA[i-1] + tmp;
  }
    for(int i = 1; i <= b; i++) {
    long long tmp;
    cin >> tmp;
    sumB[i] = sumB[i-1] + tmp;
  }

  for(int i = 0, j = b; i <= a; ++i) {
    if (sumA[i] > k) break;
    while (sumA[i] + sumB[j] > k) {
      --j;
    }
    count = max (i+j,  count);
  }
  cout << count ;
}

Measured memory_bytes: 6740
def main():
    x, n = map(int, input().split())
    ps = list(map(int, input().split()))
    anti_ps = [i for i in range(102) if i not in ps]
    anti_ps_abs = [abs(i-x) for i in range(102) if i not in ps]
    ans = anti_ps[anti_ps_abs.index(min(anti_ps_abs))]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
    	int number = scan.nextInt();
    
		if(number % 10 == 2 ||number % 10 == 4 ||number % 10 == 5 ||number % 10 == 7 ||number % 10 == 9){
    		System.out.println("hon");
		}else if(number % 10 == 3 ){
    		System.out.println("bon");
    	}else{
          System.out.println("pon");
        }
    
	}
}

Measured memory_bytes: 35776
#include<stdio.h>
#define MAX 2000000

int size, T[MAX+1];

void maxH(int a){
  int l, r, largest, t;
  l = 2*a;
  r = 2*a+1;
  if ( l <= size && T[l] > T[a] ) largest = l;
  else largest = a;
  if ( r <= size && T[r] > T[largest] ) largest = r;
  if ( largest != a ){
    t = T[a]; 
    T[a] = T[largest]; 
    T[largest] = t;
    maxH(largest);
  }
}

int extract(){
  int maxv;
  if ( size < 1 ) return;
  maxv = T[1];
  T[1] = T[size--];
  maxH(1);
  return maxv;
}

void incrKey(int j, int key){
  int tmp;
  if ( key < T[j] ) return;
  T[j] = key;
  while ( j > 1 && T[j/2] < T[j] ){
    tmp = T[j];
    T[j] = T[j/2];
    T[j/2] = tmp;
    j = j/2;
  }
}

void insert(int key){
  size++;
  T[size] = -1000000001;
  incrKey(size, key);
}

int main(){
  int key;
  char C[20];
  while(1){
    scanf("%s", C);
    if ( C[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(C, "extract") == 0  ){
      printf("%d\n", extract());
    } else break;
  }
  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int main()
{
  int x;
  cin >> x;
  string s = (x < 1200) ? "ABC" : "ARC";
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
N, K, S = map(int, input().split())

V = [0] * (N + 1)


if K > 0:
    V[1] = S
    K -= 1
else:
    V[1] = S - 1

if S >= 10 ** 9:
    flag = 1
else:
    flag = 0


for i in range(2, N + 1):
    if K > 0:
        V[i] = V[i - 1] + S
        K -= 1
    else:
        if flag:
            V[i] = V[i - 1] + (S - 1)
        else:
            V[i] = V[i - 1] + (S + 1)

ans = [0] * N
for i in range(N):
    ans[i] = V[i + 1] - V[i]

print(*ans)


Measured memory_bytes: 14540
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define CTOI(x) (x - 'A') 
#define ctoi(x) (x - 'a')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;
}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum) % MOD;
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int count(int x){
    int res = 0;
    while(x){
        res += x & 1;
        x>>=1;
    }
    return res;
}

vector<int> getsosu(int N){
    vector<int> res;
    vector<int> check(N+1, true);
    for(int i=2;i<=N;++i){
        if(check[i]){
            res.push_back(i);
            for(int j=i*2;j<=N;j+=i){
                check[j]=false;
            }
        }
    }
    return res;
}

vector<int>y;
vector<int> C;
int N, M;

int main(){
    while(cin >> N >> M && N){
        C = vector<int>(M);
        REP(i, M)cin>>C[i];
        y = vector<int>(N);
        REP(i, N)cin>>y[i];
        vector<vector<int> > dp(N+1, vector<int>(256, INF));
        dp[0][128] = 0;
        REP(i, N){
            REP(j, 256){
                REP(k, M){
                    int d = max(0, min(255, j + C[k]));
                    dp[i+1][d] = min(dp[i+1][d], (y[i]-d) * (y[i]-d) + dp[i][j]);
                }
            }
        }
        int ans = INF;
        REP(i, 256){
            ans = min(ans, dp.back()[i]);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 23764
input = readlines()
s = input.shift.chomp
t = input.shift.chomp

s_arr = s.split('')
t_arr = t.split('')

max_match = 0
s_arr.each_with_index do |chr, i|
  tmp = s[i, t_arr.length]
  next if tmp.length < t_arr.length
  match = 0
  tmp.split('').each_with_index do |c, i2|
    match += 1 if t_arr[i2] == c
  end
  max_match = match if max_match < match
end

puts t_arr.length - max_match


Measured memory_bytes: 14644
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


class PriorityQueue
  def initialize
    @size = 0
    @heap = []
  end
  private
  def maxHeapify x
    l = 2*x
    r = 2*x+1
    if l <= @size && @heap[l] > @heap[x]
      largest = l
    else
      largest = x
    end
    if r <= @size && @heap[r] > @heap[largest]
      largest = r
    end
    if largest != x
      @heap[x], @heap[largest] = @heap[largest], @heap[x]
      maxHeapify(largest)
    end
  end

  public

  def pop
    data = @heap[1]
    @heap[1] = @heap[@size]
    @size -= 1
    maxHeapify(1)
    data
  end

  def push key
    @size += 1
    @heap[@size] = key
    i = @size
    while i > 1 && @heap[i/2] < @heap[i]
      @heap[i], @heap[i/2] = @heap[i/2], @heap[i]
      i /= 2
    end
  end

  def << key
    push key
  end

  def empty?
    @heap.empty?
  end

  def size
    @heap.size
  end
end

q = PriorityQueue.new

loop{
  s,num = gs
  case s
  when "end"
    break
  when "extract"
    puts q.pop
  when "insert"
    num = num.to_i
    q << num
  end
}

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

const int N = 10;

int n, L, ALL;
int a[N];
long long f[32][324];

inline int min(const int x, const int y) {return x < y ? x : y;}
inline int max(const int x, const int y) {return x < y ? y : x;}

long double solve() {
	int i, j, k, c, to, len = n * L + L;
	memset(f, 0, sizeof f), f[0][(n + 1) * a[n]] = 1;
	for (i = 1; i < len; ++i) if (i % (n + 1)) {
		c = i % (n + 1) - 1, to = min(i + (n + 1) * a[c], len);
		for (j = 0; j <= ALL; ++j) if (!(j >> c & 1))
			for (k = i; k <= len; ++k)
				f[j | 1 << c][max(k, to)] += f[j][k];
	}
	return f[ALL][i];
}

int main() {
	int i, cc = 0; long double ans = 0.;
	scanf("%d%d", &n, &L), ALL = ~(-1 << --n);
	for (i = 0; i <= n; ++i) scanf("%d", a + i);
	std::sort(a, a + (n + 1));
	do ans += solve(), ++cc; while (std::next_permutation(a, a + n));
	printf("%.12Lg\n", ans / (cc * powl(L, n)));
	return 0;
}

Measured memory_bytes: 640
n,m,x,y=map(int,input().split())
xmax=max(list(map(int,input().split())))
ymin=min(list(map(int,input().split())))

if xmax>ymin: print('War')
else:
  ans='War'
  for i in range(xmax+1,ymin+1):
    if x<i<=y:
      ans='No War'
      break
  print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    string s; cin >> s;
    int n = s.size();
    int cnt = 0;
    rep(i,n){
        if(s[i] != s[n-i-1]) cnt++;
    }
    cout << cnt/2 << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,r,c;
    cin >> h >> w >> r >> c;
    cout << (h-r)*(w-c) << "\n";

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  ll k = 0;
  rep(i,n)if(b[i] > a[i]){
    k += (b[i]-a[i])/2;
  }else{
    k += b[i]-a[i];
  }
  if(k >= 0)cout << "Yes" << "\n";
  else cout << "No" << "\n";

  





  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
struct Vec2D
{
    T x, y;
};

void solve()
{
    using namespace std;
    int k, s;
    cin >> k >> s;

    int count {};

    for (int x = 0; x <= k; ++x)
        for (int y = 0; y <= k; ++y)
            if (s - x - y >= 0 && s - x - y <= k)
                ++count;
    
    cout << count << endl;

}

int main()
{
    solve();
    return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;


int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  vll cnt(4, 0); // n s e w
  ll n = s.size();
  rep(i, n){
    if (s[i] == 'N') cnt[0]++;
    else if (s[i] == 'S') cnt[1]++;
    else if (s[i] == 'E') cnt[2]++;
    else cnt[3]++;
  }
  string ans = "Yes";
  if (cnt[0] > 0 && cnt[1] == 0) ans = "No";
  if (cnt[0] == 0 && cnt[1] > 0) ans = "No";
  if (cnt[2] > 0 && cnt[3] == 0) ans = "No";
  if (cnt[2] == 0 && cnt[3] > 0) ans = "No";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s

#n = ip()                              #入力整数1つ
n,m= (int(i) for i in input().split())      #入力整数横2つ
#n,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#s = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a =[]
for i in range(n):
	a.append(input())
for i in range(n):
	print(a[i])
	print(a[i])


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1 && b == 1) {
    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 (a == b) {
      cout << "Draw" << endl;
    } else {
      cout << "Bob" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define outl(x) cout << x << endl
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n;
	string s;
	cin >> s;
	s[3] = '8';
	outl(s);
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    string S1, S2;
    cin >> N;
    cin >> S1;
    cin >> S2;

    vector<ll> P;
    REP(i, N){
        if(S1[i] == S2[i]){
            P.push_back(1);
        }
        else{
            P.push_back(2);
            i++;
        }
    }

    // for(auto p :P){
    //     cout << p << endl;
    // }

    ll K = P.size();

    ll ans = 1;
    REP(i, K){
        if(i == 0){
            if(P[i] == 1){
                ans = 3;
            }
            else{
                ans = 6;
            }
            continue;
        }

        if(P[i-1] == 1 && P[i] == 1){
            ans *= 2;
            ans = ans % MOD;
        }
        if(P[i-1] == 1 && P[i] == 2){
            ans *= 2;
            ans = ans % MOD;
        }
        if(P[i-1] == 2 && P[i] == 1){
            ans = ans % MOD;
        }
        if(P[i-1] == 2 && P[i] == 2){
            ans *= 3;
            ans = ans % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>

using namespace std;

int main() {
    string s;
    stack<int> St;
    int l, r;
    while (cin >> s) {
        switch (s[0]) {
            case '+':
                l = St.top();
                St.pop();
                r = St.top();
                St.pop();
                St.push(l + r);
                break;
            case '-':
                l = St.top();
                St.pop();
                r = St.top();
                St.pop();
                St.push(r - l);
                break;
            case '*':
                l = St.top();
                St.pop();
                r = St.top();
                St.pop();
                St.push(l * r);
                break;
            default:
                St.push(atoi(s.c_str()));
                break;
        }
    }

    cout << St.top() << endl;

    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  long long k;cin>>k;
  for(int i = 0; s.size() > i; i++){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
    if(i+1==k){
      cout << 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define sqr(x) (x)*(x)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=200007;
const ll inf=0x3f3f3f3f3f3f3f3f;
ll read(){
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
ll a[maxn];
ll dp[maxn][11],Sum;
int main(){

    int n=read();
    for(int i=1;i<=n;i++) a[i]=read(),Sum+=a[i];
    memset(dp,0x3f,sizeof(dp));  
    dp[0][5]=0;
    dp[1][6]=a[1];
    for(int i=2;i<=n+1;i++){
        for(int k=0;k<=10;k++){
            int now=i/2+k-5;
            if(now>=1){
                int p1=now-1-(i-1)/2+5;
                int p2=now-1-(i-2)/2+5;
                if(p1>10||p2>10||p1<0||p2<0) continue;
                dp[i][k]=min(dp[i-1][p1],dp[i-2][p2])+a[i];
            }
        }
    }
    int you=n-(n/2)+1;
    int p=you-(n+1)/2+5;
    cout<<Sum-dp[n+1][p];
    return 0;
}

Measured memory_bytes: 22304
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
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; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){

    int n;
    cin >> n;
    vector<ll> height;
    rep(i,n)
    {
        ll tmpnum;cin >> tmpnum;
        height.push_back(tmpnum);
    }
    
    int ans = 0;
    int tmpans = 0;
    int now_at = height[0]-1;

    rep(i,n)
    {
        if (now_at >= height[i])
        {
            tmpans++;
        }
        else
        {
            ans = max(ans, tmpans);
            tmpans = 0;
        }
        now_at = height[i];
    }
    ans = max(ans, tmpans);

    cout << ans << endl;
}


Measured memory_bytes: 1400
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int[] dp = new int[n + 1];
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
            int h1 = (int) Math.abs(h[i - 1] - h[i]);
            int h2 = (int) Math.abs(h[i - 2] - h[i]);
            dp[i + 1] = Math.min(dp[i] + h1, dp[i - 1] + h2);
        }
        System.out.println(dp[n]);
        sc.close();
    }
}


Measured memory_bytes: 48752
#include<stdio.h>

int main(){
char s[2][4];
scanf("%s%s",s[0],s[1]);
if(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0])puts("YES");
else puts("NO");
return 0;
}

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

struct gaunho {
	int x,y,h;
};
gaunho point[100];
int ab(int x) {
	return max(x,-x);
}
int main() {
	int n,t=0,k=0;
	cin>>n;
	for (int i=0;i<n;++i) {
		cin>>point[i].x>>point[i].y>>point[i].h;
		if (point[i].h>0) {
			k=i;
		}
	}
	int X=0,Y=0,H=0;
	while (X<=100) {
		while (Y<=100) {
			H=ab(point[k].x-X)+ab(point[k].y-Y)+point[k].h;
			if (X==2 && Y==2) {
			}
			bool ok=true;
			for (int i=0;i<n;++i){
				if (point[i].h!=max(H-ab(point[i].x-X)-ab(point[i].y-Y),0)) {
					ok=false;
				}
			}		
			if (ok==true) {
				cout<<X<<' '<<Y<<' '<<H;
				return 0;
			}
			Y=Y+1;
		}
		X=X+1;
		Y=0;
	}
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let a = v[0];
    let b = v[1];

    println!("{}", (a + b) % 24);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int a;
	char c;
	int b;
	int sum;
	
	while (1){
		scanf("%d %c %d", &a, &c, &b);
		
		sum = 0;
		switch (c){
			case ('+'):
			sum = a + b;
			printf("%d\n", sum);
			break;
			
			case ('-'):
			sum = a - b;
			printf("%d\n", sum);
			break;
		
			case ('*'):
			sum = a * b;
			printf("%d\n", sum);
			break;
			
			case ('/'):
			sum = a / b;
			printf("%d\n", sum);
			break;
		}
		if (c == '?'){
			break;
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
h,w,a,b=map(int,input().split())

ans=[[0]*w for _ in range(h)]

for r in range(h):
    for c in range(w):
        if (0<=r<b and 0<=c<a) or (b<=r<h and a<=c<w):
            ans[r][c]+=1
    
    print(''.join([str(c) for c in ans[r]]))

Measured memory_bytes: 82276
import std.algorithm;
import std.conv;
import std.math;
import std.stdio;
import std.string;

void main()
{
	auto as = readln.split.to!( int[] );
	writeln( solve( as ) );
}

auto solve( in int[] as )
{
	auto ss = sort( as.dup );
	
	return abs( ss[ 0 ] - ss[ 1 ] ) + abs( ss[ 1 ] - ss[ 2 ] );
}


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

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int n = sc.nextInt();
		int[] v = new int[n];
		int[] p = new int[n];
		
		for (int i = 0; i<n; i++) {
			v[i] = sc.nextInt();
		}
		for (int i =0; i<n; i++) {
			p[i] = sc.nextInt();
		}

		int val = 0; 

		for (int i = 0;  i<n; i++) {
			if (v[i] > p[i]) {
				val += v[i] - p[i];
			}
		}
		System.out.println(val);
	}
}


Measured memory_bytes: 35848
#include <iostream>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;

//const double PI = 3.14159265358979323846;

int main(int argc, const char * argv[]) {
    uint64_t a, b, x;
    cin >> a;
    cin >> b;
    cin >> x;
    
    uint64_t max_vol = a * a * b;
    double ans = 0.0;
    if (x <= (max_vol / 2)) {
        double h = 2.0 * double(x) / double(a * b);
        ans = 90.0 - atan2(h, double(b)) * 180.0 / M_PI;
    }else {
        uint64_t empty_vol = max_vol - x;
        double h = 2.0 * double(empty_vol) / double(a * a);
        ans = atan2(h, double(a)) * 180.0 / M_PI;
    }
    
    cout << std::setprecision(11) << ans << endl;
    return 0;
}


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

typedef long long ll;
const ll MOD =  1e9+7;
const int N = 2e5;

ll dmod(ll x){
	return x%MOD;
}

ll fe(ll x, ll p){
	if(p == 0) return 1ll;
	if(p == 1) return x;
	ll ret = fe(x,p/2);
	ret = dmod(ret*ret);
	if(p&1) ret = dmod(ret*x);
	return ret;
}

int n;
vector<int> adj[N+5];
ll subt[N+5];

void dfs(int x, int par){
	subt[x] = 1;
	for(int i=0;i<adj[x].size();i++){
		int now = adj[x][i];
		if(now == par) continue;
		dfs(now,x);
		subt[x] += subt[now];
	}
	return;
}

int main(){
	scanf("%lld",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1,-1);
	ll ans = 0ll;
	for(int i=1;i<=n;i++){
		// atas dan bawah
		ll lol1 = fe(2ll,n-subt[i]);
		ll lol2 = fe(2ll, subt[i]-1);
		ll cur = dmod(dmod( lol1 * lol2 ) - lol1 + MOD - lol2 + MOD + 1);
		
		// bawah dan bawah
		ll tmp = 1ll;
		ll kurang = 0ll;
		for(int j=0;j<adj[i].size();j++){
			int next = adj[i][j];
			if(subt[next] > subt[i]) continue;
			ll kali = fe(2ll, subt[next]);
			tmp = dmod(tmp * kali);
			kurang = dmod(kurang+kali - 1 + MOD);
		}
		cur = dmod(cur + tmp - kurang - 1 + MOD);
		ans = dmod(ans + cur);
	}
	ll bagi = fe(2ll,n);
	bagi = fe(bagi,MOD-2);
	ans = dmod(ans*bagi);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 23936
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

const ll M = 1000003;

class Felmat
{
  ll M;
  vector<ll> fac;  // n! (mod M)
  vector<ll> ifac; // k!^{M-2} (mod M)

public:
  Felmat(ll max_nk, ll m)
  {
    M = m;
    fac.reserve(max_nk + 1);
    ifac.reserve(max_nk + 1);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < max_nk; i++) {
      fac[i + 1] = fac[i] * (i + 1) % M;              // n! (mod M)
      ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
  }
  ll mfac(ll x)
  {
    int i;
    return fac[x];
  }
  ll mpow(ll x, ll n)
  { // x^n (mod M)
    ll ans = 1;
    while (n != 0) {
      if (n & 1)
        ans = ans * x % M;
      x = x * x % M;
      n = n >> 1;
    }
    return ans;
  }
  ll minv(ll a)
  { // 1/a (mod M)
    ll b = M, u = 1, v = 0;
    while (b) {
      ll tmp = a / b;
      a -= tmp * b;
      swap(a, b);
      u -= tmp * v;
      swap(u, v);
    }
    u %= M;
    if (u < 0)
      u += M;
    return u;
  }
  ll comb(ll n, ll k)
  { // nCk (mod M)
    if (n == 0 && k == 0)
      return 1;
    if (n < k || n < 0)
      return 0;
    ll tmp = ifac[n - k] * ifac[k] % M;
    return tmp * fac[n] % M;
  }
  ll perm(ll n, ll k)
  { // nPk (mod M)
    if (n < k)
      return 0;
    ll tmp = ifac[n - k] % M;
    return tmp * fac[n] % M;
  }
};

int main()
{
  int q;
  Felmat fm(1000003, M);
  cin >> q;
  int i;
  for (i = 0; i < q; i++) {
    ll x, d, n, j;
    cin >> x >> d >> n;
    ll ans = 0;
    if (x == 0) {
      ans = 0;
    } else if (d == 0) {
      ans = fm.mpow(x, n);
    } else {
      ll x_d = x * fm.minv(d) % M;
      if (M <= x_d + n - 1) {
        ans = 0;
      } else {
        ans = fm.mfac(x_d + n - 1);
        ans = ans * fm.minv(fm.mfac(x_d - 1)) % M;
        ans = ans * fm.mpow(d, n) % M;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
int abssub(int a,int b){
	if(a>b)return a-b;
	return b-a;
}
int main(){
	int n,h[100001],bp[100001]={0};
	cin>>n; 
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=2;i<=n;i++){
		if(i==2)bp[i]=bp[i-1]+abssub(h[i],h[i-1]);
		else{
			bp[i]=min(bp[i-1]+abssub(h[i],h[i-1]),bp[i-2]+abssub(h[i],h[i-2]));
		}
	}
	cout<<bp[n]<<endl;
	return 0;
}

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

int dp[1000][1000];
string str[1000];

int serch(int n)
{
    int ans=0;
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(str[i][j]=='*')dp[i][j]=0;
            else{
                if(i>0&&j>0)dp[i][j]=min(min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])+1;
                else dp[i][j]=1;
                ans=max(dp[i][j],ans);
            }
        }
    }
    return ans;
}
int main()
{
    int n;
    while(cin>>n,n){
        for(int i=0;i<n;i++)cin>>str[i];
        cout<<serch(n)<<endl;
    }
}

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

int main()
{
  int a,b;

  scanf("%d%d",&a,&b);
  if (a<=0&&b>=0)
    printf("Zero\n");
  else if (a>0)
    printf("Positive\n");
  else if (b<0)
    printf("%s\n",(b-a+1)%2==0?"Positive":"Negative");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
#define pb push_back
#define fr first
#define sc second
#define sz(v) ((int)(v).size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repd(i,a,p) for(int i=a-1;i>=p;i--) 
#define M 1000000007
#define vi vector<int>
#define vp vector<pair<int,int> >
#define ml map<int,int>
#define MPI 3.1415926536
using namespace std;
//priority_queue is best for traversing elements when it is needed in a sorted order
//dsu is pel concept
int n,m,k=0,t,i,j,c=0,x,s=0,a,b;string s1;
signed main()
{
	cin>>n>>m;
	for(i=0;i<=100000;i++)
	{
			   if(4*n-2*i==m&&n>=i)
			   {
			   
				cout<<"Yes";
				return 0;}
			}

	
	cout<<"No";
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if (k - a > 0)
    {
        ans += a;
        k -= a;
        if (k - b > 0)
        {
            k -= b;
            if (k > 0)
            {
                ans -= k;
                cout << ans << endl;
                return 0;
            }
        }
        else
        {
            cout << ans << endl;
            return 0;
        }
    }
    else
    {
        ans += k;
        cout << ans << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp1, mp2;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(i % 2 == 0) {
      mp1[a[i]]++;
    } else {
      mp2[a[i]]++;
    }
  }

  int m1 = 0;
  int idx1 = 0;
  for(auto p : mp1) {
    if(m1 < p.second) {
      m1 = p.second;
      idx1 = p.first;
    }
  }
  int m2 = 0;
  int idx2 = 0;
  for(auto p : mp2) {
    if(m2 < p.second) {
      m2 = p.second;
      idx2 = p.first;
    }
  }
  int m3 = 0;
  int idx3 = 0;
  for(auto p : mp1) {
    if(p.first == idx1) {
      continue;
    }
    if(m3 < p.second) {
      m3 = p.second;
      idx3 = p.first;
    }
  }
  int m4 = 0;
  int idx4 = 0;
  for(auto p : mp2) {
    if(p.first == idx2) {
      continue;
    }
    if(m4 < p.second) {
      m4 = p.second;
      idx4 = p.first;
    }
  }
  if(idx1 != idx2) {
    cout << n - mp1[idx1] - mp2[idx2] << endl;
  } else {
    cout << min(n - mp1[idx3] - mp2[idx2], n - mp1[idx1] - mp2[idx4]) << endl;
  }

  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  cin >> N;
  
  int j = 0;
  int k = 100000;
  for(int i = 0; i < N; i++) {
    cin >> x;
    for(j = 0; x % 2 == 0 && j <= k; j++) {
      x /= 2;
    }
    
    if(j < k) {
      k = j;
    }
    
    if(k == 0) {
      break;
    }
  }
  
  cout << k << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

long long factorical(int n)
{
  long long ans=1,i;
  for(i=n;i>1;i--)
    ans=(ans*i)%MOD;
  return ans;
}


long long beki(long long a,int n)
{
  long long s=1LL;
  while(n){
    if(n%2)s=(s*a)%MOD;
    a=(a*a)%MOD;
    n/=2;
  }
  return s;
}

#define MAX_N 2*100005

ll x[MAX_N],invx[MAX_N];

ll ncr(ll a, ll b){
  return (x[a] * invx[b] %MOD * invx[a-b])%MOD;

}


int main(void) {
  int i,j;
  int h,w,a,b;
  cin>>h>>w>>a>>b;

  ll n=h+w;
  x[0]=1;
  loop(i,1,n) x[i]=(x[i-1]*i)%MOD;

  rep(i,n) invx[i]=beki(x[i],MOD-2);

  ll ans=0;
  rep(i,h-a){
    ans+=(ncr(b-1+i,b-1)*ncr(w-1-b + h-1-i,w-1-b))%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3456
while True:
    n, x = (int(x) for x in input().split())
    if n == 0 and x == 0: break
    anw = 0
    for a in range(1, n+1):
        for b in range(a+1, n+1):
            tmp = x - a - b
            if tmp > b and tmp <= n:
                anw += 1
    print(anw)                


Measured memory_bytes: 5604
using System;
//この問題を解きやすいように解釈すると
//0,1,2,3,...,nのうちs個(s=k~n+1)取った時を考えればよい
//またこの時の最大値、最小値は
//Min=0+1+...+(s-1)
//Max=(n-s+1)+...+n
//この間は全て存在する
//計算を省略するため連続する数の和の公式も使う
//f(l,r)=l+(l+1)+..+r=(l+r)(r-l+1)/2

class Program
{
    static readonly int M = (int)Math.Pow(10, 9) + 7;
    static void Main()
    {
        string[] In = Console.ReadLine().Split(' ');
        int n = int.Parse(In[0]);
        int k = int.Parse(In[1]);
        long max, min;
        long sum = 0;
        for (int i = k; i <= n + 1; i++)
        {
            max = Wa(n-i+1,n);
            min = Wa(0,i-1);
            sum += (max - min + 1);
            sum %= M;   
        }
        Console.WriteLine(sum);
    }
    //ここのlong l, long rに注意
    static long Wa(long l, long r)
    {
        return (l+r)*(r-l+1) / 2;
    }
}
//class Program
//{
//    static readonly int M = (int)Math.Pow(10, 9) + 7;
//    static void Main()
//    {
//        string[] In = Console.ReadLine().Split(' ');
//        int n = int.Parse(In[0]);
//        int k = int.Parse(In[1]);
//        int max, min;
//        long sum=0;
//        for(int i = k; i <= n + 1; i++)
//        {
//            max = 0;
//            for(int j = n - i + 1; j <= n; j ++)
//            {
//                max += j;
//            }
//            min = 0;
//            for(int j = 0; j <= i - 1; j++)
//            {
//                min += j;
//            }
//            sum += max - min+1;
//            sum %= M;
//        }
//        Console.WriteLine(sum);
//    }
//}


Measured memory_bytes: 27848
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h = 0, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n);
  vector<pair<lli, lli>> g;
  lli time = 0, cost = 0;
  rep(i, 0, n)
  {
    cin >> a >> b;
    if (b < a)
    {
      cout << "No" << endl;
      return 0;
    }
    g.eb(mp(b, a));
    cost += a;
    time = max(time, b);
  }
  // if (time < cost)
  // {
  //   cout << "No" << endl;
  //   return 0;
  // }
  SORT(g);
  for (auto x : g)
  {
    h += x.second;
    if (h > x.first)
    {
      cout << "No" << endl;
      return 0;
    }
    // cout << "h: " << h << endl;
  }
  cout << "Yes" << endl;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size(), ans = 0;
  for (int i = 0; i < n/2; i++) {
    if (s[i] != s[n-i-1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long x = sc.nextLong();
        long[] as = new long[N];
        for (int i = 0; i < N; i++) {
            as[i] = sc.nextLong();
        }

        System.out.println( solve(N, x, as) );
    }

    private static long solve(int N, long x, long[] as) {
        long ans = 0;
        if( as[0] > x ) {
            ans += as[0] - x;
            as[0] = x;
        }

        for (int i = 1; i < N; i++) {
            long a = as[i];
            long prev = as[i-1];

            if( a + prev > x ) {
                long eat = (a + prev) - x;
                ans += eat;
                as[i] -= eat;
            }
        }
        return ans;
    }
}

Measured memory_bytes: 52300
#include<cstdio>
int a[10];
int main()
{
    int n;
    for(int i=1;i<=4;i++)
    {
        scanf("%d",&n);
        a[n]++;
    }
    if(a[1]==1 && a[9]==1 && a[7]==1 && a[4]==1)
        printf("YES");
    else
        printf("NO");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s;
    cin >> s;
    rep(i, s.size()) s[i] = 'x';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, Q = map(int, input().split())
    *C, = map(int, input().split())

    last = [-1]*(N+1)
    P = [[] for _ in [0]*(N+1)]
    for i, c in enumerate(C):
        if last[c] != -1:
            P[last[c]].append(i+1)
        last[c] = i+1

    queries = [[] for _ in [0]*(N+1)]
    for i in range(Q):
        l, r = map(int, input().split())
        queries[l].append((r, i))

    class BIT():
        def __init__(self, n, x=1):
            self.n = n
            self.T = [0]*(n+1)

        def add(self, i, x):
            while i <= self.n:
                self.T[i] += x
                i += i & -i

        def lsum(self, i):
            ret = 0
            while i > 0:
                ret += self.T[i]
                i ^= i & -i
            return ret

    A = BIT(N)
    ans = [0]*Q
    for l in range(N, 0, -1):
        for cr in P[l]:
            A.add(cr, 1)
        for r, i in queries[l]:
            ans[i] = r-l+1-A.lsum(r)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 231580
/*input
110001
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 4;

char s[N], t[N];

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  cin >> s;
  int n = strlen(s);
  strcpy(t, s);

  int ans1 = 0;
  s[0] -= '0';
  for (int i = 1; i < n; ++i) {
    s[i] -= '0';
    ans1 += (s[i] == s[i - 1]);
    s[i] = s[i - 1] ^ 1;
  }

  int ans2 = 1; 
  t[0] = (t[0] - '0') ^ 1;
  for (int i = 1; i < n; ++i) {
    t[i] -= '0';
    ans2 += (t[i] == t[i - 1]);
    t[i] = t[i - 1] ^ 1;
  }

  cout << min(ans1, ans2) << endl;

  return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
  ll a[1000003],b[1000002];
  ll l=1e13;
int main(){
    ll n,k;
    scanf("%lld%lld",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%lld",&b[i]);
    }
    sort(a,a+n);
    sort(b,b+n,greater<int>());
    ll f=-1,m,s,ans;
    while(l!=f+1){
        ans=0;
        s=0;
        m=(l+f)/2;
        for(int i=0;i<n;i++){
            ans+=max(0LL,a[i]-(m/b[i]));
            if(ans>k){
                f=m;
                s=1;
                break;
            }
        }
        if(!s){
            l=m;
        }
    }
    printf("%lld\n",l);
    return 0;
}


Measured memory_bytes: 5888